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 |