(svn r23651) -Feature: [NoGo] GSText now accepts string arguments as parameters to the constructor

This commit is contained in:
yexo
2011-12-21 14:55:28 +00:00
parent a55478aaa6
commit 5988659eea
7 changed files with 76 additions and 9 deletions

View File

@@ -885,6 +885,28 @@ namespace SQConvert {
}
}
/**
* A general template to handle creating of an instance with a complex
* constructor.
*/
template <typename Tcls>
inline SQInteger DefSQAdvancedConstructorCallback(HSQUIRRELVM vm)
{
try {
/* Find the amount of params we got */
int nparam = sq_gettop(vm);
/* Create the real instance */
Tcls *instance = new Tcls(vm);
sq_setinstanceup(vm, -nparam, instance);
sq_setreleasehook(vm, -nparam, DefSQDestructorCallback<Tcls>);
instance->AddRef();
return 0;
} catch (SQInteger e) {
return e;
}
}
} // namespace SQConvert
#endif /* SQUIRREL_HELPER_HPP */