Skip to content

Commit

Permalink
Fixed size_t error in Lua callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardodoria committed Dec 4, 2023
1 parent 000e0cd commit 9c95083
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions engine/core/script/LuaFunctionBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ void LuaFunctionBase::push_value(lua_State *vm, long n){
lua_pushnumber(vm, n);
}

void LuaFunctionBase::push_value(lua_State *vm, unsigned long n){
lua_pushnumber(vm, n);
}

void LuaFunctionBase::push_value(lua_State *vm, bool b){
lua_pushboolean(vm, b);
}
Expand All @@ -109,10 +113,6 @@ void LuaFunctionBase::push_value(lua_State *vm, wchar_t s){
lua_pushstring(vm, StringUtils::toUTF8(s).c_str());
}

void LuaFunctionBase::push_value(lua_State *vm, size_t n){
lua_pushnumber(vm, n);
}

void LuaFunctionBase::push_value(lua_State *vm, Vector3 o){
if (!luabridge::push<Vector3>(vm, o))
throw luabridge::makeErrorCode(luabridge::ErrorCode::LuaStackOverflow);
Expand Down
2 changes: 1 addition & 1 deletion engine/core/script/LuaFunctionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ namespace Supernova{
void push_value(lua_State *vm, unsigned int n);
void push_value(lua_State *vm, float n);
void push_value(lua_State *vm, long n);
void push_value(lua_State *vm, unsigned long n);
void push_value(lua_State *vm, bool b);
void push_value(lua_State *vm, const std::string &s);
void push_value(lua_State *vm, wchar_t s);
void push_value(lua_State *vm, size_t n);
void push_value(lua_State *vm, Vector3 n);
void push_value(lua_State *vm, Body2D o);
void push_value(lua_State *vm, Contact2D o);
Expand Down
8 changes: 4 additions & 4 deletions engine/core/script/binding/CoreClassesLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ void LuaBinding::registerCoreClasses(lua_State *L){
.endClass();

luabridge::getGlobalNamespace(L)
.beginClass<FunctionSubscribe<bool(Body2D, size_t, Body2D, size_t)>>("FunctionSubscribe_B_B2SB2S")
.addFunction("__call", &FunctionSubscribe<bool(Body2D, size_t, Body2D, size_t)>::call)
.addFunction("call", &FunctionSubscribe<bool(Body2D, size_t, Body2D, size_t)>::call)
.addFunction("add", (bool (FunctionSubscribe<bool(Body2D, size_t, Body2D, size_t)>::*)(const std::string&, lua_State*))&FunctionSubscribe<bool(Body2D, size_t, Body2D, size_t)>::add)
.beginClass<FunctionSubscribe<bool(Body2D, unsigned long, Body2D, unsigned long)>>("FunctionSubscribe_B_B2ULB2UL")
.addFunction("__call", &FunctionSubscribe<bool(Body2D, unsigned long, Body2D, unsigned long)>::call)
.addFunction("call", &FunctionSubscribe<bool(Body2D, unsigned long, Body2D, unsigned long)>::call)
.addFunction("add", (bool (FunctionSubscribe<bool(Body2D, unsigned long, Body2D, unsigned long)>::*)(const std::string&, lua_State*))&FunctionSubscribe<bool(Body2D, unsigned long, Body2D, unsigned long)>::add)
.endClass();

luabridge::getGlobalNamespace(L)
Expand Down
2 changes: 1 addition & 1 deletion engine/core/subsystem/PhysicsSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace Supernova{
FunctionSubscribe<void(Contact2D, Manifold2D)> preSolve2D;
FunctionSubscribe<void(Contact2D, ContactImpulse2D)> postSolve2D;

FunctionSubscribe<bool(Body2D, size_t, Body2D, size_t)> shouldCollide2D;
FunctionSubscribe<bool(Body2D, unsigned long, Body2D, unsigned long)> shouldCollide2D;

FunctionSubscribe<void(Body3D)> onBodyActivated3D;
FunctionSubscribe<void(Body3D)> onBodyDeactivated3D;
Expand Down
4 changes: 2 additions & 2 deletions engine/core/util/Box2DAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace Supernova{
}

bool ShouldCollide(b2Fixture* fixtureA, b2Fixture* fixtureB){
size_t shapeIndexA = fixtureA->GetUserData().pointer;
unsigned long shapeIndexA = fixtureA->GetUserData().pointer;
Entity entityA = fixtureA->GetBody()->GetUserData().pointer;
Body2D bodyA(scene, entityA);

size_t shapeIndexB = fixtureB->GetUserData().pointer;
unsigned long shapeIndexB = fixtureB->GetUserData().pointer;
Entity entityB = fixtureB->GetBody()->GetUserData().pointer;
Body2D bodyB(scene, entityB);

Expand Down

0 comments on commit 9c95083

Please sign in to comment.