From: Ray G. <ray...@sc...> - 2006-04-17 11:40:39
|
I have added the ability to add overloaded functions to wxLua - added = test directly into wx_bind.cpp =20 #define TESTOVERLOAD #if defined(TESTOVERLOAD) // Test Overloaded Function Binding // a std function binding static int LUACALL wx_TestOverLoad_Int(lua_State *L) { wxLuaState wxlState(L); wxString returns; int argCount =3D lua_gettop(L); int value =3D (argCount >=3D 1 ? (int)wxlState.GetNumberType(1) : = 0); returns =3D wxString::Format(wxT("wx.TestOverLoad(%d) called C Function = wx_TestOverLoad_Int"), value); lua_pushstring(L, wx2lua(returns) ); return 1; } // a std function binding static int LUACALL wx_TestOverLoad_String(lua_State *L) { wxLuaState wxlState(L); wxString returns; int argCount =3D lua_gettop(L); wxString value =3D (argCount >=3D 1 ? = lua2wx(wxlState.GetStringType(1)) : wxEmptyString); returns =3D wxString::Format(wxT("wx.TestOverLoad(\"%s\") called C = Function wx_TestOverLoad_String"), value.c_str()); lua_pushstring(L, wx2lua(returns) ); return 1; } // an overloaded function binding static int LUACALL wx_TestOverLoad(lua_State *L) { // function overload table static WXLUAMETHOD overloaded_TestOverLoad_methods[] =3D { { LuaGlobal, "wx_TestOverLoad_Int", wx_TestOverLoad_Int, 1, 0, { = &s_wxluaarg_Number,0 /* note the 0 to mark end of arg list */ } }, { LuaGlobal, "wx_TestOverLoad_String", wx_TestOverLoad_String, = 1, 1, { &s_wxluaarg_String,0 } }, }; static int overloaded_TestOverLoad_methodCount =3D = sizeof(overloaded_TestOverLoad_methods)/sizeof(overloaded_TestOverLoad_me= thods[0]); wxLuaState wxlState(L); return = wxlState.CallOverloadedFunction(overloaded_TestOverLoad_methods, = overloaded_TestOverLoad_methodCount); } #endif =20 WXLUAMETHOD* wxLuaGetBuiltinList_wx(size_t &count) { static WXLUAMETHOD builtinList[] =3D { #if defined(TESTOVERLOAD) // overloaded function { LuaGlobal, "TestOverLoad", wx_TestOverLoad, 1, 0 }, #endif ..... =20 Hopefully it will be useful =20 Ray |
From: Francesco M. <f18...@ya...> - 2006-04-17 14:09:16
|
Hi, Ray Gilbert ha scritto: > I have added the ability to add overloaded functions to wxLua indeed this feature looks great ! > - added > test directly into wx_bind.cpp > > #define TESTOVERLOAD > #if defined(TESTOVERLOAD) > // Test Overloaded Function Binding > // a std function binding > static int LUACALL wx_TestOverLoad_Int(lua_State *L) > { > wxLuaState wxlState(L); > wxString returns; > int argCount = lua_gettop(L); > int value = (argCount >= 1 ? (int)wxlState.GetNumberType(1) : 0); > returns = wxString::Format(wxT("wx.TestOverLoad(%d) called C Function > wx_TestOverLoad_Int"), value); > lua_pushstring(L, wx2lua(returns) ); > return 1; > } > // a std function binding > static int LUACALL wx_TestOverLoad_String(lua_State *L) > { > wxLuaState wxlState(L); > wxString returns; > int argCount = lua_gettop(L); > wxString value = (argCount >= 1 ? lua2wx(wxlState.GetStringType(1)) > : wxEmptyString); I did a small fix in line above: // wxT("") is required instead of wxEmptyString otherwise GCC says: // ../modules/wxbind/src/wx_bind.cpp:52: error: operands to ?: have different types wxString value = (argCount >= 1 ? lua2wx(wxlState.GetStringType(1)) : wxT("")); and just committed it; however I wonder: wx_bind.cpp is regenerated by genwxbind.lua... so, adding this code directly in wx_bind.cpp doesn't mean that next time it's regenerated, the code will be lost ? Francesco |
From: Ray G. <ray...@sc...> - 2006-04-17 20:48:04
|
Yep, I know that it will be over written. Just added it so you could see = proof of concept. =20 It should be added to genwxbind, but I will leave that to later. =20 Ray ________________________________ From: wxl...@li... on behalf of Francesco = Montorsi Sent: Tue 18/04/2006 12:08 AM To: wxl...@li... Subject: [Wxlua-users] Re: Added Overloaded Function Capability To = wxlstate Hi, Ray Gilbert ha scritto: > I have added the ability to add overloaded functions to wxLua indeed this feature looks great ! > - added > test directly into wx_bind.cpp >=20 > #define TESTOVERLOAD > #if defined(TESTOVERLOAD) > // Test Overloaded Function Binding > // a std function binding > static int LUACALL wx_TestOverLoad_Int(lua_State *L) > { > wxLuaState wxlState(L); > wxString returns; > int argCount =3D lua_gettop(L); > int value =3D (argCount >=3D 1 ? (int)wxlState.GetNumberType(1) : = 0); > returns =3D wxString::Format(wxT("wx.TestOverLoad(%d) called C = Function > wx_TestOverLoad_Int"), value); > lua_pushstring(L, wx2lua(returns) ); > return 1; > } > // a std function binding > static int LUACALL wx_TestOverLoad_String(lua_State *L) > { > wxLuaState wxlState(L); > wxString returns; > int argCount =3D lua_gettop(L); > wxString value =3D (argCount >=3D 1 ? = lua2wx(wxlState.GetStringType(1)) > : wxEmptyString); I did a small fix in line above: // wxT("") is required instead of wxEmptyString otherwise GCC says: // ../modules/wxbind/src/wx_bind.cpp:52: error: operands to ?: have different types wxString value =3D (argCount >=3D 1 ? = lua2wx(wxlState.GetStringType(1)) : wxT("")); and just committed it; however I wonder: wx_bind.cpp is regenerated by genwxbind.lua... so, adding this code directly in wx_bind.cpp doesn't mean that next time it's regenerated, the code will be lost ? Francesco ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting = language that extends applications into web and mobile media. Attend the live = webcast and join the prime developer group breaking into this new coding = territory! http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=3D= 121642 _______________________________________________ Wxlua-users mailing list Wxl...@li... https://lists.sourceforge.net/lists/listinfo/wxlua-users |
From: John L. <jla...@gm...> - 2006-04-17 21:30:38
|
On 4/17/06, Ray Gilbert <ray...@sc...> wrote: > Yep, I know that it will be over written. Just added it so you could see = proof of concept. > > It should be added to genwxbind, but I will leave that to later. I need to overwrite it to fix some issues w/ wxWidgets CVS head. Should I keep it or just let it get overwritten? What do the bindings look like for them, is this ok or is there some sort of tag for it? %class ... wxColour wxColour(const wxString& name) wxColour(int r, int g, int b) wxColour(const wxColour& colour) // and for functions bool DoStuff(int i) bool DoStuff(const wxString& i) Thanks, John Labenski > From: wxl...@li... on behalf of Francesco Mont= orsi > Sent: Tue 18/04/2006 12:08 AM > To: wxl...@li... > Subject: [Wxlua-users] Re: Added Overloaded Function Capability To wxlsta= te > > > > Hi, > > Ray Gilbert ha scritto: > > I have added the ability to add overloaded functions to wxLua > indeed this feature looks great ! > > > - added > > test directly into wx_bind.cpp > > > > #define TESTOVERLOAD > > #if defined(TESTOVERLOAD) > > // Test Overloaded Function Binding > > // a std function binding > > static int LUACALL wx_TestOverLoad_Int(lua_State *L) > > { > > wxLuaState wxlState(L); > > wxString returns; > > int argCount =3D lua_gettop(L); > > int value =3D (argCount >=3D 1 ? (int)wxlState.GetNumberType(1) : 0= ); > > returns =3D wxString::Format(wxT("wx.TestOverLoad(%d) called C Functio= n > > wx_TestOverLoad_Int"), value); > > lua_pushstring(L, wx2lua(returns) ); > > return 1; > > } > > // a std function binding > > static int LUACALL wx_TestOverLoad_String(lua_State *L) > > { > > wxLuaState wxlState(L); > > wxString returns; > > int argCount =3D lua_gettop(L); > > wxString value =3D (argCount >=3D 1 ? lua2wx(wxlState.GetStringType= (1)) > > : wxEmptyString); > I did a small fix in line above: > > // wxT("") is required instead of wxEmptyString otherwise GCC says: > // ../modules/wxbind/src/wx_bind.cpp:52: error: operands to ?: > have different types > wxString value =3D (argCount >=3D 1 ? lua2wx(wxlState.GetStringType(= 1)) > : wxT("")); > > and just committed it; however I wonder: wx_bind.cpp is regenerated by > genwxbind.lua... so, adding this code directly in wx_bind.cpp doesn't > mean that next time it's regenerated, the code will be lost ? > > Francesco > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Wxlua-users mailing list > Wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > > > > |