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
90baefe6
Commit
90baefe6
authored
Nov 08, 2018
by
Hans Leidekker
Committed by
Alexandre Julliard
Nov 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webservices: Use the search index to look up the union field, if available.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4234e597
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
15 deletions
+54
-15
writer.c
dlls/webservices/tests/writer.c
+12
-1
writer.c
dlls/webservices/writer.c
+42
-14
No files found.
dlls/webservices/tests/writer.c
View file @
90baefe6
...
@@ -3920,7 +3920,8 @@ static void test_union_type(void)
...
@@ -3920,7 +3920,8 @@ static void test_union_type(void)
WS_UNION_FIELD_DESCRIPTION
f
,
f2
,
*
fields
[
2
];
WS_UNION_FIELD_DESCRIPTION
f
,
f2
,
*
fields
[
2
];
WS_FIELD_DESCRIPTION
f_struct
,
*
fields_struct
[
1
];
WS_FIELD_DESCRIPTION
f_struct
,
*
fields_struct
[
1
];
WS_STRUCT_DESCRIPTION
s
;
WS_STRUCT_DESCRIPTION
s
;
enum
choice
{
CHOICE_A
,
CHOICE_B
,
CHOICE_NONE
};
enum
choice
{
CHOICE_A
=
30
,
CHOICE_B
=
20
,
CHOICE_C
=
10
,
CHOICE_NONE
=
0
};
ULONG
index
[
2
]
=
{
1
,
0
};
struct
test
struct
test
{
{
enum
choice
choice
;
enum
choice
choice
;
...
@@ -3987,6 +3988,7 @@ static void test_union_type(void)
...
@@ -3987,6 +3988,7 @@ static void test_union_type(void)
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
check_output
(
writer
,
"<t><a>test</a></t>"
,
__LINE__
);
check_output
(
writer
,
"<t><a>test</a></t>"
,
__LINE__
);
u
.
valueIndices
=
index
;
hr
=
set_output
(
writer
);
hr
=
set_output
(
writer
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
str_t
,
&
str_ns
,
NULL
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
str_t
,
&
str_ns
,
NULL
);
...
@@ -4004,6 +4006,15 @@ static void test_union_type(void)
...
@@ -4004,6 +4006,15 @@ static void test_union_type(void)
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
str_t
,
&
str_ns
,
NULL
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
str_t
,
&
str_ns
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
test
.
choice
=
CHOICE_C
;
hr
=
WsWriteType
(
writer
,
WS_ELEMENT_CONTENT_TYPE_MAPPING
,
WS_STRUCT_TYPE
,
&
s
,
WS_WRITE_REQUIRED_VALUE
,
&
test
,
sizeof
(
test
),
NULL
);
ok
(
hr
==
WS_E_INVALID_FORMAT
,
"got %08x
\n
"
,
hr
);
hr
=
set_output
(
writer
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
WsWriteStartElement
(
writer
,
NULL
,
&
str_t
,
&
str_ns
,
NULL
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
test
.
choice
=
CHOICE_NONE
;
test
.
choice
=
CHOICE_NONE
;
hr
=
WsWriteType
(
writer
,
WS_ELEMENT_CONTENT_TYPE_MAPPING
,
WS_STRUCT_TYPE
,
&
s
,
hr
=
WsWriteType
(
writer
,
WS_ELEMENT_CONTENT_TYPE_MAPPING
,
WS_STRUCT_TYPE
,
&
s
,
WS_WRITE_REQUIRED_VALUE
,
&
test
,
sizeof
(
test
),
NULL
);
WS_WRITE_REQUIRED_VALUE
,
&
test
,
sizeof
(
test
),
NULL
);
...
...
dlls/webservices/writer.c
View file @
90baefe6
...
@@ -3580,15 +3580,48 @@ static WS_WRITE_OPTION get_field_write_option( WS_TYPE type, ULONG options )
...
@@ -3580,15 +3580,48 @@ static WS_WRITE_OPTION get_field_write_option( WS_TYPE type, ULONG options )
}
}
}
}
static
HRESULT
write_type_field
(
struct
writer
*
,
const
WS_FIELD_DESCRIPTION
*
,
const
char
*
,
ULONG
);
static
HRESULT
find_index
(
const
WS_UNION_DESCRIPTION
*
desc
,
int
value
,
ULONG
*
idx
)
{
ULONG
i
;
static
HRESULT
write_type
(
struct
writer
*
,
WS_TYPE_MAPPING
,
WS_TYPE
,
const
void
*
,
WS_WRITE_OPTION
,
if
(
desc
->
valueIndices
)
const
void
*
,
ULONG
);
{
int
c
,
min
=
0
,
max
=
desc
->
fieldCount
-
1
;
while
(
min
<=
max
)
{
i
=
(
min
+
max
)
/
2
;
c
=
value
-
desc
->
fields
[
desc
->
valueIndices
[
i
]]
->
value
;
if
(
c
<
0
)
max
=
i
-
1
;
else
if
(
c
>
0
)
min
=
i
+
1
;
else
{
*
idx
=
desc
->
valueIndices
[
i
];
return
S_OK
;
}
}
return
WS_E_INVALID_FORMAT
;
}
/* fall back to linear search */
for
(
i
=
0
;
i
<
desc
->
fieldCount
;
i
++
)
{
if
(
desc
->
fields
[
i
]
->
value
==
value
)
{
*
idx
=
i
;
return
S_OK
;
}
}
return
WS_E_INVALID_FORMAT
;
}
static
HRESULT
write_type_field
(
struct
writer
*
,
const
WS_FIELD_DESCRIPTION
*
,
const
char
*
,
ULONG
);
static
HRESULT
write_type_union
(
struct
writer
*
writer
,
const
WS_UNION_DESCRIPTION
*
desc
,
WS_WRITE_OPTION
option
,
static
HRESULT
write_type_union
(
struct
writer
*
writer
,
const
WS_UNION_DESCRIPTION
*
desc
,
WS_WRITE_OPTION
option
,
const
void
*
value
,
ULONG
size
)
const
void
*
value
,
ULONG
size
)
{
{
ULONG
i
,
offset
;
ULONG
i
;
const
void
*
ptr
;
const
void
*
ptr
;
int
enum_value
;
int
enum_value
;
HRESULT
hr
;
HRESULT
hr
;
...
@@ -3612,18 +3645,13 @@ static HRESULT write_type_union( struct writer *writer, const WS_UNION_DESCRIPTI
...
@@ -3612,18 +3645,13 @@ static HRESULT write_type_union( struct writer *writer, const WS_UNION_DESCRIPTI
}
}
}
}
for
(
i
=
0
;
i
<
desc
->
fieldCount
;
i
++
)
if
((
hr
=
find_index
(
desc
,
enum_value
,
&
i
))
!=
S_OK
)
return
hr
;
{
return
write_type_field
(
writer
,
&
desc
->
fields
[
i
]
->
field
,
ptr
,
desc
->
fields
[
i
]
->
field
.
offset
);
if
(
desc
->
fields
[
i
]
->
value
==
enum_value
)
{
offset
=
desc
->
fields
[
i
]
->
field
.
offset
;
return
write_type_field
(
writer
,
&
desc
->
fields
[
i
]
->
field
,
ptr
,
offset
);
}
}
return
E_INVALIDARG
;
}
}
static
HRESULT
write_type
(
struct
writer
*
,
WS_TYPE_MAPPING
,
WS_TYPE
,
const
void
*
,
WS_WRITE_OPTION
,
const
void
*
,
ULONG
);
static
HRESULT
write_type_array
(
struct
writer
*
writer
,
const
WS_FIELD_DESCRIPTION
*
desc
,
const
char
*
buf
,
static
HRESULT
write_type_array
(
struct
writer
*
writer
,
const
WS_FIELD_DESCRIPTION
*
desc
,
const
char
*
buf
,
ULONG
count
)
ULONG
count
)
{
{
...
...
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