Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
5c819cb2
Commit
5c819cb2
authored
15 years ago
by
Jacek Caban
Committed by
Alexandre Julliard
15 years ago
Browse files
Options
Downloads
Patches
Plain Diff
jscript: Added Function.apply implementation.
parent
8761462b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dlls/jscript/function.c
+86
-3
86 additions, 3 deletions
dlls/jscript/function.c
dlls/jscript/tests/api.js
+7
-0
7 additions, 0 deletions
dlls/jscript/tests/api.js
with
93 additions
and
3 deletions
dlls/jscript/function.c
+
86
−
3
View file @
5c819cb2
...
...
@@ -346,11 +346,94 @@ static HRESULT Function_toString(DispatchEx *dispex, LCID lcid, WORD flags, DISP
return
S_OK
;
}
static
HRESULT
array_to_args
(
DispatchEx
*
arg_array
,
LCID
lcid
,
jsexcept_t
*
ei
,
IServiceProvider
*
caller
,
DISPPARAMS
*
args
)
{
VARIANT
var
,
*
argv
;
DWORD
length
,
i
;
HRESULT
hres
;
hres
=
jsdisp_propget_name
(
arg_array
,
lengthW
,
lcid
,
&
var
,
ei
,
NULL
/*FIXME*/
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
to_uint32
(
arg_array
->
ctx
,
&
var
,
ei
,
&
length
);
VariantClear
(
&
var
);
if
(
FAILED
(
hres
))
return
hres
;
argv
=
heap_alloc
(
length
*
sizeof
(
VARIANT
));
if
(
FAILED
(
hres
))
return
E_OUTOFMEMORY
;
for
(
i
=
0
;
i
<
length
;
i
++
)
{
hres
=
jsdisp_propget_idx
(
arg_array
,
i
,
lcid
,
argv
+
i
,
ei
,
caller
);
if
(
FAILED
(
hres
))
{
while
(
i
--
)
VariantClear
(
argv
+
i
);
heap_free
(
argv
);
return
hres
;
}
}
args
->
cArgs
=
length
;
args
->
rgvarg
=
argv
;
return
S_OK
;
}
static
HRESULT
Function_apply
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
caller
)
{
FIXME
(
"
\n
"
);
return
E_NOTIMPL
;
FunctionInstance
*
function
;
DISPPARAMS
args
=
{
NULL
,
NULL
,
0
,
0
};
DWORD
argc
,
i
;
IDispatch
*
this_obj
;
HRESULT
hres
=
S_OK
;
TRACE
(
"
\n
"
);
if
(
!
is_class
(
dispex
,
JSCLASS_FUNCTION
))
{
FIXME
(
"dispex is not a function
\n
"
);
return
E_FAIL
;
}
function
=
(
FunctionInstance
*
)
dispex
;
argc
=
arg_cnt
(
dp
);
if
(
argc
)
{
hres
=
to_object
(
dispex
->
ctx
,
get_arg
(
dp
,
0
),
&
this_obj
);
if
(
FAILED
(
hres
))
return
hres
;
}
if
(
argc
>=
2
)
{
DispatchEx
*
arg_array
=
NULL
;
if
(
V_VT
(
get_arg
(
dp
,
1
))
==
VT_DISPATCH
)
{
arg_array
=
iface_to_jsdisp
((
IUnknown
*
)
V_DISPATCH
(
get_arg
(
dp
,
1
)));
if
(
!
is_class
(
arg_array
,
JSCLASS_ARRAY
)
&&
!
is_class
(
arg_array
,
JSCLASS_ARGUMENTS
))
{
jsdisp_release
(
arg_array
);
arg_array
=
NULL
;
}
}
if
(
arg_array
)
{
hres
=
array_to_args
(
arg_array
,
lcid
,
ei
,
caller
,
&
args
);
jsdisp_release
(
arg_array
);
}
else
{
FIXME
(
"throw TypeError"
);
hres
=
E_FAIL
;
}
}
hres
=
call_function
(
function
,
this_obj
,
lcid
,
&
args
,
retv
,
ei
,
caller
);
if
(
this_obj
)
IDispatch_Release
(
this_obj
);
for
(
i
=
0
;
i
<
args
.
cArgs
;
i
++
)
VariantClear
(
args
.
rgvarg
+
i
);
heap_free
(
args
.
rgvarg
);
return
hres
;
}
static
HRESULT
Function_call
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
This diff is collapsed.
Click to expand it.
dlls/jscript/tests/api.js
+
7
−
0
View file @
5c819cb2
...
...
@@ -1137,12 +1137,19 @@ function callTest(argc) {
callTest
.
call
(
tmp
,
1
,
1
);
callTest
.
call
(
tmp
,
2
,
1
,
2
);
callTest
.
apply
(
tmp
,
[
1
,
1
]);
callTest
.
apply
(
tmp
,
[
2
,
1
,
2
]);
(
function
()
{
callTest
.
apply
(
tmp
,
arguments
);
})(
2
,
1
,
2
);
function
callTest2
()
{
ok
(
this
===
tmp
,
"
this !== tmp
\n
"
);
ok
(
arguments
.
length
===
0
,
"
callTest2: arguments.length =
"
+
arguments
.
length
+
"
expected 0
"
);
}
callTest2
.
call
(
tmp
);
callTest2
.
apply
(
tmp
,
[]);
callTest2
.
apply
(
tmp
);
(
function
()
{
callTest2
.
apply
(
tmp
,
arguments
);
})();
function
callTest3
()
{
ok
(
arguments
.
length
===
0
,
"
arguments.length =
"
+
arguments
.
length
+
"
expected 0
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment