jscript: Use the existing helpers to get from a jsdisp_t to an Instance.
Signed-off-by: Michael Stefaniuc <mstefani@redhat.de> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
99408d7859
commit
55f6e3c350
|
@ -103,7 +103,7 @@ static HRESULT get_length(script_ctx_t *ctx, vdisp_t *vdisp, jsdisp_t **jsthis,
|
||||||
static HRESULT set_length(jsdisp_t *obj, DWORD length)
|
static HRESULT set_length(jsdisp_t *obj, DWORD length)
|
||||||
{
|
{
|
||||||
if(is_class(obj, JSCLASS_ARRAY)) {
|
if(is_class(obj, JSCLASS_ARRAY)) {
|
||||||
((ArrayInstance*)obj)->length = length;
|
array_from_jsdisp(obj)->length = length;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ static HRESULT concat_obj(jsdisp_t *array, IDispatch *obj, DWORD *len)
|
||||||
jsobj = iface_to_jsdisp(obj);
|
jsobj = iface_to_jsdisp(obj);
|
||||||
if(jsobj) {
|
if(jsobj) {
|
||||||
if(is_class(jsobj, JSCLASS_ARRAY)) {
|
if(is_class(jsobj, JSCLASS_ARRAY)) {
|
||||||
hres = concat_array(array, (ArrayInstance*)jsobj, len);
|
hres = concat_array(array, array_from_jsdisp(jsobj), len);
|
||||||
jsdisp_release(jsobj);
|
jsdisp_release(jsobj);
|
||||||
return hres;
|
return hres;
|
||||||
}
|
}
|
||||||
|
@ -1022,7 +1022,7 @@ static void Array_destructor(jsdisp_t *dispex)
|
||||||
|
|
||||||
static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
|
static void Array_on_put(jsdisp_t *dispex, const WCHAR *name)
|
||||||
{
|
{
|
||||||
ArrayInstance *array = (ArrayInstance*)dispex;
|
ArrayInstance *array = array_from_jsdisp(dispex);
|
||||||
const WCHAR *ptr = name;
|
const WCHAR *ptr = name;
|
||||||
DWORD id = 0;
|
DWORD id = 0;
|
||||||
|
|
||||||
|
|
|
@ -2424,7 +2424,7 @@ static HRESULT DateConstr_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
|
||||||
if(FAILED(hres))
|
if(FAILED(hres))
|
||||||
return hres;
|
return hres;
|
||||||
|
|
||||||
di = (DateInstance*)date;
|
di = date_from_jsdisp(date);
|
||||||
di->time = utc(di->time, di);
|
di->time = utc(di->time, di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ static HRESULT Arguments_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u
|
||||||
|
|
||||||
static void Arguments_destructor(jsdisp_t *jsdisp)
|
static void Arguments_destructor(jsdisp_t *jsdisp)
|
||||||
{
|
{
|
||||||
ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
|
ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
|
||||||
|
|
||||||
TRACE("(%p)\n", arguments);
|
TRACE("(%p)\n", arguments);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ static void Arguments_destructor(jsdisp_t *jsdisp)
|
||||||
|
|
||||||
static unsigned Arguments_idx_length(jsdisp_t *jsdisp)
|
static unsigned Arguments_idx_length(jsdisp_t *jsdisp)
|
||||||
{
|
{
|
||||||
ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
|
ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
|
||||||
return arguments->argc;
|
return arguments->argc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ static jsval_t *get_argument_ref(ArgumentsInstance *arguments, unsigned idx)
|
||||||
|
|
||||||
static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
|
static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
|
||||||
{
|
{
|
||||||
ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
|
ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
|
||||||
jsval_t *ref;
|
jsval_t *ref;
|
||||||
|
|
||||||
TRACE("%p[%u]\n", arguments, idx);
|
TRACE("%p[%u]\n", arguments, idx);
|
||||||
|
@ -127,7 +127,7 @@ static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
|
||||||
|
|
||||||
static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val)
|
static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val)
|
||||||
{
|
{
|
||||||
ArgumentsInstance *arguments = (ArgumentsInstance*)jsdisp;
|
ArgumentsInstance *arguments = arguments_from_jsdisp(jsdisp);
|
||||||
jsval_t *ref;
|
jsval_t *ref;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi
|
||||||
TRACE("func %p this %p\n", func_this, jsthis);
|
TRACE("func %p this %p\n", func_this, jsthis);
|
||||||
|
|
||||||
assert(is_class(func_this, JSCLASS_FUNCTION));
|
assert(is_class(func_this, JSCLASS_FUNCTION));
|
||||||
function = (FunctionInstance*)func_this;
|
function = function_from_jsdisp(func_this);
|
||||||
|
|
||||||
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
|
flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK;
|
||||||
if(function->value_proc)
|
if(function->value_proc)
|
||||||
|
@ -530,7 +530,7 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function = (FunctionInstance*)jsthis->u.jsdisp;
|
function = function_from_jsdisp(jsthis->u.jsdisp);
|
||||||
|
|
||||||
assert(function->value_proc != NULL);
|
assert(function->value_proc != NULL);
|
||||||
return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r);
|
return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r);
|
||||||
|
@ -577,7 +577,7 @@ static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval
|
||||||
|
|
||||||
static void Function_destructor(jsdisp_t *dispex)
|
static void Function_destructor(jsdisp_t *dispex)
|
||||||
{
|
{
|
||||||
FunctionInstance *This = (FunctionInstance*)dispex;
|
FunctionInstance *This = function_from_jsdisp(dispex);
|
||||||
|
|
||||||
if(This->code)
|
if(This->code)
|
||||||
release_bytecode(This->code);
|
release_bytecode(This->code);
|
||||||
|
|
|
@ -125,7 +125,7 @@ static HRESULT do_regexp_match_next(script_ctx_t *ctx, RegExpInstance *regexp,
|
||||||
HRESULT regexp_match_next(script_ctx_t *ctx, jsdisp_t *dispex,
|
HRESULT regexp_match_next(script_ctx_t *ctx, jsdisp_t *dispex,
|
||||||
DWORD rem_flags, jsstr_t *jsstr, match_state_t **ret)
|
DWORD rem_flags, jsstr_t *jsstr, match_state_t **ret)
|
||||||
{
|
{
|
||||||
RegExpInstance *regexp = (RegExpInstance*)dispex;
|
RegExpInstance *regexp = regexp_from_jsdisp(dispex);
|
||||||
match_state_t *match;
|
match_state_t *match;
|
||||||
heap_pool_t *mark;
|
heap_pool_t *mark;
|
||||||
const WCHAR *str;
|
const WCHAR *str;
|
||||||
|
@ -182,7 +182,7 @@ HRESULT regexp_match_next(script_ctx_t *ctx, jsdisp_t *dispex,
|
||||||
static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *jsstr, BOOL gflag,
|
static HRESULT regexp_match(script_ctx_t *ctx, jsdisp_t *dispex, jsstr_t *jsstr, BOOL gflag,
|
||||||
match_result_t **match_result, DWORD *result_cnt)
|
match_result_t **match_result, DWORD *result_cnt)
|
||||||
{
|
{
|
||||||
RegExpInstance *This = (RegExpInstance*)dispex;
|
RegExpInstance *This = regexp_from_jsdisp(dispex);
|
||||||
match_result_t *ret = NULL;
|
match_result_t *ret = NULL;
|
||||||
match_state_t *result;
|
match_state_t *result;
|
||||||
DWORD i=0, ret_size = 0;
|
DWORD i=0, ret_size = 0;
|
||||||
|
@ -596,7 +596,7 @@ static HRESULT RegExp_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsi
|
||||||
|
|
||||||
static void RegExp_destructor(jsdisp_t *dispex)
|
static void RegExp_destructor(jsdisp_t *dispex)
|
||||||
{
|
{
|
||||||
RegExpInstance *This = (RegExpInstance*)dispex;
|
RegExpInstance *This = regexp_from_jsdisp(dispex);
|
||||||
|
|
||||||
if(This->jsregexp)
|
if(This->jsregexp)
|
||||||
regexp_destroy(This->jsregexp);
|
regexp_destroy(This->jsregexp);
|
||||||
|
@ -708,7 +708,7 @@ HRESULT create_regexp_var(script_ctx_t *ctx, jsval_t src_arg, jsval_t *flags_arg
|
||||||
obj = iface_to_jsdisp(get_object(src_arg));
|
obj = iface_to_jsdisp(get_object(src_arg));
|
||||||
if(obj) {
|
if(obj) {
|
||||||
if(is_class(obj, JSCLASS_REGEXP)) {
|
if(is_class(obj, JSCLASS_REGEXP)) {
|
||||||
RegExpInstance *regexp = (RegExpInstance*)obj;
|
RegExpInstance *regexp = regexp_from_jsdisp(obj);
|
||||||
|
|
||||||
hres = create_regexp(ctx, regexp->str, regexp->jsregexp->flags, ret);
|
hres = create_regexp(ctx, regexp->str, regexp->jsregexp->flags, ret);
|
||||||
jsdisp_release(obj);
|
jsdisp_release(obj);
|
||||||
|
@ -754,7 +754,7 @@ HRESULT regexp_string_match(script_ctx_t *ctx, jsdisp_t *re, jsstr_t *jsstr, jsv
|
||||||
static const WCHAR inputW[] = {'i','n','p','u','t',0};
|
static const WCHAR inputW[] = {'i','n','p','u','t',0};
|
||||||
static const WCHAR lastIndexW[] = {'l','a','s','t','I','n','d','e','x',0};
|
static const WCHAR lastIndexW[] = {'l','a','s','t','I','n','d','e','x',0};
|
||||||
|
|
||||||
RegExpInstance *regexp = (RegExpInstance*)re;
|
RegExpInstance *regexp = regexp_from_jsdisp(re);
|
||||||
match_result_t *match_result;
|
match_result_t *match_result;
|
||||||
unsigned match_cnt, i;
|
unsigned match_cnt, i;
|
||||||
const WCHAR *str;
|
const WCHAR *str;
|
||||||
|
|
|
@ -111,7 +111,7 @@ static HRESULT get_string_flat_val(script_ctx_t *ctx, vdisp_t *jsthis, jsstr_t *
|
||||||
|
|
||||||
static HRESULT String_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
static HRESULT String_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
||||||
{
|
{
|
||||||
StringInstance *string = (StringInstance*)jsthis;
|
StringInstance *string = string_from_jsdisp(jsthis);
|
||||||
|
|
||||||
TRACE("%p\n", jsthis);
|
TRACE("%p\n", jsthis);
|
||||||
|
|
||||||
|
@ -1480,7 +1480,7 @@ static HRESULT String_localeCompare(script_ctx_t *ctx, vdisp_t *jsthis, WORD fla
|
||||||
|
|
||||||
static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
||||||
{
|
{
|
||||||
StringInstance *This = (StringInstance*)jsthis;
|
StringInstance *This = string_from_jsdisp(jsthis);
|
||||||
|
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
|
|
||||||
|
@ -1490,7 +1490,7 @@ static HRESULT String_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
||||||
|
|
||||||
static void String_destructor(jsdisp_t *dispex)
|
static void String_destructor(jsdisp_t *dispex)
|
||||||
{
|
{
|
||||||
StringInstance *This = (StringInstance*)dispex;
|
StringInstance *This = string_from_jsdisp(dispex);
|
||||||
|
|
||||||
jsstr_release(This->str);
|
jsstr_release(This->str);
|
||||||
heap_free(This);
|
heap_free(This);
|
||||||
|
@ -1498,7 +1498,7 @@ static void String_destructor(jsdisp_t *dispex)
|
||||||
|
|
||||||
static unsigned String_idx_length(jsdisp_t *jsdisp)
|
static unsigned String_idx_length(jsdisp_t *jsdisp)
|
||||||
{
|
{
|
||||||
StringInstance *string = (StringInstance*)jsdisp;
|
StringInstance *string = string_from_jsdisp(jsdisp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE: For invoke version < 2, indexed array is not implemented at all.
|
* NOTE: For invoke version < 2, indexed array is not implemented at all.
|
||||||
|
@ -1512,7 +1512,7 @@ static unsigned String_idx_length(jsdisp_t *jsdisp)
|
||||||
|
|
||||||
static HRESULT String_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
|
static HRESULT String_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r)
|
||||||
{
|
{
|
||||||
StringInstance *string = (StringInstance*)jsdisp;
|
StringInstance *string = string_from_jsdisp(jsdisp);
|
||||||
jsstr_t *ret;
|
jsstr_t *ret;
|
||||||
|
|
||||||
ret = jsstr_substr(string->str, idx, 1);
|
ret = jsstr_substr(string->str, idx, 1);
|
||||||
|
|
Loading…
Reference in New Issue