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
8644a083
Commit
8644a083
authored
Jan 20, 2010
by
Piotr Caban
Committed by
Alexandre Julliard
Jan 20, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Make Array.sort generic.
parent
91dcc245
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
14 deletions
+21
-14
array.c
dlls/jscript/array.c
+11
-14
api.js
dlls/jscript/tests/api.js
+10
-0
No files found.
dlls/jscript/array.c
View file @
8644a083
...
...
@@ -685,10 +685,10 @@ static HRESULT sort_cmp(script_ctx_t *ctx, DispatchEx *cmp_func, VARIANT *v1, VA
}
/* ECMA-262 3rd Edition 15.4.4.11 */
static
HRESULT
Array_sort
(
script_ctx_t
*
ctx
,
vdisp_t
*
js
this
,
WORD
flags
,
DISPPARAMS
*
dp
,
static
HRESULT
Array_sort
(
script_ctx_t
*
ctx
,
vdisp_t
*
v
this
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
caller
)
{
DispatchEx
*
cmp_func
=
NULL
;
DispatchEx
*
jsthis
,
*
cmp_func
=
NULL
;
VARIANT
*
vtab
,
**
sorttab
=
NULL
;
DWORD
length
;
DWORD
i
;
...
...
@@ -696,12 +696,9 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
TRACE
(
"
\n
"
);
if
(
is_vclass
(
jsthis
,
JSCLASS_ARRAY
))
{
length
=
array_from_vdisp
(
jsthis
)
->
length
;
}
else
{
FIXME
(
"unsupported this not array
\n
"
);
return
E_NOTIMPL
;
}
hres
=
get_length
(
ctx
,
vthis
,
ei
,
&
jsthis
,
&
length
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
arg_cnt
(
dp
)
>
1
)
{
WARN
(
"invalid arg_cnt %d
\n
"
,
arg_cnt
(
dp
));
...
...
@@ -731,8 +728,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
jsdisp_release
(
cmp_func
);
if
(
retv
)
{
V_VT
(
retv
)
=
VT_DISPATCH
;
V_DISPATCH
(
retv
)
=
jsthis
->
u
.
disp
;
IDispatch_AddRef
(
jsthis
->
u
.
disp
);
V_DISPATCH
(
retv
)
=
(
IDispatch
*
)
_IDispatchEx_
(
jsthis
)
;
IDispatch_AddRef
(
V_DISPATCH
(
retv
)
);
}
return
S_OK
;
}
...
...
@@ -740,7 +737,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
vtab
=
heap_alloc_zero
(
length
*
sizeof
(
VARIANT
));
if
(
vtab
)
{
for
(
i
=
0
;
i
<
length
;
i
++
)
{
hres
=
jsdisp_propget_idx
(
jsthis
->
u
.
jsdisp
,
i
,
vtab
+
i
,
ei
,
caller
);
hres
=
jsdisp_propget_idx
(
jsthis
,
i
,
vtab
+
i
,
ei
,
caller
);
if
(
FAILED
(
hres
)
&&
hres
!=
DISP_E_UNKNOWNNAME
)
{
WARN
(
"Could not get elem %d: %08x
\n
"
,
i
,
hres
);
break
;
...
...
@@ -817,7 +814,7 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
}
for
(
i
=
0
;
SUCCEEDED
(
hres
)
&&
i
<
length
;
i
++
)
hres
=
jsdisp_propput_idx
(
jsthis
->
u
.
jsdisp
,
i
,
sorttab
[
i
],
ei
,
caller
);
hres
=
jsdisp_propput_idx
(
jsthis
,
i
,
sorttab
[
i
],
ei
,
caller
);
}
if
(
vtab
)
{
...
...
@@ -834,8 +831,8 @@ static HRESULT Array_sort(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, DISPPA
if
(
retv
)
{
V_VT
(
retv
)
=
VT_DISPATCH
;
V_DISPATCH
(
retv
)
=
jsthis
->
u
.
disp
;
IDispatch_AddRef
(
jsthis
->
u
.
disp
);
V_DISPATCH
(
retv
)
=
(
IDispatch
*
)
_IDispatchEx_
(
jsthis
)
;
IDispatch_AddRef
(
V_DISPATCH
(
retv
)
);
}
return
S_OK
;
...
...
dlls/jscript/tests/api.js
View file @
8644a083
...
...
@@ -695,6 +695,15 @@ ok(arr.sort() === arr, "arr.sort() !== arr");
for
(
var
i
=
0
;
i
<
arr
.
length
;
i
++
)
ok
(
arr
[
i
]
===
tmp
[
i
],
"arr["
+
i
+
"] = "
+
arr
[
i
]
+
" expected "
+
tmp
[
i
]);
arr
=
new
Object
();
arr
.
length
=
3
;
arr
[
0
]
=
1
;
arr
[
2
]
=
"aa"
;
arr
.
sort
=
Array
.
prototype
.
sort
;
tmp
=
arr
.
sort
();
ok
(
arr
===
tmp
,
"tmp !== arr"
);
ok
(
arr
[
0
]
===
1
&&
arr
[
1
]
===
"aa"
&&
arr
[
2
]
===
undefined
,
"arr is sorted incorectly"
);
arr
=
[
"1"
,
"2"
,
"3"
];
arr
.
length
=
1
;
ok
(
arr
.
length
===
1
,
"arr.length = "
+
arr
.
length
);
...
...
@@ -1903,6 +1912,7 @@ testArrayHostThis("unshift");
testArrayHostThis
(
"reverse"
);
testArrayHostThis
(
"join"
);
testArrayHostThis
(
"pop"
);
testArrayHostThis
(
"sort"
);
function
testObjectInherit
(
obj
,
constr
,
ts
,
tls
,
vo
)
{
ok
(
obj
instanceof
Object
,
"obj is not instance of Object"
);
...
...
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