]>
Commit | Line | Data |
---|---|---|
3c1705d9 RD |
1 | ? .configure |
2 | ? .emacs.desktop | |
3 | ? .test | |
4 | ? mytests | |
5 | ? switch_cvs.py | |
6 | ? Source/Modules/mystuff | |
7 | Index: Doc/Manual/Python.html | |
8 | =================================================================== | |
9 | RCS file: /cvsroot/swig/SWIG/Doc/Manual/Python.html,v | |
10 | retrieving revision 1.20 | |
11 | diff -u -4 -r1.20 Python.html | |
12 | --- Doc/Manual/Python.html 25 Oct 2004 20:42:08 -0000 1.20 | |
0bd9eee2 | 13 | +++ Doc/Manual/Python.html 15 Apr 2005 23:11:25 -0000 |
3c1705d9 RD |
14 | @@ -3869,10 +3869,10 @@ |
15 | ||
16 | <H2><a name="Python_nn65"></a>26.10 Docstring Features</H2> | |
17 | ||
18 | ||
19 | -Usign docstrings in Python code is becoming more and more important | |
20 | -ans more tools are coming on the scene that take advantage of them, | |
21 | +Using docstrings in Python code is becoming more and more important | |
22 | +and more tools are coming on the scene that take advantage of them, | |
23 | everything from full-blown documentaiton generators to class browsers | |
24 | and popup call-tips in Python-aware IDEs. Given the way that SWIG | |
25 | generates the proxy code by default, your users will normally get | |
26 | something like <tt>"function_name(*args)"</tt> in the popup calltip of | |
0bd9eee2 RD |
27 | Index: Lib/python/pyrun.swg |
28 | =================================================================== | |
29 | RCS file: /cvsroot/swig/SWIG/Lib/python/pyrun.swg,v | |
30 | retrieving revision 1.53 | |
31 | diff -u -4 -r1.53 pyrun.swg | |
32 | --- Lib/python/pyrun.swg 11 Dec 2004 23:38:44 -0000 1.53 | |
33 | +++ Lib/python/pyrun.swg 15 Apr 2005 23:11:25 -0000 | |
34 | @@ -455,9 +455,10 @@ | |
35 | } else { | |
36 | PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", | |
37 | type, otype); | |
38 | } | |
39 | - Py_DECREF(str); | |
40 | + if (str) | |
41 | + Py_DECREF(str); | |
42 | return; | |
43 | } | |
44 | } | |
45 | PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); | |
3c1705d9 RD |
46 | Index: Source/Modules/python.cxx |
47 | =================================================================== | |
48 | RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v | |
49 | retrieving revision 1.81 | |
50 | diff -u -4 -r1.81 python.cxx | |
51 | --- Source/Modules/python.cxx 13 Dec 2004 22:12:47 -0000 1.81 | |
0bd9eee2 | 52 | +++ Source/Modules/python.cxx 15 Apr 2005 23:11:26 -0000 |
3c1705d9 RD |
53 | @@ -74,9 +74,9 @@ |
54 | -modern - Use modern python features only, without compatibility code\n\ | |
55 | -apply - Use apply() in proxy classes\n\ | |
56 | -new_vwm - New value wrapper mode, use only when everything else fails \n\ | |
57 | -new_repr - Use more informative version of __repr__ in proxy classes\n\ | |
58 | - -old_repr - Use shorter ald old version of __repr__ in proxy classes\n\ | |
59 | + -old_repr - Use shorter and old version of __repr__ in proxy classes\n\ | |
60 | -noexcept - No automatic exception handling\n\ | |
61 | -noh - Don't generate the output header file\n\ | |
62 | -noproxy - Don't generate proxy classes \n\n"; | |
63 | ||
64 | @@ -749,10 +749,15 @@ | |
65 | ||
66 | // Do the param type too? | |
67 | if (showTypes) { | |
68 | type = SwigType_base(type); | |
69 | - lookup = Swig_symbol_clookup(type, 0); | |
70 | - if (lookup) type = Getattr(lookup, "sym:name"); | |
71 | + SwigType* qt = SwigType_typedef_resolve_all(type); | |
72 | + if (SwigType_isenum(qt)) | |
73 | + type = NewString("int"); | |
74 | + else { | |
75 | + lookup = Swig_symbol_clookup(type, 0); | |
76 | + if (lookup) type = Getattr(lookup, "sym:name"); | |
77 | + } | |
78 | Printf(doc, "%s ", type); | |
79 | } | |
80 | ||
81 | if (name) { | |
82 | @@ -853,13 +858,19 @@ | |
83 | } | |
84 | ||
85 | switch ( ad_type ) { | |
86 | case AUTODOC_CLASS: | |
87 | - if (CPlusPlus) { | |
88 | - Printf(doc, "Proxy of C++ %s class", class_name); | |
89 | - } else { | |
90 | - Printf(doc, "Proxy of C %s struct", class_name); | |
91 | - } | |
92 | + { | |
93 | + // Only do the autodoc if there isn't a docstring for the class | |
94 | + String* str = Getattr(n, "feature:docstring"); | |
95 | + if (str == NULL || Len(str) == 0) { | |
96 | + if (CPlusPlus) { | |
97 | + Printf(doc, "Proxy of C++ %s class", class_name); | |
98 | + } else { | |
99 | + Printf(doc, "Proxy of C %s struct", class_name); | |
100 | + } | |
101 | + } | |
102 | + } | |
103 | break; | |
104 | case AUTODOC_CTOR: | |
105 | if ( Strcmp(class_name, symname) == 0) { | |
106 | String* paramList = make_autodocParmList(n, showTypes); | |
107 | @@ -1027,10 +1038,12 @@ | |
108 | Printf(methods,"\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function); | |
109 | ||
110 | if (n && Getattr(n,"feature:callback")) { | |
111 | if (have_docstring(n)) { | |
112 | + String* ds = docstring(n, AUTODOC_FUNC, "", false); | |
113 | + Replaceall(ds, "\n", "\\n"); | |
114 | Printf(methods,"(char *)\"%s\\nswig_ptr: %s\"", | |
115 | - docstring(n, AUTODOC_FUNC, "", false), | |
116 | + ds, | |
117 | Getattr(n,"feature:callback:name")); | |
118 | } else { | |
119 | Printf(methods,"(char *)\"swig_ptr: %s\"",Getattr(n,"feature:callback:name")); | |
120 | } | |
121 | @@ -1950,11 +1963,13 @@ | |
122 | Printf(f_shadow, modern ? "(object)" : "(_object)"); | |
123 | } | |
124 | } | |
125 | Printf(f_shadow,":\n"); | |
126 | - if ( have_docstring(n) ) | |
127 | - Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL); | |
128 | - | |
129 | + if ( have_docstring(n) ) { | |
130 | + String* str = docstring(n, AUTODOC_CLASS, tab4); | |
131 | + if (str != NULL && Len(str)) | |
132 | + Printv(f_shadow, tab4, str, "\n", NIL); | |
133 | + } | |
134 | if (!modern) { | |
135 | Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); | |
136 | if (Len(base_class)) { | |
137 | Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class); | |
138 | @@ -2139,11 +2154,11 @@ | |
139 | Replaceall(pycode,"$action", pyaction); | |
140 | Delete(pyaction); | |
141 | Printv(f_shadow,pycode,"\n",NIL); | |
142 | } else { | |
143 | - Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL); | |
144 | + Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); | |
145 | if (!have_addtofunc(n)) { | |
146 | - Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); | |
147 | + Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); | |
148 | } else { | |
149 | Printv(f_shadow, "\n", NIL); | |
150 | if ( have_docstring(n) ) | |
151 | Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); | |
152 | @@ -2175,12 +2190,9 @@ | |
153 | return SWIG_OK; | |
154 | } | |
155 | ||
156 | if (shadow) { | |
157 | - // | |
158 | - // static + autodoc/prepend/append + def args not working!!!, disable by now | |
159 | - // | |
160 | - if (0 && !classic && !Getattr(n,"feature:python:callback") && have_addtofunc(n)) { | |
161 | + if ( !classic && !Getattr(n,"feature:python:callback") && have_addtofunc(n)) { | |
162 | int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0; | |
163 | Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); | |
164 | if ( have_docstring(n) ) | |
165 | Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); | |
166 | Index: Source/Swig/cwrap.c | |
167 | =================================================================== | |
168 | RCS file: /cvsroot/swig/SWIG/Source/Swig/cwrap.c,v | |
169 | retrieving revision 1.51 | |
170 | diff -u -4 -r1.51 cwrap.c | |
171 | --- Source/Swig/cwrap.c 4 Dec 2004 08:33:02 -0000 1.51 | |
0bd9eee2 | 172 | +++ Source/Swig/cwrap.c 15 Apr 2005 23:11:26 -0000 |
3c1705d9 RD |
173 | @@ -172,17 +172,26 @@ |
174 | tycode = SwigType_type(type); | |
175 | if (tycode == T_REFERENCE) { | |
176 | if (pvalue) { | |
177 | SwigType *tvalue; | |
178 | - String *defname, *defvalue, *rvalue; | |
179 | + String *defname, *defvalue, *rvalue, *qvalue; | |
180 | rvalue = SwigType_typedef_resolve_all(pvalue); | |
181 | + qvalue = SwigType_typedef_qualified(rvalue); | |
182 | defname = NewStringf("%s_defvalue", lname); | |
183 | tvalue = Copy(type); | |
184 | SwigType_del_reference(tvalue); | |
185 | - defvalue = NewStringf("%s = %s", SwigType_lstr(tvalue,defname), rvalue); | |
186 | + tycode = SwigType_type(tvalue); | |
187 | + if (tycode != T_USER) { | |
188 | + /* plain primitive type, we copy the the def value */ | |
189 | + defvalue = NewStringf("%s = %s", SwigType_lstr(tvalue,defname),qvalue); | |
190 | + } else { | |
191 | + /* user type, we copy the reference value */ | |
192 | + defvalue = NewStringf("%s = %s",SwigType_str(type,defname),qvalue); | |
193 | + } | |
194 | Wrapper_add_localv(w,defname, defvalue, NIL); | |
195 | Delete(tvalue); | |
196 | Delete(rvalue); | |
197 | + Delete(qvalue); | |
198 | Delete(defname); | |
199 | Delete(defvalue); | |
200 | } | |
201 | } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) { |