[PATCH v5 02/11] jscript: Use to_primitive when getting the default value for js objects.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Nov 19 12:03:42 CST 2021


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 dlls/jscript/array.c      | 13 +-----
 dlls/jscript/bool.c       |  4 +-
 dlls/jscript/date.c       | 11 +----
 dlls/jscript/dispex.c     | 22 +++++++---
 dlls/jscript/enumerator.c |  4 +-
 dlls/jscript/error.c      |  4 +-
 dlls/jscript/function.c   |  2 +-
 dlls/jscript/global.c     |  2 +-
 dlls/jscript/jscript.c    |  2 +-
 dlls/jscript/jscript.h    |  5 ++-
 dlls/jscript/json.c       |  2 +-
 dlls/jscript/jsregexp.c   |  4 +-
 dlls/jscript/math.c       |  2 +-
 dlls/jscript/number.c     | 14 +-----
 dlls/jscript/object.c     | 18 +-------
 dlls/jscript/set.c        |  8 ++--
 dlls/jscript/string.c     | 14 +-----
 dlls/jscript/tests/run.c  | 92 +++++++++++++++++++++++++++++++++++++++
 dlls/jscript/vbarray.c    |  2 +-
 19 files changed, 139 insertions(+), 86 deletions(-)

diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c
index 7941031..ad14abf 100644
--- a/dlls/jscript/array.c
+++ b/dlls/jscript/array.c
@@ -1222,15 +1222,6 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
     return S_OK;
 }
 
