From 8b836797e24a32bd398ab639c71cb8c59bcbfa82 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 31 Jan 2020 17:23:33 +0100 Subject: [PATCH] jscript: Directly return error code instead of using throw_type_error where possible. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/jscript/array.c | 4 ++-- dlls/jscript/bool.c | 6 +++--- dlls/jscript/dispex.c | 2 +- dlls/jscript/engine.c | 22 +++++++++++----------- dlls/jscript/enumerator.c | 8 ++++---- dlls/jscript/error.c | 2 +- dlls/jscript/function.c | 8 ++++---- dlls/jscript/jsregexp.c | 2 +- dlls/jscript/jsutils.c | 4 ++-- dlls/jscript/number.c | 14 +++++++------- dlls/jscript/object.c | 10 +++++----- dlls/jscript/vbarray.c | 14 +++++++------- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c index 5e022bc929a..55b7dd5d715 100644 --- a/dlls/jscript/array.c +++ b/dlls/jscript/array.c @@ -86,7 +86,7 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis, } if(!is_jsdisp(vdisp)) - return throw_type_error(ctx, JS_E_JSCRIPT_EXPECTED, NULL); + return JS_E_JSCRIPT_EXPECTED; hres = jsdisp_propget_name(vdisp->u.jsdisp, lengthW, &val); if(FAILED(hres)) @@ -934,7 +934,7 @@ static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un array = array_this(jsthis); if(!array) - return throw_type_error(ctx, JS_E_ARRAY_EXPECTED, NULL); + return JS_E_ARRAY_EXPECTED; return array_join(ctx, &array->dispex, array->length, default_separatorW, lstrlenW(default_separatorW), r); diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c index 2d0b9d0c1b4..3a28dddb4b1 100644 --- a/dlls/jscript/bool.c +++ b/dlls/jscript/bool.c @@ -66,7 +66,7 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns TRACE("\n"); if(!(bool = bool_this(jsthis))) - return throw_type_error(ctx, JS_E_BOOLEAN_EXPECTED, NULL); + return JS_E_BOOLEAN_EXPECTED; if(r) { jsstr_t *val; @@ -89,7 +89,7 @@ static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi TRACE("\n"); if(!(bool = bool_this(jsthis))) - return throw_type_error(ctx, JS_E_BOOLEAN_EXPECTED, NULL); + return JS_E_BOOLEAN_EXPECTED; if(r) *r = jsval_bool(bool->val); @@ -103,7 +103,7 @@ static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign switch(flags) { case INVOKE_FUNC: - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; default: FIXME("unimplemented flags %x\n", flags); return E_NOTIMPL; diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 73983a306e1..cdfbf9f57e4 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1908,7 +1908,7 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig if(!jsfunc->builtin_info->value_prop.invoke) { WARN("Not a function\n"); - return throw_type_error(jsfunc->ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; } set_disp(&vdisp, jsthis); diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index b700988f557..29270aa8e6e 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -153,7 +153,7 @@ static HRESULT stack_pop_object(script_ctx_t *ctx, IDispatch **r) v = stack_pop(ctx); if(is_object_instance(v)) { if(!get_object(v)) - return throw_type_error(ctx, JS_E_OBJECT_REQUIRED, NULL); + return JS_E_OBJECT_REQUIRED; *r = get_object(v); return S_OK; } @@ -1183,11 +1183,11 @@ static HRESULT interp_new(script_ctx_t *ctx) /* NOTE: Should use to_object here */ if(is_null(constr)) - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; else if(!is_object_instance(constr)) - return throw_type_error(ctx, JS_E_INVALID_ACTION, NULL); + return JS_E_INVALID_ACTION; else if(!get_object(constr)) - return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL); + return JS_E_INVALID_PROPERTY; clear_acc(ctx); return disp_call_value(ctx, get_object(constr), NULL, DISPATCH_CONSTRUCT | DISPATCH_JSCRIPT_CALLEREXECSSOURCE, @@ -1205,7 +1205,7 @@ static HRESULT interp_call(script_ctx_t *ctx) obj = stack_topn(ctx, argn); if(!is_object_instance(obj)) - return throw_type_error(ctx, JS_E_INVALID_PROPERTY, NULL); + return JS_E_INVALID_PROPERTY; clear_acc(ctx); return disp_call_value(ctx, get_object(obj), NULL, DISPATCH_METHOD | DISPATCH_JSCRIPT_CALLEREXECSSOURCE, @@ -1222,7 +1222,7 @@ static HRESULT interp_call_member(script_ctx_t *ctx) TRACE("%d %d\n", argn, do_ret); if(!stack_topn_exprval(ctx, argn, &ref)) - return throw_type_error(ctx, ref.u.hres, NULL); + return ref.u.hres; clear_acc(ctx); return exprval_call(ctx, &ref, DISPATCH_METHOD | DISPATCH_JSCRIPT_CALLEREXECSSOURCE, @@ -1619,7 +1619,7 @@ static HRESULT interp_instanceof(script_ctx_t *ctx) v = stack_pop(ctx); if(!is_object_instance(v) || !get_object(v)) { jsval_release(v); - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; } obj = iface_to_jsdisp(get_object(v)); @@ -1632,7 +1632,7 @@ static HRESULT interp_instanceof(script_ctx_t *ctx) if(is_class(obj, JSCLASS_FUNCTION)) { hres = jsdisp_propget_name(obj, prototypeW, &prot); }else { - hres = throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + hres = JS_E_FUNCTION_EXPECTED; } jsdisp_release(obj); if(FAILED(hres)) @@ -1679,7 +1679,7 @@ static HRESULT interp_in(script_ctx_t *ctx) obj = stack_pop(ctx); if(!is_object_instance(obj) || !get_object(obj)) { jsval_release(obj); - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; } v = stack_pop(ctx); @@ -2090,7 +2090,7 @@ static HRESULT interp_postinc(script_ctx_t *ctx) TRACE("%d\n", arg); if(!stack_pop_exprval(ctx, &ref)) - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; hres = exprval_propget(ctx, &ref, &v); if(SUCCEEDED(hres)) { @@ -2121,7 +2121,7 @@ static HRESULT interp_preinc(script_ctx_t *ctx) TRACE("%d\n", arg); if(!stack_pop_exprval(ctx, &ref)) - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; hres = exprval_propget(ctx, &ref, &v); if(SUCCEEDED(hres)) { diff --git a/dlls/jscript/enumerator.c b/dlls/jscript/enumerator.c index 753c29c9cd7..ffe01c565ad 100644 --- a/dlls/jscript/enumerator.c +++ b/dlls/jscript/enumerator.c @@ -103,7 +103,7 @@ static HRESULT Enumerator_atEnd(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, EnumeratorInstance *This; if (!(This = enumerator_this(jsthis))) - return throw_type_error(ctx, JS_E_ENUMERATOR_EXPECTED, NULL); + return JS_E_ENUMERATOR_EXPECTED; TRACE("%d\n", This->atend); @@ -120,7 +120,7 @@ static HRESULT Enumerator_item(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u TRACE("\n"); if (!(This = enumerator_this(jsthis))) - return throw_type_error(ctx, JS_E_ENUMERATOR_EXPECTED, NULL); + return JS_E_ENUMERATOR_EXPECTED; return r ? jsval_copy(This->item, r) : S_OK; } @@ -134,7 +134,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla TRACE("\n"); if (!(This = enumerator_this(jsthis))) - return throw_type_error(ctx, JS_E_ENUMERATOR_EXPECTED, NULL); + return JS_E_ENUMERATOR_EXPECTED; if (This->enumvar) { @@ -162,7 +162,7 @@ static HRESULT Enumerator_moveNext(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag TRACE("\n"); if (!(This = enumerator_this(jsthis))) - return throw_type_error(ctx, JS_E_ENUMERATOR_EXPECTED, NULL); + return JS_E_ENUMERATOR_EXPECTED; if (This->enumvar) { diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c index 50710960167..c3a099577d5 100644 --- a/dlls/jscript/error.c +++ b/dlls/jscript/error.c @@ -129,7 +129,7 @@ static HRESULT Error_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, switch(flags) { case INVOKE_FUNC: - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; default: FIXME("unimplemented flags %x\n", flags); return E_NOTIMPL; diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index e5701835b07..baa5eb10d7b 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -292,7 +292,7 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, TRACE("\n"); if(!(function = function_this(jsthis))) - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; hres = function->vtbl->toString(function, &str); if(FAILED(hres)) @@ -352,7 +352,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un TRACE("\n"); if(!(function = function_this(jsthis)) && (jsthis->flags & VDISP_JSDISP)) - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; if(argc) { if(!is_undefined(argv[0]) && !is_null(argv[0])) { @@ -417,7 +417,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns TRACE("\n"); if(!(function = function_this(jsthis))) - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; if(argc) { if(!is_undefined(argv[0]) && !is_null(argv[0])) { @@ -446,7 +446,7 @@ static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns TRACE("\n"); if(!(function = function_this(jsthis))) - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; if(argc < 1) { FIXME("no this argument\n"); diff --git a/dlls/jscript/jsregexp.c b/dlls/jscript/jsregexp.c index fc9255e1a18..72aafa209d4 100644 --- a/dlls/jscript/jsregexp.c +++ b/dlls/jscript/jsregexp.c @@ -559,7 +559,7 @@ static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi switch(flags) { case INVOKE_FUNC: - return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + return JS_E_FUNCTION_EXPECTED; default: FIXME("unimplemented flags %x\n", flags); return E_NOTIMPL; diff --git a/dlls/jscript/jsutils.c b/dlls/jscript/jsutils.c index 589eac0fbc4..421116f171b 100644 --- a/dlls/jscript/jsutils.c +++ b/dlls/jscript/jsutils.c @@ -445,7 +445,7 @@ HRESULT to_primitive(script_ctx_t *ctx, jsval_t val, jsval_t *ret, hint_t hint) jsdisp_release(jsdisp); WARN("failed\n"); - return throw_type_error(ctx, JS_E_TO_PRIMITIVE, NULL); + return JS_E_TO_PRIMITIVE; } return jsval_copy(val, ret); @@ -850,7 +850,7 @@ HRESULT to_object(script_ctx_t *ctx, jsval_t val, IDispatch **disp) case JSV_UNDEFINED: case JSV_NULL: WARN("object expected\n"); - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; case JSV_VARIANT: switch(V_VT(get_variant(val))) { case VT_ARRAY|VT_VARIANT: diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c index ff842134bba..540f510f1b6 100644 --- a/dlls/jscript/number.c +++ b/dlls/jscript/number.c @@ -241,15 +241,15 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u TRACE("\n"); if(!(number = number_this(jsthis))) - return throw_type_error(ctx, JS_E_NUMBER_EXPECTED, NULL); + return JS_E_NUMBER_EXPECTED; if(argc) { hres = to_int32(ctx, argv[0], &radix); if(FAILED(hres)) return hres; - if(radix<2 || radix>36) - return throw_type_error(ctx, JS_E_INVALIDARG, NULL); + if(radix < 2 || radix > 36) + return JS_E_INVALIDARG; } val = number->value; @@ -368,7 +368,7 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un TRACE("\n"); if(!(number = number_this(jsthis))) - return throw_type_error(ctx, JS_E_NUMBER_EXPECTED, NULL); + return JS_E_NUMBER_EXPECTED; if(argc) { hres = to_int32(ctx, argv[0], &prec); @@ -409,7 +409,7 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla TRACE("\n"); if(!(number = number_this(jsthis))) - return throw_type_error(ctx, JS_E_NUMBER_EXPECTED, NULL); + return JS_E_NUMBER_EXPECTED; if(argc) { hres = to_int32(ctx, argv[0], &prec); @@ -450,7 +450,7 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags HRESULT hres; if(!(number = number_this(jsthis))) - return throw_type_error(ctx, JS_E_NUMBER_EXPECTED, NULL); + return JS_E_NUMBER_EXPECTED; if(argc) { hres = to_int32(ctx, argv[0], &prec); @@ -495,7 +495,7 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un TRACE("\n"); if(!(number = number_this(jsthis))) - return throw_type_error(ctx, JS_E_NUMBER_EXPECTED, NULL); + return JS_E_NUMBER_EXPECTED; if(r) *r = jsval_number(number->value); diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c index 58db45b8611..3cac2777757 100644 --- a/dlls/jscript/object.c +++ b/dlls/jscript/object.c @@ -399,9 +399,9 @@ static HRESULT to_property_descriptor(script_ctx_t *ctx, jsdisp_t *attr_obj, pro if(desc->explicit_getter || desc->explicit_setter) { if(desc->explicit_value) - hres = throw_type_error(ctx, JS_E_PROP_DESC_MISMATCH, NULL); + hres = JS_E_PROP_DESC_MISMATCH; else if(desc->mask & PROPF_WRITABLE) - hres = throw_type_error(ctx, JS_E_INVALID_WRITABLE_PROP_DESC, NULL); + hres = JS_E_INVALID_WRITABLE_PROP_DESC; } if(FAILED(hres)) @@ -472,7 +472,7 @@ static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl TRACE("\n"); if(argc < 1 || !is_object_instance(argv[0])) - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; obj = to_jsdisp(get_object(argv[0])); if(!obj) { FIXME("not implemented non-JS object\n"); @@ -492,7 +492,7 @@ static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl hres = E_NOTIMPL; } }else { - hres = throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + hres = JS_E_OBJECT_EXPECTED; } jsstr_release(name_str); if(FAILED(hres)) @@ -536,7 +536,7 @@ static HRESULT Object_getOwnPropertyDescriptor(script_ctx_t *ctx, vdisp_t *jsthi TRACE("\n"); if(argc < 1 || !is_object_instance(argv[0])) - return throw_type_error(ctx, JS_E_OBJECT_EXPECTED, NULL); + return JS_E_OBJECT_EXPECTED; obj = to_jsdisp(get_object(argv[0])); if(!obj) { FIXME("not implemented non-JS object\n"); diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c index 1a474d6ac0e..a896738140e 100644 --- a/dlls/jscript/vbarray.c +++ b/dlls/jscript/vbarray.c @@ -58,7 +58,7 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, vbarray = vbarray_this(vthis); if(!vbarray) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; if(r) *r = jsval_number(SafeArrayGetDim(vbarray->safearray)); @@ -77,7 +77,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un vbarray = vbarray_this(vthis); if(!vbarray) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; if(argc < SafeArrayGetDim(vbarray->safearray)) return JS_E_SUBSCRIPT_OUT_OF_RANGE; @@ -119,7 +119,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns vbarray = vbarray_this(vthis); if(!vbarray) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; if(argc) { hres = to_int32(ctx, argv[0], &dim); @@ -153,7 +153,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un vbarray = vbarray_this(vthis); if(!vbarray) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; for(i=1; i<=SafeArrayGetDim(vbarray->safearray); i++) { SafeArrayGetLBound(vbarray->safearray, i, &lbound); @@ -205,7 +205,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns vbarray = vbarray_this(vthis); if(!vbarray) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; if(argc) { hres = to_int32(ctx, argv[0], &dim); @@ -298,13 +298,13 @@ static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags switch(flags) { case DISPATCH_METHOD: if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT)) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; return jsval_copy(argv[0], r); case DISPATCH_CONSTRUCT: if(argc<1 || !is_variant(argv[0]) || V_VT(get_variant(argv[0])) != (VT_ARRAY|VT_VARIANT)) - return throw_type_error(ctx, JS_E_VBARRAY_EXPECTED, NULL); + return JS_E_VBARRAY_EXPECTED; hres = alloc_vbarray(ctx, NULL, &vbarray); if(FAILED(hres))