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
|
|
@ -181,6 +181,7 @@ CPP_TEST_CASES += \
|
|||
namespace_typedef_class \
|
||||
namespace_typemap \
|
||||
namespace_virtual_method \
|
||||
naturalvar \
|
||||
newobject1 \
|
||||
ordering \
|
||||
operator_overload \
|
||||
|
|
@ -329,6 +330,7 @@ CPP_STD_TEST_CASES += \
|
|||
li_std_pair \
|
||||
li_std_string \
|
||||
li_std_vector \
|
||||
naturalvar \
|
||||
template_typedef_fnc \
|
||||
template_type_namespace \
|
||||
template_opaque
|
||||
|
|
|
|||
38
Examples/test-suite/naturalvar.i
Normal file
38
Examples/test-suite/naturalvar.i
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
%module(naturalvar) naturalvar
|
||||
|
||||
#ifdef __cplusplus
|
||||
%include std_string.i
|
||||
%inline
|
||||
{
|
||||
struct Foo
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
std::string s;
|
||||
struct Bar
|
||||
{
|
||||
int i;
|
||||
Foo f;
|
||||
std::string s;
|
||||
};
|
||||
}
|
||||
#else
|
||||
%inline
|
||||
{
|
||||
typedef struct _foo
|
||||
{
|
||||
}Foo;
|
||||
|
||||
|
||||
char *s;
|
||||
typedef struct _bar
|
||||
{
|
||||
int i;
|
||||
Foo f;
|
||||
char *s;
|
||||
} Bar;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
12
Examples/test-suite/python/naturalvar_runme.py
Normal file
12
Examples/test-suite/python/naturalvar_runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from naturalvar import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar()
|
||||
|
||||
b.f = f
|
||||
|
||||
cvar.s = "hello"
|
||||
b.s = "hello"
|
||||
|
||||
if b.s != cvar.s:
|
||||
raise RuntimeError
|
||||
Loading…
Add table
Add a link
Reference in a new issue