[lua] bugfix 1938142 (bool& and bool* support)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10527 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
32617f7804
commit
de6d6ccaa8
4 changed files with 67 additions and 2 deletions
|
|
@ -73,7 +73,7 @@
|
|||
%{$1 = (lua_toboolean(L, $input)!=0);%}
|
||||
|
||||
%typemap(out) bool
|
||||
%{ lua_pushboolean(L,(int)($1==true)); SWIG_arg++;%}
|
||||
%{ lua_pushboolean(L,(int)($1!=0)); SWIG_arg++;%}
|
||||
|
||||
// for const bool&, SWIG treats this as a const bool* so we must dereference it
|
||||
%typemap(in,checkfn="lua_isboolean") const bool& (bool temp)
|
||||
|
|
@ -81,7 +81,7 @@
|
|||
$1=&temp;%}
|
||||
|
||||
%typemap(out) const bool&
|
||||
%{ lua_pushboolean(L,(int)(*$1==true)); SWIG_arg++;%}
|
||||
%{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%}
|
||||
|
||||
// strings (char* and char[])
|
||||
%typemap(in,checkfn="lua_isstring") const char*, char*
|
||||
|
|
|
|||
|
|
@ -80,6 +80,22 @@ SWIG_NUMBER_TYPEMAP(long long); SWIG_NUMBER_TYPEMAP(unsigned long long); SWIG_NU
|
|||
|
||||
// note we dont do char, as a char* is probably a string not a ptr to a single char
|
||||
|
||||
// similar for booleans
|
||||
%typemap(in,checkfn="lua_isboolean") bool *INPUT(bool temp), bool &INPUT(bool temp)
|
||||
%{ temp = (lua_toboolean(L,$input)!=0);
|
||||
$1 = &temp; %}
|
||||
|
||||
%typemap(in, numinputs=0) bool *OUTPUT (bool temp),bool &OUTPUT (bool temp)
|
||||
%{ $1 = &temp; %}
|
||||
|
||||
%typemap(argout) bool *OUTPUT,bool &OUTPUT
|
||||
%{ lua_pushboolean(L, (int)((*$1)!=0)); SWIG_arg++;%}
|
||||
|
||||
%typemap(in) bool *INOUT = bool *INPUT;
|
||||
%typemap(argout) bool *INOUT = bool *OUTPUT;
|
||||
%typemap(in) bool &INOUT = bool &INPUT;
|
||||
%typemap(argout) bool &INOUT = bool &OUTPUT;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Basic Array typemaps
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -320,6 +336,11 @@ for array handling
|
|||
%typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int);
|
||||
|
||||
// TODO out variable arrays (is there a standard form for such things?)
|
||||
|
||||
// referencing so that (int *INPUT,int) and (int INPUT[],int) are the same
|
||||
%typemap(in) (TYPE INPUT[],int)=(TYPE *INPUT,int);
|
||||
%typemap(freearg) (TYPE INPUT[],int)=(TYPE *INPUT,int);
|
||||
|
||||
%enddef
|
||||
|
||||
// the following line of code
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue