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
7236d982
Commit
7236d982
authored
Sep 25, 2019
by
Hans Leidekker
Committed by
Alexandre Julliard
Sep 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Add support for writing WS_ENUM_TYPE values.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fe9a28e8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
+67
-0
writer.c
dlls/webservices/tests/writer.c
+35
-0
writer.c
dlls/webservices/writer.c
+32
-0
No files found.
dlls/webservices/tests/writer.c
View file @
7236d982
...
...
@@ -553,6 +553,11 @@ static void test_WsWriteType(void)
WS_XML_WRITER
*
writer
;
WS_XML_STRING
prefix
=
{
1
,
(
BYTE
*
)
"p"
},
localname
=
{
3
,
(
BYTE
*
)
"str"
},
ns
=
{
2
,
(
BYTE
*
)
"ns"
};
const
WCHAR
*
val_str
;
enum
{
ONE
=
1
,
TWO
=
2
};
WS_XML_STRING
one
=
{
3
,
(
BYTE
*
)
"ONE"
},
two
=
{
3
,
(
BYTE
*
)
"TWO"
};
WS_ENUM_VALUE
enum_values
[]
=
{{
ONE
,
&
one
},
{
TWO
,
&
two
}};
WS_ENUM_DESCRIPTION
enum_desc
;
int
val_enum
;
hr
=
WsCreateWriter
(
NULL
,
0
,
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
...
...
@@ -637,6 +642,36 @@ static void test_WsWriteType(void)
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
check_output
(
writer
,
"<p:str xmlns:p=
\"
ns
\"
>test</p:str>"
,
__LINE__
);
hr
=
set_output
(
writer
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteStartElement
(
writer
,
&
prefix
,
&
localname
,
&
ns
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
enum_desc
.
values
=
enum_values
;
enum_desc
.
valueCount
=
ARRAY_SIZE
(
enum_values
);
enum_desc
.
maxByteCount
=
3
;
enum_desc
.
nameIndices
=
NULL
;
val_enum
=
0
;
hr
=
WsWriteType
(
writer
,
WS_ELEMENT_TYPE_MAPPING
,
WS_ENUM_TYPE
,
&
enum_desc
,
WS_WRITE_REQUIRED_VALUE
,
&
val_enum
,
sizeof
(
val_enum
),
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
val_enum
=
3
;
hr
=
WsWriteType
(
writer
,
WS_ELEMENT_TYPE_MAPPING
,
WS_ENUM_TYPE
,
&
enum_desc
,
WS_WRITE_REQUIRED_VALUE
,
&
val_enum
,
sizeof
(
val_enum
),
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got %08x
\n
"
,
hr
);
val_enum
=
ONE
;
hr
=
WsWriteType
(
writer
,
WS_ELEMENT_TYPE_MAPPING
,
WS_ENUM_TYPE
,
&
enum_desc
,
WS_WRITE_REQUIRED_VALUE
,
&
val_enum
,
sizeof
(
val_enum
),
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteEndElement
(
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
check_output
(
writer
,
"<p:str xmlns:p=
\"
ns
\"
>ONE</p:str>"
,
__LINE__
);
WsFreeWriter
(
writer
);
}
...
...
dlls/webservices/writer.c
View file @
7236d982
...
...
@@ -3876,6 +3876,35 @@ static HRESULT write_type_struct( struct writer *writer, WS_TYPE_MAPPING mapping
return
S_OK
;
}
static
const
WS_XML_STRING
*
get_enum_value_name
(
const
WS_ENUM_DESCRIPTION
*
desc
,
int
value
)
{
ULONG
i
;
for
(
i
=
0
;
i
<
desc
->
valueCount
;
i
++
)
{
if
(
desc
->
values
[
i
].
value
==
value
)
return
desc
->
values
[
i
].
name
;
}
return
NULL
;
}
static
HRESULT
write_type_enum
(
struct
writer
*
writer
,
WS_TYPE_MAPPING
mapping
,
const
WS_ENUM_DESCRIPTION
*
desc
,
WS_WRITE_OPTION
option
,
const
void
*
value
,
ULONG
size
)
{
const
WS_XML_STRING
*
name
;
WS_XML_UTF8_TEXT
utf8
;
const
int
*
ptr
;
HRESULT
hr
;
if
(
!
desc
)
return
E_INVALIDARG
;
if
((
hr
=
get_value_ptr
(
option
,
value
,
size
,
sizeof
(
*
ptr
),
(
const
void
**
)
&
ptr
))
!=
S_OK
)
return
hr
;
if
(
!
(
name
=
get_enum_value_name
(
desc
,
*
ptr
)))
return
E_INVALIDARG
;
utf8
.
text
.
textType
=
WS_XML_TEXT_TYPE_UTF8
;
utf8
.
value
.
bytes
=
name
->
bytes
;
utf8
.
value
.
length
=
name
->
length
;
return
write_type_text
(
writer
,
mapping
,
&
utf8
.
text
);
}
static
HRESULT
write_type
(
struct
writer
*
writer
,
WS_TYPE_MAPPING
mapping
,
WS_TYPE
type
,
const
void
*
desc
,
WS_WRITE_OPTION
option
,
const
void
*
value
,
ULONG
size
)
...
...
@@ -3939,6 +3968,9 @@ static HRESULT write_type( struct writer *writer, WS_TYPE_MAPPING mapping, WS_TY
case
WS_STRUCT_TYPE
:
return
write_type_struct
(
writer
,
mapping
,
desc
,
option
,
value
,
size
);
case
WS_ENUM_TYPE
:
return
write_type_enum
(
writer
,
mapping
,
desc
,
option
,
value
,
size
);
default:
FIXME
(
"type %u not supported
\n
"
,
type
);
return
E_NOTIMPL
;
...
...
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