I have added the ability to add overloaded functions to wxLua - 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);
 returns = 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[] =
    {
        { 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 = sizeof(overloaded_TestOverLoad_methods)/sizeof(overloaded_TestOverLoad_methods[0]);
    wxLuaState wxlState(L);
    return wxlState.CallOverloadedFunction(overloaded_TestOverLoad_methods, overloaded_TestOverLoad_methodCount);
}
#endif
 
WXLUAMETHOD* wxLuaGetBuiltinList_wx(size_t &count)
{
    static WXLUAMETHOD builtinList[] =
    {
#if defined(TESTOVERLOAD)
  // overloaded function
        { LuaGlobal, "TestOverLoad", wx_TestOverLoad, 1, 0 },
#endif
.....
 
Hopefully it will be useful
 
Ray

Reply via email to