On Dec 23, 2007 9:21 AM, klaas.holwerda <[EMAIL PROTECTED]> wrote: > Hi John, > > I think i found the problem, it seems one can have not two pointers to > the same location. > The base class of MaskprocLuaWrapper has the pointer down here called > a2dLuaWP. > It has of course the same value as the pointer in the derived class. But > in the derived class it is called a2dMaskProc. > No if i outcoment the first %define_pointer a2dLuaWP, all is fine. But > if not i get the assertion. > > And i think the assertion at this spot is not a coincidence, if i > look at the name. > > luaO_rawequalObj(const lua_TValue * 0x4d678191, const lua_TValue * 0x02005698) > line 73 + 6 bytes > > Still this should not be a problem (at least if %delete means what i thought > it meant). > Maybe to make this work properly we need some smart pointer??
Nothing should be deleted at initialization nor should the garbage collector run. > So in short i have a global pointer to a command interpreter in a library, > and in my application the derived class has a global pointer to the same (but > derived class). > And both those pointer i like to wrap. I had actually changed code to make this possible, before you could only have a pointer to C++ be one type, say a wxWindow, but if a function returns it as a wxEvtHandler it'd swap all the references to the object to a wxEvtHandler from being a wxWindow. > What do you think? I tried adding an extra pointer for wxRED, which I know is not exactly the same since it sounds like you're casting the same object to two types, but at least this works. %class wxColour ... %rename wxRED %define_pointer wxLua_wxRED %rename wxREDA %define_pointer wxLua_wxRED Could you update to the newest CVS, regenerate your bindings and try again. I assume it will still fail and I'm guessing in this function. Try putting some statements like this into it for debugging. bool LUACALL wxluaT_pushuserdatatype(lua_State* L, const void *obj_ptr, int wxl_type, bool track, bool allow_NULL) { ... wxPrintf(wxT("pushuserdatatype1 %p %p pushing %p type %d\n"), a2dLuaWP, a2dMaskProc, obj_ptr, wxl_type); if (wxluaO_istrackedweakobject(L, (void*)obj_ptr, wxl_type, true)) return true; wxPrintf(wxT("pushuserdatatype2 %p %p pushing %p type %d\n"), a2dLuaWP, a2dMaskProc, obj_ptr, wxl_type); Then if it fails the second time it was pushed I'd guess it was inside of wxluaO_istrackedweakobject and see where it fails there. Thanks for looking into this, I'd really like this sort of stuff working, John > //-------------------- first binding module > luabind.i file > > %class %delete %noclassinfo a2dLuaWrapper, a2dCommandLanguageWrapper > //%define_pointer a2dLuaWP > a2dLuaWrapper( a2dCentralCanvasCommandProcessor* commandProcessor ) > ........................... > %endclass > > //-------------------- second binding module > maskproc.i > > %class %delete %noclassinfo MaskprocLuaWrapper, a2dLuaWrapper > MaskprocLuaWrapper( a2dCentralEditorCommandProcessor* > commandProcessor ) > bool Exit() > > %define_pointer a2dMaskProc > > %endclass > > > John Labenski wrote: > > On Dec 21, 2007 10:31 AM, Klaas Holwerda <[EMAIL PROTECTED]> wrote: > > > >> If i remove "%define_pointer a2dMaskProc", the RegisterBindings() fase is > >> fine. > >> The function a2dGetMaskProc() return the same pointer, and i tested a few > >> script > >> > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > wxlua-users mailing list > wxlua-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wxlua-users > ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users