diff --git a/include/hx/CFFIAPI.h b/include/hx/CFFIAPI.h index 0bb0d378a..fea68d14c 100644 --- a/include/hx/CFFIAPI.h +++ b/include/hx/CFFIAPI.h @@ -131,19 +131,28 @@ DEFFUNC_1(value,alloc_raw_string,int) // Call Function DEFFUNC_1(value,val_call0,value) +DEFFUNC_2(value,val_call0_catchexcept,value,value) DEFFUNC_2(value,val_call1,value,value) +DEFFUNC_3(value,val_call1_catchexcept,value,value,value) DEFFUNC_3(value,val_call2,value,value,value) +DEFFUNC_4(value,val_call2_catchexcept,value,value,value,value) DEFFUNC_4(value,val_call3,value,value,value,value) +DEFFUNC_5(value,val_call3_catchexcept,value,value,value,value,value) DEFFUNC_3(value,val_callN,value,value *,int) +DEFFUNC_4(value,val_callN_catchexcept,value,value *,int,value) // Call the function - catch and print any exceptions DEFFUNC_1(value,val_call0_traceexcept,value) // Call object field DEFFUNC_2(value,val_ocall0,value,int) +DEFFUNC_3(value,val_ocall0_catchexcept,value,int,value) DEFFUNC_3(value,val_ocall1,value,int,value) +DEFFUNC_4(value,val_ocall1_catchexcept,value,int,value,value) DEFFUNC_4(value,val_ocall2,value,int,value,value) +DEFFUNC_5(value,val_ocall2_catchexcept,value,int,value,value,value) DEFFUNC_4(value,val_ocallN,value,int,value *,int) +DEFFUNC_5(value,val_ocallN_catchexcept,value,int,value *,int,value) // Objects access DEFFUNC_1(int,val_id,const char *) diff --git a/src/hx/CFFI.cpp b/src/hx/CFFI.cpp index 96df8fa1c..ffbd6a36f 100644 --- a/src/hx/CFFI.cpp +++ b/src/hx/CFFI.cpp @@ -684,6 +684,25 @@ hx::Object * val_call0(hx::Object * arg1) THROWS if (!arg1) Dynamic::ThrowBadFunctionError(); return arg1->__run().GetPtr(); } +hx::Object * val_call0_catchexcept(hx::Object * arg1, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) Dynamic::ThrowBadFunctionError(); + return arg1->__run().GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_call0_traceexcept(hx::Object * arg1) THROWS { @@ -707,6 +726,25 @@ hx::Object * val_call1(hx::Object * arg1,hx::Object * arg2) THROWS if (!arg1) Dynamic::ThrowBadFunctionError(); return arg1->__run(arg2).GetPtr(); } +hx::Object * val_call1_catchexcept(hx::Object * arg1,hx::Object * arg2, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) Dynamic::ThrowBadFunctionError(); + return arg1->__run(arg2).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_call2(hx::Object * arg1,hx::Object * arg2,hx::Object * arg3) THROWS @@ -714,6 +752,25 @@ hx::Object * val_call2(hx::Object * arg1,hx::Object * arg2,hx::Object * arg3) TH if (!arg1) Dynamic::ThrowBadFunctionError(); return arg1->__run(arg2,arg3).GetPtr(); } +hx::Object * val_call2_catchexcept(hx::Object * arg1,hx::Object * arg2,hx::Object * arg3, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) Dynamic::ThrowBadFunctionError(); + return arg1->__run(arg2,arg3).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_call3(hx::Object * arg1,hx::Object * arg2,hx::Object * arg3,hx::Object * arg4) THROWS @@ -721,6 +778,25 @@ hx::Object * val_call3(hx::Object * arg1,hx::Object * arg2,hx::Object * arg3,hx: if (!arg1) Dynamic::ThrowBadFunctionError(); return arg1->__run(arg2,arg3,arg4).GetPtr(); } +hx::Object * val_call3_catchexcept(hx::Object * arg1,hx::Object * arg2,hx::Object * arg3,hx::Object * arg4, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) Dynamic::ThrowBadFunctionError(); + return arg1->__run(arg2,arg3,arg4).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_callN(hx::Object * arg1,hx::Object ** arg2, int nCount) THROWS @@ -731,6 +807,28 @@ hx::Object * val_callN(hx::Object * arg1,hx::Object ** arg2, int nCount) THROWS args << *arg2++; return arg1->__Run( args ).GetPtr(); } +hx::Object * val_callN_catchexcept(hx::Object * arg1,hx::Object ** arg2, int nCount, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) Dynamic::ThrowBadFunctionError(); + Array args = Array_obj::__new(0, nCount); + while (nCount--) + args << *arg2++; + return arg1->__Run( args ).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} // Call object field @@ -739,6 +837,25 @@ hx::Object * val_ocall0(hx::Object * arg1,int arg2) THROWS if (!arg1) hx::Throw(HX_INVALID_OBJECT); return arg1->__IField(arg2)->__run().GetPtr(); } +hx::Object * val_ocall0_catchexcept(hx::Object * arg1,int arg2, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) hx::Throw(HX_INVALID_OBJECT); + return arg1->__IField(arg2)->__run().GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_ocall1(hx::Object * arg1,int arg2,hx::Object * arg3) THROWS @@ -746,6 +863,25 @@ hx::Object * val_ocall1(hx::Object * arg1,int arg2,hx::Object * arg3) THROWS if (!arg1) hx::Throw(HX_INVALID_OBJECT); return arg1->__IField(arg2)->__run(arg3).GetPtr(); } +hx::Object * val_ocall1_catchexcept(hx::Object * arg1,int arg2,hx::Object * arg3, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) hx::Throw(HX_INVALID_OBJECT); + return arg1->__IField(arg2)->__run(arg3).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_ocall2(hx::Object * arg1,int arg2,hx::Object * arg3,hx::Object * arg4) THROWS @@ -753,6 +889,25 @@ hx::Object * val_ocall2(hx::Object * arg1,int arg2,hx::Object * arg3,hx::Object if (!arg1) hx::Throw(HX_INVALID_OBJECT); return arg1->__IField(arg2)->__run(arg3,arg4).GetPtr(); } +hx::Object * val_ocall2_catchexcept(hx::Object * arg1,int arg2,hx::Object * arg3,hx::Object * arg4, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) hx::Throw(HX_INVALID_OBJECT); + return arg1->__IField(arg2)->__run(arg3,arg4).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_ocall3(hx::Object * arg1,int arg2,hx::Object * arg3,hx::Object * arg4,hx::Object * arg5) THROWS @@ -760,6 +915,25 @@ hx::Object * val_ocall3(hx::Object * arg1,int arg2,hx::Object * arg3,hx::Object if (!arg1) hx::Throw(HX_INVALID_OBJECT); return arg1->__IField(arg2)->__run(arg3,arg4,arg5).GetPtr(); } +hx::Object * val_ocall3_catchexcept(hx::Object * arg1,int arg2,hx::Object * arg3,hx::Object * arg4,hx::Object * arg5, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) hx::Throw(HX_INVALID_OBJECT); + return arg1->__IField(arg2)->__run(arg3,arg4,arg5).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +} hx::Object * val_ocallN(hx::Object * arg1,int arg2,hx::Object * arg3) THROWS @@ -767,6 +941,25 @@ hx::Object * val_ocallN(hx::Object * arg1,int arg2,hx::Object * arg3) THROWS if (!arg1) hx::Throw(HX_INVALID_OBJECT); return arg1->__IField(arg2)->__run(Dynamic(arg3)).GetPtr(); } +hx::Object * val_ocallN_catchexcept(hx::Object * arg1,int arg2,hx::Object * arg3, hx::Object * fcatch) THROWS +{ + try + { + if (!arg1) hx::Throw(HX_INVALID_OBJECT); + return arg1->__IField(arg2)->__run(Dynamic(arg3)).GetPtr(); + } + catch(Dynamic e) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(e); + } + catch(...) + { + if(fcatch && fcatch->__ArgCount() == 1) + fcatch->__run(HX_CSTRING("Unknown error")); + } + return 0; +}