Hi John,
The index operator almost works.
The line:
a2dLayerInfo* returns = new a2dLayerInfo((*self)[(indx)]);
should become this:
a2dLayerInfo* returns = new a2dLayerInfo(*(*self)[(indx)]);
The copy constructor needs a reference, while my inde operator return a
pointer.
If it would return a reference it would be oke. So maybe in other cases
it might be oke.
Here the binding code:
%include "canvas/include/layerinf.h"
%class %noclassinfo a2dLayers, a2dCanvasObject
a2dLayers()
a2dLayers( const a2dLayers& other, a2dObject::CloneOptions options =
a2dObject::clone_deep )
%operator a2dLayerInfo* operator[] (int indx)
%operator const a2dLayerInfo* operator[] (int indx) const
Here the (already corrected by me) result:
static int LUACALL wxLua_a2dLayers_op_index(lua_State *L)
{
// int indx
int indx = (int)wxlua_getnumbertype(L, 2);
// get this
a2dLayers * self = (a2dLayers *)wxluaT_getuserdatatype(L, 1,
wxluatype_a2dLayers);
// call op_index
// allocate a new object using the copy constructor
a2dLayerInfo* returns = new a2dLayerInfo(*(*self)[(indx)]);
// add the new object to the tracked memory list
wxluaO_addgcobject(L, (a2dLayerInfo*)returns);
// push the result datatype
wxluaT_pushuserdatatype(L, returns, wxluatype_a2dLayerInfo);
return 1;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users