]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/SWIG/swig.python-docstring.patch
Allow for Cmd-click on wxMac
[wxWidgets.git] / wxPython / SWIG / swig.python-docstring.patch
... / ...
CommitLineData
1Index: Source/Modules/python.cxx
2===================================================================
3RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v
4retrieving revision 1.40
5diff -u -4 -r1.40 python.cxx
6--- Source/Modules/python.cxx 24 Jan 2004 00:25:31 -0000 1.40
7+++ Source/Modules/python.cxx 2 Jun 2004 01:38:46 -0000
8@@ -19,8 +19,9 @@
9
10 static String *const_code = 0;
11 static String *shadow_methods = 0;
12 static String *module = 0;
13+static String *package = 0;
14 static String *mainmodule = 0;
15 static String *interface = 0;
16 static String *global_name = 0;
17 static int shadow = 1;
18@@ -50,8 +51,18 @@
19 static int have_constructor;
20 static int have_repr;
21 static String *real_classname;
22
23+/* flags for the make_autodoc function */
24+enum autodoc_t {
25+ AUTODOC_CLASS,
26+ AUTODOC_CTOR,
27+ AUTODOC_DTOR,
28+ AUTODOC_STATICFUNC,
29+ AUTODOC_FUNC,
30+ AUTODOC_METHOD
31+};
32+
33 static const char *usage = (char *)"\
34 Python Options (available with -python)\n\
35 -ldflags - Print runtime libraries to link with\n\
36 -globals <name> - Set <name> used to access C global variable [default: 'cvar']\n\
37@@ -146,19 +157,22 @@
38 *
39 * use %module(directors="1") modulename at the start of the
40 * interface file to enable director generation.
41 */
42+ String* mod_docstring = NULL;
43 {
44- Node *module = Getattr(n, "module");
45- if (module) {
46- Node *options = Getattr(module, "options");
47+ Node *mod = Getattr(n, "module");
48+ if (mod) {
49+ Node *options = Getattr(mod, "options");
50 if (options) {
51 if (Getattr(options, "directors")) {
52 allow_directors();
53 }
54 if (Getattr(options, "dirprot")) {
55 allow_dirprot();
56 }
57+ mod_docstring = Getattr(options, "docstring");
58+ package = Getattr(options, "package");
59 }
60 }
61 }
62
63@@ -258,8 +272,13 @@
64 Printv(f_shadow,
65 "# This file is compatible with both classic and new-style classes.\n",
66 NIL);
67 }
68+
69+ if (mod_docstring && Len(mod_docstring)) {
70+ Printv(f_shadow, "\n\"\"\"\n", mod_docstring, "\n\"\"\"\n", NIL);
71+ Delete(mod_docstring); mod_docstring = NULL;
72+ }
73
74 Printf(f_shadow,"\nimport %s\n\n", module);
75
76 if (! modern) {
77@@ -382,9 +401,28 @@
78 virtual int importDirective(Node *n) {
79 if (shadow) {
80 String *modname = Getattr(n,"module");
81 if (modname) {
82- Printf(f_shadow,"import %s\n", modname);
83+ Printf(f_shadow,"import ");
84+
85+ // Find the module node for this imported module. It should be the
86+ // first child but search just in case.
87+ Node* mod = firstChild(n);
88+ while (mod && Strcmp(nodeType(mod), "module") != 0)
89+ mod = nextSibling(mod);
90+
91+ // Is the imported module in another package? (IOW, does it use the
92+ // %module(package="name") option and it's different than the package
93+ // of this module.)
94+ Node *options = Getattr(mod, "options");
95+ if (options && Getattr(options, "package")) {
96+ String* pkg = Getattr(options, "package");
97+ if (!package || Strcmp(pkg, package) != 0)
98+ Printf(f_shadow, "%s.", Getattr(options, "package"));
99+ }
100+
101+ // finally, output the name of the imported module
102+ Printf(f_shadow, "%s\n", modname);
103 }
104 }
105 return Language::importDirective(n);
106 }
107@@ -417,17 +455,25 @@
108 * functions.
109 * ------------------------------------------------------------ */
110
111 void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) {
112- if ( ! have_addtofunc(n) ) {
113- /* If there is no addtofunc directive then just assign from the extension module */
114+ if ( !have_pythonprepend(n) && !have_pythonappend(n) && !have_docstring(n) ) {
115+ /* If there is no pythonappend or docstring directive then just assign from the extension module */
116 Printv(f_dest, "\n", name, " = ", module, ".", name, "\n", NIL);
117 } else {
118 /* Otherwise make a wrapper function to insert the code into */
119 Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
120- Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL);
121- Printv(f_dest, tab4, addtofunc(n), "\n", NIL);
122- Printv(f_dest, tab4, "return val\n", NIL);
123+ if ( have_docstring(n) )
124+ Printv(f_dest, tab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
125+ if ( have_pythonprepend(n) )
126+ Printv(f_dest, tab4, pythonprepend(n), "\n", NIL);
127+ if ( have_pythonappend(n) ) {
128+ Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL);
129+ Printv(f_dest, tab4, pythonappend(n), "\n", NIL);
130+ Printv(f_dest, tab4, "return val\n", NIL);
131+ } else {
132+ Printv(f_dest, tab4, "return ", funcCallHelper(name, kw), "\n", NIL);
133+ }
134 }
135 }
136
137
138@@ -441,24 +487,303 @@
139 }
140
141
142 /* ------------------------------------------------------------
143- * have_addtofunc()
144- * Check if there is a %addtofunc directive and it has text
145+ * have_docstring()
146+ * Check if there is a docstring directive and it has text,
147+ * or there is an autodoc flag set
148+ * ------------------------------------------------------------ */
149+
150+ bool have_docstring(Node *n) {
151+ String* str = Getattr(n, "feature:docstring");
152+ return (str != NULL && Len(str) > 0) ||
153+ (Getattr(n,"feature:autodoc") && !Getattr(n, "feature:noautodoc"));
154+ }
155+
156+ /* ------------------------------------------------------------
157+ * docstring()
158+ * Get the docstring text, stripping off {} if neccessary,
159+ * and enclose in triple double quotes. If autodoc is also
160+ * set then it will build a combined docstring.
161+ * ------------------------------------------------------------ */
162+
163+ String *docstring(Node *n, autodoc_t ad_type, const String* indent) {
164+ String* str = Getattr(n, "feature:docstring");
165+ bool have_ds = (str != NULL && Len(str) > 0);
166+ bool have_auto = (Getattr(n,"feature:autodoc") && !Getattr(n, "feature:noautodoc"));
167+ char* triple_double = "\"\"\"";
168+ String* autodoc = NULL;
169+ String* doc = NULL;
170+
171+ if ( have_ds ) {
172+ char* t = Char(str);
173+ if (*t == '{') {
174+ Delitem(str ,0);
175+ Delitem(str,DOH_END);
176+ }
177+ }
178+
179+ if ( have_auto ) {
180+ autodoc = make_autodoc(n, ad_type);
181+ have_auto = (autodoc != NULL && Len(autodoc) > 0);
182+ }
183+
184+ // If there is more than one line then make docstrings like this:
185+ //
186+ // """
187+ // This is line1
188+ // And here is line2 followed by the rest of them
189+ // """
190+ //
191+ // otherwise, put it all on a single line
192+ //
193+ if ( have_auto && have_ds ) { // Both autodoc and docstring are present
194+ doc = NewString("");
195+ Printv(doc, triple_double, "\n",
196+ pythoncode(autodoc, indent), "\n",
197+ pythoncode(str, indent),
198+ indent, triple_double, NIL);
199+ }
200+ else if ( !have_auto && have_ds ) { // only docstring
201+ if (Strchr(str, '\n') == NULL) {
202+ doc = NewStringf("%s%s%s", triple_double, str, triple_double);
203+ }
204+ else {
205+ doc = NewString("");
206+ Printv(doc, triple_double, "\n",
207+ pythoncode(str, indent),
208+ indent, triple_double, NIL);
209+ }
210+ }
211+ else if ( have_auto && !have_ds ) { // only autodoc
212+ if (Strchr(autodoc, '\n') == NULL) {
213+ doc = NewStringf("%s%s%s", triple_double, autodoc, triple_double);
214+ }
215+ else {
216+ doc = NewString("");
217+ Printv(doc, triple_double, "\n",
218+ pythoncode(autodoc, indent),
219+ indent, triple_double, NIL);
220+ }
221+ }
222+ else
223+ doc = NewString("");
224+
225+ // Save the generated strings in the parse tree in case they are used later
226+ // by post processing tools
227+ Setattr(n, "python:docstring", doc);
228+ Setattr(n, "python:autodoc", autodoc);
229+ return doc;
230+ }
231+
232+
233+ /* ------------------------------------------------------------
234+ * make_autodoc()
235+ * Build a docstring for the node, using parameter and other
236+ * info in the parse tree. If the value of the autodoc
237+ * attribute is "0" then do not include parameter types, if
238+ * it is "1" (the default) then do. If it has some other
239+ * value then assume it is supplied by the extension writer
240+ * and use it directly.
241+ * ------------------------------------------------------------ */
242+
243+ String* make_autodoc(Node *n, autodoc_t ad_type) {
244+
245+ if (ad_type == AUTODOC_CLASS)
246+ return NULL; // No function call to document in this case
247+
248+ // If the function is overloaded then this funciton is called
249+ // for the last one. Rewind to the first so the docstrings are
250+ // in order.
251+ while ( Getattr(n, "sym:previousSibling") )
252+ n = Getattr(n, "sym:previousSibling");
253+
254+ String* doc = NewString("");
255+ while (n) {
256+ bool showTypes = false;
257+ bool skipAuto = false;
258+
259+ // check how should the parameters be rendered?
260+ String* autodoc = Getattr(n, "feature:autodoc");
261+ if (Strcmp(autodoc, "0") == 0)
262+ showTypes = false;
263+ else if (Strcmp(autodoc, "1") == 0)
264+ showTypes = true;
265+ else {
266+ // if not "0" or "1" then autodoc is already the string that should be used
267+ Printf(doc, "%s", autodoc);
268+ skipAuto = true;
269+ }
270+
271+ if (!skipAuto) {
272+ String* symname = Getattr(n, "sym:name");
273+ SwigType* type = Getattr(n, "type");
274+
275+ if (type) {
276+ if (Strcmp(type, "void") == 0)
277+ type = NULL;
278+ else {
279+ SwigType* qt = SwigType_typedef_resolve_all(type);
280+ if (SwigType_isenum(qt))
281+ type = NewString("int");
282+ else {
283+ type = SwigType_base(type);
284+ Node* lookup = Swig_symbol_clookup(type, 0);
285+ if (lookup)
286+ type = Getattr(lookup, "sym:name");
287+ }
288+ }
289+ }
290+
291+ switch ( ad_type ) {
292+ case AUTODOC_CTOR:
293+ if ( Strcmp(class_name, symname) == 0) {
294+ String* paramList = make_autodocParmList(n, showTypes);
295+ if (Len(paramList))
296+ Printf(doc, "__init__(self, %s) -> %s", paramList, class_name);
297+ else
298+ Printf(doc, "__init__(self) -> %s", class_name);
299+ }
300+ else
301+ Printf(doc, "%s(%s) -> %s", symname, make_autodocParmList(n, showTypes), class_name);
302+ break;
303+
304+ case AUTODOC_DTOR:
305+ Printf(doc, "__del__(self)");
306+ break;
307+
308+ case AUTODOC_STATICFUNC:
309+ Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes));
310+ if (type) Printf(doc, " -> %s", type);
311+ break;
312+
313+ case AUTODOC_FUNC:
314+ Printf(doc, "%s(%s)", symname, make_autodocParmList(n, showTypes));
315+ if (type) Printf(doc, " -> %s", type);
316+ break;
317+
318+ case AUTODOC_METHOD:
319+ String* paramList = make_autodocParmList(n, showTypes);
320+ if (Len(paramList))
321+ Printf(doc, "%s(self, %s)", symname, paramList);
322+ else
323+ Printf(doc, "%s(self)", symname);
324+ if (type) Printf(doc, " -> %s", type);
325+ break;
326+ }
327+ }
328+
329+ // if it's overloaded then get the next decl and loop around again
330+ n = Getattr(n, "sym:nextSibling");
331+ if (n)
332+ Printf(doc, "\n");
333+ }
334+
335+ return doc;
336+ }
337+
338+
339+ String* make_autodocParmList(Node* n, bool showTypes) {
340+ String* doc = NewString("");
341+ ParmList* plist = Getattr(n,"parms");
342+ Parm* p;
343+ Node* lookup;
344+ int lines = 0;
345+ const int maxwidth = 50;
346+
347+
348+ for (p = plist; p; p = nextSibling(p)) {
349+ String* name = Getattr(p, "name");
350+ String* value = Getattr(p, "value");
351+
352+ if ( Len(doc) ) {
353+ // add a comma to the previous one if any
354+ Printf(doc, ", ");
355+
356+ // Do we need to wrap a long line?
357+ if ((Len(doc) - lines*maxwidth) > maxwidth) {
358+ Printf(doc, "\n%s", tab4);
359+ lines += 1;
360+ }
361+ }
362+
363+ // Do the param type too?
364+ if (showTypes) {
365+ SwigType* type = SwigType_base(Getattr(p, "type"));
366+ SwigType* qt = SwigType_typedef_resolve_all(type);
367+ if (SwigType_isenum(qt))
368+ type = NewString("int");
369+ else {
370+ lookup = Swig_symbol_clookup(type, 0);
371+ if (lookup)
372+ type = Getattr(lookup, "sym:name");
373+ }
374+ Printf(doc, "%s ", type);
375+ }
376+
377+ if (name)
378+ Printf(doc, "%s", name);
379+ else
380+ Printf(doc, "??");
381+
382+ if (value) {
383+ if (Strcmp(value, "NULL") == 0)
384+ value = NewString("None");
385+ else {
386+ lookup = Swig_symbol_clookup(value, 0);
387+ if (lookup)
388+ value = Getattr(lookup, "sym:name");
389+ }
390+ Printf(doc, "=%s", value);
391+ }
392+ }
393+
394+ return doc;
395+ }
396+
397+
398+ /* ------------------------------------------------------------
399+ * have_pythonprepend()
400+ * Check if there is a %pythonprepend directive and it has text
401+ * ------------------------------------------------------------ */
402+
403+ bool have_pythonprepend(Node *n) {
404+ String* str = Getattr(n, "feature:pythonprepend");
405+ return (str != NULL && Len(str) > 0);
406+ }
407+
408+ /* ------------------------------------------------------------
409+ * pythonprepend()
410+ * Get the %pythonprepend code, stripping off {} if neccessary
411+ * ------------------------------------------------------------ */
412+
413+ String *pythonprepend(Node *n) {
414+ String* str = Getattr(n, "feature:pythonprepend");
415+ char* t = Char(str);
416+ if (*t == '{') {
417+ Delitem(str ,0);
418+ Delitem(str,DOH_END);
419+ }
420+ return str;
421+ }
422+
423+ /* ------------------------------------------------------------
424+ * have_pythonappend()
425+ * Check if there is a %pythonappend directive and it has text
426 * ------------------------------------------------------------ */
427
428- bool have_addtofunc(Node *n) {
429- String* str = Getattr(n, "feature:addtofunc");
430+ bool have_pythonappend(Node *n) {
431+ String* str = Getattr(n, "feature:pythonappend");
432 return (str != NULL && Len(str) > 0);
433 }
434
435 /* ------------------------------------------------------------
436- * addtofunc()
437- * Get the %addtofunc code, stripping off {} if neccessary
438+ * pythonappend()
439+ * Get the %pythonappend code, stripping off {} if neccessary
440 * ------------------------------------------------------------ */
441
442- String *addtofunc(Node *n) {
443- String* str = Getattr(n, "feature:addtofunc");
444+ String *pythonappend(Node *n) {
445+ String* str = Getattr(n, "feature:pythonappend");
446 char* t = Char(str);
447 if (*t == '{') {
448 Delitem(str ,0);
449 Delitem(str,DOH_END);
450@@ -1657,9 +1982,18 @@
451 mod = Getattr(n,"module");
452 if (mod) {
453 String *modname = Getattr(mod,"name");
454 if (Strcmp(modname,mainmodule) != 0) {
455- importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name"));
456+ // check if the module has a package option
457+ String* pkg = NULL;
458+ Node *options = Getattr(mod, "options");
459+ if (options && Getattr(options, "package"))
460+ pkg = Getattr(options, "package");
461+
462+ if (!package || Strcmp(pkg, package) != 0)
463+ importname = NewStringf("%s.%s.%s", pkg, modname, Getattr(n,"sym:name"));
464+ else
465+ importname = NewStringf("%s.%s", modname, Getattr(n,"sym:name"));
466 } else {
467 importname = NewString(Getattr(n,"sym:name"));
468 }
469 Setattr(n,"python:proxy",importname);
470@@ -1731,9 +2065,11 @@
471 Printf(f_shadow, modern ? "(object)" : "(_object)");
472 }
473 }
474 Printf(f_shadow,":\n");
475-
476+ if ( Getattr(n, "feature:docstring") ) // don't use have_docstring in this case because autodoc doesn't apply
477+ Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL);
478+
479 if (!modern) {
480 Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
481 if (Len(base_class)) {
482 Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
483@@ -1866,16 +2202,24 @@
484 Delete(pyaction);
485 Printv(f_shadow,pycode,"\n",NIL);
486 } else {
487
488- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL);
489- if ( have_addtofunc(n) ) {
490- Printv(f_shadow, "\n", NIL);
491- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
492- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
493- Printv(f_shadow, tab8, "return val\n", NIL);
494+ Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
495+ if ( !have_pythonprepend(n) && !have_pythonappend(n) && !have_docstring(n)) {
496+ Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
497 } else {
498- Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
499+ Printv(f_shadow, "\n", NIL);
500+ if ( have_docstring(n) )
501+ Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
502+ if ( have_pythonprepend(n) )
503+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
504+ if ( have_pythonappend(n) ) {
505+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
506+ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
507+ Printv(f_shadow, tab8, "return val\n\n", NIL);
508+ } else {
509+ Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n\n", NIL);
510+ }
511 }
512 }
513
514 }
515@@ -1890,14 +2234,22 @@
516 virtual int staticmemberfunctionHandler(Node *n) {
517 String *symname = Getattr(n,"sym:name");
518 Language::staticmemberfunctionHandler(n);
519 if (shadow) {
520- if ( !classic && have_addtofunc(n) ) {
521+ if ( !classic && (have_pythonprepend(n) || have_pythonappend(n) || have_docstring(n)) ) {
522 int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0;
523 Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
524- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL);
525- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
526- Printv(f_shadow, tab8, "return val\n", NIL);
527+ if ( have_docstring(n) )
528+ Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
529+ if ( have_pythonprepend(n) )
530+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
531+ if ( have_pythonappend(n) ) {
532+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL);
533+ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
534+ Printv(f_shadow, tab8, "return val\n\n", NIL);
535+ } else {
536+ Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL);
537+ }
538 Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname,
539 " = staticmethod(", symname, ")\n", NIL);
540
541 if (!modern) {
542@@ -1982,8 +2334,12 @@
543 }
544
545 Printv(f_shadow, tab4, "def __init__(self, *args",
546 (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL);
547+ if ( have_docstring(n) )
548+ Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
549+ if ( have_pythonprepend(n) )
550+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
551 Printv(f_shadow, pass_self, NIL);
552 if (!modern) {
553 Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ",
554 funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
555@@ -1996,10 +2352,10 @@
556 Printv(f_shadow, tab8, "self.this = newobj.this\n", NIL);
557 Printv(f_shadow, tab8, "self.thisown = 1\n", NIL);
558 Printv(f_shadow, tab8, "del newobj.thisown\n", NIL);
559 }
560- if ( have_addtofunc(n) )
561- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
562+ if ( have_pythonappend(n) )
563+ Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL);
564 Delete(pass_self);
565 }
566 have_constructor = 1;
567 } else {
568@@ -2015,13 +2371,17 @@
569 } else {
570
571 Printv(f_shadow_stubs, "\ndef ", symname, "(*args",
572 (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL);
573+ if ( have_docstring(n) )
574+ Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL);
575+ if ( have_pythonprepend(n) )
576+ Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL);
577 Printv(f_shadow_stubs, tab4, "val = ",
578 funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
579 Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
580- if ( have_addtofunc(n) )
581- Printv(f_shadow_stubs, tab4, addtofunc(n), "\n", NIL);
582+ if ( have_pythonappend(n) )
583+ Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL);
584 Printv(f_shadow_stubs, tab4, "return val\n", NIL);
585 }
586 }
587 }
588@@ -2048,13 +2408,18 @@
589 Delete(pyaction);
590 Printv(f_shadow,pycode,"\n", NIL);
591 } else {
592 Printv(f_shadow, tab4, "def __del__(self, destroy=", module, ".", Swig_name_destroy(symname), "):\n", NIL);
593- if ( have_addtofunc(n) )
594- Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
595+ if ( have_docstring(n) )
596+ Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL);
597+ if ( have_pythonprepend(n) )
598+ Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
599 Printv(f_shadow, tab8, "try:\n", NIL);
600- Printv(f_shadow, tab4, tab8, "if self.thisown: destroy(self)\n", NIL);
601+ Printv(f_shadow, tab8, tab4, "if self.thisown: destroy(self)\n", NIL);
602 Printv(f_shadow, tab8, "except: pass\n", NIL);
603+ if ( have_pythonappend(n) )
604+ Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
605+ Printv(f_shadow, "\n", NIL);
606 }
607 }
608 return SWIG_OK;
609 }