Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/webservices/reader.c | 45 +++++++++++++++++++----- dlls/webservices/tests/reader.c | 62 +++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 8 deletions(-)
diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c index 4d37a38a8a..0d0e7d09f0 100644 --- a/dlls/webservices/reader.c +++ b/dlls/webservices/reader.c @@ -5968,6 +5968,29 @@ static HRESULT read_type_qname( struct reader *reader, WS_TYPE_MAPPING mapping, return S_OK; }
+static HRESULT read_type_description( struct reader *reader, WS_TYPE_MAPPING mapping, + const WS_XML_STRING *localname, const WS_XML_STRING *ns, + const WS_STRUCT_DESCRIPTION *desc, WS_READ_OPTION option, + WS_HEAP *heap, void *ret, ULONG size, BOOL *found ) +{ + switch (option) + { + case WS_READ_REQUIRED_POINTER: + case WS_READ_OPTIONAL_POINTER: + { + if (size != sizeof(desc)) return E_INVALIDARG; + *(const WS_STRUCT_DESCRIPTION **)ret = desc; + *found = TRUE; + 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; @@ -6165,7 +6188,8 @@ static WS_READ_OPTION get_field_read_option( WS_TYPE type, ULONG options ) } }
-static HRESULT read_type_field( struct reader *, const WS_FIELD_DESCRIPTION *, WS_HEAP *, char *, ULONG ); +static HRESULT read_type_field( struct reader *, const WS_STRUCT_DESCRIPTION *, const WS_FIELD_DESCRIPTION *, + WS_HEAP *, char *, ULONG );
static HRESULT read_type_union( struct reader *reader, const WS_UNION_DESCRIPTION *desc, WS_HEAP *heap, void *ret, ULONG size, BOOL *found ) @@ -6193,7 +6217,7 @@ static HRESULT read_type_union( struct reader *reader, const WS_UNION_DESCRIPTIO else { ULONG offset = desc->fields[i]->field.offset; - if ((hr = read_type_field( reader, &desc->fields[i]->field, heap, ret, offset )) != S_OK) return hr; + if ((hr = read_type_field( reader, NULL, &desc->fields[i]->field, heap, ret, offset )) != S_OK) return hr; *(int *)((char *)ret + desc->enumOffset) = desc->fields[i]->value; }
@@ -6297,8 +6321,8 @@ static HRESULT read_type_text( struct reader *reader, const WS_FIELD_DESCRIPTION return hr; }
-static HRESULT read_type_field( struct reader *reader, const WS_FIELD_DESCRIPTION *desc, WS_HEAP *heap, char *buf, - ULONG offset ) +static HRESULT read_type_field( struct reader *reader, const WS_STRUCT_DESCRIPTION *desc_struct, + const WS_FIELD_DESCRIPTION *desc, WS_HEAP *heap, char *buf, ULONG offset ) { char *ptr; WS_READ_OPTION option; @@ -6323,8 +6347,9 @@ static HRESULT read_type_field( struct reader *reader, const WS_FIELD_DESCRIPTIO switch (desc->mapping) { case WS_TYPE_ATTRIBUTE_FIELD_MAPPING: - FIXME( "WS_TYPE_ATTRIBUTE_FIELD_MAPPING not supported\n" ); - return S_OK; + hr = read_type( reader, WS_ATTRIBUTE_TYPE_MAPPING, desc->type, desc->localName, desc->ns, + desc_struct, option, heap, ptr, size, &found ); + break;
case WS_ATTRIBUTE_FIELD_MAPPING: hr = read_type( reader, WS_ATTRIBUTE_TYPE_MAPPING, desc->type, desc->localName, desc->ns, @@ -6424,7 +6449,7 @@ static HRESULT read_type_struct( struct reader *reader, WS_TYPE_MAPPING mapping, for (i = 0; i < desc->fieldCount; i++) { offset = desc->fields[i]->offset; - if ((hr = read_type_field( reader, desc->fields[i], heap, buf, offset )) != S_OK) break; + if ((hr = read_type_field( reader, desc, desc->fields[i], heap, buf, offset )) != S_OK) break; }
switch (option) @@ -6651,6 +6676,10 @@ static HRESULT read_type( struct reader *reader, WS_TYPE_MAPPING mapping, WS_TYP hr = read_type_qname( reader, mapping, localname, ns, desc, option, heap, value, size, found ); break;
+ case WS_DESCRIPTION_TYPE: + hr = read_type_description( reader, mapping, localname, ns, desc, option, heap, value, size, found ); + break; + case WS_STRUCT_TYPE: hr = read_type_struct( reader, mapping, localname, ns, desc, option, heap, value, size, found ); break; @@ -7419,7 +7448,7 @@ static ULONG get_field_size( const WS_FIELD_DESCRIPTION *desc ) static HRESULT read_param( struct reader *reader, const WS_FIELD_DESCRIPTION *desc, WS_HEAP *heap, void *ret ) { if (!ret && !(ret = ws_alloc_zero( heap, get_field_size(desc) ))) return WS_E_QUOTA_EXCEEDED; - return read_type_field( reader, desc, heap, ret, 0 ); + return read_type_field( reader, NULL, desc, heap, ret, 0 ); }
static HRESULT read_param_array( struct reader *reader, const WS_FIELD_DESCRIPTION *desc, WS_HEAP *heap, diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c index 733ebe3eb1..4b9b589d8d 100644 --- a/dlls/webservices/tests/reader.c +++ b/dlls/webservices/tests/reader.c @@ -6841,6 +6841,67 @@ static void test_stream_input(void) WsFreeReader( reader ); }
+static void test_description_type(void) +{ + static WS_XML_STRING ns = {0, NULL}, ns2 = {2, (BYTE *)"ns"}, localname = {1, (BYTE *)"t"}; + static WS_XML_STRING val = {3, (BYTE *)"val"}; + HRESULT hr; + WS_XML_READER *reader; + WS_HEAP *heap; + WS_FIELD_DESCRIPTION f, f2, *fields[2]; + WS_STRUCT_DESCRIPTION s; + struct test + { + const WS_STRUCT_DESCRIPTION *desc; + INT32 val; + } *test; + + hr = WsCreateHeap( 1 << 16, 0, NULL, 0, &heap, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = WsCreateReader( NULL, 0, &reader, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + memset( &f, 0, sizeof(f) ); + f.mapping = WS_TYPE_ATTRIBUTE_FIELD_MAPPING; + f.type = WS_DESCRIPTION_TYPE; + fields[0] = &f; + + memset( &f2, 0, sizeof(f2) ); + f2.mapping = WS_ATTRIBUTE_FIELD_MAPPING; + f2.localName = &val; + f2.ns = &ns; + f2.offset = FIELD_OFFSET(struct test, val); + f2.type = WS_INT32_TYPE; + fields[1] = &f2; + + memset( &s, 0, sizeof(s) ); + s.size = sizeof(struct test); + s.alignment = TYPE_ALIGNMENT(struct test); + s.fields = fields; + s.fieldCount = 2; + s.typeLocalName = &localname; + s.typeNs = &ns; + + prepare_struct_type_test( reader, "<t val="-1" xmlns="ns"/>" ); + hr = WsReadToStartElement( reader, &localname, &ns2, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + test = NULL; + hr = WsReadType( reader, WS_ELEMENT_TYPE_MAPPING, WS_STRUCT_TYPE, &s, + WS_READ_REQUIRED_POINTER, heap, &test, sizeof(test), NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + ok( test != NULL, "test not set\n" ); + if (test) + { + ok( test->val == -1, "got %d\n", test->val ); + ok( test->desc == &s, "got %p\n", test->desc ); + } + + WsFreeReader( reader ); + WsFreeHeap( heap ); +} + START_TEST(reader) { test_WsCreateError(); @@ -6891,4 +6952,5 @@ START_TEST(reader) test_repeating_element_choice(); test_empty_text_field(); test_stream_input(); + test_description_type(); }