[Javascript] Fix SWIG_exception() macro (#792)

Fix SWIG_exception() macro to return from the current function.
Fixes #789, reported by Julien Dutriaux.
This commit is contained in:
Olly Betts 2016-09-17 17:29:42 +12:00 committed by GitHub
commit b138f054e5
8 changed files with 40 additions and 3 deletions

View file

@ -32,6 +32,7 @@ static JSObjectRef $jswrapper(JSContextRef context, JSObjectRef ctorObject,
size_t argc, const JSValueRef argv[], JSValueRef* exception)
{
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
fail:
return 0;
}
%}

View file

@ -53,7 +53,7 @@ SWIGINTERN bool JS_veto_set_variable(JSContextRef context, JSObjectRef thisObjec
} else {
SWIG_exception(SWIG_ERROR, msg);
}
fail:
return false;
}

View file

@ -4,7 +4,7 @@
* ---------------------------------------------------------------------------*/
#define SWIG_Error(code, msg) SWIG_JSC_exception(context, exception, code, msg)
#define SWIG_exception(code, msg) SWIG_JSC_exception(context, exception, code, msg)
#define SWIG_exception(code, msg) do { SWIG_JSC_exception(context, exception, code, msg); SWIG_fail; } while (0)
#define SWIG_fail goto fail
SWIGRUNTIME void SWIG_Javascript_Raise(JSContextRef context, JSValueRef *exception, const char* type) {

View file

@ -36,6 +36,7 @@ static SwigV8ReturnValue $jswrapper(const SwigV8Arguments &args) {
SWIGV8_HANDLESCOPE();
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
fail:
SWIGV8_RETURN(SWIGV8_UNDEFINED());
}
%}

View file

@ -83,6 +83,7 @@ SWIGRUNTIME void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<
} else {
SWIG_exception(SWIG_ERROR, msg);
}
fail: ;
}
%} // v8_helper_functions

View file

@ -97,7 +97,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
* ---------------------------------------------------------------------------*/
#define SWIG_Error(code, msg) SWIGV8_ErrorHandler.error(code, msg)
#define SWIG_exception(code, msg) SWIGV8_ErrorHandler.error(code, msg)
#define SWIG_exception(code, msg) do { SWIGV8_ErrorHandler.error(code, msg); SWIG_fail; } while (0)
#define SWIG_fail goto fail
#define SWIGV8_OVERLOAD false