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
6a58d990
Commit
6a58d990
authored
Apr 20, 2021
by
Jacek Caban
Committed by
Alexandre Julliard
Apr 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jscript: Pass container object and property name to stringify.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9885de45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
41 deletions
+41
-41
json.c
dlls/jscript/json.c
+41
-41
No files found.
dlls/jscript/json.c
View file @
6a58d990
...
@@ -490,13 +490,13 @@ static inline BOOL is_callable(jsdisp_t *obj)
...
@@ -490,13 +490,13 @@ static inline BOOL is_callable(jsdisp_t *obj)
return
is_class
(
obj
,
JSCLASS_FUNCTION
);
return
is_class
(
obj
,
JSCLASS_FUNCTION
);
}
}
static
HRESULT
stringify
(
stringify_ctx_t
*
ctx
,
js
val_t
val
);
static
HRESULT
stringify
(
stringify_ctx_t
*
ctx
,
js
disp_t
*
object
,
const
WCHAR
*
name
);
/* ECMA-262 5.1 Edition 15.12.3 (abstract operation JA) */
/* ECMA-262 5.1 Edition 15.12.3 (abstract operation JA) */
static
HRESULT
stringify_array
(
stringify_ctx_t
*
ctx
,
jsdisp_t
*
obj
)
static
HRESULT
stringify_array
(
stringify_ctx_t
*
ctx
,
jsdisp_t
*
obj
)
{
{
unsigned
length
,
i
,
j
;
unsigned
length
,
i
,
j
;
jsval_t
val
;
WCHAR
name
[
16
]
;
HRESULT
hres
;
HRESULT
hres
;
if
(
is_on_stack
(
ctx
,
obj
))
{
if
(
is_on_stack
(
ctx
,
obj
))
{
...
@@ -526,19 +526,12 @@ static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj)
...
@@ -526,19 +526,12 @@ static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj)
}
}
}
}
hres
=
jsdisp_get_idx
(
obj
,
i
,
&
val
);
_itow
(
i
,
name
,
ARRAY_SIZE
(
name
));
if
(
SUCCEEDED
(
hres
))
{
hres
=
stringify
(
ctx
,
obj
,
name
);
hres
=
stringify
(
ctx
,
val
);
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
return
hres
;
if
(
hres
==
S_FALSE
&&
!
append_string
(
ctx
,
L"null"
))
return
E_OUTOFMEMORY
;
}
else
if
(
hres
==
DISP_E_UNKNOWNNAME
)
{
if
(
!
append_string
(
ctx
,
L"null"
))
return
E_OUTOFMEMORY
;
}
else
{
return
hres
;
return
hres
;
}
if
(
hres
==
S_FALSE
&&
!
append_string
(
ctx
,
L"null"
))
return
E_OUTOFMEMORY
;
}
}
if
((
length
&&
*
ctx
->
gap
&&
!
append_char
(
ctx
,
'\n'
))
||
!
append_char
(
ctx
,
']'
))
if
((
length
&&
*
ctx
->
gap
&&
!
append_char
(
ctx
,
'\n'
))
||
!
append_char
(
ctx
,
']'
))
...
@@ -552,7 +545,6 @@ static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj)
...
@@ -552,7 +545,6 @@ static HRESULT stringify_array(stringify_ctx_t *ctx, jsdisp_t *obj)
static
HRESULT
stringify_object
(
stringify_ctx_t
*
ctx
,
jsdisp_t
*
obj
)
static
HRESULT
stringify_object
(
stringify_ctx_t
*
ctx
,
jsdisp_t
*
obj
)
{
{
DISPID
dispid
=
DISPID_STARTENUM
;
DISPID
dispid
=
DISPID_STARTENUM
;
jsval_t
val
=
jsval_undefined
();
unsigned
prop_cnt
=
0
,
i
;
unsigned
prop_cnt
=
0
,
i
;
size_t
stepback
;
size_t
stepback
;
BSTR
prop_name
;
BSTR
prop_name
;
...
@@ -570,14 +562,6 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
...
@@ -570,14 +562,6 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
return
E_OUTOFMEMORY
;
return
E_OUTOFMEMORY
;
while
((
hres
=
IDispatchEx_GetNextDispID
(
&
obj
->
IDispatchEx_iface
,
fdexEnumDefault
,
dispid
,
&
dispid
))
==
S_OK
)
{
while
((
hres
=
IDispatchEx_GetNextDispID
(
&
obj
->
IDispatchEx_iface
,
fdexEnumDefault
,
dispid
,
&
dispid
))
==
S_OK
)
{
jsval_release
(
val
);
hres
=
jsdisp_propget
(
obj
,
dispid
,
&
val
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
is_undefined
(
val
))
continue
;
stepback
=
ctx
->
buf_len
;
stepback
=
ctx
->
buf_len
;
if
(
prop_cnt
&&
!
append_char
(
ctx
,
','
))
{
if
(
prop_cnt
&&
!
append_char
(
ctx
,
','
))
{
...
@@ -601,21 +585,23 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
...
@@ -601,21 +585,23 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
hres
=
IDispatchEx_GetMemberName
(
&
obj
->
IDispatchEx_iface
,
dispid
,
&
prop_name
);
hres
=
IDispatchEx_GetMemberName
(
&
obj
->
IDispatchEx_iface
,
dispid
,
&
prop_name
);
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
break
;
return
hres
;
hres
=
json_quote
(
ctx
,
prop_name
,
SysStringLen
(
prop_name
));
hres
=
json_quote
(
ctx
,
prop_name
,
SysStringLen
(
prop_name
));
SysFreeString
(
prop_name
);
if
(
FAILED
(
hres
))
{
if
(
FAILED
(
hres
))
SysFreeString
(
prop_name
);
break
;
return
hres
;
}
if
(
!
append_char
(
ctx
,
':'
)
||
(
*
ctx
->
gap
&&
!
append_char
(
ctx
,
' '
)))
{
if
(
!
append_char
(
ctx
,
':'
)
||
(
*
ctx
->
gap
&&
!
append_char
(
ctx
,
' '
)))
{
hres
=
E_OUTOFMEMORY
;
SysFreeString
(
prop_name
)
;
break
;
return
E_OUTOFMEMORY
;
}
}
hres
=
stringify
(
ctx
,
val
);
hres
=
stringify
(
ctx
,
obj
,
prop_name
);
SysFreeString
(
prop_name
);
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
break
;
return
hres
;
if
(
hres
==
S_FALSE
)
{
if
(
hres
==
S_FALSE
)
{
ctx
->
buf_len
=
stepback
;
ctx
->
buf_len
=
stepback
;
...
@@ -624,9 +610,6 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
...
@@ -624,9 +610,6 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
prop_cnt
++
;
prop_cnt
++
;
}
}
jsval_release
(
val
);
if
(
FAILED
(
hres
))
return
hres
;
if
(
prop_cnt
&&
*
ctx
->
gap
)
{
if
(
prop_cnt
&&
*
ctx
->
gap
)
{
if
(
!
append_char
(
ctx
,
'\n'
))
if
(
!
append_char
(
ctx
,
'\n'
))
...
@@ -648,18 +631,24 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
...
@@ -648,18 +631,24 @@ static HRESULT stringify_object(stringify_ctx_t *ctx, jsdisp_t *obj)
}
}
/* ECMA-262 5.1 Edition 15.12.3 (abstract operation Str) */
/* ECMA-262 5.1 Edition 15.12.3 (abstract operation Str) */
static
HRESULT
stringify
(
stringify_ctx_t
*
ctx
,
js
val_t
val
)
static
HRESULT
stringify
(
stringify_ctx_t
*
ctx
,
js
disp_t
*
object
,
const
WCHAR
*
name
)
{
{
jsval_t
value
;
jsval_t
value
,
v
;
HRESULT
hres
;
HRESULT
hres
;
if
(
is_object_instance
(
val
)
&&
get_object
(
val
))
{
hres
=
jsdisp_propget_name
(
object
,
name
,
&
value
);
if
(
FAILED
(
hres
))
return
hres
==
DISP_E_UNKNOWNNAME
?
S_FALSE
:
hres
;
if
(
is_object_instance
(
value
)
&&
get_object
(
value
))
{
jsdisp_t
*
obj
;
jsdisp_t
*
obj
;
DISPID
id
;
DISPID
id
;
obj
=
iface_to_jsdisp
(
get_object
(
val
));
obj
=
iface_to_jsdisp
(
get_object
(
value
));
if
(
!
obj
)
if
(
!
obj
)
{
jsval_release
(
value
);
return
S_FALSE
;
return
S_FALSE
;
}
hres
=
jsdisp_get_id
(
obj
,
L"toJSON"
,
0
,
&
id
);
hres
=
jsdisp_get_id
(
obj
,
L"toJSON"
,
0
,
&
id
);
jsdisp_release
(
obj
);
jsdisp_release
(
obj
);
...
@@ -669,7 +658,9 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val)
...
@@ -669,7 +658,9 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val)
/* FIXME: Support replacer replacer. */
/* FIXME: Support replacer replacer. */
hres
=
maybe_to_primitive
(
ctx
->
ctx
,
val
,
&
value
);
v
=
value
;
hres
=
maybe_to_primitive
(
ctx
->
ctx
,
v
,
&
value
);
jsval_release
(
v
);
if
(
FAILED
(
hres
))
if
(
FAILED
(
hres
))
return
hres
;
return
hres
;
...
@@ -746,6 +737,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val)
...
@@ -746,6 +737,7 @@ static HRESULT stringify(stringify_ctx_t *ctx, jsval_t val)
static
HRESULT
JSON_stringify
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
static
HRESULT
JSON_stringify
(
script_ctx_t
*
ctx
,
vdisp_t
*
jsthis
,
WORD
flags
,
unsigned
argc
,
jsval_t
*
argv
,
jsval_t
*
r
)
{
{
stringify_ctx_t
stringify_ctx
=
{
ctx
,
NULL
,
0
,
0
,
NULL
,
0
,
0
,
{
0
}};
stringify_ctx_t
stringify_ctx
=
{
ctx
,
NULL
,
0
,
0
,
NULL
,
0
,
0
,
{
0
}};
jsdisp_t
*
obj
;
HRESULT
hres
;
HRESULT
hres
;
TRACE
(
"
\n
"
);
TRACE
(
"
\n
"
);
...
@@ -790,7 +782,12 @@ static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
...
@@ -790,7 +782,12 @@ static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
jsval_release
(
space_val
);
jsval_release
(
space_val
);
}
}
hres
=
stringify
(
&
stringify_ctx
,
argv
[
0
]);
if
(
FAILED
(
hres
=
create_object
(
ctx
,
NULL
,
&
obj
)))
goto
fail
;
if
(
FAILED
(
hres
=
jsdisp_propput_name
(
obj
,
L""
,
argv
[
0
])))
goto
fail
;
hres
=
stringify
(
&
stringify_ctx
,
obj
,
L""
);
if
(
SUCCEEDED
(
hres
)
&&
r
)
{
if
(
SUCCEEDED
(
hres
)
&&
r
)
{
assert
(
!
stringify_ctx
.
stack_top
);
assert
(
!
stringify_ctx
.
stack_top
);
...
@@ -805,6 +802,9 @@ static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
...
@@ -805,6 +802,9 @@ static HRESULT JSON_stringify(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un
}
}
}
}
fail:
if
(
obj
)
jsdisp_release
(
obj
);
heap_free
(
stringify_ctx
.
buf
);
heap_free
(
stringify_ctx
.
buf
);
heap_free
(
stringify_ctx
.
stack
);
heap_free
(
stringify_ctx
.
stack
);
return
hres
;
return
hres
;
...
...
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