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
2b5b0f01
Commit
2b5b0f01
authored
Apr 13, 2016
by
Hans Leidekker
Committed by
Alexandre Julliard
Apr 13, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Add support for reading enum values.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4bb2e5ef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
reader.c
dlls/webservices/reader.c
+68
-0
reader.c
dlls/webservices/tests/reader.c
+18
-0
No files found.
dlls/webservices/reader.c
View file @
2b5b0f01
...
...
@@ -2542,6 +2542,67 @@ static HRESULT read_type_wsz( struct reader *reader, WS_TYPE_MAPPING mapping,
return
S_OK
;
}
static
HRESULT
get_enum_value
(
const
WS_XML_UTF8_TEXT
*
text
,
const
WS_ENUM_DESCRIPTION
*
desc
,
int
*
ret
)
{
ULONG
i
;
for
(
i
=
0
;
i
<
desc
->
valueCount
;
i
++
)
{
if
(
WsXmlStringEquals
(
&
text
->
value
,
desc
->
values
[
i
].
name
,
NULL
)
==
S_OK
)
{
*
ret
=
desc
->
values
[
i
].
value
;
return
S_OK
;
}
}
return
WS_E_INVALID_FORMAT
;
}
static
HRESULT
read_type_enum
(
struct
reader
*
reader
,
WS_TYPE_MAPPING
mapping
,
const
WS_XML_STRING
*
localname
,
const
WS_XML_STRING
*
ns
,
const
WS_ENUM_DESCRIPTION
*
desc
,
WS_READ_OPTION
option
,
WS_HEAP
*
heap
,
void
*
ret
,
ULONG
size
)
{
WS_XML_UTF8_TEXT
*
utf8
;
HRESULT
hr
;
int
val
=
0
;
BOOL
found
;
if
(
!
desc
)
return
E_INVALIDARG
;
if
((
hr
=
read_get_text
(
reader
,
mapping
,
localname
,
ns
,
&
utf8
,
&
found
))
!=
S_OK
)
return
hr
;
if
(
found
&&
(
hr
=
get_enum_value
(
utf8
,
desc
,
&
val
))
!=
S_OK
)
return
hr
;
switch
(
option
)
{
case
WS_READ_REQUIRED_VALUE
:
if
(
!
found
)
return
WS_E_INVALID_FORMAT
;
if
(
size
!=
sizeof
(
int
))
return
E_INVALIDARG
;
*
(
int
*
)
ret
=
val
;
break
;
case
WS_READ_REQUIRED_POINTER
:
if
(
!
found
)
return
WS_E_INVALID_FORMAT
;
/* fall through */
case
WS_READ_OPTIONAL_POINTER
:
{
int
*
heap_val
=
NULL
;
if
(
size
!=
sizeof
(
heap_val
))
return
E_INVALIDARG
;
if
(
found
)
{
if
(
!
(
heap_val
=
ws_alloc
(
heap
,
sizeof
(
*
heap_val
)
)))
return
WS_E_QUOTA_EXCEEDED
;
*
heap_val
=
val
;
}
*
(
int
**
)
ret
=
heap_val
;
break
;
}
default:
FIXME
(
"read option %u not supported
\n
"
,
option
);
return
E_NOTIMPL
;
}
return
S_OK
;
}
static
BOOL
is_empty_text_node
(
const
struct
node
*
node
)
{
const
WS_XML_TEXT_NODE
*
text
=
(
const
WS_XML_TEXT_NODE
*
)
node
;
...
...
@@ -2608,6 +2669,7 @@ static ULONG get_type_size( WS_TYPE type, const WS_STRUCT_DESCRIPTION *desc )
case
WS_BOOL_TYPE
:
case
WS_INT32_TYPE
:
case
WS_UINT32_TYPE
:
case
WS_ENUM_TYPE
:
return
sizeof
(
INT32
);
case
WS_INT64_TYPE
:
...
...
@@ -2716,6 +2778,7 @@ static WS_READ_OPTION map_field_options( WS_TYPE type, ULONG options )
case
WS_UINT16_TYPE
:
case
WS_UINT32_TYPE
:
case
WS_UINT64_TYPE
:
case
WS_ENUM_TYPE
:
return
WS_READ_REQUIRED_VALUE
;
case
WS_WSZ_TYPE
:
...
...
@@ -2944,6 +3007,11 @@ static HRESULT read_type( struct reader *reader, WS_TYPE_MAPPING mapping, WS_TYP
return
hr
;
break
;
case
WS_ENUM_TYPE
:
if
((
hr
=
read_type_enum
(
reader
,
mapping
,
localname
,
ns
,
desc
,
option
,
heap
,
value
,
size
))
!=
S_OK
)
return
hr
;
break
;
default:
FIXME
(
"type %u not supported
\n
"
,
type
);
return
E_NOTIMPL
;
...
...
dlls/webservices/tests/reader.c
View file @
2b5b0f01
...
...
@@ -1324,6 +1324,12 @@ static void test_WsReadType(void)
HRESULT
hr
;
WS_XML_READER
*
reader
;
WS_HEAP
*
heap
;
enum
{
ONE
=
1
,
TWO
=
2
};
WS_XML_STRING
one
=
{
3
,
(
BYTE
*
)
"ONE"
};
WS_XML_STRING
two
=
{
3
,
(
BYTE
*
)
"TWO"
};
WS_ENUM_VALUE
enum_values
[]
=
{
{
ONE
,
&
one
},
{
TWO
,
&
two
}
};
WS_ENUM_DESCRIPTION
enum_desc
;
int
val_enum
;
WCHAR
*
val_str
;
BOOL
val_bool
;
INT8
val_int8
;
...
...
@@ -1561,6 +1567,18 @@ static void test_WsReadType(void)
todo_wine
ok
(
hr
==
WS_E_INVALID_FORMAT
,
"got %08x
\n
"
,
hr
);
ok
(
!
val_uint64
,
"wrong value
\n
"
);
enum_desc
.
values
=
enum_values
;
enum_desc
.
valueCount
=
sizeof
(
enum_values
)
/
sizeof
(
enum_values
[
0
]);
enum_desc
.
maxByteCount
=
3
;
enum_desc
.
nameIndices
=
NULL
;
val_enum
=
0
;
prepare_type_test
(
reader
,
"<t>ONE</t>"
,
sizeof
(
"<t>ONE</t>"
)
-
1
);
hr
=
WsReadType
(
reader
,
WS_ELEMENT_CONTENT_TYPE_MAPPING
,
WS_ENUM_TYPE
,
&
enum_desc
,
WS_READ_REQUIRED_VALUE
,
heap
,
&
val_enum
,
sizeof
(
val_enum
),
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
val_enum
==
1
,
"got %d
\n
"
,
val_enum
);
WsFreeReader
(
reader
);
WsFreeHeap
(
heap
);
}
...
...
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