(svn r23623) -Add: allow bi-directional communication with the AdminPort and GameScript

This commit is contained in:
truebrain
2011-12-19 21:00:32 +00:00
parent 77b7366c29
commit 3a535690d4
27 changed files with 656 additions and 7 deletions

View File

@@ -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 <typename Tcls, typename Tmethod>
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.