Skip to content

Commit

Permalink
Export cTestclass to lua.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seadragon91 committed Oct 20, 2016
1 parent f8f0dc4 commit 5c20f36
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
62 changes: 61 additions & 1 deletion src/Bindings/ManualBindings.cpp
Expand Up @@ -38,7 +38,7 @@
#include "../BuildInfo.h"
#include "../HTTP/UrlParser.h"
#include "../BoundingBox.h"

#include "../Testclass.h"



Expand Down Expand Up @@ -3799,6 +3799,59 @@ static int tolua_cCompositeChat_UnderlineUrls(lua_State * tolua_S)



static int tolua_cTestclass_new(lua_State * tolua_S)
{
cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cTestclass"))
{
return 0;
}
L.Push(static_cast<cTestclass *>(Mtolua_new(cTestclass())));
return 1;
}





static int tolua_cTestclass_new_local(lua_State * tolua_S)
{
// Use the same constructor as global, just register it for GC:
auto res = tolua_cTestclass_new(tolua_S);
if (res == 1)
{
tolua_register_gc(tolua_S, lua_gettop(tolua_S));
}
return res;
}






static int tolua_cTestclass_GetName(lua_State * tolua_S)
{
cLuaState L(tolua_S);
if (!L.CheckParamUserType(1, "cTestclass"))
{
return 0;
}

cTestclass * self = reinterpret_cast<cTestclass *>(tolua_tousertype(tolua_S, 1, nullptr));
if (self == nullptr)
{
tolua_error(tolua_S, "invalid 'self' in function 'cTestclass:GetName'", nullptr);
return 0;
}
L.Push(self->GetName());
return 1;
}





void cManualBindings::Bind(lua_State * tolua_S)
{
tolua_beginmodule(tolua_S, nullptr);
Expand Down Expand Up @@ -4014,6 +4067,13 @@ void cManualBindings::Bind(lua_State * tolua_S)
tolua_variable(tolua_S, "PostParams", tolua_get_HTTPRequest_PostParams, nullptr);
tolua_endmodule(tolua_S);

tolua_beginmodule(tolua_S, "cTestclass");
tolua_function(tolua_S, "new", tolua_cTestclass_new);
tolua_function(tolua_S, "new_local", tolua_cTestclass_new_local);
tolua_function(tolua_S, ".call", tolua_cTestclass_new_local);
tolua_function(tolua_S, "GetName", tolua_cTestclass_GetName);
tolua_endmodule(tolua_S);

BindNetwork(tolua_S);
BindRankManager(tolua_S);
BindWorld(tolua_S);
Expand Down
15 changes: 15 additions & 0 deletions src/Testclass.h
@@ -0,0 +1,15 @@

// Testclass.h

class cTestclass {
public:
cTestclass(void) {}
~cTestclass() {}

/** Get class name of the class. */
const AString GetName() { return AString("cTestclass"); }
};




0 comments on commit 5c20f36

Please sign in to comment.