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
5afdfaba
Commit
5afdfaba
authored
Jan 15, 2010
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 18, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msxml3: Don't preallocate root element, return new instance on each call.
parent
ea589686
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
19 deletions
+139
-19
xmldoc.c
dlls/msxml3/tests/xmldoc.c
+7
-0
xmlelem.c
dlls/msxml3/tests/xmlelem.c
+126
-10
xmldoc.c
dlls/msxml3/xmldoc.c
+6
-9
No files found.
dlls/msxml3/tests/xmldoc.c
View file @
5afdfaba
...
@@ -141,6 +141,13 @@ static void test_xmldoc(void)
...
@@ -141,6 +141,13 @@ static void test_xmldoc(void)
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
element
!=
NULL
,
"Expected non-NULL element
\n
"
);
ok
(
element
!=
NULL
,
"Expected non-NULL element
\n
"
);
/* ::root() returns new instance each time */
hr
=
IXMLDocument_get_root
(
doc
,
&
child
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
child
!=
NULL
,
"Expected non-NULL element
\n
"
);
ok
(
child
!=
element
,
"Expected new element instance
\n
"
);
IXMLElement_Release
(
child
);
hr
=
IXMLElement_get_type
(
element
,
&
type
);
hr
=
IXMLElement_get_type
(
element
,
&
type
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
type
==
XMLELEMTYPE_ELEMENT
,
"Expected XMLELEMTYPE_ELEMENT, got %d
\n
"
,
type
);
ok
(
type
==
XMLELEMTYPE_ELEMENT
,
"Expected XMLELEMTYPE_ELEMENT, got %d
\n
"
,
type
);
...
...
dlls/msxml3/tests/xmlelem.c
View file @
5afdfaba
...
@@ -53,11 +53,7 @@ static void test_xmlelem(void)
...
@@ -53,11 +53,7 @@ static void test_xmlelem(void)
hr
=
CoCreateInstance
(
&
CLSID_XMLDocument
,
NULL
,
CLSCTX_INPROC_SERVER
,
hr
=
CoCreateInstance
(
&
CLSID_XMLDocument
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IXMLDocument
,
(
LPVOID
*
)
&
doc
);
&
IID_IXMLDocument
,
(
LPVOID
*
)
&
doc
);
if
(
FAILED
(
hr
))
ok
(
hr
==
S_OK
,
"Expected S_OK, got 0x%08x
\n
"
,
hr
);
{
skip
(
"Failed to create XMLDocument instance
\n
"
);
return
;
}
V_VT
(
&
vType
)
=
VT_I4
;
V_VT
(
&
vType
)
=
VT_I4
;
V_I4
(
&
vType
)
=
XMLELEMTYPE_ELEMENT
;
V_I4
(
&
vType
)
=
XMLELEMTYPE_ELEMENT
;
...
@@ -265,11 +261,7 @@ static void test_xmlelem_collection(void)
...
@@ -265,11 +261,7 @@ static void test_xmlelem_collection(void)
hr
=
CoCreateInstance
(
&
CLSID_XMLDocument
,
NULL
,
CLSCTX_INPROC_SERVER
,
hr
=
CoCreateInstance
(
&
CLSID_XMLDocument
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IXMLDocument
,
(
LPVOID
*
)
&
doc
);
&
IID_IXMLDocument
,
(
LPVOID
*
)
&
doc
);
if
(
FAILED
(
hr
))
ok
(
hr
==
S_OK
,
"Expected S_OK, got 0x%08x
\n
"
,
hr
);
{
skip
(
"Failed to create XMLDocument instance
\n
"
);
return
;
}
create_xml_file
(
szBankXML
);
create_xml_file
(
szBankXML
);
GetFullPathNameA
(
szBankXML
,
MAX_PATH
,
pathA
,
NULL
);
GetFullPathNameA
(
szBankXML
,
MAX_PATH
,
pathA
,
NULL
);
...
@@ -438,6 +430,123 @@ cleanup:
...
@@ -438,6 +430,123 @@ cleanup:
DeleteFileA
(
"bank.xml"
);
DeleteFileA
(
"bank.xml"
);
}
}
static
void
test_xmlelem_children
(
void
)
{
IXMLDocument
*
doc
=
NULL
;
IXMLElement
*
element
=
NULL
,
*
child
=
NULL
,
*
child2
=
NULL
;
IXMLElementCollection
*
collection
=
NULL
;
VARIANT
vType
,
vName
,
vIndex
;
LONG
length
;
HRESULT
hr
;
hr
=
CoCreateInstance
(
&
CLSID_XMLDocument
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IXMLDocument
,
(
LPVOID
*
)
&
doc
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
V_VT
(
&
vType
)
=
VT_I4
;
V_I4
(
&
vType
)
=
XMLELEMTYPE_ELEMENT
;
V_VT
(
&
vName
)
=
VT_NULL
;
hr
=
IXMLDocument_createElement
(
doc
,
vType
,
vName
,
&
element
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
element
!=
NULL
,
"Expected non-NULL element
\n
"
);
V_VT
(
&
vType
)
=
VT_I4
;
V_I4
(
&
vType
)
=
XMLELEMTYPE_TEXT
;
V_VT
(
&
vName
)
=
VT_NULL
;
hr
=
IXMLDocument_createElement
(
doc
,
vType
,
vName
,
&
child
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
child
!=
NULL
,
"Expected non-NULL child
\n
"
);
V_VT
(
&
vType
)
=
VT_I4
;
V_I4
(
&
vType
)
=
XMLELEMTYPE_TEXT
;
V_VT
(
&
vName
)
=
VT_NULL
;
hr
=
IXMLDocument_createElement
(
doc
,
vType
,
vName
,
&
child2
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
child2
!=
NULL
,
"Expected non-NULL child
\n
"
);
hr
=
IXMLElement_addChild
(
element
,
child
,
0
,
-
1
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXMLElement_get_children
(
element
,
&
collection
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
collection
!=
NULL
,
"Expected non-NULL collection
\n
"
);
length
=
0
;
hr
=
IXMLElementCollection_get_length
(
collection
,
&
length
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
length
==
1
,
"Expected 1, got %08x
\n
"
,
length
);
/* remove/add child and check what happens with collection */
hr
=
IXMLElement_removeChild
(
element
,
child
);
todo_wine
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
length
=
-
1
;
hr
=
IXMLElementCollection_get_length
(
collection
,
&
length
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
todo_wine
ok
(
length
==
0
,
"Expected 0, got %08x
\n
"
,
length
);
IXMLElementCollection_Release
(
collection
);
hr
=
IXMLElement_AddRef
(
child
);
ok
(
hr
==
2
,
"Expected 2, got %08x
\n
"
,
hr
);
IXMLElement_Release
(
child
);
hr
=
IXMLElement_addChild
(
element
,
child
,
0
,
-
1
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXMLElement_AddRef
(
child
);
ok
(
hr
==
2
,
"Expected 2, got %08x
\n
"
,
hr
);
IXMLElement_Release
(
child
);
hr
=
IXMLElement_addChild
(
element
,
child2
,
0
,
-
1
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
hr
=
IXMLElement_get_children
(
element
,
&
collection
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
collection
!=
NULL
,
"Expected non-NULL collection
\n
"
);
hr
=
IXMLElement_AddRef
(
child
);
ok
(
hr
==
2
,
"Expected 2, got %08x
\n
"
,
hr
);
IXMLElement_Release
(
child
);
length
=
0
;
hr
=
IXMLElementCollection_get_length
(
collection
,
&
length
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
length
==
2
,
"Expected 2, got %08x
\n
"
,
length
);
IXMLElement_Release
(
child2
);
length
=
0
;
hr
=
IXMLElementCollection_get_length
(
collection
,
&
length
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
length
==
2
,
"Expected 2, got %08x
\n
"
,
length
);
V_VT
(
&
vIndex
)
=
VT_I4
;
V_I4
(
&
vIndex
)
=
1
;
hr
=
IXMLElementCollection_item
(
collection
,
vIndex
,
vName
,
(
IDispatch
**
)
&
child2
);
ok
(
hr
==
S_OK
,
"Expected S_OK, got %08x
\n
"
,
hr
);
ok
(
child2
!=
NULL
,
"Expected not NULL child
\n
"
);
IXMLElement_Release
(
element
);
IXMLElement_Release
(
child
);
IXMLElementCollection_Release
(
collection
);
IXMLDocument_Release
(
doc
);
}
static
BOOL
test_try_xmldoc
(
void
)
{
IXMLDocument
*
doc
=
NULL
;
HRESULT
hr
;
hr
=
CoCreateInstance
(
&
CLSID_XMLDocument
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IXMLDocument
,
(
LPVOID
*
)
&
doc
);
if
(
FAILED
(
hr
))
{
skip
(
"Failed to create XMLDocument instance
\n
"
);
return
FALSE
;
}
IXMLDocument_Release
(
doc
);
return
TRUE
;
}
START_TEST
(
xmlelem
)
START_TEST
(
xmlelem
)
{
{
HRESULT
hr
;
HRESULT
hr
;
...
@@ -445,8 +554,15 @@ START_TEST(xmlelem)
...
@@ -445,8 +554,15 @@ START_TEST(xmlelem)
hr
=
CoInitialize
(
NULL
);
hr
=
CoInitialize
(
NULL
);
ok
(
hr
==
S_OK
,
"failed to init com
\n
"
);
ok
(
hr
==
S_OK
,
"failed to init com
\n
"
);
if
(
!
test_try_xmldoc
())
{
CoUninitialize
();
return
;
}
test_xmlelem
();
test_xmlelem
();
test_xmlelem_collection
();
test_xmlelem_collection
();
test_xmlelem_children
();
CoUninitialize
();
CoUninitialize
();
}
}
dlls/msxml3/xmldoc.c
View file @
5afdfaba
...
@@ -54,7 +54,6 @@ typedef struct _xmldoc
...
@@ -54,7 +54,6 @@ typedef struct _xmldoc
HRESULT
error
;
HRESULT
error
;
/* IXMLDocument */
/* IXMLDocument */
IXMLElement
*
root
;
xmlDocPtr
xmldoc
;
xmlDocPtr
xmldoc
;
/* IPersistStream */
/* IPersistStream */
...
@@ -198,17 +197,19 @@ static HRESULT WINAPI xmldoc_Invoke(IXMLDocument *iface, DISPID dispIdMember,
...
@@ -198,17 +197,19 @@ static HRESULT WINAPI xmldoc_Invoke(IXMLDocument *iface, DISPID dispIdMember,
static
HRESULT
WINAPI
xmldoc_get_root
(
IXMLDocument
*
iface
,
IXMLElement
**
p
)
static
HRESULT
WINAPI
xmldoc_get_root
(
IXMLDocument
*
iface
,
IXMLElement
**
p
)
{
{
xmldoc
*
This
=
impl_from_IXMLDocument
(
iface
);
xmldoc
*
This
=
impl_from_IXMLDocument
(
iface
);
xmlNodePtr
root
;
TRACE
(
"(%p, %p)
\n
"
,
iface
,
p
);
TRACE
(
"(%p, %p)
\n
"
,
iface
,
p
);
if
(
!
p
)
if
(
!
p
)
return
E_INVALIDARG
;
return
E_INVALIDARG
;
*
p
=
This
->
root
;
*
p
=
NULL
;
if
(
!*
p
)
if
(
!
(
root
=
xmlDocGetRootElement
(
This
->
xmldoc
)))
return
E_FAIL
;
return
E_FAIL
;
return
S_OK
;
return
XMLElement_create
((
IUnknown
*
)
This
,
root
,
(
LPVOID
*
)
p
)
;
}
}
static
HRESULT
WINAPI
xmldoc_get_fileSize
(
IXMLDocument
*
iface
,
BSTR
*
p
)
static
HRESULT
WINAPI
xmldoc_get_fileSize
(
IXMLDocument
*
iface
,
BSTR
*
p
)
...
@@ -604,7 +605,6 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
...
@@ -604,7 +605,6 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
IPersistStreamInit
*
iface
,
LPSTREAM
pStm
)
IPersistStreamInit
*
iface
,
LPSTREAM
pStm
)
{
{
xmldoc
*
This
=
impl_from_IPersistStreamInit
(
iface
);
xmldoc
*
This
=
impl_from_IPersistStreamInit
(
iface
);
xmlNodePtr
xmlnode
;
HRESULT
hr
;
HRESULT
hr
;
HGLOBAL
hglobal
;
HGLOBAL
hglobal
;
DWORD
read
,
written
,
len
;
DWORD
read
,
written
,
len
;
...
@@ -653,9 +653,7 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
...
@@ -653,9 +653,7 @@ static HRESULT WINAPI xmldoc_IPersistStreamInit_Load(
return
E_FAIL
;
return
E_FAIL
;
}
}
if
(
This
->
root
)
IXMLElement_Release
(
This
->
root
);
return
S_OK
;
xmlnode
=
xmlDocGetRootElement
(
This
->
xmldoc
);
return
XMLElement_create
((
IUnknown
*
)
This
,
xmlnode
,
(
LPVOID
*
)
&
This
->
root
);
}
}
static
HRESULT
WINAPI
xmldoc_IPersistStreamInit_Save
(
static
HRESULT
WINAPI
xmldoc_IPersistStreamInit_Save
(
...
@@ -708,7 +706,6 @@ HRESULT XMLDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
...
@@ -708,7 +706,6 @@ HRESULT XMLDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
doc
->
lpvtblIPersistStreamInit
=
&
xmldoc_IPersistStreamInit_VTable
;
doc
->
lpvtblIPersistStreamInit
=
&
xmldoc_IPersistStreamInit_VTable
;
doc
->
ref
=
1
;
doc
->
ref
=
1
;
doc
->
error
=
S_OK
;
doc
->
error
=
S_OK
;
doc
->
root
=
NULL
;
doc
->
xmldoc
=
NULL
;
doc
->
xmldoc
=
NULL
;
doc
->
stream
=
NULL
;
doc
->
stream
=
NULL
;
...
...
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