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
2177403b
Commit
2177403b
authored
May 21, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
May 21, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xmllite/writer: Initial implementation of WriteStartElement().
parent
05a80d0f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
132 additions
and
9 deletions
+132
-9
writer.c
dlls/xmllite/tests/writer.c
+92
-0
writer.c
dlls/xmllite/writer.c
+40
-9
No files found.
dlls/xmllite/tests/writer.c
View file @
2177403b
...
@@ -410,6 +410,7 @@ static void test_bom(void)
...
@@ -410,6 +410,7 @@ static void test_bom(void)
static
const
WCHAR
versionW
[]
=
{
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
,
0
};
static
const
WCHAR
versionW
[]
=
{
'v'
,
'e'
,
'r'
,
's'
,
'i'
,
'o'
,
'n'
,
'='
,
'"'
,
'1'
,
'.'
,
'0'
,
'"'
,
0
};
static
const
WCHAR
utf16W
[]
=
{
'u'
,
't'
,
'f'
,
'-'
,
'1'
,
'6'
,
0
};
static
const
WCHAR
utf16W
[]
=
{
'u'
,
't'
,
'f'
,
'-'
,
'1'
,
'6'
,
0
};
static
const
WCHAR
xmlW
[]
=
{
'x'
,
'm'
,
'l'
,
0
};
static
const
WCHAR
xmlW
[]
=
{
'x'
,
'm'
,
'l'
,
0
};
static
const
WCHAR
aW
[]
=
{
'a'
,
0
};
IXmlWriterOutput
*
output
;
IXmlWriterOutput
*
output
;
unsigned
char
*
ptr
;
unsigned
char
*
ptr
;
IXmlWriter
*
writer
;
IXmlWriter
*
writer
;
...
@@ -473,8 +474,98 @@ static void test_bom(void)
...
@@ -473,8 +474,98 @@ static void test_bom(void)
GlobalUnlock
(
hglobal
);
GlobalUnlock
(
hglobal
);
IUnknown_Release
(
output
);
IUnknown_Release
(
output
);
IStream_Release
(
stream
);
/* start with element */
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
pCreateXmlWriterOutputWithEncodingName
((
IUnknown
*
)
stream
,
NULL
,
utf16W
,
&
output
);
ok
(
hr
==
S_OK
,
"got %08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
output
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
aW
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
GetHGlobalFromStream
(
stream
,
&
hglobal
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
ptr
[
0
]
==
0xff
&&
ptr
[
1
]
==
0xfe
,
"got %x,%x
\n
"
,
ptr
[
0
],
ptr
[
1
]);
GlobalUnlock
(
hglobal
);
IUnknown_Release
(
output
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
IXmlWriter_Release
(
writer
);
}
static
void
test_writestartelement
(
void
)
{
static
const
WCHAR
aW
[]
=
{
'a'
,
0
};
char
*
ptr
;
IXmlWriter
*
writer
;
IStream
*
stream
;
HGLOBAL
hglobal
;
HRESULT
hr
;
hr
=
CreateStreamOnHGlobal
(
NULL
,
TRUE
,
&
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
pCreateXmlWriter
(
&
IID_IXmlWriter
,
(
void
**
)
&
writer
,
NULL
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
aW
,
NULL
);
ok
(
hr
==
E_UNEXPECTED
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_SetOutput
(
writer
,
(
IUnknown
*
)
stream
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
aW
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
NULL
,
aW
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
aW
,
NULL
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
GetHGlobalFromStream
(
stream
,
&
hglobal
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_Flush
(
writer
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ptr
=
GlobalLock
(
hglobal
);
ok
(
!
strncmp
(
ptr
,
"<a"
,
2
),
"got %s
\n
"
,
ptr
);
GlobalUnlock
(
hglobal
);
hr
=
IXmlWriter_WriteStartDocument
(
writer
,
XmlStandalone_Yes
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
/* write another element without closing previous one */
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
aW
,
NULL
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteStartElement
(
writer
,
NULL
,
NULL
,
NULL
);
ok
(
hr
==
E_INVALIDARG
,
"got 0x%08x
\n
"
,
hr
);
hr
=
IXmlWriter_WriteProcessingInstruction
(
writer
,
aW
,
aW
);
ok
(
hr
==
WR_E_INVALIDACTION
,
"got 0x%08x
\n
"
,
hr
);
IStream_Release
(
stream
);
IStream_Release
(
stream
);
IXmlWriter_Release
(
writer
);
}
}
START_TEST
(
writer
)
START_TEST
(
writer
)
...
@@ -485,6 +576,7 @@ START_TEST(writer)
...
@@ -485,6 +576,7 @@ START_TEST(writer)
test_writer_create
();
test_writer_create
();
test_writeroutput
();
test_writeroutput
();
test_writestartdocument
();
test_writestartdocument
();
test_writestartelement
();
test_flush
();
test_flush
();
test_omitxmldeclaration
();
test_omitxmldeclaration
();
test_bom
();
test_bom
();
...
...
dlls/xmllite/writer.c
View file @
2177403b
...
@@ -51,7 +51,8 @@ typedef enum
...
@@ -51,7 +51,8 @@ typedef enum
XmlWriterState_Initial
,
/* output is not set yet */
XmlWriterState_Initial
,
/* output is not set yet */
XmlWriterState_Ready
,
/* SetOutput() was called, ready to start */
XmlWriterState_Ready
,
/* SetOutput() was called, ready to start */
XmlWriterState_PIDocStarted
,
/* document was started with manually added 'xml' PI */
XmlWriterState_PIDocStarted
,
/* document was started with manually added 'xml' PI */
XmlWriterState_DocStarted
/* document was started with WriteStartDocument() */
XmlWriterState_DocStarted
,
/* document was started with WriteStartDocument() */
XmlWriterState_ElemStarted
/* writing element */
}
XmlWriterState
;
}
XmlWriterState
;
typedef
struct
typedef
struct
...
@@ -593,11 +594,19 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP
...
@@ -593,11 +594,19 @@ static HRESULT WINAPI xmlwriter_WriteProcessingInstruction(IXmlWriter *iface, LP
TRACE
(
"(%p)->(%s %s)
\n
"
,
This
,
wine_dbgstr_w
(
name
),
wine_dbgstr_w
(
text
));
TRACE
(
"(%p)->(%s %s)
\n
"
,
This
,
wine_dbgstr_w
(
name
),
wine_dbgstr_w
(
text
));
if
(
This
->
state
==
XmlWriterState_Initial
)
switch
(
This
->
state
)
{
case
XmlWriterState_Initial
:
return
E_UNEXPECTED
;
return
E_UNEXPECTED
;
case
XmlWriterState_DocStarted
:
if
(
This
->
state
==
XmlWriterState_DocStarted
&&
!
strcmpW
(
name
,
xmlW
))
if
(
!
strcmpW
(
name
,
xmlW
))
return
WR_E_INVALIDACTION
;
break
;
case
XmlWriterState_ElemStarted
:
return
WR_E_INVALIDACTION
;
return
WR_E_INVALIDACTION
;
default:
;
}
write_encoding_bom
(
This
);
write_encoding_bom
(
This
);
write_output_buffer
(
This
->
output
,
openpiW
,
sizeof
(
openpiW
)
/
sizeof
(
WCHAR
));
write_output_buffer
(
This
->
output
,
openpiW
,
sizeof
(
openpiW
)
/
sizeof
(
WCHAR
));
...
@@ -656,6 +665,7 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
...
@@ -656,6 +665,7 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
This
->
state
=
XmlWriterState_DocStarted
;
This
->
state
=
XmlWriterState_DocStarted
;
return
S_OK
;
return
S_OK
;
case
XmlWriterState_DocStarted
:
case
XmlWriterState_DocStarted
:
case
XmlWriterState_ElemStarted
:
return
WR_E_INVALIDACTION
;
return
WR_E_INVALIDACTION
;
default:
default:
;
;
...
@@ -690,15 +700,36 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
...
@@ -690,15 +700,36 @@ static HRESULT WINAPI xmlwriter_WriteStartDocument(IXmlWriter *iface, XmlStandal
return
S_OK
;
return
S_OK
;
}
}
static
HRESULT
WINAPI
xmlwriter_WriteStartElement
(
IXmlWriter
*
iface
,
LPCWSTR
pwszPrefix
,
static
HRESULT
WINAPI
xmlwriter_WriteStartElement
(
IXmlWriter
*
iface
,
LPCWSTR
prefix
,
LPCWSTR
local_name
,
LPCWSTR
uri
)
LPCWSTR
pwszLocalName
,
LPCWSTR
pwszNamespaceUri
)
{
{
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
xmlwriter
*
This
=
impl_from_IXmlWriter
(
iface
);
static
const
WCHAR
ltW
[]
=
{
'<'
};
FIXME
(
"%p %s %s %s
\n
"
,
This
,
wine_dbgstr_w
(
pwszPrefix
),
wine_dbgstr_w
(
pwszLocalName
),
TRACE
(
"(%p)->(%s %s %s)
\n
"
,
This
,
wine_dbgstr_w
(
prefix
),
wine_dbgstr_w
(
local_name
),
wine_dbgstr_w
(
uri
));
wine_dbgstr_w
(
pwszNamespaceUri
));
return
E_NOTIMPL
;
if
(
This
->
state
==
XmlWriterState_Initial
)
return
E_UNEXPECTED
;
if
(
!
local_name
)
return
E_INVALIDARG
;
if
(
This
->
state
==
XmlWriterState_ElemStarted
)
return
WR_E_INVALIDACTION
;
write_encoding_bom
(
This
);
This
->
state
=
XmlWriterState_ElemStarted
;
write_output_buffer
(
This
->
output
,
ltW
,
1
);
if
(
prefix
)
{
static
const
WCHAR
colW
[]
=
{
':'
};
write_output_buffer
(
This
->
output
,
prefix
,
-
1
);
write_output_buffer
(
This
->
output
,
colW
,
1
);
}
write_output_buffer
(
This
->
output
,
local_name
,
-
1
);
return
S_OK
;
}
}
static
HRESULT
WINAPI
xmlwriter_WriteString
(
IXmlWriter
*
iface
,
LPCWSTR
pwszText
)
static
HRESULT
WINAPI
xmlwriter_WriteString
(
IXmlWriter
*
iface
,
LPCWSTR
pwszText
)
...
...
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