jscript: Replace the value_prop in builtin_info with a call method.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2021-11-25 21:01:37 +01:00 committed by Alexandre Julliard
parent adad455049
commit ce1b3f5f1d
18 changed files with 40 additions and 91 deletions

View File

@ -1222,15 +1222,6 @@ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi
return S_OK; 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) static void Array_destructor(jsdisp_t *dispex)
{ {
heap_free(dispex); heap_free(dispex);
@ -1279,7 +1270,7 @@ static const builtin_prop_t Array_props[] = {
static const builtin_info_t Array_info = { static const builtin_info_t Array_info = {
JSCLASS_ARRAY, JSCLASS_ARRAY,
{NULL, NULL,0, Array_get_value}, NULL,
ARRAY_SIZE(Array_props), ARRAY_SIZE(Array_props),
Array_props, Array_props,
Array_destructor, Array_destructor,
@ -1292,7 +1283,7 @@ static const builtin_prop_t ArrayInst_props[] = {
static const builtin_info_t ArrayInst_info = { static const builtin_info_t ArrayInst_info = {
JSCLASS_ARRAY, JSCLASS_ARRAY,
{NULL, NULL,0, Array_get_value}, NULL,
ARRAY_SIZE(ArrayInst_props), ARRAY_SIZE(ArrayInst_props),
ArrayInst_props, ArrayInst_props,
Array_destructor, Array_destructor,
@ -1397,7 +1388,7 @@ static const builtin_prop_t ArrayConstr_props[] = {
static const builtin_info_t ArrayConstr_info = { static const builtin_info_t ArrayConstr_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(ArrayConstr_props), ARRAY_SIZE(ArrayConstr_props),
ArrayConstr_props, ArrayConstr_props,
NULL, NULL,

View File

@ -114,7 +114,7 @@ static const builtin_prop_t Bool_props[] = {
static const builtin_info_t Bool_info = { static const builtin_info_t Bool_info = {
JSCLASS_BOOLEAN, JSCLASS_BOOLEAN,
{NULL, Bool_value, 0}, Bool_value,
ARRAY_SIZE(Bool_props), ARRAY_SIZE(Bool_props),
Bool_props, Bool_props,
NULL, NULL,
@ -123,7 +123,7 @@ static const builtin_info_t Bool_info = {
static const builtin_info_t BoolInst_info = { static const builtin_info_t BoolInst_info = {
JSCLASS_BOOLEAN, JSCLASS_BOOLEAN,
{NULL, Bool_value, 0}, Bool_value,
0, NULL, 0, NULL,
NULL, NULL,
NULL NULL

View File

@ -1846,13 +1846,6 @@ static HRESULT Date_setYear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
return S_OK; 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[] = { static const builtin_prop_t Date_props[] = {
{L"getDate", Date_getDate, PROPF_METHOD}, {L"getDate", Date_getDate, PROPF_METHOD},
{L"getDay", Date_getDay, 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 = { static const builtin_info_t Date_info = {
JSCLASS_DATE, JSCLASS_DATE,
{NULL, NULL,0, Date_get_value}, NULL,
ARRAY_SIZE(Date_props), ARRAY_SIZE(Date_props),
Date_props, Date_props,
NULL, NULL,
@ -1912,7 +1905,7 @@ static const builtin_info_t Date_info = {
static const builtin_info_t DateInst_info = { static const builtin_info_t DateInst_info = {
JSCLASS_DATE, JSCLASS_DATE,
{NULL, NULL,0, Date_get_value}, NULL,
0, NULL, 0, NULL,
NULL, NULL,
NULL NULL
@ -2440,7 +2433,7 @@ static const builtin_prop_t DateConstr_props[] = {
static const builtin_info_t DateConstr_info = { static const builtin_info_t DateConstr_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(DateConstr_props), ARRAY_SIZE(DateConstr_props),
DateConstr_props, DateConstr_props,
NULL, NULL,

View File

@ -1830,7 +1830,7 @@ HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *b
static const builtin_info_t dispex_info = { static const builtin_info_t dispex_info = {
JSCLASS_NONE, JSCLASS_NONE,
{NULL, NULL, 0}, NULL,
0, NULL, 0, NULL,
NULL, NULL,
NULL NULL
@ -1981,14 +1981,14 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig
}else { }else {
vdisp_t vdisp; vdisp_t vdisp;
if(!jsfunc->builtin_info->value_prop.invoke) { if(!jsfunc->builtin_info->call) {
WARN("Not a function\n"); WARN("Not a function\n");
return JS_E_FUNCTION_EXPECTED; return JS_E_FUNCTION_EXPECTED;
} }
set_disp(&vdisp, jsthis); set_disp(&vdisp, jsthis);
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK; flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
hres = jsfunc->builtin_info->value_prop.invoke(jsfunc->ctx, &vdisp, flags, argc, argv, r); hres = jsfunc->builtin_info->call(jsfunc->ctx, &vdisp, flags, argc, argv, r);
vdisp_release(&vdisp); vdisp_release(&vdisp);
} }
return hres; return hres;

View File

@ -180,7 +180,7 @@ static const builtin_prop_t Enumerator_props[] = {
static const builtin_info_t Enumerator_info = { static const builtin_info_t Enumerator_info = {
JSCLASS_ENUMERATOR, JSCLASS_ENUMERATOR,
{NULL, NULL, 0}, NULL,
ARRAY_SIZE(Enumerator_props), ARRAY_SIZE(Enumerator_props),
Enumerator_props, Enumerator_props,
NULL, NULL,
@ -189,7 +189,7 @@ static const builtin_info_t Enumerator_info = {
static const builtin_info_t EnumeratorInst_info = { static const builtin_info_t EnumeratorInst_info = {
JSCLASS_ENUMERATOR, JSCLASS_ENUMERATOR,
{NULL, NULL, 0, NULL}, NULL,
0, 0,
NULL, NULL,
Enumerator_destructor, Enumerator_destructor,
@ -317,7 +317,7 @@ static HRESULT EnumeratorConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD fl
static const builtin_info_t EnumeratorConstr_info = { static const builtin_info_t EnumeratorConstr_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
0, 0,
NULL, NULL,
NULL, NULL,

View File

@ -136,7 +136,7 @@ static const builtin_prop_t Error_props[] = {
static const builtin_info_t Error_info = { static const builtin_info_t Error_info = {
JSCLASS_ERROR, JSCLASS_ERROR,
{NULL, Error_value, 0}, Error_value,
ARRAY_SIZE(Error_props), ARRAY_SIZE(Error_props),
Error_props, Error_props,
NULL, NULL,
@ -145,7 +145,7 @@ static const builtin_info_t Error_info = {
static const builtin_info_t ErrorInst_info = { static const builtin_info_t ErrorInst_info = {
JSCLASS_ERROR, JSCLASS_ERROR,
{NULL, Error_value, 0}, Error_value,
0, 0,
NULL, NULL,
NULL, NULL,

View File

@ -172,7 +172,7 @@ static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val)
static const builtin_info_t Arguments_info = { static const builtin_info_t Arguments_info = {
JSCLASS_ARGUMENTS, JSCLASS_ARGUMENTS,
{NULL, Arguments_value, 0}, Arguments_value,
0, NULL, 0, NULL,
Arguments_destructor, Arguments_destructor,
NULL, NULL,
@ -545,7 +545,7 @@ static const builtin_prop_t Function_props[] = {
static const builtin_info_t Function_info = { static const builtin_info_t Function_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(Function_props), ARRAY_SIZE(Function_props),
Function_props, Function_props,
Function_destructor, Function_destructor,
@ -559,7 +559,7 @@ static const builtin_prop_t FunctionInst_props[] = {
static const builtin_info_t FunctionInst_info = { static const builtin_info_t FunctionInst_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(FunctionInst_props), ARRAY_SIZE(FunctionInst_props),
FunctionInst_props, FunctionInst_props,
Function_destructor, Function_destructor,

View File

@ -904,7 +904,7 @@ static const builtin_prop_t JSGlobal_props[] = {
static const builtin_info_t JSGlobal_info = { static const builtin_info_t JSGlobal_info = {
JSCLASS_GLOBAL, JSCLASS_GLOBAL,
{NULL, NULL, 0}, NULL,
ARRAY_SIZE(JSGlobal_props), ARRAY_SIZE(JSGlobal_props),
JSGlobal_props, JSGlobal_props,
NULL, NULL,

View File

@ -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 = { static const builtin_info_t disp_info = {
JSCLASS_GLOBAL, JSCLASS_GLOBAL,
{NULL, NULL, 0}, NULL,
0, NULL, 0, NULL,
NULL, NULL,
NULL NULL

View File

@ -232,7 +232,7 @@ typedef struct {
typedef struct { typedef struct {
jsclass_t class; jsclass_t class;
builtin_prop_t value_prop; builtin_invoke_t call;
DWORD props_cnt; DWORD props_cnt;
const builtin_prop_t *props; const builtin_prop_t *props;
void (*destructor)(jsdisp_t*); void (*destructor)(jsdisp_t*);
@ -340,7 +340,6 @@ 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_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; HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
struct _function_code_t *Function_get_code(jsdisp_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}
HRESULT throw_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN; HRESULT throw_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
jsdisp_t *create_builtin_error(script_ctx_t *ctx) DECLSPEC_HIDDEN; jsdisp_t *create_builtin_error(script_ctx_t *ctx) DECLSPEC_HIDDEN;

View File

@ -839,7 +839,7 @@ static const builtin_prop_t JSON_props[] = {
static const builtin_info_t JSON_info = { static const builtin_info_t JSON_info = {
JSCLASS_JSON, JSCLASS_JSON,
{NULL, NULL, 0}, NULL,
ARRAY_SIZE(JSON_props), ARRAY_SIZE(JSON_props),
JSON_props, JSON_props,
NULL, NULL,

View File

@ -563,7 +563,7 @@ static const builtin_prop_t RegExp_props[] = {
static const builtin_info_t RegExp_info = { static const builtin_info_t RegExp_info = {
JSCLASS_REGEXP, JSCLASS_REGEXP,
{NULL, RegExp_value, 0}, RegExp_value,
ARRAY_SIZE(RegExp_props), ARRAY_SIZE(RegExp_props),
RegExp_props, RegExp_props,
RegExp_destructor, RegExp_destructor,
@ -580,7 +580,7 @@ static const builtin_prop_t RegExpInst_props[] = {
static const builtin_info_t RegExpInst_info = { static const builtin_info_t RegExpInst_info = {
JSCLASS_REGEXP, JSCLASS_REGEXP,
{NULL, RegExp_value, 0}, RegExp_value,
ARRAY_SIZE(RegExpInst_props), ARRAY_SIZE(RegExpInst_props),
RegExpInst_props, RegExpInst_props,
RegExp_destructor, RegExp_destructor,
@ -952,7 +952,7 @@ static const builtin_prop_t RegExpConstr_props[] = {
static const builtin_info_t RegExpConstr_info = { static const builtin_info_t RegExpConstr_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(RegExpConstr_props), ARRAY_SIZE(RegExpConstr_props),
RegExpConstr_props, RegExpConstr_props,
NULL, NULL,

View File

@ -492,7 +492,7 @@ static const builtin_prop_t Math_props[] = {
static const builtin_info_t Math_info = { static const builtin_info_t Math_info = {
JSCLASS_MATH, JSCLASS_MATH,
{NULL, NULL, 0}, NULL,
ARRAY_SIZE(Math_props), ARRAY_SIZE(Math_props),
Math_props, Math_props,
NULL, NULL,

View File

@ -494,16 +494,6 @@ static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK; 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[] = { static const builtin_prop_t Number_props[] = {
{L"toExponential", Number_toExponential, PROPF_METHOD|1}, {L"toExponential", Number_toExponential, PROPF_METHOD|1},
{L"toFixed", Number_toFixed, PROPF_METHOD}, {L"toFixed", Number_toFixed, PROPF_METHOD},
@ -515,7 +505,7 @@ static const builtin_prop_t Number_props[] = {
static const builtin_info_t Number_info = { static const builtin_info_t Number_info = {
JSCLASS_NUMBER, JSCLASS_NUMBER,
{NULL, NULL,0, Number_get_value}, NULL,
ARRAY_SIZE(Number_props), ARRAY_SIZE(Number_props),
Number_props, Number_props,
NULL, NULL,
@ -524,7 +514,7 @@ static const builtin_info_t Number_info = {
static const builtin_info_t NumberInst_info = { static const builtin_info_t NumberInst_info = {
JSCLASS_NUMBER, JSCLASS_NUMBER,
{NULL, NULL,0, Number_get_value}, NULL,
0, NULL, 0, NULL,
NULL, NULL,
NULL NULL

View File

@ -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); 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) static void Object_destructor(jsdisp_t *dispex)
{ {
heap_free(dispex); heap_free(dispex);
@ -274,7 +260,7 @@ static const builtin_prop_t Object_props[] = {
static const builtin_info_t Object_info = { static const builtin_info_t Object_info = {
JSCLASS_OBJECT, JSCLASS_OBJECT,
{NULL, NULL,0, Object_get_value}, NULL,
ARRAY_SIZE(Object_props), ARRAY_SIZE(Object_props),
Object_props, Object_props,
Object_destructor, Object_destructor,
@ -283,7 +269,7 @@ static const builtin_info_t Object_info = {
static const builtin_info_t ObjectInst_info = { static const builtin_info_t ObjectInst_info = {
JSCLASS_OBJECT, JSCLASS_OBJECT,
{NULL, NULL,0, Object_get_value}, NULL,
0, NULL, 0, NULL,
Object_destructor, Object_destructor,
NULL NULL
@ -889,7 +875,7 @@ static const builtin_prop_t ObjectConstr_props[] = {
static const builtin_info_t ObjectConstr_info = { static const builtin_info_t ObjectConstr_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(ObjectConstr_props), ARRAY_SIZE(ObjectConstr_props),
ObjectConstr_props, ObjectConstr_props,
NULL, NULL,

View File

@ -89,7 +89,7 @@ static const builtin_prop_t Set_props[] = {
static const builtin_info_t Set_prototype_info = { static const builtin_info_t Set_prototype_info = {
JSCLASS_SET, JSCLASS_SET,
{NULL, Set_value, 0}, Set_value,
ARRAY_SIZE(Set_props), ARRAY_SIZE(Set_props),
Set_props, Set_props,
NULL, NULL,
@ -98,7 +98,7 @@ static const builtin_info_t Set_prototype_info = {
static const builtin_info_t Set_info = { static const builtin_info_t Set_info = {
JSCLASS_SET, JSCLASS_SET,
{NULL, Set_value, 0}, Set_value,
0, NULL, 0, NULL,
NULL, NULL,
NULL NULL
@ -414,7 +414,7 @@ static const builtin_prop_t Map_props[] = {
static const builtin_info_t Map_prototype_info = { static const builtin_info_t Map_prototype_info = {
JSCLASS_OBJECT, JSCLASS_OBJECT,
{NULL, Map_value, 0}, Map_value,
ARRAY_SIZE(Map_prototype_props), ARRAY_SIZE(Map_prototype_props),
Map_prototype_props, Map_prototype_props,
NULL, NULL,
@ -423,7 +423,7 @@ static const builtin_info_t Map_prototype_info = {
static const builtin_info_t Map_info = { static const builtin_info_t Map_info = {
JSCLASS_MAP, JSCLASS_MAP,
{NULL, Map_value, 0}, Map_value,
ARRAY_SIZE(Map_props), ARRAY_SIZE(Map_props),
Map_props, Map_props,
Map_destructor, Map_destructor,

View File

@ -1493,16 +1493,6 @@ static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return E_NOTIMPL; 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) static void String_destructor(jsdisp_t *dispex)
{ {
StringInstance *This = string_from_jsdisp(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 = { static const builtin_info_t String_info = {
JSCLASS_STRING, JSCLASS_STRING,
{NULL, NULL,0, String_get_value}, NULL,
ARRAY_SIZE(String_props), ARRAY_SIZE(String_props),
String_props, String_props,
String_destructor, String_destructor,
@ -1592,7 +1582,7 @@ static const builtin_prop_t StringInst_props[] = {
static const builtin_info_t StringInst_info = { static const builtin_info_t StringInst_info = {
JSCLASS_STRING, JSCLASS_STRING,
{NULL, NULL,0, String_get_value}, NULL,
ARRAY_SIZE(StringInst_props), ARRAY_SIZE(StringInst_props),
StringInst_props, StringInst_props,
String_destructor, String_destructor,
@ -1710,7 +1700,7 @@ static const builtin_prop_t StringConstr_props[] = {
static const builtin_info_t StringConstr_info = { static const builtin_info_t StringConstr_info = {
JSCLASS_FUNCTION, JSCLASS_FUNCTION,
DEFAULT_FUNCTION_VALUE, Function_value,
ARRAY_SIZE(StringConstr_props), ARRAY_SIZE(StringConstr_props),
StringConstr_props, StringConstr_props,
NULL, NULL,

View File

@ -251,7 +251,7 @@ static const builtin_prop_t VBArray_props[] = {
static const builtin_info_t VBArray_info = { static const builtin_info_t VBArray_info = {
JSCLASS_VBARRAY, JSCLASS_VBARRAY,
{NULL, VBArray_value, 0}, VBArray_value,
ARRAY_SIZE(VBArray_props), ARRAY_SIZE(VBArray_props),
VBArray_props, VBArray_props,
VBArray_destructor, VBArray_destructor,