[lua] Added a typemap DISOWN for SWIGTYPE* and SWIGTYPE[], and support for %delobject feature.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10326 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
97b910d726
commit
11647d87e8
14 changed files with 377 additions and 19 deletions
|
|
@ -120,14 +120,14 @@
|
|||
// the checkfn SWIG_isptrtype will work for both userdata and nil's
|
||||
%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE*,SWIGTYPE[]
|
||||
%{
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,0))){
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){
|
||||
SWIG_fail_ptr("$symname",$argnum,$descriptor);
|
||||
}
|
||||
%}
|
||||
|
||||
%typemap(in,checkfn="lua_isuserdata") SWIGTYPE&
|
||||
%{
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,0))){
|
||||
if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,$disown))){
|
||||
SWIG_fail_ptr("$symname",$argnum,$descriptor);
|
||||
}
|
||||
%}
|
||||
|
|
@ -165,6 +165,17 @@
|
|||
%{temp=($*ltype)SWIG_MustGetPtr(L,$input,$*descriptor,0,$argnum,"$symname");
|
||||
$1=&temp;%}
|
||||
|
||||
// DISOWN-ing typemaps
|
||||
// if you have an object pointer which must be disowned, use this typemap
|
||||
// eg. for void destroy_foo(Foo* toDie);
|
||||
// use %apply SWIGTYPE* DISOWN {Foo* toDie};
|
||||
// you could just use %delobject, but this is more flexible
|
||||
%typemap(in,checkfn="SWIG_isptrtype") SWIGTYPE* DISOWN,SWIGTYPE DISOWN[]
|
||||
%{ if (!SWIG_IsOK(SWIG_ConvertPtr(L,$input,(void**)&$1,$descriptor,SWIG_POINTER_DISOWN))){
|
||||
SWIG_fail_ptr("$symname",$argnum,$descriptor);
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
// Primitive types--return by value
|
||||
// must make a new object, copy the data & return the new object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue