[3/3] webservices: Implement WsReadValue.

Hans Leidekker hans at codeweavers.com
Wed May 18 06:51:22 CDT 2016


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/reader.c              | 18 ++++++++++++
 dlls/webservices/tests/reader.c        | 52 ++++++++++++++++++++++++++++++++++
 dlls/webservices/webservices.spec      |  2 +-
 dlls/webservices/webservices_private.h |  1 +
 dlls/webservices/writer.c              |  2 +-
 5 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/dlls/webservices/reader.c b/dlls/webservices/reader.c
index c79f8cc..56fa28c 100644
--- a/dlls/webservices/reader.c
+++ b/dlls/webservices/reader.c
@@ -3616,6 +3616,24 @@ HRESULT WINAPI WsReadElement( WS_XML_READER *handle, const WS_ELEMENT_DESCRIPTIO
 }
 
 /**************************************************************************
+ *          WsReadValue		[webservices.@]
+ */
+HRESULT WINAPI WsReadValue( WS_XML_READER *handle, WS_VALUE_TYPE value_type, void *value, ULONG size,
+                            WS_ERROR *error )
+{
+    struct reader *reader = (struct reader *)handle;
+    WS_TYPE type = map_value_type( value_type );
+
+    TRACE( "%p %u %p %u %p\n", handle, type, value, size, error );
+    if (error) FIXME( "ignoring error parameter\n" );
+
+    if (!reader || !value || type == ~0u) return E_INVALIDARG;
+
+    return read_type( reader, WS_ELEMENT_TYPE_MAPPING, type, NULL, NULL, NULL, WS_READ_REQUIRED_VALUE,
+                      NULL, value, size );
+}
+
+/**************************************************************************
  *          WsSetErrorProperty		[webservices.@]
  */
 HRESULT WINAPI WsSetErrorProperty( WS_ERROR *handle, WS_ERROR_PROPERTY_ID id, const void *value,
diff --git a/dlls/webservices/tests/reader.c b/dlls/webservices/tests/reader.c
index 4430a76..1e167c3 100644
--- a/dlls/webservices/tests/reader.c
+++ b/dlls/webservices/tests/reader.c
@@ -3308,6 +3308,57 @@ static void test_WsReadElement(void)
     WsFreeReader( reader );
 }
 
+static void test_WsReadValue(void)
+{
+    HRESULT hr;
+    WS_XML_READER *reader;
+    UINT32 val;
+
+    hr = WsCreateReader( NULL, 0, &reader, NULL ) ;
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    prepare_struct_type_test( reader, "<t>1</t>" );
+    hr = WsReadValue( NULL, WS_UINT32_TYPE, &val, sizeof(val), NULL );
+    ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+    prepare_struct_type_test( reader, "<t>1</t>" );
+    hr = WsReadValue( reader, WS_UINT32_TYPE, NULL, sizeof(val), NULL );
+    ok( hr == E_INVALIDARG, "got %08x\n", hr );
+
+    /* reader must be positioned correctly */
+    prepare_struct_type_test( reader, "<t>1</t>" );
+    hr = WsReadValue( reader, WS_UINT32_TYPE, &val, sizeof(val), NULL );
+    ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
+
+    prepare_struct_type_test( reader, "<t>1</t>" );
+    hr = WsReadToStartElement( reader, NULL, NULL, NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsReadValue( reader, WS_UINT32_TYPE, &val, sizeof(val), NULL );
+    ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
+
+    prepare_struct_type_test( reader, "<t>1</t>" );
+    hr = WsReadToStartElement( reader, NULL, NULL, NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsReadStartElement( reader, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    val = 0xdeadbeef;
+    hr = WsReadValue( reader, WS_UINT32_TYPE, &val, sizeof(val), NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( val == 1, "got %u\n", val );
+
+    prepare_struct_type_test( reader, "<u t='1'></u>" );
+    hr = WsReadToStartElement( reader, NULL, NULL, NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsReadValue( reader, WS_UINT32_TYPE, &val, sizeof(val), NULL );
+    ok( hr == WS_E_INVALID_FORMAT, "got %08x\n", hr );
+
+    WsFreeReader( reader );
+}
+
 START_TEST(reader)
 {
     test_WsCreateError();
@@ -3338,4 +3389,5 @@ START_TEST(reader)
     test_WsFileTimeToDateTime();
     test_double();
     test_WsReadElement();
+    test_WsReadValue();
 }
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index 9b58d99..22cfe95 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -122,7 +122,7 @@
 @ stdcall WsReadStartElement(ptr ptr)
 @ stdcall WsReadToStartElement(ptr ptr ptr ptr ptr)
 @ stdcall WsReadType(ptr long long ptr long ptr ptr long ptr)
-@ stub WsReadValue
+@ stdcall WsReadValue(ptr long ptr long ptr)
 @ stub WsReadXmlBuffer
 @ stub WsReadXmlBufferFromBytes
 @ stub WsReceiveMessage
diff --git a/dlls/webservices/webservices_private.h b/dlls/webservices/webservices_private.h
index c33038d..363f164 100644
--- a/dlls/webservices/webservices_private.h
+++ b/dlls/webservices/webservices_private.h
@@ -32,6 +32,7 @@ WS_XML_STRING *alloc_xml_string( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
 WS_XML_UTF8_TEXT *alloc_utf8_text( const unsigned char *, ULONG ) DECLSPEC_HIDDEN;
 HRESULT append_attribute( WS_XML_ELEMENT_NODE *, WS_XML_ATTRIBUTE * ) DECLSPEC_HIDDEN;
 void free_attribute( WS_XML_ATTRIBUTE * ) DECLSPEC_HIDDEN;
+WS_TYPE map_value_type( WS_VALUE_TYPE ) DECLSPEC_HIDDEN;
 
 struct node
 {
diff --git a/dlls/webservices/writer.c b/dlls/webservices/writer.c
index a6ecf24..20e17d0 100644
--- a/dlls/webservices/writer.c
+++ b/dlls/webservices/writer.c
@@ -1559,7 +1559,7 @@ HRESULT WINAPI WsWriteType( WS_XML_WRITER *handle, WS_TYPE_MAPPING mapping, WS_T
     return hr;
 }
 
-static WS_TYPE map_value_type( WS_VALUE_TYPE type )
+WS_TYPE map_value_type( WS_VALUE_TYPE type )
 {
     switch (type)
     {
-- 
2.8.1




More information about the wine-patches mailing list