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.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8089 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
75e1c22229
commit
a275bbd30f
8 changed files with 134 additions and 17 deletions
|
|
@ -20,6 +20,7 @@ char cvsroot_lang_cxx[] = "$Header$";
|
|||
|
||||
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 */
|
||||
void Wrapper_director_mode_set(int flag) {
|
||||
|
|
@ -30,6 +31,10 @@ void Wrapper_director_protected_mode_set(int flag) {
|
|||
director_protected_mode = flag;
|
||||
}
|
||||
|
||||
void Wrapper_naturalvar_mode_set(int flag) {
|
||||
naturalvar_mode = flag;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int Swig_director_mode()
|
||||
{
|
||||
|
|
@ -377,6 +382,18 @@ void swig_pragma(char *lang, char *name, char *value) {
|
|||
* ---------------------------------------------------------------------- */
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -1251,7 +1268,11 @@ Language::membervariableHandler(Node *n) {
|
|||
tm = Swig_typemap_lookup_new("memberin",n,target,0);
|
||||
}
|
||||
int flags = Extend | SmartPointer;
|
||||
//if (CPlusPlus) flags |= CWRAP_VAR_REFERENCE;
|
||||
|
||||
if (naturalvar_mode || GetFlag(n,"feature:naturalvar")) {
|
||||
flags |= CWRAP_NATURAL_VAR;
|
||||
}
|
||||
|
||||
Swig_MembersetToFunction(n,ClassType, flags);
|
||||
if (!Extend) {
|
||||
/* Check for a member in typemap here */
|
||||
|
|
@ -1296,7 +1317,12 @@ Language::membervariableHandler(Node *n) {
|
|||
}
|
||||
/* Emit get function */
|
||||
{
|
||||
Swig_MembergetToFunction(n,ClassType, Extend | SmartPointer);
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,6 +411,12 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
} else if (strcmp(argv[i],"-nofastdispatch") == 0) {
|
||||
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");
|
||||
Wrapper_director_mode_set(1);
|
||||
|
|
|
|||
|
|
@ -354,6 +354,8 @@ void Wrapper_director_mode_set(int);
|
|||
void Wrapper_director_protected_mode_set(int);
|
||||
void Wrapper_fast_dispatch_mode_set(int);
|
||||
void Wrapper_cast_dispatch_mode_set(int);
|
||||
void Wrapper_naturalvar_mode_set(int);
|
||||
|
||||
|
||||
void clean_overloaded(Node *n);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue