From 33e7a456570bef516ebc239d9f6ccb3f0d2a60a0 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Wed, 20 May 2020 22:23:02 +1000 Subject: [PATCH] Removing the closure parameter for class constructor, as we now have the typetag --- sp/src/vscript/vscript_squirrel.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sp/src/vscript/vscript_squirrel.cpp b/sp/src/vscript/vscript_squirrel.cpp index 204d5b63..f3d0516e 100644 --- a/sp/src/vscript/vscript_squirrel.cpp +++ b/sp/src/vscript/vscript_squirrel.cpp @@ -911,12 +911,8 @@ SQInteger destructor_stub_instance(SQUserPointer p, SQInteger size) SQInteger constructor_stub(HSQUIRRELVM vm) { - SQInteger top = sq_gettop(vm); - - SQUserPointer userptr = nullptr; - sq_getuserpointer(vm, top, &userptr); - - ScriptClassDesc_t* pClassDesc = (ScriptClassDesc_t*)userptr; + ScriptClassDesc_t* pClassDesc = nullptr; + sq_gettypetag(vm, 1, (SQUserPointer*)&pClassDesc); if (!pClassDesc->m_pfnConstruct) { @@ -1412,8 +1408,7 @@ bool SquirrelVM::RegisterClass(ScriptClassDesc_t* pClassDesc) sq_setclassudsize(vm_, -1, sizeof(ClassInstanceData)); sq_pushstring(vm_, "constructor", -1); - sq_pushuserpointer(vm_, pClassDesc); - sq_newclosure(vm_, constructor_stub, 1); + sq_newclosure(vm_, constructor_stub, 0); sq_newslot(vm_, -3, SQFalse); for (int i = 0; i < pClassDesc->m_FunctionBindings.Count(); ++i)