]> git.saurik.com Git - wxWidgets.git/blame - wxPython/SWIG/swig.python.patch
Another addtomethod removed
[wxWidgets.git] / wxPython / SWIG / swig.python.patch
CommitLineData
d14a1e28
RD
1Index: Source/Modules/python.cxx
2===================================================================
3RCS file: /cvsroot/SWIG/Source/Modules/python.cxx,v
4retrieving revision 1.25
5diff -u -r1.25 python.cxx
6--- Source/Modules/python.cxx 23 Sep 2003 21:26:04 -0000 1.25
7+++ Source/Modules/python.cxx 30 Oct 2003 02:39:33 -0000
8@@ -292,6 +292,9 @@
9 static String *shadow_indent = 0;
10 static int in_class = 0;
11 static int classic = 0;
12+static int modern = 0;
13+static int apply = 0;
14+static int new_repr = 0;
15
16 /* C++ Support + Shadow Classes */
17
18@@ -306,6 +309,9 @@
19 -interface <lib>- Set the lib name to <lib>\n\
20 -keyword - Use keyword arguments\n\
21 -classic - Use classic classes only\n\
22+ -modern - Use modern python features only, without compatibility code\n\
23+ -apply - Use apply() in proxy classes\n\
24+ -new_repr - Use more informative version of __repr__ in proxy classes\n\
25 -noexcept - No automatic exception handling\n\
26 -noproxy - Don't generate proxy classes \n\n";
27
28@@ -344,6 +350,12 @@
29 } else if ((strcmp(argv[i],"-shadow") == 0) || ((strcmp(argv[i],"-proxy") == 0))) {
30 shadow = 1;
31 Swig_mark_arg(i);
32+ } else if (strcmp(argv[i],"-apply") == 0) {
33+ apply = 1;
34+ Swig_mark_arg(i);
35+ } else if (strcmp(argv[i],"-new_repr") == 0) {
36+ new_repr = 1;
37+ Swig_mark_arg(i);
38 } else if ((strcmp(argv[i],"-noproxy") == 0)) {
39 shadow = 0;
40 Swig_mark_arg(i);
41@@ -353,6 +365,10 @@
42 } else if (strcmp(argv[i],"-classic") == 0) {
43 classic = 1;
44 Swig_mark_arg(i);
45+ } else if (strcmp(argv[i],"-modern") == 0) {
46+ classic = 0;
47+ modern = 1;
48+ Swig_mark_arg(i);
49 } else if (strcmp(argv[i],"-help") == 0) {
50 fputs(usage,stderr);
51 } else if (strcmp (argv[i], "-ldflags") == 0) {
52@@ -480,47 +496,54 @@
53 Printv(f_shadow,
54 "# This file was created automatically by SWIG.\n",
55 "# Don't modify this file, modify the SWIG interface instead.\n",
56- "# This file is compatible with both classic and new-style classes.\n",
57 NIL);
58
59- Printf(f_shadow,"import %s\n", module);
60-
61- // Python-2.2 object hack
62-
63- Printv(f_shadow,
64- "def _swig_setattr(self,class_type,name,value):\n",
65- tab4, "if (name == \"this\"):\n",
66- tab4, tab4, "if isinstance(value, class_type):\n",
67- tab4, tab8, "self.__dict__[name] = value.this\n",
68- tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n",
69- tab4, tab8, "del value.thisown\n",
70- tab4, tab8, "return\n",
71- // tab8, "if (name == \"this\") or (name == \"thisown\"): self.__dict__[name] = value; return\n",
72- tab4, "method = class_type.__swig_setmethods__.get(name,None)\n",
73- tab4, "if method: return method(self,value)\n",
74- tab4, "self.__dict__[name] = value\n\n",
75- NIL);
76+ if (! modern) {
77+ Printv(f_shadow,
78+ "# This file is compatible with both classic and new-style classes.\n",
79+ NIL);
80+ }
81+
82+ Printf(f_shadow,"\nimport %s\n\n", module);
83
84- Printv(f_shadow,
85- "def _swig_getattr(self,class_type,name):\n",
86- tab4, "method = class_type.__swig_getmethods__.get(name,None)\n",
87- tab4, "if method: return method(self)\n",
88- tab4, "raise AttributeError,name\n\n",
89- NIL);
90+ if (! modern) {
91+ // Python-2.2 object hack
92+ Printv(f_shadow,
93+ "def _swig_setattr(self,class_type,name,value):\n",
94+ tab4, "if (name == \"this\"):\n",
95+ tab4, tab4, "if isinstance(value, class_type):\n",
96+ tab4, tab8, "self.__dict__[name] = value.this\n",
97+ tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n",
98+ tab4, tab8, "del value.thisown\n",
99+ tab4, tab8, "return\n",
100+ // tab8, "if (name == \"this\") or (name == \"thisown\"): self.__dict__[name] = value; return\n",
101+ tab4, "method = class_type.__swig_setmethods__.get(name,None)\n",
102+ tab4, "if method: return method(self,value)\n",
103+ tab4, "self.__dict__[name] = value\n\n",
104+ NIL);
105
106- if (!classic) {
107- Printv(f_shadow,
108- "import types\n",
109- "try:\n",
110- " _object = types.ObjectType\n",
111- " _newclass = 1\n",
112- "except AttributeError:\n",
113- " class _object : pass\n",
114- " _newclass = 0\n",
115- "\n\n",
116- NIL);
117+ Printv(f_shadow,
118+ "def _swig_getattr(self,class_type,name):\n",
119+ tab4, "method = class_type.__swig_getmethods__.get(name,None)\n",
120+ tab4, "if method: return method(self)\n",
121+ tab4, "raise AttributeError,name\n\n",
122+ NIL);
123+
124+ if (!classic) {
125+ Printv(f_shadow,
126+ "import types\n",
127+ "try:\n",
128+ " _object = types.ObjectType\n",
129+ " _newclass = 1\n",
130+ "except AttributeError:\n",
131+ " class _object : pass\n",
132+ " _newclass = 0\n",
133+ "del types\n",
134+ "\n\n",
135+ NIL);
136+ }
137 }
138-
139+
140 if (directorsEnabled()) {
141 // Try loading weakref.proxy, which is only available in Python 2.1 and higher
142 Printv(f_shadow,
143@@ -610,6 +633,83 @@
144 return Language::importDirective(n);
145 }
146
147+
148+ /* ------------------------------------------------------------
149+ * emitFuncCallHelper()
150+ * Write the shadow code to call a function in the extension
151+ * module. Takes into account the -apply flag and whether
152+ * to use keyword args or not.
153+ * ------------------------------------------------------------ */
154+
155+ String *funcCallHelper(String *name, int kw) {
156+ String *str;
157+
158+ str = NewString("");
159+ if (apply) {
160+ Printv(str, "apply(", module, ".", name, ", args", (kw ? ", kwargs" : ""), ")", NIL);
161+ } else {
162+ Printv(str, module, ".", name, "(*args", (kw ? ", **kwargs" : ""), ")", NIL);
163+ }
164+ return str;
165+ }
166+
167+
168+ /* ------------------------------------------------------------
169+ * emitFunctionShadowHelper()
170+ * Refactoring some common code out of functionWrapper and
171+ * dispatchFunction that writes the proxy code for non-member
172+ * functions.
173+ * ------------------------------------------------------------ */
174+
175+ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) {
176+ if ( ! have_addtofunc(n) ) {
177+ /* If there is no addtofunc directive then just assign from the extension module */
178+ Printv(f_dest, "\n", name, " = ", module, ".", name, "\n", NIL);
179+ } else {
180+ /* Otherwise make a wrapper function to insert the code into */
181+ Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
182+ Printv(f_dest, tab4, "val = ", funcCallHelper(name, kw), "\n", NIL);
183+ Printv(f_dest, tab4, addtofunc(n), "\n", NIL);
184+ Printv(f_dest, tab4, "return val\n", NIL);
185+ }
186+ }
187+
188+
189+ /* ------------------------------------------------------------
190+ * check_kwargs()
191+ * check if using kwargs is allowed for this Node
192+ * ------------------------------------------------------------ */
193+
194+ int check_kwargs(Node *n) {
195+ return ((use_kw || Getattr(n,"feature:kwargs")) && !Getattr(n, "feature:nokwargs")) ? 1 : 0;
196+ }
197+
198+
199+ /* ------------------------------------------------------------
200+ * have_addtofunc()
201+ * Check if there is a %addtofunc directive and it has text
202+ * ------------------------------------------------------------ */
203+
204+ bool have_addtofunc(Node *n) {
205+ String* str = Getattr(n, "feature:addtofunc");
206+ return (str != NULL && Len(str) > 0);
207+ }
208+
209+ /* ------------------------------------------------------------
210+ * addtofunc()
211+ * Get the %addtofunc code, stripping off {} if neccessary
212+ * ------------------------------------------------------------ */
213+
214+ String *addtofunc(Node *n) {
215+ String* str = Getattr(n, "feature:addtofunc");
216+ char* t = Char(str);
217+ if (*t == '{') {
218+ Delitem(str ,0);
219+ Delitem(str,DOH_END);
220+ }
221+ return str;
222+ }
223+
224 /* ------------------------------------------------------------
225 * add_method()
226 * ------------------------------------------------------------ */
227@@ -650,7 +750,7 @@
228 int num_required;
229 int num_arguments;
230 int varargs = 0;
231- int allow_kwargs = (use_kw || Getattr(n,"feature:kwargs")) ? 1 : 0;
232+ int allow_kwargs = check_kwargs(n);
233
234 /* member of a director class? */
235 String *nodeType = Getattr(n, "nodeType");
236@@ -1007,11 +1107,7 @@
237
238 /* Create a shadow for this function (if enabled and not in a member function) */
239 if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
240- if (in_class) {
241- Printv(f_shadow_stubs,iname, " = ", module, ".", iname, "\n\n", NIL);
242- } else {
243- Printv(f_shadow,iname, " = ", module, ".", iname, "\n\n", NIL);
244- }
245+ emitFunctionShadowHelper(n, in_class ? f_shadow_stubs : f_shadow, iname, allow_kwargs);
246 }
247 } else {
248 if (!Getattr(n,"sym:nextSibling")) {
249@@ -1068,7 +1164,7 @@
250
251 /* Create a shadow for this function (if enabled and not in a member function) */
252 if ((shadow) && (!(shadow & PYSHADOW_MEMBER))) {
253- Printv(f_shadow_stubs,symname, " = ", module, ".", symname, "\n\n", NIL);
254+ emitFunctionShadowHelper(n, f_shadow_stubs, symname, 0);
255 }
256 DelWrapper(f);
257 Delete(dispatch);
258@@ -1754,6 +1850,7 @@
259
260 virtual int classHandler(Node *n) {
261 int oldclassic = classic;
262+ int oldmodern = modern;
263
264 if (shadow) {
265
266@@ -1763,8 +1860,16 @@
267
268 if (Getattr(n,"cplus:exceptionclass")) {
269 classic = 1;
270+ modern = 0;
271+ }
272+ if (Getattr(n,"feature:classic")) {
273+ classic = 1;
274+ modern = 0;
275+ }
276+ if (Getattr(n,"feature:modern")) {
277+ classic = 0;
278+ modern = 1;
279 }
280- if (Getattr(n,"feature:classic")) classic = 1;
281
282 shadow_indent = (String *) tab4;
283
284@@ -1798,30 +1903,32 @@
285 Printf(f_shadow,"(%s)", base_class);
286 } else {
287 if (!classic) {
288- Printf(f_shadow,"(_object)");
289+ Printf(f_shadow, modern ? "(object)" : "(_object)");
290 }
291 }
292 Printf(f_shadow,":\n");
293
294- Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
295- if (Len(base_class)) {
296- Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
297- }
298+ if (!modern) {
299+ Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
300+ if (Len(base_class)) {
301+ Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
302+ }
303
304- Printv(f_shadow,
305- tab4, "__setattr__ = lambda self, name, value: _swig_setattr(self, ", class_name, ", name, value)\n",
306- NIL);
307+ Printv(f_shadow,
308+ tab4, "__setattr__ = lambda self, name, value: _swig_setattr(self, ", class_name, ", name, value)\n",
309+ NIL);
310
311- Printv(f_shadow,tab4,"__swig_getmethods__ = {}\n",NIL);
312- if (Len(base_class)) {
313- Printf(f_shadow,"%sfor _s in [%s]: __swig_getmethods__.update(_s.__swig_getmethods__)\n",tab4,base_class);
314- }
315+ Printv(f_shadow,tab4,"__swig_getmethods__ = {}\n",NIL);
316+ if (Len(base_class)) {
317+ Printf(f_shadow,"%sfor _s in [%s]: __swig_getmethods__.update(_s.__swig_getmethods__)\n",tab4,base_class);
318+ }
319
320- Printv(f_shadow,
321- tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n",
322- NIL);
323+ Printv(f_shadow,
324+ tab4, "__getattr__ = lambda self, name: _swig_getattr(self, ", class_name, ", name)\n",
325+ NIL);
326+ }
327 }
328-
329+
330 /* Emit all of the members */
331
332 in_class = 1;
333@@ -1853,21 +1960,37 @@
334
335 if (!have_repr) {
336 /* Supply a repr method for this class */
337- Printv(f_shadow,
338- tab4, "def __repr__(self):\n",
339- tab8, "return \"<C ", class_name," instance at %s>\" % (self.this,)\n",
340- NIL);
341+ if (new_repr) {
342+ Printv(f_shadow,
343+ tab4, "def __repr__(self):\n",
344+ tab8, "return \"<%s.%s; proxy of ", CPlusPlus ? "C++ " : "C ", real_classname," instance at %s>\" % (self.__class__.__module__, self.__class__.__name__, self.this,)\n",
345+ NIL);
346+ }
347+ else {
348+ Printv(f_shadow,
349+ tab4, "def __repr__(self):\n",
350+ tab8, "return \"<C ", real_classname," instance at %s>\" % (self.this,)\n",
351+ NIL);
352+ }
353 }
354- /* Now build the real class with a normal constructor */
355+ /* Now the Ptr class */
356 Printv(f_shadow,
357 "\nclass ", class_name, "Ptr(", class_name, "):\n",
358- tab4, "def __init__(self,this):\n",
359- tab8, "_swig_setattr(self, ", class_name, ", 'this', this)\n",
360- tab8, "if not hasattr(self,\"thisown\"): _swig_setattr(self, ", class_name, ", 'thisown', 0)\n",
361+ tab4, "def __init__(self, this):\n", NIL);
362+ if (!modern) {
363+ Printv(f_shadow,
364+ tab8, "_swig_setattr(self, ", class_name, ", 'this', this)\n",
365+ tab8, "if not hasattr(self,\"thisown\"): _swig_setattr(self, ", class_name, ", 'thisown', 0)\n",
366+ tab8, "_swig_setattr(self, ", class_name, ",self.__class__,", class_name, ")\n",
367+ NIL);
368+ } else {
369+ Printv(f_shadow,
370+ tab8, "self.this = this\n",
371+ tab8, "if not hasattr(self,\"thisown\"): self.thisown = 0\n",
372+ tab8, "self.__class__ = ", class_name, "\n", NIL);
373 // tab8,"try: self.this = this.this; self.thisown = getattr(this,'thisown',0); this.thisown=0\n",
374 // tab8,"except AttributeError: self.this = this\n"
375- tab8, "_swig_setattr(self, ", class_name, ",self.__class__,", class_name, ")\n",
376- NIL);
377+ }
378
379 Printf(f_shadow,"%s.%s_swigregister(%sPtr)\n", module, class_name, class_name,0);
380 shadow_indent = 0;
381@@ -1875,6 +1998,7 @@
382 Clear(f_shadow_stubs);
383 }
384 classic = oldclassic;
385+ modern = oldmodern;
386 return SWIG_OK;
387 }
388
389@@ -1894,7 +2018,7 @@
390
391 if (!Getattr(n,"sym:nextSibling")) {
392 if (shadow) {
393- int allow_kwargs = (use_kw || Getattr(n,"feature:kwargs")) ? 1 : 0;
394+ int allow_kwargs = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0;
395 if (Strcmp(symname,"__repr__") == 0)
396 have_repr = 1;
397
398@@ -1902,14 +2026,18 @@
399 String *pycode = pythoncode(Getattr(n,"feature:shadow"),tab4);
400 Printv(f_shadow,pycode,"\n",NIL);
401 } else {
402- if (allow_kwargs && !Getattr(n,"sym:overloaded")) {
403- Printv(f_shadow,tab4, "def ", symname, "(*args, **kwargs): ", NIL);
404- Printv(f_shadow, "return apply(", module, ".", Swig_name_member(class_name,symname), ",args, kwargs)\n", NIL);
405- } else {
406- Printv(f_shadow, tab4, "def ", symname, "(*args): ", NIL);
407- Printv(f_shadow, "return apply(", module, ".", Swig_name_member(class_name,symname), ",args)\n",NIL);
408- }
409- }
410+
411+ Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL);
412+ if ( have_addtofunc(n) ) {
413+ Printv(f_shadow, "\n", NIL);
414+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
415+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
416+ Printv(f_shadow, tab8, "return val\n", NIL);
417+ } else {
418+ Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
419+ }
420+ }
421+
422 }
423 }
424 return SWIG_OK;
425@@ -1923,10 +2051,28 @@
426 String *symname = Getattr(n,"sym:name");
427 Language::staticmemberfunctionHandler(n);
428 if (shadow) {
429- Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(class_name, symname), "\n", NIL);
430- if (!classic) {
431- Printv(f_shadow, tab4, "if _newclass:", symname, " = staticmethod(", module, ".",
432- Swig_name_member(class_name, symname), ")\n", NIL);
433+ if ( !classic && have_addtofunc(n) ) {
434+ int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0;
435+ Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
436+ Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL);
437+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
438+ Printv(f_shadow, tab8, "return val\n", NIL);
439+ Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname,
440+ " = staticmethod(", symname, ")\n", NIL);
441+
442+ if (!modern) {
443+ Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", symname, "\n", NIL);
444+ }
445+
446+ } else {
447+ if (!modern) {
448+ Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = lambda x: ", module, ".", Swig_name_member(class_name, symname), "\n", NIL);
449+ }
450+ if (!classic) {
451+ Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname,
452+ " = staticmethod(", module, ".",
453+ Swig_name_member(class_name, symname), ")\n", NIL);
454+ }
455 }
456 }
457 return SWIG_OK;
458@@ -1972,7 +2118,7 @@
459
460 if (!Getattr(n,"sym:nextSibling")) {
461 if (shadow) {
462- int allow_kwargs = (use_kw || Getattr(n,"feature:kwargs")) ? 1 : 0;
463+ int allow_kwargs = (check_kwargs(n) && (!Getattr(n,"sym:overloaded"))) ? 1 : 0;
464 if (!have_constructor) {
465 if (Getattr(n,"feature:shadow")) {
466 String *pycode = pythoncode(Getattr(n,"feature:shadow"),tab4);
467@@ -1991,18 +2137,25 @@
468 tab8, tab4, "args = (self,) + args\n",
469 NIL);
470 }
471- if ((allow_kwargs) && (!Getattr(n,"sym:overloaded"))) {
472- Printv(f_shadow, tab4, "def __init__(self,*args,**kwargs):\n", NIL);
473- Printv(f_shadow, pass_self, NIL);
474- Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', apply(", module, ".", Swig_name_construct(symname), ",args, kwargs))\n", NIL);
475- } else {
476- Printv(f_shadow, tab4, "def __init__(self,*args):\n",NIL);
477- Printv(f_shadow, pass_self, NIL);
478- Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', apply(", module, ".", Swig_name_construct(symname), ",args))\n", NIL);
479- }
480- Printv(f_shadow,
481- tab8, "_swig_setattr(self, ", rclassname, ", 'thisown', 1)\n",
482- NIL);
483+
484+ Printv(f_shadow, tab4, "def __init__(self, *args",
485+ (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL);
486+ Printv(f_shadow, pass_self, NIL);
487+ if (!modern) {
488+ Printv(f_shadow, tab8, "_swig_setattr(self, ", rclassname, ", 'this', ",
489+ funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
490+ Printv(f_shadow,
491+ tab8, "_swig_setattr(self, ", rclassname, ", 'thisown', 1)\n",
492+ NIL);
493+ } else {
494+ Printv(f_shadow, tab8, "newobj = ",
495+ funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
496+ Printv(f_shadow, tab8, "self.this = newobj.this\n", NIL);
497+ Printv(f_shadow, tab8, "self.thisown = 1\n", NIL);
498+ Printv(f_shadow, tab8, "del newobj.thisown\n", NIL);
499+ }
500+ if ( have_addtofunc(n) )
501+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
502 Delete(pass_self);
503 }
504 have_constructor = 1;
505@@ -2014,19 +2167,16 @@
506 String *pycode = pythoncode(Getattr(n,"feature:shadow"),"");
507 Printv(f_shadow_stubs,pycode,"\n",NIL);
508 } else {
509- if ((allow_kwargs) && (!Getattr(n,"sym:overloaded")))
510- Printv(f_shadow_stubs, "def ", symname, "(*args,**kwargs):\n", NIL);
511- else
512- Printv(f_shadow_stubs, "def ", symname, "(*args):\n", NIL);
513-
514- Printv(f_shadow_stubs, tab4, "val = apply(", NIL);
515- if ((allow_kwargs) && (!Getattr(n,"sym:overloaded")))
516- Printv(f_shadow_stubs, module, ".", Swig_name_construct(symname), ",args,kwargs)\n", NIL);
517- else
518- Printv(f_shadow_stubs, module, ".", Swig_name_construct(symname), ",args)\n", NIL);
519- Printv(f_shadow_stubs,tab4, "val.thisown = 1\n",
520- tab4, "return val\n\n", NIL);
521- }
522+
523+ Printv(f_shadow_stubs, "\ndef ", symname, "(*args",
524+ (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL);
525+ Printv(f_shadow_stubs, tab4, "val = ",
526+ funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
527+ Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
528+ if ( have_addtofunc(n) )
529+ Printv(f_shadow_stubs, tab4, addtofunc(n), "\n", NIL);
530+ Printv(f_shadow_stubs, tab4, "return val\n", NIL);
531+ }
532 }
533 }
534 }
535@@ -2045,7 +2195,9 @@
536 Language::destructorHandler(n);
537 shadow = oldshadow;
538 if (shadow) {
539- Printv(f_shadow, tab4, "def __del__(self, destroy= ", module, ".", Swig_name_destroy(symname), "):\n", NIL);
540+ Printv(f_shadow, tab4, "def __del__(self, destroy=", module, ".", Swig_name_destroy(symname), "):\n", NIL);
541+ if ( have_addtofunc(n) )
542+ Printv(f_shadow, tab8, addtofunc(n), "\n", NIL);
543 Printv(f_shadow, tab8, "try:\n", NIL);
544 Printv(f_shadow, tab4, tab8, "if self.thisown: destroy(self)\n", NIL);
545 Printv(f_shadow, tab8, "except: pass\n", NIL);
546@@ -2066,21 +2218,22 @@
547 shadow = oldshadow;
548
549 if (shadow) {
550- int immutable = 0;
551- if (!Getattr(n,"feature:immutable")) {
552- Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", Swig_name_set(Swig_name_member(class_name,symname)), "\n", NIL);
553- } else {
554- immutable = 1;
555+ int immutable = (Getattr(n,"feature:immutable") != NULL);
556+ if (!modern) {
557+ if (!immutable) {
558+ Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", Swig_name_set(Swig_name_member(class_name,symname)), "\n", NIL);
559+ }
560+ Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", Swig_name_get(Swig_name_member(class_name,symname)),"\n", NIL);
561 }
562- Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", Swig_name_get(Swig_name_member(class_name,symname)),"\n", NIL);
563-
564 if (!classic) {
565 if (immutable) {
566- Printv(f_shadow,tab4,"if _newclass:", symname," = property(", module, ".",
567+ Printv(f_shadow,tab4, modern ? "" : "if _newclass:",
568+ symname," = property(", module, ".",
569 Swig_name_get(Swig_name_member(class_name,symname)),")\n", NIL);
570 } else {
571- Printv(f_shadow,tab4,"if _newclass:", symname," = property(",
572- module, ".", Swig_name_get(Swig_name_member(class_name,symname)),",",
573+ Printv(f_shadow,tab4, modern ? "" : "if _newclass:",
574+ symname," = property(",
575+ module, ".", Swig_name_get(Swig_name_member(class_name,symname)),", ",
576 module, ".", Swig_name_set(Swig_name_member(class_name,symname)),")\n", NIL);
577 }
578 }
579@@ -2142,8 +2295,9 @@
580 Delitem(temp,0);
581 Delitem(temp,DOH_END);
582 }
583+
584 /* Split the input text into lines */
585- List *clist = DohSplit(temp,'\n',-1);
586+ List *clist = DohSplitLines(temp);
587 Delete(temp);
588 int initial = 0;
589 String *s = 0;
590@@ -2194,7 +2348,7 @@
591 if ((!ImportMode) && ((Cmp(section,"python") == 0) || (Cmp(section,"shadow") == 0))) {
592 if (shadow) {
593 String *pycode = pythoncode(code,shadow_indent);
594- Printv(f_shadow, pycode, "\n", NIL);
595+ Printv(f_shadow, pycode, NIL);
596 Delete(pycode);
597 }
598 } else {