@@ -57794,7 +57794,7 @@ static const JSDOMExceptionNameDef js_dom_exception_names_table[] = {
57794
57794
{ "InvalidModificationError", "INVALID_MODIFICATION_ERR" },
57795
57795
{ "NamespaceError", "NAMESPACE_ERR" },
57796
57796
{ "InvalidAccessError", "INVALID_ACCESS_ERR" },
57797
- { NULL, NULL },
57797
+ { NULL, "VALIDATION_ERR" },
57798
57798
{ "TypeMismatchError", "TYPE_MISMATCH_ERR" },
57799
57799
{ "SecurityError", "SECURITY_ERR" },
57800
57800
{ "NetworkError", "NETWORK_ERR" },
@@ -57828,7 +57828,7 @@ static void js_domexception_mark(JSRuntime *rt, JSValueConst val,
57828
57828
57829
57829
static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_target,
57830
57830
int argc, JSValueConst *argv,
57831
- bool add_backtrace )
57831
+ int backtrace_flags )
57832
57832
{
57833
57833
JSDOMExceptionData *s;
57834
57834
JSValue obj, message, name;
@@ -57839,13 +57839,13 @@ static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_tar
57839
57839
if (!JS_IsUndefined(argv[0]))
57840
57840
message = JS_ToString(ctx, argv[0]);
57841
57841
else
57842
- message = JS_NewString (ctx, "" );
57842
+ message = JS_AtomToString (ctx, JS_ATOM_empty_string );
57843
57843
if (JS_IsException(message))
57844
57844
goto fail1;
57845
57845
if (!JS_IsUndefined(argv[1]))
57846
57846
name = JS_ToString(ctx, argv[1]);
57847
57847
else
57848
- name = JS_NewString (ctx, "Error" );
57848
+ name = JS_AtomToString (ctx, JS_ATOM_Error );
57849
57849
if (JS_IsException(name))
57850
57850
goto fail2;
57851
57851
s = js_malloc(ctx, sizeof(*s));
@@ -57855,9 +57855,7 @@ static JSValue js_domexception_constructor0(JSContext *ctx, JSValueConst new_tar
57855
57855
s->message = message;
57856
57856
s->code = -1;
57857
57857
JS_SetOpaqueInternal(obj, s);
57858
- if (add_backtrace)
57859
- build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0,
57860
- JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL);
57858
+ build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0, backtrace_flags);
57861
57859
return obj;
57862
57860
fail3:
57863
57861
JS_FreeValue(ctx, name);
@@ -57873,27 +57871,21 @@ static JSValue js_domexception_constructor(JSContext *ctx, JSValueConst new_targ
57873
57871
{
57874
57872
if (JS_IsUndefined(new_target))
57875
57873
return JS_ThrowTypeError(ctx, "constructor requires 'new'");
57876
- return js_domexception_constructor0(ctx, new_target, argc, argv, true);
57877
- }
57878
-
57879
- static JSValue js_domexception_get_name(JSContext *ctx, JSValueConst this_val)
57880
- {
57881
- JSDOMExceptionData *s;
57882
-
57883
- s = JS_GetOpaque2(ctx, this_val, JS_CLASS_DOM_EXCEPTION);
57884
- if (!s)
57885
- return JS_EXCEPTION;
57886
- return js_dup(s->name);
57874
+ return js_domexception_constructor0(ctx, new_target, argc, argv,
57875
+ JS_BACKTRACE_FLAG_SKIP_FIRST_LEVEL);
57887
57876
}
57888
57877
57889
- static JSValue js_domexception_get_message(JSContext *ctx, JSValueConst this_val)
57878
+ static JSValue js_domexception_getfield(JSContext *ctx, JSValueConst this_val,
57879
+ int magic)
57890
57880
{
57891
57881
JSDOMExceptionData *s;
57882
+ JSValue *valp;
57892
57883
57893
57884
s = JS_GetOpaque2(ctx, this_val, JS_CLASS_DOM_EXCEPTION);
57894
57885
if (!s)
57895
57886
return JS_EXCEPTION;
57896
- return js_dup(s->message);
57887
+ valp = (void *)((char *)s + magic);
57888
+ return js_dup(*valp);
57897
57889
}
57898
57890
57899
57891
static JSValue js_domexception_get_code(JSContext *ctx, JSValueConst this_val)
@@ -57924,8 +57916,10 @@ static JSValue js_domexception_get_code(JSContext *ctx, JSValueConst this_val)
57924
57916
}
57925
57917
57926
57918
static const JSCFunctionListEntry js_domexception_proto_funcs[] = {
57927
- JS_CGETSET_DEF("name", js_domexception_get_name, NULL ),
57928
- JS_CGETSET_DEF("message", js_domexception_get_message, NULL ),
57919
+ JS_CGETSET_MAGIC_DEF("name", js_domexception_getfield, NULL,
57920
+ offsetof(JSDOMExceptionData, name) ),
57921
+ JS_CGETSET_MAGIC_DEF("message", js_domexception_getfield, NULL,
57922
+ offsetof(JSDOMExceptionData, message) ),
57929
57923
JS_CGETSET_DEF("code", js_domexception_get_code, NULL ),
57930
57924
JS_PROP_STRING_DEF("[Symbol.toStringTag]", "DOMException", JS_PROP_CONFIGURABLE ),
57931
57925
};
@@ -57941,6 +57935,7 @@ JSValue JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowDOMException(JSContext *ctx, const c
57941
57935
va_list ap;
57942
57936
char buf[256];
57943
57937
57938
+ assert(JS_IsRegisteredClass(ctx->rt, JS_CLASS_DOM_EXCEPTION));
57944
57939
va_start(ap, fmt);
57945
57940
vsnprintf(buf, sizeof(buf), fmt, ap);
57946
57941
va_end(ap);
@@ -57954,12 +57949,11 @@ JSValue JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowDOMException(JSContext *ctx, const c
57954
57949
}
57955
57950
argv[0] = js_message;
57956
57951
argv[1] = js_name;
57957
- obj = js_domexception_constructor0(ctx, JS_UNDEFINED, 2, argv, false );
57952
+ obj = js_domexception_constructor0(ctx, JS_UNDEFINED, 2, argv, 0 );
57958
57953
JS_FreeValue(ctx, js_message);
57959
57954
JS_FreeValue(ctx, js_name);
57960
57955
if (JS_IsException(obj))
57961
57956
return JS_EXCEPTION;
57962
- build_backtrace(ctx, obj, JS_UNDEFINED, NULL, 0, 0, 0);
57963
57957
return JS_Throw(ctx, obj);
57964
57958
}
57965
57959
@@ -57982,8 +57976,6 @@ void JS_AddIntrinsicDOMException(JSContext *ctx)
57982
57976
JS_CFUNC_constructor_or_func, 0);
57983
57977
JS_SetConstructor(ctx, ctor, proto);
57984
57978
for (i = 0; i < countof(js_dom_exception_names_table); i++) {
57985
- if (!js_dom_exception_names_table[i].code_name)
57986
- continue;
57987
57979
name = JS_NewAtom(ctx, js_dom_exception_names_table[i].code_name);
57988
57980
JS_DefinePropertyValue(ctx, proto, name, js_int32(i + 1),
57989
57981
JS_PROP_ENUMERABLE);
0 commit comments