From 6b86fd795c044b3cb2b91b1cbe5792607c7dada0 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 3 May 2018 14:58:55 +0200 Subject: [PATCH] jscript: Use new PROPF_WRITABLE flag instead of PROPF_CONST. This is closer to how ES5 defines them. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/jscript/dispex.c | 22 ++++++++++++---------- dlls/jscript/function.c | 2 +- dlls/jscript/jscript.h | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index 63ab21d2fb2..f896b3001f5 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -218,8 +218,10 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name, if(builtin) { unsigned flags = builtin->flags; if(flags & PROPF_METHOD) - flags |= PROPF_CONFIGURABLE; - flags &= PROPF_ENUM | PROPF_CONST | PROPF_CONFIGURABLE; + flags |= PROPF_WRITABLE | PROPF_CONFIGURABLE; + else if(builtin->setter) + flags |= PROPF_WRITABLE; + flags &= PROPF_ENUM | PROPF_WRITABLE | PROPF_CONFIGURABLE; prop = alloc_prop(This, name, PROP_BUILTIN, flags); if(!prop) return E_OUTOFMEMORY; @@ -236,7 +238,7 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name, for(ptr = name; isdigitW(*ptr) && idx < 0x10000; ptr++) idx = idx*10 + (*ptr-'0'); if(!*ptr && idx < This->builtin_info->idx_length(This)) { - prop = alloc_prop(This, name, PROP_IDX, This->builtin_info->idx_put ? 0 : PROPF_CONST); + prop = alloc_prop(This, name, PROP_IDX, This->builtin_info->idx_put ? PROPF_WRITABLE : 0); if(!prop) return E_OUTOFMEMORY; @@ -272,7 +274,6 @@ static HRESULT find_prop_name_prot(jsdisp_t *This, unsigned hash, const WCHAR *n if(prop) { if(del) { del->type = PROP_PROTREF; - del->flags = 0; del->u.ref = prop - This->prototype->props; prop = del; }else { @@ -474,7 +475,7 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val) { HRESULT hres; - if(prop->flags & PROPF_CONST) + if(!(prop->flags & PROPF_WRITABLE) && prop->type != PROP_PROTREF) return S_OK; switch(prop->type) { @@ -489,7 +490,7 @@ static HRESULT prop_put(jsdisp_t *This, dispex_prop_t *prop, jsval_t val) /* fall through */ case PROP_PROTREF: prop->type = PROP_JSVAL; - prop->flags = PROPF_ENUM | PROPF_CONFIGURABLE; + prop->flags = PROPF_ENUM | PROPF_CONFIGURABLE | PROPF_WRITABLE; prop->u.val = jsval_undefined(); break; case PROP_JSVAL: @@ -1039,7 +1040,8 @@ HRESULT jsdisp_get_id(jsdisp_t *jsdisp, const WCHAR *name, DWORD flags, DISPID * HRESULT hres; if(flags & fdexNameEnsure) - hres = ensure_prop_name(jsdisp, name, TRUE, PROPF_ENUM | PROPF_CONFIGURABLE, &prop); + hres = ensure_prop_name(jsdisp, name, TRUE, PROPF_ENUM | PROPF_CONFIGURABLE | PROPF_WRITABLE, + &prop); else hres = find_prop_name_prot(jsdisp, string_hash(name), name, &prop); if(FAILED(hres)) @@ -1311,7 +1313,7 @@ HRESULT jsdisp_propput(jsdisp_t *obj, const WCHAR *name, DWORD flags, jsval_t va HRESULT jsdisp_propput_name(jsdisp_t *obj, const WCHAR *name, jsval_t val) { - return jsdisp_propput(obj, name, PROPF_ENUM | PROPF_CONFIGURABLE, val); + return jsdisp_propput(obj, name, PROPF_ENUM | PROPF_CONFIGURABLE | PROPF_WRITABLE, val); } HRESULT jsdisp_propput_const(jsdisp_t *obj, const WCHAR *name, jsval_t val) @@ -1319,7 +1321,7 @@ HRESULT jsdisp_propput_const(jsdisp_t *obj, const WCHAR *name, jsval_t val) dispex_prop_t *prop; HRESULT hres; - hres = ensure_prop_name(obj, name, FALSE, PROPF_CONST, &prop); + hres = ensure_prop_name(obj, name, FALSE, 0, &prop); if(FAILED(hres)) return hres; @@ -1328,7 +1330,7 @@ HRESULT jsdisp_propput_const(jsdisp_t *obj, const WCHAR *name, jsval_t val) HRESULT jsdisp_propput_dontenum(jsdisp_t *obj, const WCHAR *name, jsval_t val) { - return jsdisp_propput(obj, name, PROPF_CONFIGURABLE, val); + return jsdisp_propput(obj, name, PROPF_CONFIGURABLE | PROPF_WRITABLE, val); } HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val) diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c index 2e905a993b0..ac0640f7964 100644 --- a/dlls/jscript/function.c +++ b/dlls/jscript/function.c @@ -184,7 +184,7 @@ HRESULT setup_arguments_object(script_ctx_t *ctx, call_frame_t *frame) if(SUCCEEDED(hres)) hres = jsdisp_propput_dontenum(&args->jsdisp, caleeW, jsval_disp(to_disp(&args->function->dispex))); if(SUCCEEDED(hres)) - hres = jsdisp_propput(frame->base_scope->jsobj, argumentsW, 0, jsval_obj(&args->jsdisp)); + hres = jsdisp_propput(frame->base_scope->jsobj, argumentsW, PROPF_WRITABLE, jsval_obj(&args->jsdisp)); if(FAILED(hres)) { jsdisp_release(&args->jsdisp); return hres; diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 03a96c3e723..335df1ad286 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -91,7 +91,7 @@ extern HINSTANCE jscript_hinstance DECLSPEC_HIDDEN; #define PROPF_METHOD 0x0100 #define PROPF_ENUM 0x0200 #define PROPF_CONSTR 0x0400 -#define PROPF_CONST 0x0800 +#define PROPF_WRITABLE 0x0800 #define PROPF_CONFIGURABLE 0x1000 #define PROPF_VERSION_MASK 0x01ff0000