I have a function I am trying to pass a null (0) pointer to:
virtual IGUIWindow * addWindow (const core::rect< s32 > &rectangle, bool modal=false, const wchar_t *text=0, IGUIElement *parent=0, s32 id=-1)=0
I registered it as:
r = engine->RegisterObjectMethod("GEnvironment", "GWindow@ addWindow(const recti &in,bool &in,const stringw &in,GElement@ &in,s32 &in)", asMETHOD(irr::gui::IGUIEnvironment, addWindow), asCALL_THISCALL); assert(r >= 0);
But I get a segfault when I try to create it in the script like this:
@conWin = GUIEnv.addWindow(windowPos,false,consoleTitle,null,ID_GUI_CONSOLE_WINDOW);
Normally, in C++, the equivalent call I am trying to make would be:
recti windowPos = recti(50,50,400,450);
stringw consoleTitle = L"Console"
IGUIWindow* win = gui_env->addWindow(windowPos,false,consoleTitle,0,ID_GUI_CONSOLE_WINDOW);
The only difference is the 4th field, null and 0 respectively. To troubleshoot, I made a wrapper function:
static irr::gui::IGUIWindow* addWindowWrapper(const irr::core::recti &a,bool b,const wchar_t* c,irr::gui::IGUIElement* d,s32 e,irr::gui::IGUIEnvironment* env)
{
d = 0;
env->addWindow(a,b,c,d,e);
}
And changed the registration call to:
r = engine->RegisterObjectMethod("GEnvironment", "GWindow@ addWindow(const recti &in,bool &in,const stringw &in,GElement@ &in,s32 &in)", asFUNCTION(addWindowWrapper), asCALL_CDECL_OBJLAST); assert(r >= 0);
In the wrapper, without the "d = 0" line to set the IGUIElement* pointer to 0, a value of 0xfffffff4 gets passed to the addWindow function, crashing it.
So I have a work around in place, my question is, how do you pass a pointer to 0 from the script? null seems to equate to 0xfffffff4 as seen above. I tried inputting an int, but it messed up the declaration because I have other functions that expect a pointer to an IGUIElement and not null, so I need a handle in the script call somewhere.
Any suggestions?