Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
102fe73e
Commit
102fe73e
authored
Jun 04, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jun 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Add Object.keys implementation.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
78d6d41c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
2 deletions
+77
-2
dispex.c
dlls/jscript/dispex.c
+11
-0
jscript.h
dlls/jscript/jscript.h
+1
-0
object.c
dlls/jscript/object.c
+49
-2
es5.js
dlls/mshtml/tests/es5.js
+16
-0
No files found.
dlls/jscript/dispex.c
View file @
102fe73e
...
@@ -2572,3 +2572,14 @@ HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned f
...
@@ -2572,3 +2572,14 @@ HRESULT jsdisp_define_data_property(jsdisp_t *obj, const WCHAR *name, unsigned f
prop_desc
.
value
=
value
;
prop_desc
.
value
=
value
;
return
jsdisp_define_property
(
obj
,
name
,
&
prop_desc
);
return
jsdisp_define_property
(
obj
,
name
,
&
prop_desc
);
}
}
HRESULT
jsdisp_get_prop_name
(
jsdisp_t
*
obj
,
DISPID
id
,
jsstr_t
**
r
)
{
dispex_prop_t
*
prop
=
get_prop
(
obj
,
id
);
if
(
!
prop
||
!
prop
->
name
||
prop
->
type
==
PROP_DELETED
)
return
DISP_E_MEMBERNOTFOUND
;
*
r
=
jsstr_alloc
(
prop
->
name
);
return
*
r
?
S_OK
:
E_OUTOFMEMORY
;
}
dlls/jscript/jscript.h
View file @
102fe73e
...
@@ -314,6 +314,7 @@ HRESULT jsdisp_get_own_property(jsdisp_t*,const WCHAR*,BOOL,property_desc_t*) DE
...
@@ -314,6 +314,7 @@ HRESULT jsdisp_get_own_property(jsdisp_t*,const WCHAR*,BOOL,property_desc_t*) DE
HRESULT
jsdisp_define_property
(
jsdisp_t
*
,
const
WCHAR
*
,
property_desc_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_define_property
(
jsdisp_t
*
,
const
WCHAR
*
,
property_desc_t
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_define_data_property
(
jsdisp_t
*
,
const
WCHAR
*
,
unsigned
,
jsval_t
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_define_data_property
(
jsdisp_t
*
,
const
WCHAR
*
,
unsigned
,
jsval_t
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_next_prop
(
jsdisp_t
*
,
DISPID
,
BOOL
,
DISPID
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_next_prop
(
jsdisp_t
*
,
DISPID
,
BOOL
,
DISPID
*
)
DECLSPEC_HIDDEN
;
HRESULT
jsdisp_get_prop_name
(
jsdisp_t
*
,
DISPID
,
jsstr_t
**
);
HRESULT
create_builtin_function
(
script_ctx_t
*
,
builtin_invoke_t
,
const
WCHAR
*
,
const
builtin_info_t
*
,
DWORD
,
HRESULT
create_builtin_function
(
script_ctx_t
*
,
builtin_invoke_t
,
const
WCHAR
*
,
const
builtin_info_t
*
,
DWORD
,
jsdisp_t
*
,
jsdisp_t
**
)
DECLSPEC_HIDDEN
;
jsdisp_t
*
,
jsdisp_t
**
)
DECLSPEC_HIDDEN
;
...
...
dlls/jscript/object.c
View file @
102fe73e
...
@@ -610,7 +610,7 @@ static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
...
@@ -610,7 +610,7 @@ static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return
E_NOTIMPL
;
return
E_NOTIMPL
;
}
}
TRACE
(
"(%s)
\n
"
,
debugstr_jsval
(
argv
[
1
]));
TRACE
(
"(%s)
\n
"
,
debugstr_jsval
(
argv
[
0
]));
obj
=
to_jsdisp
(
get_object
(
argv
[
0
]));
obj
=
to_jsdisp
(
get_object
(
argv
[
0
]));
if
(
!
obj
)
{
if
(
!
obj
)
{
...
@@ -625,12 +625,59 @@ static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
...
@@ -625,12 +625,59 @@ static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl
return
S_OK
;
return
S_OK
;
}
}
static
HRESULT
Object_keys
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
DISPID
id
=
DISPID_STARTENUM
;
jsdisp_t
*
obj
,
*
array
;
unsigned
i
=
0
;
jsstr_t
*
key
;
HRESULT
hres
;
if
(
!
argc
||
!
is_object_instance
(
argv
[
0
]))
{
FIXME
(
"invalid arguments %s
\n
"
,
debugstr_jsval
(
argv
[
0
]));
return
E_NOTIMPL
;
}
TRACE
(
"(%s)
\n
"
,
debugstr_jsval
(
argv
[
0
]));
obj
=
to_jsdisp
(
get_object
(
argv
[
0
]));
if
(
!
obj
)
{
FIXME
(
"Non-JS object
\n
"
);
return
E_NOTIMPL
;
}
hres
=
create_array
(
ctx
,
0
,
&
array
);
if
(
FAILED
(
hres
))
return
hres
;
do
{
hres
=
jsdisp_next_prop
(
obj
,
id
,
TRUE
,
&
id
);
if
(
hres
!=
S_OK
)
break
;
hres
=
jsdisp_get_prop_name
(
obj
,
id
,
&
key
);
if
(
FAILED
(
hres
))
break
;
hres
=
jsdisp_propput_idx
(
array
,
i
++
,
jsval_string
(
key
));
jsstr_release
(
key
);
}
while
(
hres
==
S_OK
);
if
(
SUCCEEDED
(
hres
)
&&
r
)
*
r
=
jsval_obj
(
array
);
else
jsdisp_release
(
array
);
return
hres
;
}
static
const
builtin_prop_t
ObjectConstr_props
[]
=
{
static
const
builtin_prop_t
ObjectConstr_props
[]
=
{
{
L"create"
,
Object_create
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"create"
,
Object_create
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"defineProperties"
,
Object_defineProperties
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"defineProperties"
,
Object_defineProperties
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"defineProperty"
,
Object_defineProperty
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"defineProperty"
,
Object_defineProperty
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"getOwnPropertyDescriptor"
,
Object_getOwnPropertyDescriptor
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"getOwnPropertyDescriptor"
,
Object_getOwnPropertyDescriptor
,
PROPF_ES5
|
PROPF_METHOD
|
2
},
{
L"getPrototypeOf"
,
Object_getPrototypeOf
,
PROPF_ES5
|
PROPF_METHOD
|
1
}
{
L"getPrototypeOf"
,
Object_getPrototypeOf
,
PROPF_ES5
|
PROPF_METHOD
|
1
},
{
L"keys"
,
Object_keys
,
PROPF_ES5
|
PROPF_METHOD
|
1
}
};
};
static
const
builtin_info_t
ObjectConstr_info
=
{
static
const
builtin_info_t
ObjectConstr_info
=
{
...
...
dlls/mshtml/tests/es5.js
View file @
102fe73e
...
@@ -865,3 +865,19 @@ sync_test("bind", function() {
...
@@ -865,3 +865,19 @@ sync_test("bind", function() {
ok
(
Function
.
prototype
.
bind
.
length
===
1
,
"Function.prototype.bind.length = "
+
Function
.
prototype
.
bind
.
length
);
ok
(
Function
.
prototype
.
bind
.
length
===
1
,
"Function.prototype.bind.length = "
+
Function
.
prototype
.
bind
.
length
);
});
});
sync_test
(
"keys"
,
function
()
{
var
o
=
{
a
:
1
,
b
:
2
,
c
:
3
};
var
keys
=
Object
.
keys
(
o
).
sort
().
join
();
ok
(
keys
===
"a,b,c"
,
"keys = "
+
keys
);
o
=
Object
.
create
(
o
);
keys
=
Object
.
keys
(
o
).
sort
().
join
();
ok
(
keys
===
""
,
"keys = "
+
keys
);
o
.
test
=
1
;
keys
=
Object
.
keys
(
o
).
sort
().
join
();
ok
(
keys
===
"test"
,
"keys = "
+
keys
);
ok
(
Object
.
keys
.
length
===
1
,
"Object.keys.length = "
+
Object
.
keys
.
length
);
});
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