[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:
Mark Gossage 2008-03-27 01:58:30 +00:00
commit 11647d87e8
14 changed files with 377 additions and 19 deletions

View file

@ -0,0 +1,35 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
// before we grab the header file, we must warn SWIG about some of these functions.
// these functions create data, so must be managed
%newobject createCircle;
%newobject createSquare;
// this method returns as pointer which must be managed
%newobject ShapeOwner::remove;
// you cannot use %delobject on ShapeOwner::add()
// as this disowns the ShapeOwner, not the Shape (oops)
//%delobject ShapeOwner::add(Shape*); DO NOT USE
// either you can use a new function (such as this)
/*%delobject add_Shape;
%inline %{
void add_Shape(Shape* s,ShapeOwner* own){own->add(s);}
%}*/
// or a better solution is a typemap
%apply SWIGTYPE *DISOWN {Shape* ptr};
//%ignore ShapeOwner::add;
// now we can grab the header file
%include "example.h"