Commit 234115c8 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

webservices: Implement WS_TYPE_ATTRIBUTE_FIELD_MAPPING for the writer.

parent 9616d258
......@@ -4793,6 +4793,61 @@ static void test_stream_output(void)
WsFreeWriter( writer );
}
static void test_description_type(void)
{
static WS_XML_STRING ns = {0, NULL}, localname = {1, (BYTE *)"t"}, val = {3, (BYTE *)"val"};
HRESULT hr;
WS_XML_WRITER *writer;
WS_FIELD_DESCRIPTION f, f2, *fields[2];
WS_STRUCT_DESCRIPTION s;
struct test
{
const WS_STRUCT_DESCRIPTION *desc;
INT32 val;
} test;
hr = WsCreateWriter( NULL, 0, &writer, 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;
test.desc = &s;
test.val = -1;
hr = set_output( writer );
hr = WsWriteStartElement( writer, NULL, &localname, &ns, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsWriteType( writer, WS_ELEMENT_TYPE_MAPPING, WS_STRUCT_TYPE, &s,
WS_WRITE_REQUIRED_VALUE, &test, sizeof(test), NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = WsWriteEndElement( writer, NULL );
ok( hr == S_OK, "got %08x\n", hr );
check_output( writer, "<t val=\"-1\"/>", __LINE__ );
WsFreeWriter( writer );
}
START_TEST(writer)
{
test_WsCreateWriter();
......@@ -4837,4 +4892,5 @@ START_TEST(writer)
test_text_types_binary();
test_repeating_element_choice();
test_stream_output();
test_description_type();
}
......@@ -3760,8 +3760,8 @@ static HRESULT write_type_field( struct writer *writer, const WS_FIELD_DESCRIPTI
return E_NOTIMPL;
}
/* zero-terminated strings are always pointers */
if (desc->type == WS_WSZ_TYPE) field_options |= WS_FIELD_POINTER;
/* zero-terminated strings and descriptions are always pointers */
if (desc->type == WS_WSZ_TYPE || desc->type == WS_DESCRIPTION_TYPE) field_options |= WS_FIELD_POINTER;
if (field_options & WS_FIELD_POINTER)
size = sizeof(const void *);
......@@ -3790,6 +3790,10 @@ static HRESULT write_type_field( struct writer *writer, const WS_FIELD_DESCRIPTI
switch (desc->mapping)
{
case WS_TYPE_ATTRIBUTE_FIELD_MAPPING:
mapping = WS_ATTRIBUTE_TYPE_MAPPING;
break;
case WS_ATTRIBUTE_FIELD_MAPPING:
if (!desc->localName || !desc->ns) return E_INVALIDARG;
if ((hr = write_add_attribute( writer, NULL, desc->localName, desc->ns, FALSE )) != S_OK)
......@@ -3910,6 +3914,17 @@ static HRESULT write_type_enum( struct writer *writer, WS_TYPE_MAPPING mapping,
return write_type_text( writer, mapping, &utf8.text );
}
static HRESULT write_type_description( struct writer *writer, WS_TYPE_MAPPING mapping,
WS_WRITE_OPTION option, const void *value, ULONG size )
{
const WS_STRUCT_DESCRIPTION *ptr;
HRESULT hr;
if ((hr = get_value_ptr( option, value, size, sizeof(*ptr), (const void **)&ptr )) != S_OK) return hr;
if (ptr) FIXME( "ignoring type description %p\n", ptr );
return S_OK;
}
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 )
......@@ -3970,6 +3985,9 @@ static HRESULT write_type( struct writer *writer, WS_TYPE_MAPPING mapping, WS_TY
case WS_XML_QNAME_TYPE:
return write_type_qname( writer, mapping, desc, option, value, size );
case WS_DESCRIPTION_TYPE:
return write_type_description( writer, mapping, option, value, size );
case WS_STRUCT_TYPE:
return write_type_struct( writer, mapping, desc, option, value, size );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment