diff -r b2cc6f31363c -r 5f26f4bc574b src/squirrel_helper.hpp --- a/src/squirrel_helper.hpp Sun Mar 25 15:22:56 2007 +0000 +++ b/src/squirrel_helper.hpp Sun Mar 25 16:10:40 2007 +0000 @@ -379,14 +379,27 @@ /* Find the amount of params we got */ int nparam = sq_gettop(vm); SQUserPointer ptr = NULL; - SQUserPointer instance = NULL; + SQUserPointer real_instance = NULL; + HSQOBJECT instance; + + /* Get the 'SQ' instance of this class */ + Squirrel::GetInstance(vm, &instance); + + /* Protect against calls to a non-static method in a static way */ + sq_pushroottable(vm); + sq_pushstring(vm, Tcls::GetClassName(), -1); + sq_get(vm, -2); + sq_pushobject(vm, instance); + if (sq_instanceof(vm) != SQTrue) return sq_throwerror(vm, "class method is non-static"); + sq_settop(vm, nparam); /* Get the 'real' instance of this class */ - sq_getinstanceup(vm, 1, &instance, 0); + sq_getinstanceup(vm, 1, &real_instance, 0); /* Get the real function pointer */ sq_getuserdata(vm, nparam, &ptr, 0); + /* Delegate it to a template that can handle this specific function */ - return HelperT::SQCall((Tcls *)instance, *(Tmethod *)ptr, vm); + return HelperT::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm); } }; // namespace SQConvert