-static HRESULT Array_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
-{
-    ArrayInstance *array = array_from_jsdisp(jsthis);
-
-    TRACE("\n");
-
-    return array_join(ctx, &array->dispex, array->length, L",", 1, r);
-}
-
 static void Array_destructor(jsdisp_t *dispex)
 {
     heap_free(dispex);
@@ -1279,7 +1270,7 @@ static const builtin_prop_t Array_props[] = {
 
 static const builtin_info_t Array_info = {
     JSCLASS_ARRAY,
-    {NULL, NULL,0, Array_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(Array_props),
     Array_props,
     Array_destructor,
@@ -1292,7 +1283,7 @@ static const builtin_prop_t ArrayInst_props[] = {
 
 static const builtin_info_t ArrayInst_info = {
     JSCLASS_ARRAY,
-    {NULL, NULL,0, Array_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(ArrayInst_props),
     ArrayInst_props,
     Array_destructor,
diff --git a/dlls/jscript/bool.c b/dlls/jscript/bool.c
index 44a8b72..15229d8 100644
--- a/dlls/jscript/bool.c
+++ b/dlls/jscript/bool.c
@@ -114,7 +114,7 @@ static const builtin_prop_t Bool_props[] = {
 
 static const builtin_info_t Bool_info = {
     JSCLASS_BOOLEAN,
-    {NULL, Bool_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Bool_value),
     ARRAY_SIZE(Bool_props),
     Bool_props,
     NULL,
@@ -123,7 +123,7 @@ static const builtin_info_t Bool_info = {
 
 static const builtin_info_t BoolInst_info = {
     JSCLASS_BOOLEAN,
-    {NULL, Bool_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Bool_value),
     0, NULL,
     NULL,
     NULL
diff --git a/dlls/jscript/date.c b/dlls/jscript/date.c
index 96d366c..5627ba4 100644
--- a/dlls/jscript/date.c
+++ b/dlls/jscript/date.c
@@ -1846,13 +1846,6 @@ static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
     return S_OK;
 }
 
-static HRESULT Date_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
-{
-    TRACE("\n");
-
-    return dateobj_to_string(date_from_jsdisp(jsthis), r);
-}
-
 static const builtin_prop_t Date_props[] = {
     {L"getDate",             Date_getDate,               PROPF_METHOD},
     {L"getDay",              Date_getDay,                PROPF_METHOD},
@@ -1903,7 +1896,7 @@ static const builtin_prop_t Date_props[] = {
 
 static const builtin_info_t Date_info = {
     JSCLASS_DATE,
-    {NULL, NULL,0, Date_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(Date_props),
     Date_props,
     NULL,
@@ -1912,7 +1905,7 @@ static const builtin_info_t Date_info = {
 
 static const builtin_info_t DateInst_info = {
     JSCLASS_DATE,
-    {NULL, NULL,0, Date_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     0, NULL,
     NULL,
     NULL
diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c
index a5b3543..a3da9fa 100644
--- a/dlls/jscript/dispex.c
+++ b/dlls/jscript/dispex.c
@@ -1591,6 +1591,11 @@ static HRESULT WINAPI DispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lc
         jsval_t val;
         DWORD i;
 
+        if(id == DISPID_VALUE) {
+            hres = DISP_E_MEMBERNOTFOUND;
+            break;
+        }
+
         for(i=0; i < pdp->cNamedArgs; i++) {
             if(pdp->rgdispidNamedArgs[i] == DISPID_PROPERTYPUT)
                 break;
@@ -1773,12 +1778,8 @@ HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *b
         jsdisp_addref(prototype);
 
     dispex->prop_cnt = 1;
-    if(builtin_info->value_prop.invoke || builtin_info->value_prop.getter) {
-        dispex->props[0].type = PROP_BUILTIN;
-        dispex->props[0].u.p = &builtin_info->value_prop;
-    }else {
-        dispex->props[0].type = PROP_DELETED;
-    }
+    dispex->props[0].type = PROP_BUILTIN;
+    dispex->props[0].u.p = &builtin_info->value_prop;
 
     script_addref(ctx);
     dispex->ctx = ctx;
@@ -1786,9 +1787,16 @@ HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *b
     return S_OK;
 }
 
+HRESULT jsdisp_builtin_get_default_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
+{
+    HRESULT hres = to_primitive(ctx, jsval_obj(jsthis), r, NO_HINT);
+
+    return hres == JS_E_TO_PRIMITIVE ? DISP_E_MEMBERNOTFOUND : hres;
+}
+
 static const builtin_info_t dispex_info = {
     JSCLASS_NONE,
-    {NULL, NULL, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     0, NULL,
     NULL,
     NULL
diff --git a/dlls/jscript/enumerator.c b/dlls/jscript/enumerator.c
index dea1940..35865da 100644
--- a/dlls/jscript/enumerator.c
+++ b/dlls/jscript/enumerator.c
@@ -180,7 +180,7 @@ static const builtin_prop_t Enumerator_props[] = {
 
 static const builtin_info_t Enumerator_info = {
     JSCLASS_ENUMERATOR,
-    {NULL, NULL, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(Enumerator_props),
     Enumerator_props,
     NULL,
@@ -189,7 +189,7 @@ static const builtin_info_t Enumerator_info = {
 
 static const builtin_info_t EnumeratorInst_info = {
     JSCLASS_ENUMERATOR,
-    {NULL, NULL, 0, NULL},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     0,
     NULL,
     Enumerator_destructor,
diff --git a/dlls/jscript/error.c b/dlls/jscript/error.c
index bb9e5a2..a5494f6 100644
--- a/dlls/jscript/error.c
+++ b/dlls/jscript/error.c
@@ -136,7 +136,7 @@ static const builtin_prop_t Error_props[] = {
 
 static const builtin_info_t Error_info = {
     JSCLASS_ERROR,
-    {NULL, Error_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Error_value),
     ARRAY_SIZE(Error_props),
     Error_props,
     NULL,
@@ -145,7 +145,7 @@ static const builtin_info_t Error_info = {
 
 static const builtin_info_t ErrorInst_info = {
     JSCLASS_ERROR,
-    {NULL, Error_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Error_value),
     0,
     NULL,
     NULL,
diff --git a/dlls/jscript/function.c b/dlls/jscript/function.c
index 318d6be..9998e8b 100644
--- a/dlls/jscript/function.c
+++ b/dlls/jscript/function.c
@@ -172,7 +172,7 @@ static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val)
 
 static const builtin_info_t Arguments_info = {
     JSCLASS_ARGUMENTS,
-    {NULL, Arguments_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Arguments_value),
     0, NULL,
     Arguments_destructor,
     NULL,
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 2665bec..e488a37 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -904,7 +904,7 @@ static const builtin_prop_t JSGlobal_props[] = {
 
 static const builtin_info_t JSGlobal_info = {
     JSCLASS_GLOBAL,
-    {NULL, NULL, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(JSGlobal_props),
     JSGlobal_props,
     NULL,
diff --git a/dlls/jscript/jscript.c b/dlls/jscript/jscript.c
index 9148451..f2440b3 100644
--- a/dlls/jscript/jscript.c
+++ b/dlls/jscript/jscript.c
@@ -112,7 +112,7 @@ HRESULT create_named_item_script_obj(script_ctx_t *ctx, named_item_t *item)
 {
     static const builtin_info_t disp_info = {
         JSCLASS_GLOBAL,
-        {NULL, NULL, 0},
+        JSDISP_DEFINE_BUILTIN_VALUE(NULL),
         0, NULL,
         NULL,
         NULL
diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h
index 69897cd..d37fbd1 100644
--- a/dlls/jscript/jscript.h
+++ b/dlls/jscript/jscript.h
@@ -230,6 +230,9 @@ typedef struct {
     builtin_setter_t setter;
 } builtin_prop_t;
 
+HRESULT jsdisp_builtin_get_default_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
+#define JSDISP_DEFINE_BUILTIN_VALUE(value) {NULL, value,0, jsdisp_builtin_get_default_value}
+
 typedef struct {
     jsclass_t class;
     builtin_prop_t value_prop;
@@ -340,7 +343,7 @@ HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DE
 HRESULT Function_value(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
 HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
 struct _function_code_t *Function_get_code(jsdisp_t*) DECLSPEC_HIDDEN;
-#define DEFAULT_FUNCTION_VALUE {NULL, Function_value,0, Function_get_value}
+#define DEFAULT_FUNCTION_VALUE JSDISP_DEFINE_BUILTIN_VALUE(Function_value)
 
 HRESULT throw_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
 jsdisp_t *create_builtin_error(script_ctx_t *ctx) DECLSPEC_HIDDEN;
diff --git a/dlls/jscript/json.c b/dlls/jscript/json.c
index f2fbb80..55fe124 100644
--- a/dlls/jscript/json.c
+++ b/dlls/jscript/json.c
@@ -839,7 +839,7 @@ static const builtin_prop_t JSON_props[] = {
 
 static const builtin_info_t JSON_info = {
     JSCLASS_JSON,
-    {NULL, NULL, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(JSON_props),
     JSON_props,
     NULL,
diff --git a/dlls/jscript/jsregexp.c b/dlls/jscript/jsregexp.c
index f80452d..4d73715 100644
--- a/dlls/jscript/jsregexp.c
+++ b/dlls/jscript/jsregexp.c
@@ -563,7 +563,7 @@ static const builtin_prop_t RegExp_props[] = {
 
 static const builtin_info_t RegExp_info = {
     JSCLASS_REGEXP,
-    {NULL, RegExp_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(RegExp_value),
     ARRAY_SIZE(RegExp_props),
     RegExp_props,
     RegExp_destructor,
@@ -580,7 +580,7 @@ static const builtin_prop_t RegExpInst_props[] = {
 
 static const builtin_info_t RegExpInst_info = {
     JSCLASS_REGEXP,
-    {NULL, RegExp_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(RegExp_value),
     ARRAY_SIZE(RegExpInst_props),
     RegExpInst_props,
     RegExp_destructor,
diff --git a/dlls/jscript/math.c b/dlls/jscript/math.c
index 475b9b2..d434366 100644
--- a/dlls/jscript/math.c
+++ b/dlls/jscript/math.c
@@ -492,7 +492,7 @@ static const builtin_prop_t Math_props[] = {
 
 static const builtin_info_t Math_info = {
     JSCLASS_MATH,
-    {NULL, NULL, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(Math_props),
     Math_props,
     NULL,
diff --git a/dlls/jscript/number.c b/dlls/jscript/number.c
index 3c96532..dbd5b88 100644
--- a/dlls/jscript/number.c
+++ b/dlls/jscript/number.c
@@ -494,16 +494,6 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
     return S_OK;
 }
 
-static HRESULT Number_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
-{
-    NumberInstance *number = number_from_jsdisp(jsthis);
-
-    TRACE("(%p)\n", number);
-
-    *r = jsval_number(number->value);
-    return S_OK;
-}
-
 static const builtin_prop_t Number_props[] = {
     {L"toExponential",       Number_toExponential,         PROPF_METHOD|1},
     {L"toFixed",             Number_toFixed,               PROPF_METHOD},
@@ -515,7 +505,7 @@ static const builtin_prop_t Number_props[] = {
 
 static const builtin_info_t Number_info = {
     JSCLASS_NUMBER,
-    {NULL, NULL,0, Number_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(Number_props),
     Number_props,
     NULL,
@@ -524,7 +514,7 @@ static const builtin_info_t Number_info = {
 
 static const builtin_info_t NumberInst_info = {
     JSCLASS_NUMBER,
-    {NULL, NULL,0, Number_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     0, NULL,
     NULL,
     NULL
diff --git a/dlls/jscript/object.c b/dlls/jscript/object.c
index 89684f5..39248ab 100644
--- a/dlls/jscript/object.c
+++ b/dlls/jscript/object.c
@@ -243,20 +243,6 @@ static HRESULT Object_set_proto_(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t va
     return jsdisp_change_prototype(jsthis, proto);
 }
 
-static HRESULT Object_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
-{
-    jsstr_t *ret;
-
-    TRACE("\n");
-
-    ret = jsstr_alloc(L"[object Object]");
-    if(!ret)
-        return E_OUTOFMEMORY;
-
-    *r = jsval_string(ret);
-    return S_OK;
-}
-
 static void Object_destructor(jsdisp_t *dispex)
 {
     heap_free(dispex);
@@ -274,7 +260,7 @@ static const builtin_prop_t Object_props[] = {
 
 static const builtin_info_t Object_info = {
     JSCLASS_OBJECT,
-    {NULL, NULL,0, Object_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(Object_props),
     Object_props,
     Object_destructor,
@@ -283,7 +269,7 @@ static const builtin_info_t Object_info = {
 
 static const builtin_info_t ObjectInst_info = {
     JSCLASS_OBJECT,
-    {NULL, NULL,0, Object_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     0, NULL,
     Object_destructor,
     NULL
diff --git a/dlls/jscript/set.c b/dlls/jscript/set.c
index 8f355f4..173f4f7 100644
--- a/dlls/jscript/set.c
+++ b/dlls/jscript/set.c
@@ -89,7 +89,7 @@ static const builtin_prop_t Set_props[] = {
 
 static const builtin_info_t Set_prototype_info = {
     JSCLASS_SET,
-    {NULL, Set_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Set_value),
     ARRAY_SIZE(Set_props),
     Set_props,
     NULL,
@@ -98,7 +98,7 @@ static const builtin_info_t Set_prototype_info = {
 
 static const builtin_info_t Set_info = {
     JSCLASS_SET,
-    {NULL, Set_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Set_value),
     0, NULL,
     NULL,
     NULL
@@ -414,7 +414,7 @@ static const builtin_prop_t Map_props[] = {
 
 static const builtin_info_t Map_prototype_info = {
     JSCLASS_OBJECT,
-    {NULL, Map_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Map_value),
     ARRAY_SIZE(Map_prototype_props),
     Map_prototype_props,
     NULL,
@@ -423,7 +423,7 @@ static const builtin_info_t Map_prototype_info = {
 
 static const builtin_info_t Map_info = {
     JSCLASS_MAP,
-    {NULL, Map_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(Map_value),
     ARRAY_SIZE(Map_props),
     Map_props,
     Map_destructor,
diff --git a/dlls/jscript/string.c b/dlls/jscript/string.c
index 4f6d8cd..dba0612 100644
--- a/dlls/jscript/string.c
+++ b/dlls/jscript/string.c
@@ -1493,16 +1493,6 @@ static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
     return E_NOTIMPL;
 }
 
-static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
-{
-    StringInstance *This = string_from_jsdisp(jsthis);
-
-    TRACE("\n");
-
-    *r = jsval_string(jsstr_addref(This->str));
-    return S_OK;
-}
-
 static void String_destructor(jsdisp_t *dispex)
 {
     StringInstance *This = string_from_jsdisp(dispex);
@@ -1579,7 +1569,7 @@ static const builtin_prop_t String_props[] = {
 
 static const builtin_info_t String_info = {
     JSCLASS_STRING,
-    {NULL, NULL,0, String_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(String_props),
     String_props,
     String_destructor,
@@ -1592,7 +1582,7 @@ static const builtin_prop_t StringInst_props[] = {
 
 static const builtin_info_t StringInst_info = {
     JSCLASS_STRING,
-    {NULL, NULL,0, String_get_value},
+    JSDISP_DEFINE_BUILTIN_VALUE(NULL),
     ARRAY_SIZE(StringInst_props),
     StringInst_props,
     String_destructor,
diff --git a/dlls/jscript/tests/run.c b/dlls/jscript/tests/run.c
index ef0f39f..0e2f633 100644
--- a/dlls/jscript/tests/run.c
+++ b/dlls/jscript/tests/run.c
@@ -2789,6 +2789,8 @@ static void test_retval(void)
 
 static void test_default_value(void)
 {
+    static DISPID propput_dispid = DISPID_PROPERTYPUT;
+    IActiveScript *script;
     DISPPARAMS dp = {0};
     IDispatch *disp;
     VARIANT v;
@@ -2806,9 +2808,99 @@ static void test_default_value(void)
     {
         ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
     }
+    VariantClear(&v);
+    IDispatch_Release(disp);
+
+    hres = parse_script_expr(L"var arr = [5]; arr.toString = function() {return \"foo\";}; arr.valueOf = function() {return 42;}; arr", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
+
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+    ok(hres == S_OK, "Invoke failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_I4, "V_VT(v) = %d\n", V_VT(&v));
+    ok(V_I4(&v) == 42, "V_I4(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
+    IDispatch_Release(disp);
+    close_script(script);
+
+    hres = parse_script_expr(L"var arr = [5]; arr.toString = function() {return \"foo\";}; arr", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
 
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+    ok(hres == S_OK, "Invoke failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
+    ok(!lstrcmpW(V_BSTR(&v), L"foo"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
     VariantClear(&v);
     IDispatch_Release(disp);
+    close_script(script);
+
+    hres = parse_script_expr(L"var arr = [5]; arr", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
+
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+    ok(hres == S_OK, "Invoke failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
+    ok(!lstrcmpW(V_BSTR(&v), L"5"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+    IDispatch_Release(disp);
+    close_script(script);
+
+    hres = parse_script_expr(L"var obj = Object.prototype; delete obj.valueOf; obj", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
+
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+    ok(hres == S_OK, "Invoke failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v) = %d\n", V_VT(&v));
+    ok(!lstrcmpW(V_BSTR(&v), L"[object Object]"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+    IDispatch_Release(disp);
+    close_script(script);
+
+    hres = parse_script_expr(L"var obj = Object.prototype; delete obj.toString; obj", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
+
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dp, &v, NULL, NULL);
+    ok(hres == DISP_E_MEMBERNOTFOUND, "Invoke failed: %08x\n", hres);
+    IDispatch_Release(disp);
+    close_script(script);
+
+    hres = parse_script_expr(L"Object.prototype", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
+
+    dp.cArgs = dp.cNamedArgs = 1;
+    dp.rgdispidNamedArgs = &propput_dispid;
+    dp.rgvarg = &v;
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dp, NULL, NULL, NULL);
+    ok(hres == DISP_E_MEMBERNOTFOUND, "Invoke failed: %08x\n", hres);
+    IDispatch_Release(disp);
+    close_script(script);
+
+    hres = parse_script_expr(L"var f = function() {return 42;}; f", &v, &script);
+    ok(hres == S_OK, "parse_script_expr failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_DISPATCH, "V_VT(v) = %d\n", V_VT(&v));
+    disp = V_DISPATCH(&v);
+
+    V_VT(&v) = VT_EMPTY;
+    hres = IDispatch_Invoke(disp, DISPID_VALUE, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dp, NULL, NULL, NULL);
+    ok(hres == DISP_E_MEMBERNOTFOUND, "Invoke failed: %08x\n", hres);
+    IDispatch_Release(disp);
+    close_script(script);
 }
 
 static void test_script_exprs(void)
diff --git a/dlls/jscript/vbarray.c b/dlls/jscript/vbarray.c
index 69a77f1..50d53b9 100644
--- a/dlls/jscript/vbarray.c
+++ b/dlls/jscript/vbarray.c
@@ -251,7 +251,7 @@ static const builtin_prop_t VBArray_props[] = {
 
 static const builtin_info_t VBArray_info = {
     JSCLASS_VBARRAY,
-    {NULL, VBArray_value, 0},
+    JSDISP_DEFINE_BUILTIN_VALUE(VBArray_value),
     ARRAY_SIZE(VBArray_props),
     VBArray_props,
     VBArray_destructor,
-- 
2.31.1




More information about the wine-devel mailing list