update to typemap for object by value, to make it c89 compliant
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9558 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a08135e1c7
commit
487ba5add5
1 changed files with 11 additions and 24 deletions
|
|
@ -60,16 +60,16 @@
|
||||||
|
|
||||||
// strings (char* and char[])
|
// strings (char* and char[])
|
||||||
%typemap(in,checkfn="lua_isstring") const char*, char*
|
%typemap(in,checkfn="lua_isstring") const char*, char*
|
||||||
%{$1 = ($1_ltype)lua_tostring(L, $input);%}
|
%{$1 = ($ltype)lua_tostring(L, $input);%}
|
||||||
|
|
||||||
%typemap(in,checkfn="lua_isstring") const char[ANY], char[ANY]
|
%typemap(in,checkfn="lua_isstring") const char[ANY], char[ANY]
|
||||||
%{$1 = (char*)lua_tostring(L, $input);%}
|
%{$1 = ($ltype)lua_tostring(L, $input);%}
|
||||||
|
|
||||||
%typemap(out) const char*, char*
|
%typemap(out) const char*, char*
|
||||||
%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%}
|
%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%}
|
||||||
|
|
||||||
%typemap(out) const char[ANY], char[ANY]
|
%typemap(out) const char[ANY], char[ANY]
|
||||||
%{ lua_pushstring(L,$1); SWIG_arg++;%}
|
%{ lua_pushstring(L,(const char*)$1); SWIG_arg++;%}
|
||||||
|
|
||||||
// char's
|
// char's
|
||||||
// currently treating chars as small strings, not as numbers
|
// currently treating chars as small strings, not as numbers
|
||||||
|
|
@ -130,38 +130,25 @@
|
||||||
|
|
||||||
// Primitive types--return by value
|
// Primitive types--return by value
|
||||||
// must make a new object, copy the data & return the new object
|
// must make a new object, copy the data & return the new object
|
||||||
|
// Note: the brackets are {...} and not %{..%}, because we want them to be included in the wrapper
|
||||||
|
// this is because out tpyemaps do not support local variables, like in typemaps do
|
||||||
|
// and we need the $&1_ltype resultptr; to be declared
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
%typemap(out) SWIGTYPE
|
%typemap(out) SWIGTYPE
|
||||||
%{
|
{
|
||||||
$&1_ltype resultptr;
|
$&1_ltype resultptr = new $1_ltype(($1_ltype &) $1);
|
||||||
resultptr = new $1_ltype(($1_ltype &) $1);
|
|
||||||
SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++;
|
SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++;
|
||||||
%}
|
}
|
||||||
#else
|
#else
|
||||||
%typemap(out) SWIGTYPE
|
%typemap(out) SWIGTYPE
|
||||||
%{
|
{
|
||||||
$&1_ltype resultptr;
|
$&1_ltype resultptr;
|
||||||
resultptr = ($&1_ltype) malloc(sizeof($1_type));
|
resultptr = ($&1_ltype) malloc(sizeof($1_type));
|
||||||
memmove(resultptr, &$1, sizeof($1_type));
|
memmove(resultptr, &$1, sizeof($1_type));
|
||||||
SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++;
|
SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++;
|
||||||
%}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*#ifdef __cplusplus
|
|
||||||
%typemap(out) SWIGTYPE ($&1_ltype resultptr)
|
|
||||||
%{
|
|
||||||
resultptr = new $1_ltype(($1_ltype &) $1);
|
|
||||||
SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++;
|
|
||||||
%}
|
|
||||||
#else
|
|
||||||
%typemap(out) SWIGTYPE ($&1_ltype resultptr)
|
|
||||||
%{
|
|
||||||
resultptr = ($&1_ltype) malloc(sizeof($1_type));
|
|
||||||
memmove(resultptr, &$1, sizeof($1_type));
|
|
||||||
SWIG_NewPointerObj(L,(void *) resultptr,$&1_descriptor,1); SWIG_arg++;
|
|
||||||
%}
|
|
||||||
#endif*/
|
|
||||||
|
|
||||||
// member function pointer
|
// member function pointer
|
||||||
// a member fn ptr is not 4 bytes like a normal pointer, but 8 bytes
|
// a member fn ptr is not 4 bytes like a normal pointer, but 8 bytes
|
||||||
// so the standard wrappering cannot be done
|
// so the standard wrappering cannot be done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue