From: Marcelo M. <mar...@us...> - 2005-12-27 21:44:15
|
Update of /cvsroot/swig/SWIG/Source/Modules In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14712/Modules Modified Files: lang.cxx main.cxx Log Message: add the 'naturalvar' option/mode/feature, to allow member variables to be treated in a natural way, as the global ones. This mean use the const SWIGTYPE &(C++)/SWIGTYPE(C) typemaps instead of the plain SWIGTYPE * typemap for the set/get methods. Index: main.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/main.cxx,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** main.cxx 22 Dec 2005 08:38:02 -0000 1.69 --- main.cxx 27 Dec 2005 21:44:05 -0000 1.70 *************** *** 412,415 **** --- 412,421 ---- Wrapper_fast_dispatch_mode_set(0); Swig_mark_arg(i); + } else if (strcmp(argv[i],"-naturalvar") == 0) { + Wrapper_naturalvar_mode_set(1); + Swig_mark_arg(i); + } else if (strcmp(argv[i],"-nonaturalvar") == 0) { + Wrapper_naturalvar_mode_set(0); + Swig_mark_arg(i); } else if (strcmp(argv[i],"-directors") == 0) { SWIG_setfeature("feature:director","1"); Index: lang.cxx =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Modules/lang.cxx,v retrieving revision 1.126 retrieving revision 1.127 diff -C2 -d -r1.126 -r1.127 *** lang.cxx 22 Dec 2005 08:38:02 -0000 1.126 --- lang.cxx 27 Dec 2005 21:44:05 -0000 1.127 *************** *** 21,24 **** --- 21,25 ---- static int director_mode = 0; /* set to 0 on default */ static int director_protected_mode = 0; /* set to 0 on default */ + static int naturalvar_mode = 0; /* Set director_protected_mode */ *************** *** 31,34 **** --- 32,39 ---- } + void Wrapper_naturalvar_mode_set(int flag) { + naturalvar_mode = flag; + } + extern "C" { int Swig_director_mode() *************** *** 378,381 **** --- 383,398 ---- int Language::top(Node *n) { + Node *mod = Getattr(n, "module"); + if (mod) { + Node *options = Getattr(mod, "options"); + if (options) { + if (Getattr(options, "naturalvar")) { + naturalvar_mode = 1; + } + if (Getattr(options, "nonaturalvar")) { + naturalvar_mode = 0; + } + } + } return emit_children(n); } *************** *** 1252,1256 **** } int flags = Extend | SmartPointer; ! //if (CPlusPlus) flags |= CWRAP_VAR_REFERENCE; Swig_MembersetToFunction(n,ClassType, flags); if (!Extend) { --- 1269,1277 ---- } int flags = Extend | SmartPointer; ! ! if (naturalvar_mode || GetFlag(n,"feature:naturalvar")) { ! flags |= CWRAP_NATURAL_VAR; ! } ! Swig_MembersetToFunction(n,ClassType, flags); if (!Extend) { *************** *** 1297,1301 **** /* Emit get function */ { ! Swig_MembergetToFunction(n,ClassType, Extend | SmartPointer); Setattr(n,"sym:name", mrename_get); functionWrapper(n); --- 1318,1327 ---- /* Emit get function */ { ! int flags = Extend | SmartPointer; ! if (naturalvar_mode || GetFlag(n,"feature:naturalvar")) { ! flags |= CWRAP_NATURAL_VAR; ! } ! ! Swig_MembergetToFunction(n,ClassType, flags); Setattr(n,"sym:name", mrename_get); functionWrapper(n); |