[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
|
|
@ -1,6 +1,10 @@
|
||||||
Version 1.3.36 (in progress)
|
Version 1.3.36 (in progress)
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
|
06/17/2008: mgossage
|
||||||
|
[Lua] Added missing support for bool& and bool*. Added runtest for li_typemaps testcase.
|
||||||
|
(Bug #1938142)
|
||||||
|
|
||||||
06/07/2008: bhy
|
06/07/2008: bhy
|
||||||
Added test case keyword_rename, then made the keyword renaming works properly
|
Added test case keyword_rename, then made the keyword renaming works properly
|
||||||
by fixing Swig_name_make() for a incomplete condition checking.
|
by fixing Swig_name_make() for a incomplete condition checking.
|
||||||
|
|
|
||||||
40
Examples/test-suite/lua/li_typemaps_runme.lua
Normal file
40
Examples/test-suite/lua/li_typemaps_runme.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
require("import") -- the import fn
|
||||||
|
import("li_typemaps") -- import code
|
||||||
|
|
||||||
|
-- catch "undefined" global variables
|
||||||
|
setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end})
|
||||||
|
|
||||||
|
-- Check double INPUT typemaps
|
||||||
|
assert(li_typemaps.in_double(22.22) == 22.22)
|
||||||
|
assert(li_typemaps.inr_double(22.22) == 22.22)
|
||||||
|
|
||||||
|
-- Check double OUTPUT typemaps
|
||||||
|
assert(li_typemaps.out_double(22.22) == 22.22)
|
||||||
|
assert(li_typemaps.outr_double(22.22) == 22.22)
|
||||||
|
|
||||||
|
-- Check double INOUT typemaps
|
||||||
|
assert(li_typemaps.inout_double(22.22) == 22.22)
|
||||||
|
assert(li_typemaps.inoutr_double(22.22) == 22.22)
|
||||||
|
|
||||||
|
-- check long long
|
||||||
|
assert(li_typemaps.in_ulonglong(20)==20)
|
||||||
|
assert(li_typemaps.inr_ulonglong(20)==20)
|
||||||
|
assert(li_typemaps.out_ulonglong(20)==20)
|
||||||
|
assert(li_typemaps.outr_ulonglong(20)==20)
|
||||||
|
assert(li_typemaps.inout_ulonglong(20)==20)
|
||||||
|
assert(li_typemaps.inoutr_ulonglong(20)==20)
|
||||||
|
|
||||||
|
-- check bools
|
||||||
|
assert(li_typemaps.in_bool(true)==true)
|
||||||
|
assert(li_typemaps.inr_bool(false)==false)
|
||||||
|
assert(li_typemaps.out_bool(true)==true)
|
||||||
|
assert(li_typemaps.outr_bool(false)==false)
|
||||||
|
assert(li_typemaps.inout_bool(true)==true)
|
||||||
|
assert(li_typemaps.inoutr_bool(false)==false)
|
||||||
|
|
||||||
|
-- the others
|
||||||
|
a,b=li_typemaps.inoutr_int2(1,2)
|
||||||
|
assert(a==1 and b==2)
|
||||||
|
|
||||||
|
f,i=li_typemaps.out_foo(10)
|
||||||
|
assert(f.a==10 and i==20)
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
%{$1 = (lua_toboolean(L, $input)!=0);%}
|
%{$1 = (lua_toboolean(L, $input)!=0);%}
|
||||||
|
|
||||||
%typemap(out) bool
|
%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
|
// for const bool&, SWIG treats this as a const bool* so we must dereference it
|
||||||
%typemap(in,checkfn="lua_isboolean") const bool& (bool temp)
|
%typemap(in,checkfn="lua_isboolean") const bool& (bool temp)
|
||||||
|
|
@ -81,7 +81,7 @@
|
||||||
$1=&temp;%}
|
$1=&temp;%}
|
||||||
|
|
||||||
%typemap(out) const bool&
|
%typemap(out) const bool&
|
||||||
%{ lua_pushboolean(L,(int)(*$1==true)); SWIG_arg++;%}
|
%{ lua_pushboolean(L,(int)((*$1)!=0)); SWIG_arg++;%}
|
||||||
|
|
||||||
// strings (char* and char[])
|
// strings (char* and char[])
|
||||||
%typemap(in,checkfn="lua_isstring") const char*, 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
|
// 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
|
* Basic Array typemaps
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -320,6 +336,11 @@ for array handling
|
||||||
%typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int);
|
%typemap(freearg) (TYPE *INOUT,int)=(TYPE *INPUT,int);
|
||||||
|
|
||||||
// TODO out variable arrays (is there a standard form for such things?)
|
// 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
|
%enddef
|
||||||
|
|
||||||
// the following line of code
|
// the following line of code
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue