Commit d541b525 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Pass 'this' as jsdisp_t to getters.

parent da5041eb
......@@ -49,9 +49,14 @@ static const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',0};
static const WCHAR default_separatorW[] = {',',0};
static inline ArrayInstance *array_from_jsdisp(jsdisp_t *jsdisp)
{
return CONTAINING_RECORD(jsdisp, ArrayInstance, dispex);
}
static inline ArrayInstance *array_from_vdisp(vdisp_t *vdisp)
{
return (ArrayInstance*)vdisp->u.jsdisp;
return array_from_jsdisp(vdisp->u.jsdisp);
}
static inline ArrayInstance *array_this(vdisp_t *jsthis)
......@@ -113,13 +118,11 @@ static WCHAR *idx_to_str(DWORD idx, WCHAR *ptr)
return ptr+1;
}
static HRESULT Array_get_length(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT Array_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
ArrayInstance *This = array_from_vdisp(jsthis);
TRACE("%p\n", jsthis);
TRACE("%p %d\n", This, This->length);
*r = jsval_number(This->length);
*r = jsval_number(array_from_jsdisp(jsthis)->length);
return S_OK;
}
......@@ -995,11 +998,13 @@ 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, vdisp_t *jsthis, jsval_t *r)
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, jsthis->u.jsdisp, array_from_vdisp(jsthis)->length, default_separatorW, r);
return array_join(ctx, &array->dispex, array->length, default_separatorW, r);
}
static void Array_destructor(jsdisp_t *dispex)
......
......@@ -94,9 +94,14 @@ static const WCHAR setYearW[] = {'s','e','t','Y','e','a','r',0};
static const WCHAR UTCW[] = {'U','T','C',0};
static const WCHAR parseW[] = {'p','a','r','s','e',0};
static inline DateInstance *date_from_jsdisp(jsdisp_t *jsdisp)
{
return CONTAINING_RECORD(jsdisp, DateInstance, dispex);
}
static inline DateInstance *date_this(vdisp_t *jsthis)
{
return is_vclass(jsthis, JSCLASS_DATE) ? (DateInstance*)jsthis->u.jsdisp : NULL;
return is_vclass(jsthis, JSCLASS_DATE) ? date_from_jsdisp(jsthis->u.jsdisp) : NULL;
}
/*ECMA-262 3rd Edition 15.9.1.2 */
......@@ -1917,11 +1922,11 @@ 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, vdisp_t *jsthis, jsval_t *r)
static HRESULT Date_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return dateobj_to_string((DateInstance*)jsthis->u.jsdisp, r);
return dateobj_to_string(date_from_jsdisp(jsthis), r);
}
static const builtin_prop_t Date_props[] = {
......
......@@ -421,11 +421,7 @@ static HRESULT prop_get(jsdisp_t *This, dispex_prop_t *prop, DISPPARAMS *dp,
switch(prop->type) {
case PROP_BUILTIN:
if(prop->u.p->getter) {
vdisp_t vthis;
set_jsdisp(&vthis, This);
hres = prop->u.p->getter(This->ctx, &vthis, r);
vdisp_release(&vthis);
hres = prop->u.p->getter(This->ctx, This, r);
}else {
jsdisp_t *obj;
......
......@@ -43,9 +43,14 @@ typedef struct {
jsdisp_t *var_obj;
} ArgumentsInstance;
static inline FunctionInstance *function_from_jsdisp(jsdisp_t *jsdisp)
{
return CONTAINING_RECORD(jsdisp, FunctionInstance, dispex);
}
static inline FunctionInstance *function_from_vdisp(vdisp_t *vdisp)
{
return (FunctionInstance*)vdisp->u.jsdisp;
return function_from_jsdisp(vdisp->u.jsdisp);
}
static inline FunctionInstance *function_this(vdisp_t *jsthis)
......@@ -362,13 +367,11 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi
return invoke_source(function->dispex.ctx, function, jsthis, argc, argv, r);
}
static HRESULT Function_get_length(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
FunctionInstance *This = function_from_vdisp(jsthis);
TRACE("%p\n", jsthis);
TRACE("%p %d\n", This, This->length);
*r = jsval_number(This->length);
*r = jsval_number(function_from_jsdisp(jsthis)->length);
return S_OK;
}
......@@ -538,15 +541,14 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r);
}
HRESULT Function_get_value(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
HRESULT Function_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp;
jsstr_t *str;
HRESULT hres;
TRACE("\n");
hres = function_to_string(function, &str);
hres = function_to_string(function_from_jsdisp(jsthis), &str);
if(FAILED(hres))
return hres;
......@@ -554,9 +556,9 @@ HRESULT Function_get_value(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
return S_OK;
}
static HRESULT Function_get_arguments(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
FunctionInstance *function = (FunctionInstance*)jsthis->u.jsdisp;
FunctionInstance *function = function_from_jsdisp(jsthis);
TRACE("\n");
......
......@@ -187,7 +187,7 @@ static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
}
typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
typedef HRESULT (*builtin_getter_t)(script_ctx_t*,vdisp_t*,jsval_t*);
typedef HRESULT (*builtin_getter_t)(script_ctx_t*,jsdisp_t*,jsval_t*);
typedef HRESULT (*builtin_setter_t)(script_ctx_t*,vdisp_t*,jsval_t);
HRESULT builtin_set_const(script_ctx_t*,vdisp_t*,jsval_t) DECLSPEC_HIDDEN;
......@@ -296,7 +296,7 @@ HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,c
HRESULT Function_invoke(jsdisp_t*,IDispatch*,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*,vdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
HRESULT Function_get_value(script_ctx_t*,jsdisp_t*,jsval_t*) DECLSPEC_HIDDEN;
#define DEFAULT_FUNCTION_VALUE {NULL, Function_value,0, Function_get_value}
HRESULT throw_eval_error(script_ctx_t*,HRESULT,const WCHAR*) DECLSPEC_HIDDEN;
......
......@@ -58,9 +58,14 @@ static const WCHAR idx7W[] = {'$','7',0};
static const WCHAR idx8W[] = {'$','8',0};
static const WCHAR idx9W[] = {'$','9',0};
static inline RegExpInstance *regexp_from_jsdisp(jsdisp_t *jsdisp)
{
return CONTAINING_RECORD(jsdisp, RegExpInstance, dispex);
}
static inline RegExpInstance *regexp_from_vdisp(vdisp_t *vdisp)
{
return (RegExpInstance*)vdisp->u.jsdisp;
return regexp_from_jsdisp(vdisp->u.jsdisp);
}
static void set_last_index(RegExpInstance *This, DWORD last_index)
......@@ -243,13 +248,11 @@ static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *jsstr,
return S_OK;
}
static HRESULT RegExp_get_source(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExp_get_source(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
RegExpInstance *This = regexp_from_vdisp(jsthis);
TRACE("\n");
*r = jsval_string(jsstr_addref(This->str));
*r = jsval_string(jsstr_addref(regexp_from_jsdisp(jsthis)->str));
return S_OK;
}
......@@ -259,7 +262,7 @@ static HRESULT RegExp_set_source(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t val
return E_NOTIMPL;
}
static HRESULT RegExp_get_global(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExp_get_global(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
FIXME("\n");
return E_NOTIMPL;
......@@ -271,7 +274,7 @@ static HRESULT RegExp_set_global(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t val
return E_NOTIMPL;
}
static HRESULT RegExp_get_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExp_get_ignoreCase(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
FIXME("\n");
return E_NOTIMPL;
......@@ -283,7 +286,7 @@ static HRESULT RegExp_set_ignoreCase(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t
return E_NOTIMPL;
}
static HRESULT RegExp_get_multiline(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExp_get_multiline(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
FIXME("\n");
return E_NOTIMPL;
......@@ -310,9 +313,9 @@ static INT index_from_val(script_ctx_t *ctx, jsval_t v)
return is_int32(n) ? n : 0;
}
static HRESULT RegExp_get_lastIndex(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExp_get_lastIndex(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
RegExpInstance *regexp = regexp_from_vdisp(jsthis);
RegExpInstance *regexp = regexp_from_jsdisp(jsthis);
TRACE("\n");
......@@ -854,61 +857,61 @@ static HRESULT global_idx(script_ctx_t *ctx, DWORD idx, jsval_t *r)
return S_OK;
}
static HRESULT RegExpConstr_get_idx1(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx1(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 0, r);
}
static HRESULT RegExpConstr_get_idx2(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx2(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 1, r);
}
static HRESULT RegExpConstr_get_idx3(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx3(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 2, r);
}
static HRESULT RegExpConstr_get_idx4(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx4(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 3, r);
}
static HRESULT RegExpConstr_get_idx5(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx5(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 4, r);
}
static HRESULT RegExpConstr_get_idx6(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx6(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 5, r);
}
static HRESULT RegExpConstr_get_idx7(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx7(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 6, r);
}
static HRESULT RegExpConstr_get_idx8(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx8(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 7, r);
}
static HRESULT RegExpConstr_get_idx9(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_idx9(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
TRACE("\n");
return global_idx(ctx, 8, r);
}
static HRESULT RegExpConstr_get_leftContext(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_leftContext(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
jsstr_t *ret;
......@@ -922,7 +925,7 @@ static HRESULT RegExpConstr_get_leftContext(script_ctx_t *ctx, vdisp_t *jsthis,
return S_OK;
}
static HRESULT RegExpConstr_get_rightContext(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT RegExpConstr_get_rightContext(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
jsstr_t *ret;
......
......@@ -44,9 +44,14 @@ static const WCHAR valueOfW[] = {'v','a','l','u','e','O','f',0};
#define NUMBER_TOSTRING_BUF_SIZE 64
#define NUMBER_DTOA_SIZE 18
static inline NumberInstance *number_from_jsdisp(jsdisp_t *jsdisp)
{
return CONTAINING_RECORD(jsdisp, NumberInstance, dispex);
}
static inline NumberInstance *number_from_vdisp(vdisp_t *vdisp)
{
return (NumberInstance*)vdisp->u.jsdisp;
return number_from_jsdisp(vdisp->u.jsdisp);
}
static inline NumberInstance *number_this(vdisp_t *jsthis)
......@@ -500,9 +505,9 @@ 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, vdisp_t *jsthis, jsval_t *r)
static HRESULT Number_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
NumberInstance *number = number_from_vdisp(jsthis);
NumberInstance *number = number_from_jsdisp(jsthis);
TRACE("(%p)\n", number);
......
......@@ -207,7 +207,7 @@ static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return E_NOTIMPL;
}
static HRESULT Object_get_value(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT Object_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
jsstr_t *ret;
......
......@@ -68,9 +68,14 @@ static const WCHAR toLocaleUpperCaseW[] = {'t','o','L','o','c','a','l','e','U','
static const WCHAR localeCompareW[] = {'l','o','c','a','l','e','C','o','m','p','a','r','e',0};
static const WCHAR fromCharCodeW[] = {'f','r','o','m','C','h','a','r','C','o','d','e',0};
static inline StringInstance *string_from_jsdisp(jsdisp_t *jsdisp)
{
return CONTAINING_RECORD(jsdisp, StringInstance, dispex);
}
static inline StringInstance *string_from_vdisp(vdisp_t *vdisp)
{
return (StringInstance*)vdisp->u.jsdisp;
return string_from_jsdisp(vdisp->u.jsdisp);
}
static inline StringInstance *string_this(vdisp_t *jsthis)
......@@ -106,9 +111,9 @@ static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t *
return E_OUTOFMEMORY;
}
static HRESULT String_get_length(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t *r)
static HRESULT String_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
StringInstance *string = string_from_vdisp(jsthis);
StringInstance *string = (StringInstance*)jsthis;
TRACE("%p\n", jsthis);
......@@ -1467,9 +1472,9 @@ 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, vdisp_t *jsthis, jsval_t *r)
static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
StringInstance *This = string_from_vdisp(jsthis);
StringInstance *This = (StringInstance*)jsthis;
TRACE("\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment