]>
Commit | Line | Data |
---|---|---|
2f810297 RD |
1 | Index: Doc/Manual/Python.html |
2 | =================================================================== | |
3 | RCS file: /cvsroot/swig/SWIG/Doc/Manual/Python.html,v | |
4 | retrieving revision 1.31 | |
5 | diff -u -4 -r1.31 Python.html | |
6 | --- Doc/Manual/Python.html 6 Oct 2005 21:49:58 -0000 1.31 | |
7c30eb5a | 7 | +++ Doc/Manual/Python.html 11 Feb 2006 18:59:48 -0000 |
2f810297 RD |
8 | @@ -4461,10 +4461,10 @@ |
9 | <H2><a name="Python_nn65"></a>26.10 Docstring Features</H2> | |
10 | ||
11 | ||
12 | <p> | |
13 | -Usign docstrings in Python code is becoming more and more important | |
14 | -ans more tools are coming on the scene that take advantage of them, | |
15 | +Using docstrings in Python code is becoming more and more important | |
16 | +and more tools are coming on the scene that take advantage of them, | |
17 | everything from full-blown documentaiton generators to class browsers | |
18 | and popup call-tips in Python-aware IDEs. Given the way that SWIG | |
19 | generates the proxy code by default, your users will normally get | |
20 | something like <tt>"function_name(*args)"</tt> in the popup calltip of | |
21 | Index: Lib/swig.swg | |
22 | =================================================================== | |
23 | RCS file: /cvsroot/swig/SWIG/Lib/swig.swg,v | |
24 | retrieving revision 1.49 | |
25 | diff -u -4 -r1.49 swig.swg | |
26 | --- Lib/swig.swg 15 Oct 2005 00:15:30 -0000 1.49 | |
7c30eb5a | 27 | +++ Lib/swig.swg 11 Feb 2006 18:59:48 -0000 |
2f810297 RD |
28 | @@ -51,9 +51,9 @@ |
29 | ||
30 | #define %nodefault %feature("nodefault","1") | |
31 | #define %default %feature("nodefault","0") | |
32 | #define %clearnodefault %feature("nodefault","") | |
33 | -#define %makedefault %cleardefault | |
34 | +#define %makedefault %clearnodefault | |
35 | ||
36 | /* the %exception directive */ | |
37 | ||
38 | #ifdef SWIGCSHARP | |
39 | Index: Lib/swiginit.swg | |
40 | =================================================================== | |
41 | RCS file: /cvsroot/swig/SWIG/Lib/swiginit.swg,v | |
42 | retrieving revision 1.5 | |
43 | diff -u -4 -r1.5 swiginit.swg | |
44 | --- Lib/swiginit.swg 12 Sep 2005 23:25:03 -0000 1.5 | |
7c30eb5a | 45 | +++ Lib/swiginit.swg 11 Feb 2006 18:59:48 -0000 |
2f810297 RD |
46 | @@ -40,14 +40,19 @@ |
47 | **/ | |
48 | ||
49 | #ifdef __cplusplus | |
50 | extern "C" { | |
51 | +#if 0 | |
52 | +} /* c-mode */ | |
53 | +#endif | |
54 | +#endif | |
55 | + | |
56 | +#if 0 | |
57 | +#define SWIGRUNTIME_DEBUG | |
58 | #endif | |
59 | ||
60 | SWIGRUNTIME void | |
61 | SWIG_InitializeModule(void *clientdata) { | |
62 | - swig_type_info *type, *ret; | |
63 | - swig_cast_info *cast; | |
64 | size_t i; | |
65 | swig_module_info *module_head; | |
66 | static int init_run = 0; | |
67 | ||
68 | @@ -71,18 +76,35 @@ | |
69 | SWIG_SetModule(clientdata, &swig_module); | |
70 | } | |
71 | ||
72 | /* Now work on filling in swig_module.types */ | |
73 | +#ifdef SWIGRUNTIME_DEBUG | |
74 | + printf("SWIG_InitializeModule: size %d\n", swig_module.size); | |
75 | +#endif | |
76 | for (i = 0; i < swig_module.size; ++i) { | |
77 | - type = 0; | |
78 | + swig_type_info *type = 0; | |
79 | + swig_type_info *ret; | |
80 | + swig_cast_info *cast; | |
81 | + | |
82 | +#ifdef SWIGRUNTIME_DEBUG | |
83 | + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); | |
84 | +#endif | |
85 | ||
86 | /* if there is another module already loaded */ | |
87 | if (swig_module.next != &swig_module) { | |
88 | type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); | |
89 | } | |
90 | if (type) { | |
91 | /* Overwrite clientdata field */ | |
92 | - if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata; | |
93 | +#ifdef SWIGRUNTIME_DEBUG | |
94 | + printf("SWIG_InitializeModule: found type %s\n", type->name); | |
95 | +#endif | |
96 | + if (swig_module.type_initial[i]->clientdata) { | |
97 | + type->clientdata = swig_module.type_initial[i]->clientdata; | |
98 | +#ifdef SWIGRUNTIME_DEBUG | |
99 | + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); | |
100 | +#endif | |
101 | + } | |
102 | } else { | |
103 | type = swig_module.type_initial[i]; | |
104 | } | |
105 | ||
106 | @@ -91,31 +113,66 @@ | |
107 | while (cast->type) { | |
108 | ||
109 | /* Don't need to add information already in the list */ | |
110 | ret = 0; | |
111 | +#ifdef SWIGRUNTIME_DEBUG | |
112 | + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); | |
113 | +#endif | |
114 | if (swig_module.next != &swig_module) { | |
115 | ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); | |
116 | +#ifdef SWIGRUNTIME_DEBUG | |
117 | + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); | |
118 | +#endif | |
119 | } | |
120 | - if (ret && type == swig_module.type_initial[i]) { | |
121 | - cast->type = ret; | |
122 | - ret = 0; | |
123 | + if (ret) { | |
124 | + if (type == swig_module.type_initial[i]) { | |
125 | +#ifdef SWIGRUNTIME_DEBUG | |
126 | + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); | |
127 | +#endif | |
128 | + cast->type = ret; | |
129 | + ret = 0; | |
130 | + } else { | |
131 | + /* Check for casting already in the list */ | |
132 | + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); | |
133 | +#ifdef SWIGRUNTIME_DEBUG | |
134 | + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); | |
135 | +#endif | |
136 | + if (!ocast) ret = 0; | |
137 | + } | |
138 | } | |
139 | - | |
140 | + | |
141 | if (!ret) { | |
142 | +#ifdef SWIGRUNTIME_DEBUG | |
143 | + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); | |
144 | +#endif | |
145 | if (type->cast) { | |
146 | type->cast->prev = cast; | |
147 | cast->next = type->cast; | |
148 | } | |
149 | type->cast = cast; | |
150 | } | |
151 | - | |
152 | cast++; | |
153 | } | |
154 | - | |
155 | /* Set entry in modules->types array equal to the type */ | |
156 | swig_module.types[i] = type; | |
157 | } | |
158 | swig_module.types[i] = 0; | |
159 | + | |
160 | +#ifdef SWIGRUNTIME_DEBUG | |
161 | + printf("**** SWIG_InitializeModule: Cast List ******\n"); | |
162 | + for (i = 0; i < swig_module.size; ++i) { | |
163 | + int j = 0; | |
164 | + swig_cast_info *cast = swig_module.cast_initial[i]; | |
165 | + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); | |
166 | + while (cast->type) { | |
167 | + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); | |
168 | + cast++; | |
169 | + ++j; | |
170 | + } | |
171 | + printf("---- Total casts: %d\n",j); | |
172 | + } | |
173 | + printf("**** SWIG_InitializeModule: Cast List ******\n"); | |
174 | +#endif | |
175 | } | |
176 | ||
177 | /* This function will propagate the clientdata field of type to | |
178 | * any new swig_type_info structures that have been added into the list | |
179 | @@ -145,6 +202,9 @@ | |
180 | } | |
181 | } | |
182 | ||
183 | #ifdef __cplusplus | |
184 | +#if 0 | |
185 | +{ /* c-mode */ | |
186 | +#endif | |
187 | } | |
188 | #endif | |
189 | Index: Source/Modules/python.cxx | |
190 | =================================================================== | |
191 | RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v | |
192 | retrieving revision 1.107 | |
193 | diff -u -4 -r1.107 python.cxx | |
194 | --- Source/Modules/python.cxx 7 Oct 2005 13:17:41 -0000 1.107 | |
7c30eb5a | 195 | +++ Source/Modules/python.cxx 11 Feb 2006 18:59:48 -0000 |
2f810297 RD |
196 | @@ -36,9 +36,8 @@ |
197 | static File *f_directors_h = 0; | |
198 | static File *f_init = 0; | |
199 | static File *f_shadow_py = 0; | |
200 | static String *f_shadow = 0; | |
201 | -static String *f_shadow_imports = 0; | |
202 | static String *f_shadow_stubs = 0; | |
203 | ||
204 | static String *methods; | |
205 | static String *class_name; | |
7c30eb5a | 206 | @@ -322,9 +321,8 @@ |
2f810297 RD |
207 | } |
208 | Delete(filen); filen = NULL; | |
209 | ||
210 | f_shadow = NewString(""); | |
211 | - f_shadow_imports = NewString(""); | |
212 | f_shadow_stubs = NewString(""); | |
213 | ||
214 | Swig_register_filebyname("shadow",f_shadow); | |
215 | Swig_register_filebyname("python",f_shadow); | |
7c30eb5a | 216 | @@ -343,8 +341,10 @@ |
2f810297 RD |
217 | if (mod_docstring && Len(mod_docstring)) { |
218 | Printv(f_shadow, "\n\"\"\"\n", mod_docstring, "\n\"\"\"\n", NIL); | |
219 | Delete(mod_docstring); mod_docstring = NULL; | |
220 | } | |
221 | + | |
222 | + Printf(f_shadow,"\nimport %s\n\n", module); | |
223 | ||
224 | /* if (!modern) */ | |
225 | /* always needed, a class can be forced to be no-modern, such as an exception */ | |
226 | { | |
7c30eb5a | 227 | @@ -445,10 +445,8 @@ |
2f810297 RD |
228 | Printf(f_wrappers,"}\n"); |
229 | Printf(f_wrappers,"#endif\n"); | |
230 | ||
231 | if (shadow) { | |
232 | - Printf(f_shadow_imports,"\nimport %s\n", module); | |
233 | - Printv(f_shadow_py, f_shadow_imports, "\n",NIL); | |
234 | Printv(f_shadow_py, f_shadow, "\n",NIL); | |
235 | Printv(f_shadow_py, f_shadow_stubs, "\n",NIL); | |
236 | ||
237 | Close(f_shadow_py); | |
7c30eb5a | 238 | @@ -507,12 +505,9 @@ |
2f810297 RD |
239 | } |
240 | ||
241 | // finally, output the name of the imported module | |
242 | Printf(import, "%s\n", modname); | |
243 | - | |
244 | - if (!Strstr(f_shadow_imports, import)) { | |
245 | - Printf(f_shadow_imports, "%s", import); | |
246 | - } | |
247 | + Printf(f_shadow, "%s", import); | |
248 | Delete(import); | |
249 | } | |
250 | } | |
251 | return Language::importDirective(n); | |
7c30eb5a | 252 | @@ -774,10 +769,15 @@ |
2f810297 RD |
253 | |
254 | // Do the param type too? | |
255 | if (showTypes) { | |
256 | type = SwigType_base(type); | |
257 | - lookup = Swig_symbol_clookup(type, 0); | |
258 | - if (lookup) type = Getattr(lookup, "sym:name"); | |
259 | + SwigType* qt = SwigType_typedef_resolve_all(type); | |
260 | + if (SwigType_isenum(qt)) | |
261 | + type = NewString("int"); | |
262 | + else { | |
263 | + lookup = Swig_symbol_clookup(type, 0); | |
264 | + if (lookup) type = Getattr(lookup, "sym:name"); | |
265 | + } | |
266 | Printf(doc, "%s ", type); | |
267 | } | |
268 | ||
269 | if (name) { |