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
9c25917e
Commit
9c25917e
authored
Sep 15, 2008
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 16, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Added Array constructor implementation.
parent
199952bf
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
3 deletions
+114
-3
array.c
dlls/jscript/array.c
+66
-3
jscript.h
dlls/jscript/jscript.h
+11
-0
api.js
dlls/jscript/tests/api.js
+33
-0
rsrc.rc
dlls/jscript/tests/rsrc.rc
+3
-0
run.c
dlls/jscript/tests/run.c
+1
-0
No files found.
dlls/jscript/array.c
View file @
9c25917e
...
...
@@ -24,6 +24,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript);
typedef
struct
{
DispatchEx
dispex
;
DWORD
length
;
}
ArrayInstance
;
static
const
WCHAR
lengthW
[]
=
{
'l'
,
'e'
,
'n'
,
'g'
,
't'
,
'h'
,
0
};
...
...
@@ -212,10 +214,56 @@ static const builtin_info_t Array_info = {
};
static
HRESULT
ArrayConstr_value
(
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
;
DispatchEx
*
obj
;
VARIANT
*
arg_var
;
DWORD
i
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
switch
(
flags
)
{
case
DISPATCH_CONSTRUCT
:
{
if
(
arg_cnt
(
dp
)
==
1
&&
V_VT
((
arg_var
=
get_arg
(
dp
,
0
)))
==
VT_I4
)
{
if
(
V_I4
(
arg_var
)
<
0
)
{
FIXME
(
"throw RangeError
\n
"
);
return
E_FAIL
;
}
hres
=
create_array
(
dispex
->
ctx
,
V_I4
(
arg_var
),
&
obj
);
if
(
FAILED
(
hres
))
return
hres
;
V_VT
(
retv
)
=
VT_DISPATCH
;
V_DISPATCH
(
retv
)
=
(
IDispatch
*
)
_IDispatchEx_
(
obj
);
return
S_OK
;
}
hres
=
create_array
(
dispex
->
ctx
,
arg_cnt
(
dp
),
&
obj
);
if
(
FAILED
(
hres
))
return
hres
;
for
(
i
=
0
;
i
<
arg_cnt
(
dp
);
i
++
)
{
hres
=
jsdisp_propput_idx
(
obj
,
i
,
lcid
,
get_arg
(
dp
,
i
),
ei
,
caller
);
if
(
FAILED
(
hres
))
break
;
}
if
(
FAILED
(
hres
))
{
jsdisp_release
(
obj
);
return
hres
;
}
V_VT
(
retv
)
=
VT_DISPATCH
;
V_DISPATCH
(
retv
)
=
(
IDispatch
*
)
_IDispatchEx_
(
obj
);
break
;
}
default:
FIXME
(
"unimplemented flags: %x
\n
"
,
flags
);
return
E_NOTIMPL
;
}
return
S_OK
;
}
static
HRESULT
alloc_array
(
script_ctx_t
*
ctx
,
BOOL
use_constr
,
ArrayInstance
**
ret
)
...
...
@@ -251,3 +299,18 @@ HRESULT create_array_constr(script_ctx_t *ctx, DispatchEx **ret)
IDispatchEx_Release
(
_IDispatchEx_
(
&
array
->
dispex
));
return
hres
;
}
HRESULT
create_array
(
script_ctx_t
*
ctx
,
DWORD
length
,
DispatchEx
**
ret
)
{
ArrayInstance
*
array
;
HRESULT
hres
;
hres
=
alloc_array
(
ctx
,
TRUE
,
&
array
);
if
(
FAILED
(
hres
))
return
hres
;
array
->
length
=
length
;
*
ret
=
&
array
->
dispex
;
return
S_OK
;
}
dlls/jscript/jscript.h
View file @
9c25917e
...
...
@@ -115,6 +115,7 @@ HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,DWORD,DispatchEx*
HRESULT
create_object
(
script_ctx_t
*
,
DispatchEx
*
,
DispatchEx
**
);
HRESULT
create_math
(
script_ctx_t
*
,
DispatchEx
**
);
HRESULT
create_array
(
script_ctx_t
*
,
DWORD
,
DispatchEx
**
);
HRESULT
to_primitive
(
script_ctx_t
*
,
VARIANT
*
,
jsexcept_t
*
,
VARIANT
*
);
HRESULT
to_boolean
(
VARIANT
*
,
VARIANT_BOOL
*
);
...
...
@@ -163,6 +164,16 @@ HRESULT create_object_constr(script_ctx_t*,DispatchEx**);
HRESULT
create_regexp_constr
(
script_ctx_t
*
,
DispatchEx
**
);
HRESULT
create_string_constr
(
script_ctx_t
*
,
DispatchEx
**
);
static
inline
VARIANT
*
get_arg
(
DISPPARAMS
*
dp
,
DWORD
i
)
{
return
dp
->
rgvarg
+
dp
->
cArgs
-
i
-
1
;
}
static
inline
DWORD
arg_cnt
(
const
DISPPARAMS
*
dp
)
{
return
dp
->
cArgs
-
dp
->
cNamedArgs
;
}
const
char
*
debugstr_variant
(
const
VARIANT
*
);
HRESULT
WINAPI
JScriptFactory_CreateInstance
(
IClassFactory
*
,
IUnknown
*
,
REFIID
,
void
**
);
...
...
dlls/jscript/tests/api.js
0 → 100644
View file @
9c25917e
/*
* Copyright 2008 Jacek Caban for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
var
arr
=
new
Array
();
ok
(
typeof
(
arr
)
===
"object"
,
"arr () is not object"
);
ok
(
arr
[
"0"
]
===
undefined
,
"arr[0] is not undefined"
);
var
arr
=
new
Array
(
1
,
2
,
"test"
);
ok
(
typeof
(
arr
)
===
"object"
,
"arr (1,2,test) is not object"
);
ok
(
arr
[
"0"
]
===
1
,
"arr[0] is not 1"
);
ok
(
arr
[
"1"
]
===
2
,
"arr[1] is not 2"
);
ok
(
arr
[
"2"
]
===
"test"
,
"arr[2] is not
\"
test
\"
"
);
var
arr
=
new
Array
(
6
);
ok
(
typeof
(
arr
)
===
"object"
,
"arr (6) is not object"
);
ok
(
arr
[
"0"
]
===
undefined
,
"arr[0] is not undefined"
);
reportSuccess
();
dlls/jscript/tests/rsrc.rc
View file @
9c25917e
...
...
@@ -16,5 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/* @makedep: api.js */
api.js 40 "api.js"
/* @makedep: lang.js */
lang.js 40 "lang.js"
dlls/jscript/tests/run.c
View file @
9c25917e
...
...
@@ -582,6 +582,7 @@ static void run_tests(void)
CHECK_CALLED
(
global_success_i
);
run_from_res
(
"lang.js"
);
run_from_res
(
"api.js"
);
}
START_TEST
(
run
)
...
...
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