Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
da842966
Commit
da842966
authored
Nov 22, 2022
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Nov 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Pass a jsval as the 'this' to disp_call_value.
Signed-off-by:
Gabriel Ivăncescu
<
gabrielopcode@gmail.com
>
parent
9d4e93cf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
33 deletions
+46
-33
array.c
dlls/jscript/array.c
+21
-16
dispex.c
dlls/jscript/dispex.c
+14
-4
engine.c
dlls/jscript/engine.c
+5
-5
function.c
dlls/jscript/function.c
+1
-2
jscript.h
dlls/jscript/jscript.h
+1
-1
json.c
dlls/jscript/json.c
+1
-1
set.c
dlls/jscript/set.c
+3
-4
No files found.
dlls/jscript/array.c
View file @
da842966
...
...
@@ -1026,9 +1026,10 @@ static HRESULT Array_toLocaleString(script_ctx_t *ctx, jsval_t vthis, WORD flags
static
HRESULT
Array_every
(
script_ctx_t
*
ctx
,
jsval_t
vthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
context_obj
=
NULL
,
*
callback
;
jsval_t
context_this
=
jsval_undefined
()
;
jsval_t
value
,
args
[
3
],
res
;
BOOL
boolval
,
ret
=
TRUE
;
IDispatch
*
callback
;
unsigned
length
,
i
;
jsdisp_t
*
jsthis
;
HRESULT
hres
;
...
...
@@ -1053,7 +1054,7 @@ static HRESULT Array_every(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigne
hres
=
E_NOTIMPL
;
goto
done
;
}
context_
obj
=
get_object
(
argv
[
1
])
;
context_
this
=
argv
[
1
]
;
}
for
(
i
=
0
;
i
<
length
;
i
++
)
{
...
...
@@ -1066,7 +1067,7 @@ static HRESULT Array_every(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigne
args
[
0
]
=
value
;
args
[
1
]
=
jsval_number
(
i
);
args
[
2
]
=
jsval_obj
(
jsthis
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
obj
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
this
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
jsval_release
(
value
);
if
(
FAILED
(
hres
))
goto
done
;
...
...
@@ -1092,10 +1093,11 @@ done:
static
HRESULT
Array_filter
(
script_ctx_t
*
ctx
,
jsval_t
vthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
context_obj
=
NULL
,
*
callback
;
jsval_t
context_this
=
jsval_undefined
()
;
jsval_t
value
,
args
[
3
],
res
;
unsigned
length
,
i
,
j
=
0
;
jsdisp_t
*
jsthis
,
*
arr
;
IDispatch
*
callback
;
HRESULT
hres
;
BOOL
boolval
;
...
...
@@ -1119,7 +1121,7 @@ static HRESULT Array_filter(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsign
hres
=
E_NOTIMPL
;
goto
done
;
}
context_
obj
=
get_object
(
argv
[
1
])
;
context_
this
=
argv
[
1
]
;
}
hres
=
create_array
(
ctx
,
0
,
&
arr
);
...
...
@@ -1138,7 +1140,7 @@ static HRESULT Array_filter(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsign
args
[
0
]
=
value
;
args
[
1
]
=
jsval_number
(
i
);
args
[
2
]
=
jsval_obj
(
jsthis
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
obj
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
this
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
if
(
SUCCEEDED
(
hres
))
{
hres
=
to_boolean
(
res
,
&
boolval
);
jsval_release
(
res
);
...
...
@@ -1166,8 +1168,9 @@ done:
static
HRESULT
Array_forEach
(
script_ctx_t
*
ctx
,
jsval_t
vthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
context_obj
=
NULL
,
*
callback
;
jsval_t
context_this
=
jsval_undefined
()
;
jsval_t
value
,
args
[
3
],
res
;
IDispatch
*
callback
;
jsdisp_t
*
jsthis
;
unsigned
length
,
i
;
HRESULT
hres
;
...
...
@@ -1192,7 +1195,7 @@ static HRESULT Array_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsig
hres
=
E_NOTIMPL
;
goto
done
;
}
context_
obj
=
get_object
(
argv
[
1
])
;
context_
this
=
argv
[
1
]
;
}
for
(
i
=
0
;
i
<
length
;
i
++
)
{
...
...
@@ -1205,7 +1208,7 @@ static HRESULT Array_forEach(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsig
args
[
0
]
=
value
;
args
[
1
]
=
jsval_number
(
i
);
args
[
2
]
=
jsval_obj
(
jsthis
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
obj
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
this
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
jsval_release
(
value
);
if
(
FAILED
(
hres
))
goto
done
;
...
...
@@ -1341,9 +1344,10 @@ done:
static
HRESULT
Array_map
(
script_ctx_t
*
ctx
,
jsval_t
vthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
context_this
=
NULL
,
*
callback
;
jsval_t
context_this
=
jsval_undefined
()
;
jsval_t
callback_args
[
3
],
mapped_value
;
jsdisp_t
*
jsthis
,
*
array
;
IDispatch
*
callback
;
UINT32
length
,
k
;
HRESULT
hres
;
...
...
@@ -1365,7 +1369,7 @@ static HRESULT Array_map(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned
if
(
argc
>
1
)
{
if
(
is_object_instance
(
argv
[
1
]))
{
context_this
=
get_object
(
argv
[
1
])
;
context_this
=
argv
[
1
]
;
}
else
if
(
!
is_undefined
(
argv
[
1
]))
{
FIXME
(
"Unsupported context this %s
\n
"
,
debugstr_jsval
(
argv
[
1
]));
hres
=
E_NOTIMPL
;
...
...
@@ -1407,9 +1411,9 @@ done:
static
HRESULT
Array_reduce
(
script_ctx_t
*
ctx
,
jsval_t
vthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
context_this
=
NULL
,
*
callback
;
jsval_t
callback_args
[
4
],
acc
,
new_acc
;
BOOL
have_value
=
FALSE
;
IDispatch
*
callback
;
jsdisp_t
*
jsthis
;
UINT32
length
,
k
;
HRESULT
hres
;
...
...
@@ -1453,7 +1457,7 @@ static HRESULT Array_reduce(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsign
callback_args
[
0
]
=
acc
;
callback_args
[
2
]
=
jsval_number
(
k
);
callback_args
[
3
]
=
jsval_obj
(
jsthis
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_this
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
callback_args
),
callback_args
,
&
new_acc
);
hres
=
disp_call_value
(
ctx
,
callback
,
jsval_undefined
()
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
callback_args
),
callback_args
,
&
new_acc
);
jsval_release
(
callback_args
[
1
]);
if
(
FAILED
(
hres
))
break
;
...
...
@@ -1479,9 +1483,10 @@ done:
static
HRESULT
Array_some
(
script_ctx_t
*
ctx
,
jsval_t
vthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
context_obj
=
NULL
,
*
callback
;
jsval_t
context_this
=
jsval_undefined
()
;
jsval_t
value
,
args
[
3
],
res
;
BOOL
boolval
,
ret
=
FALSE
;
IDispatch
*
callback
;
unsigned
length
,
i
;
jsdisp_t
*
jsthis
;
HRESULT
hres
;
...
...
@@ -1506,7 +1511,7 @@ static HRESULT Array_some(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned
hres
=
E_NOTIMPL
;
goto
done
;
}
context_
obj
=
get_object
(
argv
[
1
])
;
context_
this
=
argv
[
1
]
;
}
for
(
i
=
0
;
i
<
length
;
i
++
)
{
...
...
@@ -1519,7 +1524,7 @@ static HRESULT Array_some(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsigned
args
[
0
]
=
value
;
args
[
1
]
=
jsval_number
(
i
);
args
[
2
]
=
jsval_obj
(
jsthis
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
obj
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
hres
=
disp_call_value
(
ctx
,
callback
,
context_
this
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
jsval_release
(
value
);
if
(
FAILED
(
hres
))
goto
done
;
...
...
dlls/jscript/dispex.c
View file @
da842966
...
...
@@ -573,7 +573,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
TRACE
(
"call %s %p
\n
"
,
debugstr_w
(
prop
->
name
),
get_object
(
prop
->
u
.
val
));
return
disp_call_value
(
This
->
ctx
,
get_object
(
prop
->
u
.
val
),
js
this
?
jsthis
:
(
IDispatch
*
)
&
This
->
IDispatchEx_iface
,
js
val_disp
(
jsthis
?
jsthis
:
(
IDispatch
*
)
&
This
->
IDispatchEx_iface
)
,
flags
,
argc
,
argv
,
r
);
}
case
PROP_ACCESSOR
:
...
...
@@ -586,7 +586,7 @@ static HRESULT invoke_prop_func(jsdisp_t *This, IDispatch *jsthis, dispex_prop_t
if
(
is_object_instance
(
val
))
{
hres
=
disp_call_value
(
This
->
ctx
,
get_object
(
val
),
js
this
?
jsthis
:
(
IDispatch
*
)
&
This
->
IDispatchEx_iface
,
js
val_disp
(
jsthis
?
jsthis
:
(
IDispatch
*
)
&
This
->
IDispatchEx_iface
)
,
flags
,
argc
,
argv
,
r
);
}
else
{
FIXME
(
"invoke %s
\n
"
,
debugstr_jsval
(
val
));
...
...
@@ -2189,10 +2189,11 @@ HRESULT disp_call_name(script_ctx_t *ctx, IDispatch *disp, const WCHAR *name, WO
return
disp_call
(
ctx
,
disp
,
id
,
flags
,
argc
,
argv
,
ret
);
}
HRESULT
disp_call_value
(
script_ctx_t
*
ctx
,
IDispatch
*
disp
,
IDispatch
*
js
this
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
HRESULT
disp_call_value
(
script_ctx_t
*
ctx
,
IDispatch
*
disp
,
jsval_t
v
this
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
VARIANT
buf
[
6
],
retv
,
*
args
=
buf
;
IDispatch
*
jsthis
;
jsdisp_t
*
jsdisp
;
DISPPARAMS
dp
;
unsigned
i
;
...
...
@@ -2204,13 +2205,22 @@ HRESULT disp_call_value(script_ctx_t *ctx, IDispatch *disp, IDispatch *jsthis, W
jsdisp
=
iface_to_jsdisp
(
disp
);
if
(
jsdisp
&&
jsdisp
->
ctx
==
ctx
)
{
hres
=
jsdisp_call_value
(
jsdisp
,
jsthis
?
jsval_disp
(
jsthis
)
:
jsval_undefined
()
,
flags
,
argc
,
argv
,
r
);
hres
=
jsdisp_call_value
(
jsdisp
,
vthis
,
flags
,
argc
,
argv
,
r
);
jsdisp_release
(
jsdisp
);
return
hres
;
}
if
(
jsdisp
)
jsdisp_release
(
jsdisp
);
if
(
is_undefined
(
vthis
))
jsthis
=
NULL
;
else
if
(
is_object_instance
(
vthis
))
jsthis
=
get_object
(
vthis
);
else
{
FIXME
(
"Unimplemented 'this' passed to host object: %s
\n
"
,
debugstr_jsval
(
vthis
));
return
E_NOTIMPL
;
}
flags
&=
~
DISPATCH_JSCRIPT_INTERNAL_MASK
;
if
(
r
&&
argc
&&
flags
==
DISPATCH_METHOD
)
flags
|=
DISPATCH_PROPERTYGET
;
...
...
dlls/jscript/engine.c
View file @
da842966
...
...
@@ -327,7 +327,7 @@ static HRESULT exprval_call(script_ctx_t *ctx, exprval_t *ref, WORD flags, unsig
return
E_FAIL
;
}
return
disp_call_value
(
ctx
,
get_object
(
v
),
NULL
,
flags
,
argc
,
argv
,
r
);
return
disp_call_value
(
ctx
,
get_object
(
v
),
jsval_undefined
()
,
flags
,
argc
,
argv
,
r
);
}
case
EXPRVAL_IDREF
:
/* ECMA-262 3rd Edition 11.2.3.7 / ECMA-262 5.1 Edition 11.2.3.6 *
...
...
@@ -340,7 +340,7 @@ static HRESULT exprval_call(script_ctx_t *ctx, exprval_t *ref, WORD flags, unsig
FIXME
(
"invoke %s
\n
"
,
debugstr_jsval
(
v
));
hres
=
E_FAIL
;
}
else
{
hres
=
disp_call_value
(
ctx
,
get_object
(
v
),
NULL
,
flags
,
argc
,
argv
,
r
);
hres
=
disp_call_value
(
ctx
,
get_object
(
v
),
jsval_undefined
()
,
flags
,
argc
,
argv
,
r
);
}
jsval_release
(
v
);
return
hres
;
...
...
@@ -351,7 +351,7 @@ static HRESULT exprval_call(script_ctx_t *ctx, exprval_t *ref, WORD flags, unsig
hres
=
to_object
(
ctx
,
ref
->
u
.
val
,
&
obj
);
if
(
SUCCEEDED
(
hres
))
{
hres
=
disp_call_value
(
ctx
,
obj
,
NULL
,
flags
,
argc
,
argv
,
r
);
hres
=
disp_call_value
(
ctx
,
obj
,
jsval_undefined
()
,
flags
,
argc
,
argv
,
r
);
IDispatch_Release
(
obj
);
}
return
hres
;
...
...
@@ -1380,7 +1380,7 @@ static HRESULT interp_new(script_ctx_t *ctx)
return
JS_E_INVALID_ACTION
;
clear_acc
(
ctx
);
return
disp_call_value
(
ctx
,
get_object
(
constr
),
NULL
,
DISPATCH_CONSTRUCT
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
return
disp_call_value
(
ctx
,
get_object
(
constr
),
jsval_undefined
()
,
DISPATCH_CONSTRUCT
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
argc
,
stack_args
(
ctx
,
argc
),
&
ctx
->
acc
);
}
...
...
@@ -1398,7 +1398,7 @@ static HRESULT interp_call(script_ctx_t *ctx)
return
JS_E_INVALID_PROPERTY
;
clear_acc
(
ctx
);
return
disp_call_value
(
ctx
,
get_object
(
obj
),
NULL
,
DISPATCH_METHOD
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
return
disp_call_value
(
ctx
,
get_object
(
obj
),
jsval_undefined
()
,
DISPATCH_METHOD
|
DISPATCH_JSCRIPT_CALLEREXECSSOURCE
,
argn
,
stack_args
(
ctx
,
argn
),
do_ret
?
&
ctx
->
acc
:
NULL
);
}
...
...
dlls/jscript/function.c
View file @
da842966
...
...
@@ -386,8 +386,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, jsval_t vthis, WORD flags, unsi
hres
=
function
->
vtbl
->
call
(
ctx
,
function
,
this_val
,
flags
,
cnt
,
args
,
r
);
}
else
{
jsval_t
res
;
hres
=
disp_call_value
(
ctx
,
get_object
(
vthis
),
is_object_instance
(
this_val
)
?
get_object
(
this_val
)
:
NULL
,
DISPATCH_METHOD
,
cnt
,
args
,
&
res
);
hres
=
disp_call_value
(
ctx
,
get_object
(
vthis
),
this_val
,
DISPATCH_METHOD
,
cnt
,
args
,
&
res
);
if
(
SUCCEEDED
(
hres
))
{
if
(
r
)
*
r
=
res
;
...
...
dlls/jscript/jscript.h
View file @
da842966
...
...
@@ -225,7 +225,7 @@ HRESULT init_dispex_from_constr(jsdisp_t*,script_ctx_t*,const builtin_info_t*,js
HRESULT
disp_call
(
script_ctx_t
*
,
IDispatch
*
,
DISPID
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
disp_call_name
(
script_ctx_t
*
,
IDispatch
*
,
const
WCHAR
*
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
disp_call_value
(
script_ctx_t
*
,
IDispatch
*
,
IDispatch
*
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
disp_call_value
(
script_ctx_t
*
,
IDispatch
*
,
jsval_t
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_call_value
(
jsdisp_t
*
,
jsval_t
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_call
(
jsdisp_t
*
,
DISPID
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_call_name
(
jsdisp_t
*
,
const
WCHAR
*
,
WORD
,
unsigned
,
jsval_t
*
,
jsval_t
*
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/json.c
View file @
da842966
...
...
@@ -350,7 +350,7 @@ static jsval_t transform_json_object(struct transform_json_object_ctx *proc_ctx,
}
args
[
0
]
=
jsval_string
(
name
);
proc_ctx
->
hres
=
disp_call_value
(
proc_ctx
->
ctx
,
proc_ctx
->
reviver
,
(
IDispatch
*
)
&
holder
->
IDispatchEx_iface
,
proc_ctx
->
hres
=
disp_call_value
(
proc_ctx
->
ctx
,
proc_ctx
->
reviver
,
jsval_obj
(
holder
)
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
res
);
return
FAILED
(
proc_ctx
->
hres
)
?
jsval_undefined
()
:
res
;
}
...
...
dlls/jscript/set.c
View file @
da842966
...
...
@@ -184,7 +184,7 @@ static HRESULT set_map_entry(MapInstance *map, jsval_t key, jsval_t value, jsval
static
HRESULT
iterate_map
(
MapInstance
*
map
,
script_ctx_t
*
ctx
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
struct
list
*
iter
=
list_head
(
&
map
->
entries
);
IDispatch
*
context_obj
=
NULL
;
jsval_t
context_this
=
jsval_undefined
()
;
HRESULT
hres
;
if
(
!
argc
||
!
is_object_instance
(
argv
[
0
]))
{
...
...
@@ -197,7 +197,7 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j
FIXME
(
"Unsupported context this %s
\n
"
,
debugstr_jsval
(
argv
[
1
]));
return
E_NOTIMPL
;
}
context_
obj
=
get_object
(
argv
[
1
])
;
context_
this
=
argv
[
1
]
;
}
while
(
iter
)
{
...
...
@@ -213,8 +213,7 @@ static HRESULT iterate_map(MapInstance *map, script_ctx_t *ctx, unsigned argc, j
args
[
1
]
=
entry
->
key
;
args
[
2
]
=
jsval_obj
(
&
map
->
dispex
);
grab_map_entry
(
entry
);
hres
=
disp_call_value
(
ctx
,
get_object
(
argv
[
0
]),
context_obj
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
v
);
hres
=
disp_call_value
(
ctx
,
get_object
(
argv
[
0
]),
context_this
,
DISPATCH_METHOD
,
ARRAY_SIZE
(
args
),
args
,
&
v
);
iter
=
list_next
(
&
map
->
entries
,
iter
);
release_map_entry
(
entry
);
if
(
FAILED
(
hres
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment