Commit 7a1c6453 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

jscript: Pass a jsval "this" to builtin functions.

And get rid of vdisp_t since it's no longer needed. Signed-off-by: 's avatarGabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 57c28516
...@@ -138,7 +138,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid) ...@@ -138,7 +138,7 @@ static IUnknown *create_activex_object(script_ctx_t *ctx, const WCHAR *progid)
return obj; return obj;
} }
static HRESULT ActiveXObject_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT ActiveXObject_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsstr_t * progid_str; jsstr_t * progid_str;
......
...@@ -36,14 +36,16 @@ static inline BoolInstance *bool_from_jsdisp(jsdisp_t *jsdisp) ...@@ -36,14 +36,16 @@ static inline BoolInstance *bool_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, BoolInstance, dispex); return CONTAINING_RECORD(jsdisp, BoolInstance, dispex);
} }
static inline BoolInstance *bool_from_vdisp(vdisp_t *vdisp) static inline HRESULT boolval_this(jsval_t vthis, BOOL *ret)
{ {
return bool_from_jsdisp(vdisp->u.jsdisp); jsdisp_t *jsdisp;
} if(is_bool(vthis))
*ret = get_bool(vthis);
static inline BoolInstance *bool_this(vdisp_t *jsthis) else if(is_object_instance(vthis) && (jsdisp = to_jsdisp(get_object(vthis))) && is_class(jsdisp, JSCLASS_BOOLEAN))
{ *ret = bool_from_jsdisp(jsdisp)->val;
return is_vclass(jsthis, JSCLASS_BOOLEAN) ? bool_from_vdisp(jsthis) : NULL; else
return JS_E_BOOLEAN_EXPECTED;
return S_OK;
} }
BOOL bool_obj_value(jsdisp_t *obj) BOOL bool_obj_value(jsdisp_t *obj)
...@@ -53,19 +55,21 @@ BOOL bool_obj_value(jsdisp_t *obj) ...@@ -53,19 +55,21 @@ BOOL bool_obj_value(jsdisp_t *obj)
} }
/* ECMA-262 3rd Edition 15.6.4.2 */ /* ECMA-262 3rd Edition 15.6.4.2 */
static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) static HRESULT Bool_toString(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
BoolInstance *bool; BOOL boolval;
HRESULT hres;
TRACE("\n"); TRACE("\n");
if(!(bool = bool_this(jsthis))) hres = boolval_this(vthis, &boolval);
return JS_E_BOOLEAN_EXPECTED; if(FAILED(hres))
return hres;
if(r) { if(r) {
jsstr_t *val; jsstr_t *val;
val = jsstr_alloc(bool->val ? L"true" : L"false"); val = jsstr_alloc(boolval ? L"true" : L"false");
if(!val) if(!val)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -76,21 +80,23 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns ...@@ -76,21 +80,23 @@ static HRESULT Bool_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
} }
/* ECMA-262 3rd Edition 15.6.4.3 */ /* ECMA-262 3rd Edition 15.6.4.3 */
static HRESULT Bool_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) static HRESULT Bool_valueOf(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
BoolInstance *bool; BOOL boolval;
HRESULT hres;
TRACE("\n"); TRACE("\n");
if(!(bool = bool_this(jsthis))) hres = boolval_this(vthis, &boolval);
return JS_E_BOOLEAN_EXPECTED; if(FAILED(hres))
return hres;
if(r) if(r)
*r = jsval_bool(bool->val); *r = jsval_bool(boolval);
return S_OK; return S_OK;
} }
static HRESULT Bool_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Bool_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -129,7 +135,7 @@ static const builtin_info_t BoolInst_info = { ...@@ -129,7 +135,7 @@ static const builtin_info_t BoolInst_info = {
NULL NULL
}; };
static HRESULT BoolConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT BoolConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
BOOL value = FALSE; BOOL value = FALSE;
......
...@@ -550,7 +550,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t ...@@ -550,7 +550,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
switch(prop->type) { switch(prop->type) {
case PROP_BUILTIN: { case PROP_BUILTIN: {
vdisp_t vthis; jsval_t vthis;
if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) { if(flags == DISPATCH_CONSTRUCT && (prop->flags & PROPF_METHOD)) {
WARN("%s is not a constructor\n", debugstr_w(prop->name)); WARN("%s is not a constructor\n", debugstr_w(prop->name));
...@@ -560,13 +560,10 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t ...@@ -560,13 +560,10 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
if(This->builtin_info->class != JSCLASS_FUNCTION && prop->u.p->invoke != JSGlobal_eval) if(This->builtin_info->class != JSCLASS_FUNCTION && prop->u.p->invoke != JSGlobal_eval)
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK; flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
if(jsthis) if(jsthis)
set_disp(&vthis, jsthis); vthis = jsval_disp(jsthis);
else else
set_jsdisp(&vthis, This); vthis = jsval_obj(This);
hres = prop->u.p->invoke(This->ctx, &vthis, flags, argc, argv, r); return prop->u.p->invoke(This->ctx, vthis, flags, argc, argv, r);
vdisp_release(&vthis);
return hres;
} }
case PROP_PROTREF: case PROP_PROTREF:
return invoke_prop_func(This->prototype, jsthis ? jsthis : (IDispatch *)&This->IDispatchEx_iface, return invoke_prop_func(This->prototype, jsthis ? jsthis : (IDispatch *)&This->IDispatchEx_iface,
...@@ -1979,17 +1976,13 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig ...@@ -1979,17 +1976,13 @@ HRESULT jsdisp_call_value(jsdisp_t *jsfunc, IDispatch *jsthis, WORD flags, unsig
if(is_class(jsfunc, JSCLASS_FUNCTION)) { if(is_class(jsfunc, JSCLASS_FUNCTION)) {
hres = Function_invoke(jsfunc, jsthis, flags, argc, argv, r); hres = Function_invoke(jsfunc, jsthis, flags, argc, argv, r);
}else { }else {
vdisp_t vdisp;
if(!jsfunc->builtin_info->call) { 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);
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK; flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
hres = jsfunc->builtin_info->call(jsfunc->ctx, &vdisp, flags, argc, argv, r); hres = jsfunc->builtin_info->call(jsfunc->ctx, jsval_disp(jsthis), flags, argc, argv, r);
vdisp_release(&vdisp);
} }
return hres; return hres;
} }
......
...@@ -38,14 +38,10 @@ static inline EnumeratorInstance *enumerator_from_jsdisp(jsdisp_t *jsdisp) ...@@ -38,14 +38,10 @@ static inline EnumeratorInstance *enumerator_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, EnumeratorInstance, dispex); return CONTAINING_RECORD(jsdisp, EnumeratorInstance, dispex);
} }
static inline EnumeratorInstance *enumerator_from_vdisp(vdisp_t *vdisp) static inline EnumeratorInstance *enumerator_this(jsval_t vthis)
{ {
return enumerator_from_jsdisp(vdisp->u.jsdisp); jsdisp_t *jsdisp = is_object_instance(vthis) ? to_jsdisp(get_object(vthis)) : NULL;
} return (jsdisp && is_class(jsdisp, JSCLASS_ENUMERATOR)) ? enumerator_from_jsdisp(jsdisp) : NULL;
static inline EnumeratorInstance *enumerator_this(vdisp_t *jsthis)
{
return is_vclass(jsthis, JSCLASS_ENUMERATOR) ? enumerator_from_vdisp(jsthis) : NULL;
} }
static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This) static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This)
...@@ -92,12 +88,12 @@ static void Enumerator_destructor(jsdisp_t *dispex) ...@@ -92,12 +88,12 @@ static void Enumerator_destructor(jsdisp_t *dispex)
heap_free(dispex); heap_free(dispex);
} }
static HRESULT Enumerator_atEnd(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Enumerator_atEnd(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
EnumeratorInstance *This; EnumeratorInstance *This;
if (!(This = enumerator_this(jsthis))) if (!(This = enumerator_this(vthis)))
return JS_E_ENUMERATOR_EXPECTED; return JS_E_ENUMERATOR_EXPECTED;
TRACE("%d\n", This->atend); TRACE("%d\n", This->atend);
...@@ -107,20 +103,20 @@ static HRESULT Enumerator_atEnd(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, ...@@ -107,20 +103,20 @@ static HRESULT Enumerator_atEnd(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT Enumerator_item(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Enumerator_item(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
EnumeratorInstance *This; EnumeratorInstance *This;
TRACE("\n"); TRACE("\n");
if (!(This = enumerator_this(jsthis))) if (!(This = enumerator_this(vthis)))
return JS_E_ENUMERATOR_EXPECTED; return JS_E_ENUMERATOR_EXPECTED;
return r ? jsval_copy(This->item, r) : S_OK; return r ? jsval_copy(This->item, r) : S_OK;
} }
static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
EnumeratorInstance *This; EnumeratorInstance *This;
...@@ -128,7 +124,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla ...@@ -128,7 +124,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
TRACE("\n"); TRACE("\n");
if (!(This = enumerator_this(jsthis))) if (!(This = enumerator_this(vthis)))
return JS_E_ENUMERATOR_EXPECTED; return JS_E_ENUMERATOR_EXPECTED;
if (This->enumvar) if (This->enumvar)
...@@ -148,7 +144,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla ...@@ -148,7 +144,7 @@ static HRESULT Enumerator_moveFirst(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return S_OK; return S_OK;
} }
static HRESULT Enumerator_moveNext(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Enumerator_moveNext(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
EnumeratorInstance *This; EnumeratorInstance *This;
...@@ -156,7 +152,7 @@ static HRESULT Enumerator_moveNext(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag ...@@ -156,7 +152,7 @@ static HRESULT Enumerator_moveNext(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag
TRACE("\n"); TRACE("\n");
if (!(This = enumerator_this(jsthis))) if (!(This = enumerator_this(vthis)))
return JS_E_ENUMERATOR_EXPECTED; return JS_E_ENUMERATOR_EXPECTED;
if (This->enumvar) if (This->enumvar)
...@@ -287,7 +283,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re ...@@ -287,7 +283,7 @@ static HRESULT create_enumerator(script_ctx_t *ctx, jsval_t *argv, jsdisp_t **re
return S_OK; return S_OK;
} }
static HRESULT EnumeratorConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT EnumeratorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsdisp_t *obj; jsdisp_t *obj;
......
...@@ -29,17 +29,21 @@ ...@@ -29,17 +29,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(jscript); WINE_DEFAULT_DEBUG_CHANNEL(jscript);
/* ECMA-262 3rd Edition 15.11.4.4 */ /* ECMA-262 3rd Edition 15.11.4.4 */
static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, static HRESULT Error_toString(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
jsdisp_t *jsthis;
jsstr_t *name = NULL, *msg = NULL, *ret = NULL; jsstr_t *name = NULL, *msg = NULL, *ret = NULL;
jsdisp_t *jsthis = NULL;
jsval_t v; jsval_t v;
HRESULT hres; HRESULT hres;
TRACE("\n"); TRACE("\n");
jsthis = get_jsdisp(vthis); if(is_object_instance(vthis))
jsthis = to_jsdisp(get_object(vthis));
else if(ctx->version >= SCRIPTLANGUAGEVERSION_ES5)
return JS_E_OBJECT_EXPECTED;
if(!jsthis || ctx->version < 2) { if(!jsthis || ctx->version < 2) {
if(r) { if(r) {
jsstr_t *str; jsstr_t *str;
...@@ -114,7 +118,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, ...@@ -114,7 +118,7 @@ static HRESULT Error_toString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT Error_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT Error_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -260,56 +264,56 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_ ...@@ -260,56 +264,56 @@ static HRESULT error_constr(script_ctx_t *ctx, WORD flags, unsigned argc, jsval_
} }
} }
static HRESULT ErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT ErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->error_constr);
} }
static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT EvalErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->eval_error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->eval_error_constr);
} }
static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT RangeErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->range_error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->range_error_constr);
} }
static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT ReferenceErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->reference_error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->reference_error_constr);
} }
static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT RegExpErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->regexp_error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->regexp_error_constr);
} }
static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT SyntaxErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->syntax_error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->syntax_error_constr);
} }
static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT TypeErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
return error_constr(ctx, flags, argc, argv, r, ctx->type_error_constr); return error_constr(ctx, flags, argc, argv, r, ctx->type_error_constr);
} }
static HRESULT URIErrorConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, static HRESULT URIErrorConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags,
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
......
...@@ -77,14 +77,10 @@ static inline FunctionInstance *function_from_jsdisp(jsdisp_t *jsdisp) ...@@ -77,14 +77,10 @@ static inline FunctionInstance *function_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, FunctionInstance, dispex); return CONTAINING_RECORD(jsdisp, FunctionInstance, dispex);
} }
static inline FunctionInstance *function_from_vdisp(vdisp_t *vdisp) static inline FunctionInstance *function_this(jsval_t vthis)
{ {
return function_from_jsdisp(vdisp->u.jsdisp); jsdisp_t *jsdisp = is_object_instance(vthis) ? to_jsdisp(get_object(vthis)) : NULL;
} return (jsdisp && is_class(jsdisp, JSCLASS_FUNCTION)) ? function_from_jsdisp(jsdisp) : NULL;
static inline FunctionInstance *function_this(vdisp_t *jsthis)
{
return is_vclass(jsthis, JSCLASS_FUNCTION) ? function_from_vdisp(jsthis) : NULL;
} }
static inline ArgumentsInstance *arguments_from_jsdisp(jsdisp_t *jsdisp) static inline ArgumentsInstance *arguments_from_jsdisp(jsdisp_t *jsdisp)
...@@ -92,7 +88,7 @@ static inline ArgumentsInstance *arguments_from_jsdisp(jsdisp_t *jsdisp) ...@@ -92,7 +88,7 @@ static inline ArgumentsInstance *arguments_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, ArgumentsInstance, jsdisp); return CONTAINING_RECORD(jsdisp, ArgumentsInstance, jsdisp);
} }
static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Arguments_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
...@@ -271,7 +267,7 @@ static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t ...@@ -271,7 +267,7 @@ static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t
return S_OK; return S_OK;
} }
static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_toString(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
...@@ -280,7 +276,7 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, ...@@ -280,7 +276,7 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
TRACE("\n"); TRACE("\n");
if(!(function = function_this(jsthis))) if(!(function = function_this(vthis)))
return JS_E_FUNCTION_EXPECTED; return JS_E_FUNCTION_EXPECTED;
hres = function->vtbl->toString(function, &str); hres = function->vtbl->toString(function, &str);
...@@ -330,7 +326,7 @@ static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, unsigned *a ...@@ -330,7 +326,7 @@ static HRESULT array_to_args(script_ctx_t *ctx, jsdisp_t *arg_array, unsigned *a
return S_OK; return S_OK;
} }
static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) static HRESULT Function_apply(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
jsval_t *args = NULL; jsval_t *args = NULL;
...@@ -340,7 +336,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -340,7 +336,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
if(!(function = function_this(jsthis)) && (jsthis->flags & VDISP_JSDISP)) if(!is_object_instance(vthis) || (!(function = function_this(vthis)) && to_jsdisp(get_object(vthis))))
return JS_E_FUNCTION_EXPECTED; return JS_E_FUNCTION_EXPECTED;
if(argc) { if(argc) {
...@@ -377,7 +373,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -377,7 +373,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
hres = function->vtbl->call(ctx, function, this_obj, flags, cnt, args, r); hres = function->vtbl->call(ctx, function, this_obj, flags, cnt, args, r);
}else { }else {
jsval_t res; jsval_t res;
hres = disp_call_value(ctx, jsthis->u.disp, this_obj, DISPATCH_METHOD, cnt, args, &res); hres = disp_call_value(ctx, get_object(vthis), this_obj, DISPATCH_METHOD, cnt, args, &res);
if(SUCCEEDED(hres)) { if(SUCCEEDED(hres)) {
if(r) if(r)
*r = res; *r = res;
...@@ -395,7 +391,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -395,7 +391,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return hres; return hres;
} }
static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_call(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
...@@ -405,7 +401,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns ...@@ -405,7 +401,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
if(!(function = function_this(jsthis))) if(!(function = function_this(vthis)))
return JS_E_FUNCTION_EXPECTED; return JS_E_FUNCTION_EXPECTED;
if(argc) { if(argc) {
...@@ -425,7 +421,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns ...@@ -425,7 +421,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
return hres; return hres;
} }
static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Function_bind(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
IDispatch *bound_this = NULL; IDispatch *bound_this = NULL;
...@@ -435,7 +431,7 @@ static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns ...@@ -435,7 +431,7 @@ static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
TRACE("\n"); TRACE("\n");
if(!(function = function_this(jsthis))) if(!(function = function_this(vthis)))
return JS_E_FUNCTION_EXPECTED; return JS_E_FUNCTION_EXPECTED;
if(argc < 1) { if(argc < 1) {
...@@ -461,19 +457,18 @@ static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns ...@@ -461,19 +457,18 @@ static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
return S_OK; return S_OK;
} }
HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, HRESULT Function_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FunctionInstance *function; FunctionInstance *function;
TRACE("\n"); TRACE("\n");
if(!is_vclass(jsthis, JSCLASS_FUNCTION)) { if(!(function = function_this(vthis))) {
ERR("dispex is not a function\n"); ERR("dispex is not a function\n");
return E_FAIL; return E_FAIL;
} }
function = function_from_jsdisp(jsthis->u.jsdisp);
return function->vtbl->call(ctx, function, NULL, flags, argc, argv, r); return function->vtbl->call(ctx, function, NULL, flags, argc, argv, r);
} }
...@@ -599,18 +594,14 @@ static HRESULT NativeFunction_call(script_ctx_t *ctx, FunctionInstance *func, ID ...@@ -599,18 +594,14 @@ static HRESULT NativeFunction_call(script_ctx_t *ctx, FunctionInstance *func, ID
unsigned argc, jsval_t *argv, jsval_t *r) unsigned argc, jsval_t *argv, jsval_t *r)
{ {
NativeFunction *function = (NativeFunction*)func; NativeFunction *function = (NativeFunction*)func;
vdisp_t vthis; jsval_t vthis;
HRESULT hres;
if(this_disp) if(this_disp)
set_disp(&vthis, this_disp); vthis = jsval_disp(this_disp);
else else
set_disp(&vthis, lookup_global_host(ctx)); vthis = jsval_disp(lookup_global_host(ctx));
hres = function->proc(ctx, &vthis, flags & ~DISPATCH_JSCRIPT_INTERNAL_MASK, argc, argv, r);
vdisp_release(&vthis); return function->proc(ctx, vthis, flags & ~DISPATCH_JSCRIPT_INTERNAL_MASK, argc, argv, r);
return hres;
} }
static HRESULT NativeFunction_toString(FunctionInstance *func, jsstr_t **ret) static HRESULT NativeFunction_toString(FunctionInstance *func, jsstr_t **ret)
...@@ -984,7 +975,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg ...@@ -984,7 +975,7 @@ static HRESULT construct_function(script_ctx_t *ctx, unsigned argc, jsval_t *arg
return S_OK; return S_OK;
} }
static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT FunctionConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
HRESULT hres; HRESULT hres;
...@@ -1011,7 +1002,7 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla ...@@ -1011,7 +1002,7 @@ static HRESULT FunctionConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return S_OK; return S_OK;
} }
static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT FunctionProt_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
......
...@@ -65,7 +65,7 @@ static WCHAR int_to_char(int i) ...@@ -65,7 +65,7 @@ static WCHAR int_to_char(int i)
return 'A'+i-10; return 'A'+i-10;
} }
static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_escape(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsstr_t *ret_str, *str; jsstr_t *ret_str, *str;
...@@ -130,7 +130,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u ...@@ -130,7 +130,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
} }
/* ECMA-262 3rd Edition 15.1.2.1 */ /* ECMA-262 3rd Edition 15.1.2.1 */
HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, HRESULT JSGlobal_eval(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
call_frame_t *frame = ctx->call_ctx; call_frame_t *frame = ctx->call_ctx;
...@@ -174,7 +174,7 @@ HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned a ...@@ -174,7 +174,7 @@ HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned a
return hres; return hres;
} }
static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
...@@ -197,7 +197,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -197,7 +197,7 @@ static HRESULT JSGlobal_isNaN(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_isFinite(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
...@@ -231,7 +231,7 @@ static INT char_to_int(WCHAR c) ...@@ -231,7 +231,7 @@ static INT char_to_int(WCHAR c)
return 100; return 100;
} }
static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
BOOL neg = FALSE, empty = TRUE; BOOL neg = FALSE, empty = TRUE;
...@@ -314,7 +314,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, ...@@ -314,7 +314,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
LONGLONG d = 0, hlp; LONGLONG d = 0, hlp;
...@@ -421,7 +421,7 @@ static inline int hex_to_int(const WCHAR wch) { ...@@ -421,7 +421,7 @@ static inline int hex_to_int(const WCHAR wch) {
return -1; return -1;
} }
static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_unescape(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsstr_t *ret_str, *str; jsstr_t *ret_str, *str;
...@@ -491,14 +491,14 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, ...@@ -491,14 +491,14 @@ static HRESULT JSGlobal_unescape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_GetObject(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -516,7 +516,7 @@ static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl ...@@ -516,7 +516,7 @@ static HRESULT JSGlobal_ScriptEngine(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -526,7 +526,7 @@ static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jst ...@@ -526,7 +526,7 @@ static HRESULT JSGlobal_ScriptEngineMajorVersion(script_ctx_t *ctx, vdisp_t *jst
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -536,7 +536,7 @@ static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jst ...@@ -536,7 +536,7 @@ static HRESULT JSGlobal_ScriptEngineMinorVersion(script_ctx_t *ctx, vdisp_t *jst
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -546,7 +546,7 @@ static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jst ...@@ -546,7 +546,7 @@ static HRESULT JSGlobal_ScriptEngineBuildVersion(script_ctx_t *ctx, vdisp_t *jst
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
static int once = 0; static int once = 0;
...@@ -555,7 +555,7 @@ static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD ...@@ -555,7 +555,7 @@ static HRESULT JSGlobal_CollectGarbage(script_ctx_t *ctx, vdisp_t *jsthis, WORD
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
const WCHAR *ptr, *uri; const WCHAR *ptr, *uri;
...@@ -620,7 +620,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -620,7 +620,7 @@ static HRESULT JSGlobal_encodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
const WCHAR *ptr, *uri; const WCHAR *ptr, *uri;
...@@ -706,7 +706,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -706,7 +706,7 @@ static HRESULT JSGlobal_decodeURI(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsstr_t *str, *ret_str; jsstr_t *str, *ret_str;
...@@ -770,7 +770,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W ...@@ -770,7 +770,7 @@ static HRESULT JSGlobal_encodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, W
} }
/* ECMA-262 3rd Edition 15.1.3.2 */ /* ECMA-262 3rd Edition 15.1.3.2 */
static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT JSGlobal_decodeURIComponent(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
const WCHAR *ptr, *uri; const WCHAR *ptr, *uri;
......
...@@ -138,71 +138,7 @@ typedef enum { ...@@ -138,71 +138,7 @@ typedef enum {
jsdisp_t *iface_to_jsdisp(IDispatch*) DECLSPEC_HIDDEN; jsdisp_t *iface_to_jsdisp(IDispatch*) DECLSPEC_HIDDEN;
typedef struct { typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,jsval_t,WORD,unsigned,jsval_t*,jsval_t*);
union {
IDispatch *disp;
IDispatchEx *dispex;
jsdisp_t *jsdisp;
} u;
DWORD flags;
} vdisp_t;
#define VDISP_DISPEX 0x0001
#define VDISP_JSDISP 0x0002
static inline void vdisp_release(vdisp_t *vdisp)
{
IDispatch_Release(vdisp->u.disp);
}
static inline BOOL is_jsdisp(vdisp_t *vdisp)
{
return (vdisp->flags & VDISP_JSDISP) != 0;
}
static inline BOOL is_dispex(vdisp_t *vdisp)
{
return (vdisp->flags & VDISP_DISPEX) != 0;
}
static inline void set_jsdisp(vdisp_t *vdisp, jsdisp_t *jsdisp)
{
vdisp->u.jsdisp = jsdisp;
vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
IDispatch_AddRef(vdisp->u.disp);
}
static inline void set_disp(vdisp_t *vdisp, IDispatch *disp)
{
IDispatchEx *dispex;
jsdisp_t *jsdisp;
HRESULT hres;
jsdisp = iface_to_jsdisp(disp);
if(jsdisp) {
vdisp->u.jsdisp = jsdisp;
vdisp->flags = VDISP_JSDISP | VDISP_DISPEX;
return;
}
hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
if(SUCCEEDED(hres)) {
vdisp->u.dispex = dispex;
vdisp->flags = VDISP_DISPEX;
return;
}
IDispatch_AddRef(disp);
vdisp->u.disp = disp;
vdisp->flags = 0;
}
static inline jsdisp_t *get_jsdisp(vdisp_t *vdisp)
{
return is_jsdisp(vdisp) ? vdisp->u.jsdisp : NULL;
}
typedef HRESULT (*builtin_invoke_t)(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*);
typedef HRESULT (*builtin_getter_t)(script_ctx_t*,jsdisp_t*,jsval_t*); typedef HRESULT (*builtin_getter_t)(script_ctx_t*,jsdisp_t*,jsval_t*);
typedef HRESULT (*builtin_setter_t)(script_ctx_t*,jsdisp_t*,jsval_t); typedef HRESULT (*builtin_setter_t)(script_ctx_t*,jsdisp_t*,jsval_t);
...@@ -337,7 +273,7 @@ HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,c ...@@ -337,7 +273,7 @@ HRESULT create_builtin_constructor(script_ctx_t*,builtin_invoke_t,const WCHAR*,c
jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN;
HRESULT Function_invoke(jsdisp_t*,IDispatch*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; 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_value(script_ctx_t*,jsval_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;
...@@ -514,18 +450,13 @@ HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,jsstr_t*,jsval_t*) DECLSPEC_ ...@@ -514,18 +450,13 @@ HRESULT regexp_string_match(script_ctx_t*,jsdisp_t*,jsstr_t*,jsval_t*) DECLSPEC_
BOOL bool_obj_value(jsdisp_t*) DECLSPEC_HIDDEN; BOOL bool_obj_value(jsdisp_t*) DECLSPEC_HIDDEN;
unsigned array_get_length(jsdisp_t*) DECLSPEC_HIDDEN; unsigned array_get_length(jsdisp_t*) DECLSPEC_HIDDEN;
HRESULT JSGlobal_eval(script_ctx_t*,vdisp_t*,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN; HRESULT JSGlobal_eval(script_ctx_t*,jsval_t,WORD,unsigned,jsval_t*,jsval_t*) DECLSPEC_HIDDEN;
static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class) static inline BOOL is_class(jsdisp_t *jsdisp, jsclass_t class)
{ {
return jsdisp->builtin_info->class == class; return jsdisp->builtin_info->class == class;
} }
static inline BOOL is_vclass(vdisp_t *vdisp, jsclass_t class)
{
return is_jsdisp(vdisp) && is_class(vdisp->u.jsdisp, class);
}
static inline BOOL is_int32(double d) static inline BOOL is_int32(double d)
{ {
return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d; return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d;
......
...@@ -268,7 +268,7 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r) ...@@ -268,7 +268,7 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r)
} }
/* ECMA-262 5.1 Edition 15.12.2 */ /* ECMA-262 5.1 Edition 15.12.2 */
static HRESULT JSON_parse(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) static HRESULT JSON_parse(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
json_parse_ctx_t parse_ctx; json_parse_ctx_t parse_ctx;
const WCHAR *buf; const WCHAR *buf;
...@@ -749,7 +749,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsdisp_t *object, const WCHAR *na ...@@ -749,7 +749,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsdisp_t *object, const WCHAR *na
} }
/* ECMA-262 5.1 Edition 15.12.3 */ /* ECMA-262 5.1 Edition 15.12.3 */
static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) static HRESULT JSON_stringify(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
{ {
stringify_ctx_t stringify_ctx = { ctx }; stringify_ctx_t stringify_ctx = { ctx };
jsdisp_t *obj = NULL, *replacer; jsdisp_t *obj = NULL, *replacer;
......
...@@ -39,9 +39,10 @@ static inline RegExpInstance *regexp_from_jsdisp(jsdisp_t *jsdisp) ...@@ -39,9 +39,10 @@ static inline RegExpInstance *regexp_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, RegExpInstance, dispex); return CONTAINING_RECORD(jsdisp, RegExpInstance, dispex);
} }
static inline RegExpInstance *regexp_from_vdisp(vdisp_t *vdisp) static inline RegExpInstance *regexp_this(jsval_t vthis)
{ {
return regexp_from_jsdisp(vdisp->u.jsdisp); jsdisp_t *jsdisp = is_object_instance(vthis) ? to_jsdisp(get_object(vthis)) : NULL;
return (jsdisp && is_class(jsdisp, JSCLASS_REGEXP)) ? regexp_from_jsdisp(jsdisp) : NULL;
} }
static void set_last_index(RegExpInstance *This, DWORD last_index) static void set_last_index(RegExpInstance *This, DWORD last_index)
...@@ -294,7 +295,7 @@ static HRESULT RegExp_set_lastIndex(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t ...@@ -294,7 +295,7 @@ static HRESULT RegExp_set_lastIndex(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t
return S_OK; return S_OK;
} }
static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_toString(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
RegExpInstance *regexp; RegExpInstance *regexp;
...@@ -304,12 +305,11 @@ static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u ...@@ -304,12 +305,11 @@ static HRESULT RegExp_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
TRACE("\n"); TRACE("\n");
if(!is_vclass(jsthis, JSCLASS_REGEXP)) { if(!(regexp = regexp_this(vthis))) {
WARN("Not a RegExp\n"); WARN("Not a RegExp\n");
return JS_E_REGEXP_EXPECTED; return JS_E_REGEXP_EXPECTED;
} }
regexp = regexp_from_vdisp(jsthis);
if(!r) if(!r)
return S_OK; return S_OK;
...@@ -408,7 +408,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input_str, ...@@ -408,7 +408,7 @@ static HRESULT create_match_array(script_ctx_t *ctx, jsstr_t *input_str,
return S_OK; return S_OK;
} }
static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, static HRESULT run_exec(script_ctx_t *ctx, jsval_t vthis, jsval_t arg,
jsstr_t **input, match_state_t **result, BOOL *ret) jsstr_t **input, match_state_t **result, BOOL *ret)
{ {
RegExpInstance *regexp; RegExpInstance *regexp;
...@@ -418,13 +418,11 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, ...@@ -418,13 +418,11 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg,
jsstr_t *jsstr; jsstr_t *jsstr;
HRESULT hres; HRESULT hres;
if(!is_vclass(jsthis, JSCLASS_REGEXP)) { if(!(regexp = regexp_this(vthis))) {
FIXME("Not a RegExp\n"); WARN("Not a RegExp\n");
return E_NOTIMPL; return JS_E_REGEXP_EXPECTED;
} }
regexp = regexp_from_vdisp(jsthis);
hres = to_flat_string(ctx, arg, &jsstr, &string); hres = to_flat_string(ctx, arg, &jsstr, &string);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
...@@ -463,7 +461,7 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg, ...@@ -463,7 +461,7 @@ static HRESULT run_exec(script_ctx_t *ctx, vdisp_t *jsthis, jsval_t arg,
return S_OK; return S_OK;
} }
static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_exec(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
match_state_t *match; match_state_t *match;
...@@ -476,7 +474,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -476,7 +474,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
mark = heap_pool_mark(&ctx->tmp_heap); mark = heap_pool_mark(&ctx->tmp_heap);
hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(jsstr_empty()), &string, &match, &b); hres = run_exec(ctx, vthis, argc ? argv[0] : jsval_string(jsstr_empty()), &string, &match, &b);
if(FAILED(hres)) { if(FAILED(hres)) {
heap_pool_clear(mark); heap_pool_clear(mark);
return hres; return hres;
...@@ -499,7 +497,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -499,7 +497,7 @@ static HRESULT RegExp_exec(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
return hres; return hres;
} }
static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_test(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
match_state_t *match; match_state_t *match;
...@@ -511,7 +509,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -511,7 +509,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
TRACE("\n"); TRACE("\n");
mark = heap_pool_mark(&ctx->tmp_heap); mark = heap_pool_mark(&ctx->tmp_heap);
hres = run_exec(ctx, jsthis, argc ? argv[0] : jsval_string(undef_str = jsstr_undefined()), NULL, &match, &b); hres = run_exec(ctx, vthis, argc ? argv[0] : jsval_string(undef_str = jsstr_undefined()), NULL, &match, &b);
heap_pool_clear(mark); heap_pool_clear(mark);
if(!argc) if(!argc)
jsstr_release(undef_str); jsstr_release(undef_str);
...@@ -523,7 +521,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -523,7 +521,7 @@ static HRESULT RegExp_test(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
return S_OK; return S_OK;
} }
static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExp_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
...@@ -886,7 +884,7 @@ static HRESULT RegExpConstr_get_rightContext(script_ctx_t *ctx, jsdisp_t *jsthis ...@@ -886,7 +884,7 @@ static HRESULT RegExpConstr_get_rightContext(script_ctx_t *ctx, jsdisp_t *jsthis
return S_OK; return S_OK;
} }
static HRESULT RegExpConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT RegExpConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
TRACE("\n"); TRACE("\n");
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(jscript); WINE_DEFAULT_DEBUG_CHANNEL(jscript);
/* ECMA-262 3rd Edition 15.8.2.12 */ /* ECMA-262 3rd Edition 15.8.2.12 */
static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_abs(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double d; double d;
...@@ -52,7 +52,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -52,7 +52,7 @@ static HRESULT Math_abs(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_acos(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -75,7 +75,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne ...@@ -75,7 +75,7 @@ static HRESULT Math_acos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_asin(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -98,7 +98,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne ...@@ -98,7 +98,7 @@ static HRESULT Math_asin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_atan(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -121,7 +121,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne ...@@ -121,7 +121,7 @@ static HRESULT Math_atan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_atan2(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x, y; double x, y;
...@@ -149,7 +149,7 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign ...@@ -149,7 +149,7 @@ static HRESULT Math_atan2(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
} }
/* ECMA-262 3rd Edition 15.8.2.6 */ /* ECMA-262 3rd Edition 15.8.2.6 */
static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_ceil(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -172,7 +172,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne ...@@ -172,7 +172,7 @@ static HRESULT Math_ceil(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_cos(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -195,7 +195,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -195,7 +195,7 @@ static HRESULT Math_cos(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_exp(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -218,7 +218,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -218,7 +218,7 @@ static HRESULT Math_exp(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_floor(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -241,7 +241,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign ...@@ -241,7 +241,7 @@ static HRESULT Math_floor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
return S_OK; return S_OK;
} }
static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_log(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -265,7 +265,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -265,7 +265,7 @@ static HRESULT Math_log(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
/* ECMA-262 3rd Edition 15.8.2.11 */ /* ECMA-262 3rd Edition 15.8.2.11 */
static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_max(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
DOUBLE max, d; DOUBLE max, d;
...@@ -299,7 +299,7 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -299,7 +299,7 @@ static HRESULT Math_max(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
/* ECMA-262 3rd Edition 15.8.2.12 */ /* ECMA-262 3rd Edition 15.8.2.12 */
static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_min(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
DOUBLE min, d; DOUBLE min, d;
...@@ -333,7 +333,7 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -333,7 +333,7 @@ static HRESULT Math_min(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
/* ECMA-262 3rd Edition 15.8.2.13 */ /* ECMA-262 3rd Edition 15.8.2.13 */
static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_pow(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x, y; double x, y;
...@@ -361,7 +361,7 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -361,7 +361,7 @@ static HRESULT Math_pow(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
} }
/* ECMA-262 3rd Edition 15.8.2.14 */ /* ECMA-262 3rd Edition 15.8.2.14 */
static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_random(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
UINT x; UINT x;
...@@ -377,7 +377,7 @@ static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -377,7 +377,7 @@ static HRESULT Math_random(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
} }
/* ECMA-262 3rd Edition 15.8.2.15 */ /* ECMA-262 3rd Edition 15.8.2.15 */
static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_round(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -400,7 +400,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign ...@@ -400,7 +400,7 @@ static HRESULT Math_round(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
return S_OK; return S_OK;
} }
static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_sin(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -423,7 +423,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -423,7 +423,7 @@ static HRESULT Math_sin(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_sqrt(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
...@@ -446,7 +446,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne ...@@ -446,7 +446,7 @@ static HRESULT Math_sqrt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
static HRESULT Math_tan(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Math_tan(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double x; double x;
......
...@@ -39,14 +39,16 @@ static inline NumberInstance *number_from_jsdisp(jsdisp_t *jsdisp) ...@@ -39,14 +39,16 @@ static inline NumberInstance *number_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, NumberInstance, dispex); return CONTAINING_RECORD(jsdisp, NumberInstance, dispex);
} }
static inline NumberInstance *number_from_vdisp(vdisp_t *vdisp) static inline HRESULT numberval_this(jsval_t vthis, DOUBLE *ret)
{ {
return number_from_jsdisp(vdisp->u.jsdisp); jsdisp_t *jsdisp;
} if(is_number(vthis))
*ret = get_number(vthis);
static inline NumberInstance *number_this(vdisp_t *jsthis) else if(is_object_instance(vthis) && (jsdisp = to_jsdisp(get_object(vthis))) && is_class(jsdisp, JSCLASS_NUMBER))
{ *ret = number_from_jsdisp(jsdisp)->value;
return is_vclass(jsthis, JSCLASS_NUMBER) ? number_from_vdisp(jsthis) : NULL; else
return JS_E_NUMBER_EXPECTED;
return S_OK;
} }
static inline void number_to_str(double d, WCHAR *buf, int size, int *dec_point) static inline void number_to_str(double d, WCHAR *buf, int size, int *dec_point)
...@@ -222,10 +224,9 @@ static inline jsstr_t *number_to_exponential(double val, int prec) ...@@ -222,10 +224,9 @@ static inline jsstr_t *number_to_exponential(double val, int prec)
} }
/* ECMA-262 3rd Edition 15.7.4.2 */ /* ECMA-262 3rd Edition 15.7.4.2 */
static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toString(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
NumberInstance *number;
INT radix = 10; INT radix = 10;
DOUBLE val; DOUBLE val;
jsstr_t *str; jsstr_t *str;
...@@ -233,8 +234,9 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u ...@@ -233,8 +234,9 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
TRACE("\n"); TRACE("\n");
if(!(number = number_this(jsthis))) hres = numberval_this(vthis, &val);
return JS_E_NUMBER_EXPECTED; if(FAILED(hres))
return hres;
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], &radix); hres = to_int32(ctx, argv[0], &radix);
...@@ -245,8 +247,6 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u ...@@ -245,8 +247,6 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
return JS_E_INVALIDARG; return JS_E_INVALIDARG;
} }
val = number->value;
if(radix==10 || !isfinite(val)) { if(radix==10 || !isfinite(val)) {
hres = to_string(ctx, jsval_number(val), &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
...@@ -341,17 +341,16 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u ...@@ -341,17 +341,16 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
return S_OK; return S_OK;
} }
static HRESULT Number_toLocaleString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toLocaleString(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toFixed(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
NumberInstance *number;
DOUBLE val; DOUBLE val;
INT prec = 0; INT prec = 0;
jsstr_t *str; jsstr_t *str;
...@@ -359,8 +358,9 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -359,8 +358,9 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
TRACE("\n"); TRACE("\n");
if(!(number = number_this(jsthis))) hres = numberval_this(vthis, &val);
return JS_E_NUMBER_EXPECTED; if(FAILED(hres))
return hres;
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], &prec); hres = to_int32(ctx, argv[0], &prec);
...@@ -371,7 +371,6 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -371,7 +371,6 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return JS_E_FRACTION_DIGITS_OUT_OF_RANGE; return JS_E_FRACTION_DIGITS_OUT_OF_RANGE;
} }
val = number->value;
if(!isfinite(val)) { if(!isfinite(val)) {
hres = to_string(ctx, jsval_number(val), &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
...@@ -389,10 +388,9 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un ...@@ -389,10 +388,9 @@ static HRESULT Number_toFixed(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
return S_OK; return S_OK;
} }
static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toExponential(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
NumberInstance *number;
DOUBLE val; DOUBLE val;
INT prec = 0; INT prec = 0;
jsstr_t *str; jsstr_t *str;
...@@ -400,8 +398,9 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla ...@@ -400,8 +398,9 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
TRACE("\n"); TRACE("\n");
if(!(number = number_this(jsthis))) hres = numberval_this(vthis, &val);
return JS_E_NUMBER_EXPECTED; if(FAILED(hres))
return hres;
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], &prec); hres = to_int32(ctx, argv[0], &prec);
...@@ -412,7 +411,6 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla ...@@ -412,7 +411,6 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return JS_E_FRACTION_DIGITS_OUT_OF_RANGE; return JS_E_FRACTION_DIGITS_OUT_OF_RANGE;
} }
val = number->value;
if(!isfinite(val)) { if(!isfinite(val)) {
hres = to_string(ctx, jsval_number(val), &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
...@@ -432,17 +430,17 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla ...@@ -432,17 +430,17 @@ static HRESULT Number_toExponential(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
return S_OK; return S_OK;
} }
static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_toPrecision(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
NumberInstance *number;
INT prec = 0, size; INT prec = 0, size;
jsstr_t *str; jsstr_t *str;
DOUBLE val; DOUBLE val;
HRESULT hres; HRESULT hres;
if(!(number = number_this(jsthis))) hres = numberval_this(vthis, &val);
return JS_E_NUMBER_EXPECTED; if(FAILED(hres))
return hres;
if(argc) { if(argc) {
hres = to_int32(ctx, argv[0], &prec); hres = to_int32(ctx, argv[0], &prec);
...@@ -453,7 +451,6 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -453,7 +451,6 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return JS_E_PRECISION_OUT_OF_RANGE; return JS_E_PRECISION_OUT_OF_RANGE;
} }
val = number->value;
if(!isfinite(val) || !prec) { if(!isfinite(val) || !prec) {
hres = to_string(ctx, jsval_number(val), &str); hres = to_string(ctx, jsval_number(val), &str);
if(FAILED(hres)) if(FAILED(hres))
...@@ -479,18 +476,20 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags ...@@ -479,18 +476,20 @@ static HRESULT Number_toPrecision(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags
return S_OK; return S_OK;
} }
static HRESULT Number_valueOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Number_valueOf(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
NumberInstance *number; HRESULT hres;
DOUBLE val;
TRACE("\n"); TRACE("\n");
if(!(number = number_this(jsthis))) hres = numberval_this(vthis, &val);
return JS_E_NUMBER_EXPECTED; if(FAILED(hres))
return hres;
if(r) if(r)
*r = jsval_number(number->value); *r = jsval_number(val);
return S_OK; return S_OK;
} }
...@@ -520,7 +519,7 @@ static const builtin_info_t NumberInst_info = { ...@@ -520,7 +519,7 @@ static const builtin_info_t NumberInst_info = {
NULL NULL
}; };
static HRESULT NumberConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT NumberConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
double n; double n;
......
...@@ -37,42 +37,42 @@ typedef struct { ...@@ -37,42 +37,42 @@ typedef struct {
size_t size; size_t size;
} MapInstance; } MapInstance;
static HRESULT Set_add(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_add(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("%p\n", jsthis); FIXME("%p\n", debugstr_jsval(vthis));
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Set_clear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("%p\n", jsthis); FIXME("%p\n", debugstr_jsval(vthis));
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Set_delete(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("%p\n", jsthis); FIXME("%p\n", debugstr_jsval(vthis));
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Set_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("%p\n", jsthis); FIXME("%p\n", debugstr_jsval(vthis));
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Set_has(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("%p\n", jsthis); FIXME("%p\n", debugstr_jsval(vthis));
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT Set_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
...@@ -104,7 +104,7 @@ static const builtin_info_t Set_info = { ...@@ -104,7 +104,7 @@ static const builtin_info_t Set_info = {
NULL NULL
}; };
static HRESULT Set_constructor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Set_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
SetInstance *set; SetInstance *set;
...@@ -176,14 +176,19 @@ static int jsval_map_compare(const void *k, const struct wine_rb_entry *e) ...@@ -176,14 +176,19 @@ static int jsval_map_compare(const void *k, const struct wine_rb_entry *e)
} }
} }
static MapInstance *get_map_this(vdisp_t *jsthis) static HRESULT get_map_this(jsval_t vthis, MapInstance **ret)
{ {
if(!(jsthis->flags & VDISP_JSDISP) || !is_class(jsthis->u.jsdisp, JSCLASS_MAP)) { jsdisp_t *jsdisp;
if(!is_object_instance(vthis))
return JS_E_OBJECT_EXPECTED;
if(!(jsdisp = to_jsdisp(get_object(vthis))) || !is_class(jsdisp, JSCLASS_MAP)) {
WARN("not a Map object passed as 'this'\n"); WARN("not a Map object passed as 'this'\n");
return NULL; return JS_E_MAP_EXPECTED;
} }
return CONTAINING_RECORD(jsthis->u.jsdisp, MapInstance, dispex); *ret = CONTAINING_RECORD(jsdisp, MapInstance, dispex);
return S_OK;
} }
static struct jsval_map_entry *get_map_entry(MapInstance *map, jsval_t key) static struct jsval_map_entry *get_map_entry(MapInstance *map, jsval_t key)
...@@ -215,12 +220,15 @@ static void delete_map_entry(MapInstance *map, struct jsval_map_entry *entry) ...@@ -215,12 +220,15 @@ static void delete_map_entry(MapInstance *map, struct jsval_map_entry *entry)
release_map_entry(entry); release_map_entry(entry);
} }
static HRESULT Map_clear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_clear(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
MapInstance *map; MapInstance *map;
HRESULT hres;
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED; hres = get_map_this(vthis, &map);
if(FAILED(hres))
return hres;
TRACE("%p\n", map); TRACE("%p\n", map);
...@@ -233,14 +241,17 @@ static HRESULT Map_clear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne ...@@ -233,14 +241,17 @@ static HRESULT Map_clear(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigne
return S_OK; return S_OK;
} }
static HRESULT Map_delete(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_delete(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsval_t key = argc >= 1 ? argv[0] : jsval_undefined(); jsval_t key = argc >= 1 ? argv[0] : jsval_undefined();
struct jsval_map_entry *entry; struct jsval_map_entry *entry;
MapInstance *map; MapInstance *map;
HRESULT hres;
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED; hres = get_map_this(vthis, &map);
if(FAILED(hres))
return hres;
TRACE("%p (%s)\n", map, debugstr_jsval(key)); TRACE("%p (%s)\n", map, debugstr_jsval(key));
...@@ -249,7 +260,7 @@ static HRESULT Map_delete(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign ...@@ -249,7 +260,7 @@ static HRESULT Map_delete(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsign
return S_OK; return S_OK;
} }
static HRESULT Map_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsval_t callback = argc ? argv[0] : jsval_undefined(); jsval_t callback = argc ? argv[0] : jsval_undefined();
...@@ -257,7 +268,9 @@ static HRESULT Map_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -257,7 +268,9 @@ static HRESULT Map_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
MapInstance *map; MapInstance *map;
HRESULT hres; HRESULT hres;
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED; hres = get_map_this(vthis, &map);
if(FAILED(hres))
return hres;
TRACE("%p (%s)\n", map, debugstr_jsval(argc >= 1 ? argv[0] : jsval_undefined())); TRACE("%p (%s)\n", map, debugstr_jsval(argc >= 1 ? argv[0] : jsval_undefined()));
...@@ -290,14 +303,17 @@ static HRESULT Map_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig ...@@ -290,14 +303,17 @@ static HRESULT Map_forEach(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsig
return S_OK; return S_OK;
} }
static HRESULT Map_get(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_get(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsval_t key = argc >= 1 ? argv[0] : jsval_undefined(); jsval_t key = argc >= 1 ? argv[0] : jsval_undefined();
struct jsval_map_entry *entry; struct jsval_map_entry *entry;
MapInstance *map; MapInstance *map;
HRESULT hres;
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED; hres = get_map_this(vthis, &map);
if(FAILED(hres))
return hres;
TRACE("%p (%s)\n", map, debugstr_jsval(key)); TRACE("%p (%s)\n", map, debugstr_jsval(key));
...@@ -309,7 +325,7 @@ static HRESULT Map_get(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -309,7 +325,7 @@ static HRESULT Map_get(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return r ? jsval_copy(entry->value, r) : S_OK; return r ? jsval_copy(entry->value, r) : S_OK;
} }
static HRESULT Map_set(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_set(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsval_t key = argc >= 1 ? argv[0] : jsval_undefined(); jsval_t key = argc >= 1 ? argv[0] : jsval_undefined();
...@@ -318,7 +334,9 @@ static HRESULT Map_set(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -318,7 +334,9 @@ static HRESULT Map_set(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
MapInstance *map; MapInstance *map;
HRESULT hres; HRESULT hres;
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED; hres = get_map_this(vthis, &map);
if(FAILED(hres))
return hres;
TRACE("%p (%s %s)\n", map, debugstr_jsval(key), debugstr_jsval(value)); TRACE("%p (%s %s)\n", map, debugstr_jsval(key), debugstr_jsval(value));
...@@ -353,14 +371,17 @@ static HRESULT Map_set(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned ...@@ -353,14 +371,17 @@ static HRESULT Map_set(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
return S_OK; return S_OK;
} }
static HRESULT Map_has(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_has(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
jsval_t key = argc >= 1 ? argv[0] : jsval_undefined(); jsval_t key = argc >= 1 ? argv[0] : jsval_undefined();
struct jsval_map_entry *entry; struct jsval_map_entry *entry;
MapInstance *map; MapInstance *map;
HRESULT hres;
if(!(map = get_map_this(jsthis))) return JS_E_MAP_EXPECTED; hres = get_map_this(vthis, &map);
if(FAILED(hres))
return hres;
TRACE("%p (%s)\n", map, debugstr_jsval(key)); TRACE("%p (%s)\n", map, debugstr_jsval(key));
...@@ -379,7 +400,7 @@ static HRESULT Map_get_size(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r) ...@@ -379,7 +400,7 @@ static HRESULT Map_get_size(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
return S_OK; return S_OK;
} }
static HRESULT Map_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
...@@ -430,7 +451,7 @@ static const builtin_info_t Map_info = { ...@@ -430,7 +451,7 @@ static const builtin_info_t Map_info = {
NULL NULL
}; };
static HRESULT Map_constructor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT Map_constructor(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
MapInstance *map; MapInstance *map;
......
...@@ -33,17 +33,13 @@ static inline VBArrayInstance *vbarray_from_jsdisp(jsdisp_t *jsdisp) ...@@ -33,17 +33,13 @@ static inline VBArrayInstance *vbarray_from_jsdisp(jsdisp_t *jsdisp)
return CONTAINING_RECORD(jsdisp, VBArrayInstance, dispex); return CONTAINING_RECORD(jsdisp, VBArrayInstance, dispex);
} }
static inline VBArrayInstance *vbarray_from_vdisp(vdisp_t *vdisp) static inline VBArrayInstance *vbarray_this(jsval_t vthis)
{ {
return vbarray_from_jsdisp(vdisp->u.jsdisp); jsdisp_t *jsdisp = is_object_instance(vthis) ? to_jsdisp(get_object(vthis)) : NULL;
return (jsdisp && is_class(jsdisp, JSCLASS_VBARRAY)) ? vbarray_from_jsdisp(jsdisp) : NULL;
} }
static inline VBArrayInstance *vbarray_this(vdisp_t *jsthis) static HRESULT VBArray_dimensions(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
{
return is_vclass(jsthis, JSCLASS_VBARRAY) ? vbarray_from_vdisp(jsthis) : NULL;
}
static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
...@@ -59,7 +55,7 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, ...@@ -59,7 +55,7 @@ static HRESULT VBArray_dimensions(script_ctx_t *ctx, vdisp_t *vthis, WORD flags,
return S_OK; return S_OK;
} }
static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_getItem(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
...@@ -103,7 +99,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un ...@@ -103,7 +99,7 @@ static HRESULT VBArray_getItem(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
return hres; return hres;
} }
static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_lbound(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
...@@ -134,7 +130,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns ...@@ -134,7 +130,7 @@ static HRESULT VBArray_lbound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
return S_OK; return S_OK;
} }
static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_toArray(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
...@@ -189,7 +185,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un ...@@ -189,7 +185,7 @@ static HRESULT VBArray_toArray(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, un
return S_OK; return S_OK;
} }
static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_ubound(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
...@@ -220,7 +216,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns ...@@ -220,7 +216,7 @@ static HRESULT VBArray_ubound(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, uns
return S_OK; return S_OK;
} }
static HRESULT VBArray_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArray_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
FIXME("\n"); FIXME("\n");
...@@ -282,7 +278,7 @@ static HRESULT alloc_vbarray(script_ctx_t *ctx, jsdisp_t *object_prototype, VBAr ...@@ -282,7 +278,7 @@ static HRESULT alloc_vbarray(script_ctx_t *ctx, jsdisp_t *object_prototype, VBAr
return S_OK; return S_OK;
} }
static HRESULT VBArrayConstr_value(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, static HRESULT VBArrayConstr_value(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned argc, jsval_t *argv,
jsval_t *r) jsval_t *r)
{ {
VBArrayInstance *vbarray; VBArrayInstance *vbarray;
......
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