--- a/src/squirrel_helper.hpp Tue Jun 17 22:37:09 2008 +0000
+++ b/src/squirrel_helper.hpp Tue Jun 17 23:16:33 2008 +0000
@@ -110,7 +110,8 @@
if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &tmp))) {
*data.Append() = (int32)tmp;
} else {
- // TODO: handle following error properly: "array member is not numeric; ignoring member"
+ sq_pop(vm, 4);
+ throw sq_throwerror(vm, _SC("a member of an array used as parameter to a function is not numeric"));
}
sq_pop(vm, 2);
@@ -637,8 +638,13 @@
/* Remove the userdata from the stack */
sq_pop(vm, 1);
- /* Delegate it to a template that can handle this specific function */
- return HelperT<Tmethod>::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm);
+ try {
+ /* Delegate it to a template that can handle this specific function */
+ return HelperT<Tmethod>::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm);
+ } catch (SQInteger e) {
+ sq_pop(vm, nparam);
+ return e;
+ }
}
/**
@@ -693,8 +699,13 @@
/* Get the real function pointer */
sq_getuserdata(vm, nparam, &ptr, 0);
- /* Delegate it to a template that can handle this specific function */
- return HelperT<Tmethod>::SQCall((Tcls *)NULL, *(Tmethod *)ptr, vm);
+ try {
+ /* Delegate it to a template that can handle this specific function */
+ return HelperT<Tmethod>::SQCall((Tcls *)NULL, *(Tmethod *)ptr, vm);
+ } catch (SQInteger e) {
+ sq_pop(vm, nparam);
+ return e;
+ }
}
/**
@@ -717,12 +728,20 @@
template <typename Tcls, typename Tmethod, int Tnparam>
inline SQInteger DefSQConstructorCallback(HSQUIRRELVM vm)
{
- /* Create the real instance */
- Tcls *instance = HelperT<Tmethod>::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm);
- sq_setinstanceup(vm, -Tnparam, instance);
- sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
- instance->AddRef();
- return 0;
+ /* Find the amount of params we got */
+ int nparam = sq_gettop(vm);
+
+ try {
+ /* Create the real instance */
+ Tcls *instance = HelperT<Tmethod>::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm);
+ sq_setinstanceup(vm, -Tnparam, instance);
+ sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>);
+ instance->AddRef();
+ return 0;
+ } catch (SQInteger e) {
+ sq_pop(vm, nparam);
+ return e;
+ }
}
}; // namespace SQConvert