1999-05-11 00:46:31 +04:00
|
|
|
// Test02.cpp
|
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
#include "nsINode.h"
|
1999-05-11 00:46:31 +04:00
|
|
|
#include "nsCOMPtr.h"
|
2002-02-12 07:12:50 +03:00
|
|
|
#include "nsString.h"
|
1999-05-11 00:46:31 +04:00
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
NS_DEF_PTR(nsINode);
|
1999-05-11 00:46:31 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
This test file compares the generated code size of similar functions
|
2002-02-12 07:12:50 +03:00
|
|
|
between raw COM interface pointers (|AddRef|ing and |Release|ing by hand) and
|
|
|
|
|nsCOMPtr|s.
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
Function size results were determined by examining dissassembly of the
|
|
|
|
generated code. mXXX is the size of the generated code on the Macintosh. wXXX
|
|
|
|
is the size on Windows. For these tests, all reasonable optimizations were
|
|
|
|
enabled and exceptions were disabled (just as we build for release).
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
The tests in this file explore more complicated functionality: assigning
|
2002-02-12 07:12:50 +03:00
|
|
|
a pointer to be reference counted into a [raw, nsCOMPtr] object using
|
1999-05-11 00:46:31 +04:00
|
|
|
|QueryInterface|; ensuring that it is |AddRef|ed and |Release|d
|
|
|
|
appropriately; calling through the pointer to a function supplied by the
|
|
|
|
underlying COM interface. The tests in this file expand on the tests in
|
|
|
|
"Test01.cpp" by adding |QueryInterface|.
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
Windows:
|
|
|
|
raw01
|
|
|
|
52 nsCOMPtr 63 raw
|
|
|
|
66 nsCOMPtr* 68
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
Macintosh:
|
|
|
|
nsCOMPtr 120 (1.0000) Raw01
|
|
|
|
128 (1.1429) i.e., 14.29% bigger than nsCOMPtr Raw00
|
|
|
|
144 (1.2000)
|
|
|
|
*/
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
void // nsresult
|
|
|
|
Test02_Raw00(nsISupports* aDOMNode, nsString* aResult)
|
|
|
|
// m144, w66
|
|
|
|
{
|
|
|
|
// -- the following code is assumed, but is commented out so we compare only
|
|
|
|
// the relevent generated code
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
// if ( !aDOMNode )
|
|
|
|
// return NS_ERROR_NULL_POINTER;
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
nsINode* node = 0;
|
|
|
|
nsresult status =
|
|
|
|
aDOMNode->QueryInterface(NS_GET_IID(nsINode), (void**)&node);
|
1999-05-11 00:46:31 +04:00
|
|
|
if (NS_SUCCEEDED(status)) {
|
|
|
|
node->GetNodeName(*aResult);
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
NS_IF_RELEASE(node);
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
// return status;
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
void // nsresult
|
|
|
|
Test02_Raw01(nsISupports* aDOMNode, nsString* aResult)
|
|
|
|
// m128, w52
|
|
|
|
{
|
|
|
|
// if ( !aDOMNode )
|
|
|
|
// return NS_ERROR_NULL_POINTER;
|
2018-12-14 21:10:35 +03:00
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
nsINode* node;
|
|
|
|
nsresult status =
|
|
|
|
aDOMNode->QueryInterface(NS_GET_IID(nsINode), (void**)&node);
|
1999-05-11 00:46:31 +04:00
|
|
|
if (NS_SUCCEEDED(status)) {
|
|
|
|
node->GetNodeName(*aResult);
|
|
|
|
NS_RELEASE(node);
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
// return status;
|
|
|
|
}
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
void // nsresult
|
|
|
|
Test02_nsCOMPtr(nsISupports* aDOMNode, nsString* aResult)
|
|
|
|
// m120, w63/68
|
|
|
|
{
|
|
|
|
nsresult status;
|
2018-05-30 05:58:49 +03:00
|
|
|
nsCOMPtr<nsINode> node = do_QueryInterface(aDOMNode, &status);
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
if (node) node->GetNodeName(*aResult);
|
2018-12-14 21:10:35 +03:00
|
|
|
|
1999-05-11 00:46:31 +04:00
|
|
|
// return status;
|
|
|
|
}
|