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
868bfdbf
Commit
868bfdbf
authored
Sep 02, 2009
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 02, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added Array.unshift implementation.
parent
f39d5e46
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
3 deletions
+106
-3
array.c
dlls/jscript/array.c
+77
-3
api.js
dlls/jscript/tests/api.js
+29
-0
No files found.
dlls/jscript/array.c
View file @
868bfdbf
...
...
@@ -69,6 +69,21 @@ static HRESULT set_jsdisp_length(DispatchEx *obj, LCID lcid, jsexcept_t *ei, DWO
return
jsdisp_propput_name
(
obj
,
lengthW
,
lcid
,
&
var
,
ei
,
NULL
/*FIXME*/
);
}
static
WCHAR
*
idx_to_str
(
DWORD
idx
,
WCHAR
*
ptr
)
{
if
(
!
idx
)
{
*
ptr
=
'0'
;
return
ptr
;
}
while
(
idx
)
{
*
ptr
--
=
'0'
+
(
idx
%
10
);
idx
/=
10
;
}
return
ptr
+
1
;
}
static
HRESULT
Array_length
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
VARIANT
*
retv
,
jsexcept_t
*
ei
,
IServiceProvider
*
sp
)
{
...
...
@@ -764,10 +779,69 @@ static HRESULT Array_toLocaleString(DispatchEx *dispex, LCID lcid, WORD flags, D
}
static
HRESULT
Array_unshift
(
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
;
WCHAR
buf
[
14
],
*
buf_end
,
*
str
;
DWORD
argc
,
i
,
length
;
VARIANT
var
;
DISPID
id
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
if
(
is_class
(
dispex
,
JSCLASS_ARRAY
))
{
length
=
((
ArrayInstance
*
)
dispex
)
->
length
;
}
else
{
hres
=
get_jsdisp_length
(
dispex
,
lcid
,
ei
,
&
length
);
if
(
FAILED
(
hres
))
return
hres
;
}
argc
=
arg_cnt
(
dp
);
if
(
!
argc
)
{
if
(
retv
)
V_VT
(
retv
)
=
VT_EMPTY
;
return
S_OK
;
}
buf_end
=
buf
+
sizeof
(
buf
)
/
sizeof
(
WCHAR
)
-
1
;
*
buf_end
--
=
0
;
i
=
length
;
while
(
i
--
)
{
str
=
idx_to_str
(
i
,
buf_end
);
hres
=
jsdisp_get_id
(
dispex
,
str
,
0
,
&
id
);
if
(
SUCCEEDED
(
hres
))
{
hres
=
jsdisp_propget
(
dispex
,
id
,
lcid
,
&
var
,
ei
,
caller
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
jsdisp_propput_idx
(
dispex
,
i
+
argc
,
lcid
,
&
var
,
ei
,
caller
);
VariantClear
(
&
var
);
}
else
if
(
hres
==
DISP_E_UNKNOWNNAME
)
{
hres
=
IDispatchEx_DeleteMemberByDispID
(
_IDispatchEx_
(
dispex
),
id
);
}
if
(
FAILED
(
hres
))
return
hres
;
}
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
hres
=
jsdisp_propput_idx
(
dispex
,
i
,
lcid
,
get_arg
(
dp
,
i
),
ei
,
caller
);
if
(
FAILED
(
hres
))
return
hres
;
}
if
(
!
is_class
(
dispex
,
JSCLASS_ARRAY
))
{
hres
=
set_jsdisp_length
(
dispex
,
lcid
,
ei
,
length
+
argc
);
if
(
FAILED
(
hres
))
return
hres
;
}
if
(
retv
)
V_VT
(
retv
)
=
VT_EMPTY
;
return
S_OK
;
}
static
HRESULT
Array_value
(
DispatchEx
*
dispex
,
LCID
lcid
,
WORD
flags
,
DISPPARAMS
*
dp
,
...
...
dlls/jscript/tests/api.js
View file @
868bfdbf
...
...
@@ -594,6 +594,35 @@ ok(arr.toString() === "a,b,c", "arr.toString() = " + arr.toString());
ok
(
arr
.
valueOf
===
Object
.
prototype
.
valueOf
,
"arr.valueOf !== Object.prototype.valueOf"
);
ok
(
arr
===
arr
.
valueOf
(),
"arr !== arr.valueOf"
);
arr
=
[
1
,
2
,
3
];
tmp
=
arr
.
unshift
(
0
);
ok
(
tmp
===
undefined
,
"[1,2,3].unshift(0) returned "
+
tmp
);
ok
(
arr
.
length
===
4
,
"arr.length = "
+
arr
.
length
);
ok
(
arr
.
toString
()
===
"0,1,2,3"
,
"arr.toString() = "
+
arr
.
toString
());
arr
=
new
Array
(
3
);
arr
[
0
]
=
1
;
arr
[
2
]
=
3
;
tmp
=
arr
.
unshift
(
-
1
,
0
);
ok
(
tmp
===
undefined
,
"unshift returned "
+
tmp
);
ok
(
arr
.
length
===
5
,
"arr.length = "
+
arr
.
length
);
ok
(
arr
.
toString
()
===
"-1,0,1,,3"
,
"arr.toString() = "
+
arr
.
toString
());
arr
=
[
1
,
2
,
3
];
tmp
=
arr
.
unshift
();
ok
(
tmp
===
undefined
,
"unshift returned "
+
tmp
);
ok
(
arr
.
length
===
3
,
"arr.length = "
+
arr
.
length
);
ok
(
arr
.
toString
()
===
"1,2,3"
,
"arr.toString() = "
+
arr
.
toString
());
arr
=
new
Object
();
arr
.
length
=
2
;
arr
[
0
]
=
1
;
arr
[
1
]
=
2
;
tmp
=
Array
.
prototype
.
unshift
.
call
(
arr
,
0
);
ok
(
tmp
===
undefined
,
"unshift returned "
+
tmp
);
ok
(
arr
.
length
===
3
,
"arr.length = "
+
arr
.
length
);
ok
(
arr
[
0
]
===
0
&&
arr
[
1
]
===
1
&&
arr
[
2
]
===
2
,
"unexpected array"
);
var
num
=
new
Number
(
6
);
arr
=
[
0
,
1
,
2
];
tmp
=
arr
.
concat
(
3
,
[
4
,
5
],
num
);
...
...
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