From: Marcelo M. <mar...@us...> - 2006-03-04 11:06:56
|
Update of /cvsroot/swig/SWIG/Source/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31037/Source/Modules Modified Files: python.cxx Log Message: add -fastinit option after issue reported by Robin Dunn Index: python.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v retrieving revision 1.194 retrieving revision 1.195 diff -C2 -d -r1.194 -r1.195 *** python.cxx 28 Feb 2006 00:39:25 -0000 1.194 --- python.cxx 4 Mar 2006 11:06:51 -0000 1.195 *************** *** 71,74 **** --- 71,75 ---- static int fastunpack = 0; static int fastproxy = 0; + static int fastinit = 0; static int olddefs = 0; static int modernargs = 0; *************** *** 101,104 **** --- 102,106 ---- -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ + -fastinit - Use fast init mechanism for classes \n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ -fastproxy - Use fast proxy mechanism for member methods \n\ *************** *** 118,121 **** --- 120,124 ---- -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ + -nofastinit - Use traditional init mechanism for classes (default) \n\ -nofastunpack - Use traditional UnpackTuple method to parse the argument functions (default) \n\ -nofastproxy - Use traditional proxy mechanism for member methods (default) \n\ *************** *** 139,143 **** -O - Enable all the optimizations options: \n\ -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual \n\ ! -noproxydel -fastproxy -fastunpack -modernargs -nobuildnone \n\ \n"; --- 142,146 ---- -O - Enable all the optimizations options: \n\ -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual \n\ ! -noproxydel -fastproxy -fastinit -fastunpack -modernargs -nobuildnone \n\ \n"; *************** *** 337,340 **** --- 340,349 ---- fastproxy = 0; Swig_mark_arg(i); + } else if (strcmp(argv[i],"-fastinit") == 0) { + fastinit = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i],"-nofastinit") == 0) { + fastinit = 0; + Swig_mark_arg(i); } else if (strcmp(argv[i],"-olddefs") == 0) { olddefs = 1; *************** *** 403,406 **** --- 412,416 ---- fastunpack = 1; fastproxy = 1; + fastinit = 1; modernargs = 1; Wrapper_fast_dispatch_mode_set(1); *************** *** 2689,2694 **** if (!have_constructor) { Printv(f_shadow_file, tab4,"def __init__(self): raise AttributeError, \"No constructor defined\"\n", NIL); } - if (!have_repr) { /* Supply a repr method for this class */ --- 2699,2711 ---- if (!have_constructor) { Printv(f_shadow_file, tab4,"def __init__(self): raise AttributeError, \"No constructor defined\"\n", NIL); + } else if (fastinit) { + + Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); + Printv(f_wrappers, tab4, "return SWIG_Python_InitShadowInstance(args);\n", + "}\n\n",NIL); + String *cname = NewStringf("%s_swiginit", class_name); + add_method(cname, cname, 0); + Delete(cname); } if (!have_repr) { /* Supply a repr method for this class */ *************** *** 2975,3003 **** } ! Printv(f_shadow, tab4, "def __init__(self, *args", ! (allow_kwargs ? ", **kwargs" : ""),"):\n", NIL); if ( have_docstring(n) ) ! Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if ( have_pythonprepend(n) ) Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pass_self, NIL); ! Printv(f_shadow, tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs),"\n", NIL); ! if (!modern) { ! Printv(f_shadow, tab8, "try: self.this.append(this)\n", NIL); ! Printv(f_shadow, tab8, "except: self.this = this\n", NIL); ! Printv(f_shadow, ! #ifdef USE_THISOWN ! tab8, "_swig_setattr(self, ", rclassname, ", 'thisown', 1)\n", ! #endif ! NIL); ! } else { ! Printv(f_shadow, tab8, "try: self.this.append(this)\n", NIL); ! Printv(f_shadow, tab8, "except: self.this = this\n", NIL); ! #ifdef USE_THISOWN ! Printv(f_shadow, tab8, "self.thisown = 1\n", NIL); ! Printv(f_shadow, tab8, "del newobj.thisown\n", NIL); ! #endif ! } ! if ( have_pythonappend(n) ) Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); Delete(pass_self); --- 2992,3011 ---- } ! Printv(f_shadow, tab4, "def __init__(self, *args",(allow_kwargs ? ", **kwargs" : ""),"): \n", NIL); if ( have_docstring(n) ) ! Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8),"\n",NIL); if ( have_pythonprepend(n) ) Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pass_self, NIL); ! if (fastinit) { ! Printv(f_shadow, ! tab8, module, ".", class_name, "_swiginit(self,", funcCallHelper(Swig_name_construct(symname), allow_kwargs),")\n", NIL); ! } else { ! Printv(f_shadow, ! tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs),"\n", ! tab8, "try: self.this.append(this)\n", ! tab8, "except: self.this = this\n", NIL); ! } ! if ( have_pythonappend(n) ) Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); Delete(pass_self); |