From 3a535690d4e9aaa896a062e7b5b5454b1b07ac47 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 21:00:32 +0000 Subject: (svn r23623) -Add: allow bi-directional communication with the AdminPort and GameScript --- src/script/squirrel_helper.hpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/script/squirrel_helper.hpp') diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index cdc4b8b8f..a72199dce 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -831,6 +831,28 @@ namespace SQConvert { } } + + /** + * A general template for all static advanced method callbacks from Squirrel. + * In here the function_proc is recovered, and the SQCall is called that + * can handle this exact amount of params. + */ + template + inline SQInteger DefSQAdvancedStaticCallback(HSQUIRRELVM vm) + { + /* Find the amount of params we got */ + int nparam = sq_gettop(vm); + SQUserPointer ptr = NULL; + + /* Get the real function pointer */ + sq_getuserdata(vm, nparam, &ptr, 0); + /* Remove the userdata from the stack */ + sq_pop(vm, 1); + + /* Call the function, which its only param is always the VM */ + return (SQInteger)(*(*(Tmethod *)ptr))(vm); + } + /** * A general template for the destructor of SQ instances. This is needed * here as it has to be in the same scope as DefSQConstructorCallback. -- cgit v1.2.3-54-g00ecf