Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
edd43164
Commit
edd43164
authored
Apr 21, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Apr 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Support null this in Function.prototype.bind.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3af3375b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
4 deletions
+12
-4
function.c
dlls/jscript/function.c
+9
-4
es5.js
dlls/mshtml/tests/es5.js
+3
-0
No files found.
dlls/jscript/function.c
View file @
edd43164
...
...
@@ -439,6 +439,7 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
static
HRESULT
Function_bind
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
IDispatch
*
bound_this
=
NULL
;
FunctionInstance
*
function
;
jsdisp_t
*
new_function
;
HRESULT
hres
;
...
...
@@ -453,12 +454,14 @@ static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns
return
E_NOTIMPL
;
}
if
(
!
is_object_instance
(
argv
[
0
])
||
!
get_object
(
argv
[
0
]))
{
if
(
is_object_instance
(
argv
[
0
]))
{
bound_this
=
get_object
(
argv
[
0
]);
}
else
if
(
!
is_null
(
argv
[
0
]))
{
FIXME
(
"%s is not an object instance
\n
"
,
debugstr_jsval
(
argv
[
0
]));
return
E_NOTIMPL
;
}
hres
=
create_bind_function
(
ctx
,
function
,
get_object
(
argv
[
0
])
,
argc
-
1
,
argv
+
1
,
&
new_function
);
hres
=
create_bind_function
(
ctx
,
function
,
bound_this
,
argc
-
1
,
argv
+
1
,
&
new_function
);
if
(
FAILED
(
hres
))
return
hres
;
...
...
@@ -875,7 +878,8 @@ static void BindFunction_destructor(FunctionInstance *func)
for
(
i
=
0
;
i
<
function
->
argc
;
i
++
)
jsval_release
(
function
->
args
[
i
]);
jsdisp_release
(
&
function
->
target
->
dispex
);
IDispatch_Release
(
function
->
this
);
if
(
function
->
this
)
IDispatch_Release
(
function
->
this
);
}
static
const
function_vtbl_t
BindFunctionVtbl
=
{
...
...
@@ -899,7 +903,8 @@ static HRESULT create_bind_function(script_ctx_t *ctx, FunctionInstance *target,
jsdisp_addref
(
&
target
->
dispex
);
function
->
target
=
target
;
IDispatch_AddRef
(
function
->
this
=
bound_this
);
if
(
bound_this
)
IDispatch_AddRef
(
function
->
this
=
bound_this
);
for
(
function
->
argc
=
0
;
function
->
argc
<
argc
;
function
->
argc
++
)
{
hres
=
jsval_copy
(
argv
[
function
->
argc
],
function
->
args
+
function
->
argc
);
...
...
dlls/mshtml/tests/es5.js
View file @
edd43164
...
...
@@ -862,6 +862,9 @@ function test_bind() {
f
=
(
function
()
{
return
this
;
}).
bind
(
a
);
ok
(
f
()
===
a
,
"f() != a"
);
f
=
(
function
()
{
return
this
;
}).
bind
(
null
);
ok
(
f
()
===
window
,
"f() = "
+
f
());
var
t
;
f
=
(
function
()
{
return
t
=
this
;
}).
bind
(
a
);
ok
(
new
f
()
===
t
,
"new f() != a"
);
...
...
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