bug 203836 - changes impl of addref/release for default sopa encoeding so they don't inherit the model for gnereal encodings, also changes some class names

r=rayw sr=jst a=asa
This commit is contained in:
jgaunt%netscape.com 2003-05-08 22:43:39 +00:00
parent 91224d0244
commit 8d04276ced
7 changed files with 71 additions and 40 deletions

View File

@ -59,7 +59,7 @@
#include "nsWebScriptsAccess.h" #include "nsWebScriptsAccess.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Define the contructor function for the objects // Define the constructor function for the objects
// //
// NOTE: This creates an instance of objects by using the default constructor // NOTE: This creates an instance of objects by using the default constructor
// //
@ -73,8 +73,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPEncoding)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPFault) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPFault)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPHeaderBlock) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPHeaderBlock)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPParameter) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPParameter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultSOAPEncoder_1_1) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultSOAPEncoding_1_1)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultSOAPEncoder_1_2) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultSOAPEncoding_1_2)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSOAPTransport) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSOAPTransport)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSSOAPTransport) NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSSOAPTransport)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPPropertyBagMutator) NS_GENERIC_FACTORY_CONSTRUCTOR(nsSOAPPropertyBagMutator)
@ -276,12 +276,12 @@ static const nsModuleComponentInfo gComponents[] = {
NS_CI_INTERFACE_GETTER_NAME(nsSOAPParameter), NS_CI_INTERFACE_GETTER_NAME(nsSOAPParameter),
nsnull, &NS_CLASSINFO_NAME(nsSOAPParameter), nsnull, &NS_CLASSINFO_NAME(nsSOAPParameter),
nsIClassInfo::DOM_OBJECT }, nsIClassInfo::DOM_OBJECT },
{ "Default SOAP 1.1 Encoder", NS_DEFAULTSOAPENCODER_1_1_CID, { "Default SOAP 1.1 Encoding", NS_DEFAULTSOAPENCODING_1_1_CID,
NS_DEFAULTSOAPENCODER_1_1_CONTRACTID, NS_DEFAULTSOAPENCODING_1_1_CONTRACTID,
nsDefaultSOAPEncoder_1_1Constructor }, nsDefaultSOAPEncoding_1_1Constructor },
{ "Default SOAP 1.2 Encoder", NS_DEFAULTSOAPENCODER_1_2_CID, { "Default SOAP 1.2 Encoding", NS_DEFAULTSOAPENCODING_1_2_CID,
NS_DEFAULTSOAPENCODER_1_2_CONTRACTID, NS_DEFAULTSOAPENCODING_1_2_CONTRACTID,
nsDefaultSOAPEncoder_1_2Constructor }, nsDefaultSOAPEncoding_1_2Constructor },
{ "HTTP SOAP Transport", NS_HTTPSOAPTRANSPORT_CID, { "HTTP SOAP Transport", NS_HTTPSOAPTRANSPORT_CID,
NS_HTTPSOAPTRANSPORT_CONTRACTID, NS_HTTPSOAPTRANSPORT_CONTRACTID,
nsHTTPSOAPTransportConstructor, nsnull, nsnull, nsnull, nsHTTPSOAPTransportConstructor, nsnull, nsnull, nsnull,

View File

@ -297,16 +297,16 @@ interface nsISOAPEncoding : nsISupports {
"@mozilla.org/xmlextras/soap/encoding;1" "@mozilla.org/xmlextras/soap/encoding;1"
#define NS_SOAPENCODING_CONTRACTID_PREFIX \ #define NS_SOAPENCODING_CONTRACTID_PREFIX \
NS_SOAPENCODING_CONTRACTID "?uri=" NS_SOAPENCODING_CONTRACTID "?uri="
#define NS_DEFAULTSOAPENCODER_1_1_CID \ #define NS_DEFAULTSOAPENCODING_1_1_CID \
{ /* 06fb035c-1dd2-11b2-bc30-f6d8e314d6b9 */ \ { /* 06fb035c-1dd2-11b2-bc30-f6d8e314d6b9 */ \
0x06fb035c, 0x1dd2, 0x11b2, \ 0x06fb035c, 0x1dd2, 0x11b2, \
{0xbc, 0x30, 0xf6, 0xd8, 0xe3, 0x14, 0xd6, 0xb9} } {0xbc, 0x30, 0xf6, 0xd8, 0xe3, 0x14, 0xd6, 0xb9} }
#define NS_DEFAULTSOAPENCODER_1_1_CONTRACTID \ #define NS_DEFAULTSOAPENCODING_1_1_CONTRACTID \
NS_SOAPENCODING_CONTRACTID_PREFIX "http://schemas.xmlsoap.org/soap/encoding/" NS_SOAPENCODING_CONTRACTID_PREFIX "http://schemas.xmlsoap.org/soap/encoding/"
#define NS_DEFAULTSOAPENCODER_1_2_CID \ #define NS_DEFAULTSOAPENCODING_1_2_CID \
{ /* e0ee4044-1dd1-11b2-9d7e-8899d4d89648 */ \ { /* e0ee4044-1dd1-11b2-9d7e-8899d4d89648 */ \
0xe0ee4044, 0x1dd1, 0x11b2, \ 0xe0ee4044, 0x1dd1, 0x11b2, \
{0x9d, 0x7e, 0x88, 0x99, 0xd4, 0xd8, 0x96, 0x48} } {0x9d, 0x7e, 0x88, 0x99, 0xd4, 0xd8, 0x96, 0x48} }
#define NS_DEFAULTSOAPENCODER_1_2_CONTRACTID \ #define NS_DEFAULTSOAPENCODING_1_2_CONTRACTID \
NS_SOAPENCODING_CONTRACTID_PREFIX "http://www.w3.org/2001/09/soap-encoding" NS_SOAPENCODING_CONTRACTID_PREFIX "http://www.w3.org/2001/09/soap-encoding"
%} %}

View File

@ -128,6 +128,12 @@ static NS_NAMED_LITERAL_STRING(kNonNegativeIntegerSchemaType,
"nonNegativeInteger"); "nonNegativeInteger");
static NS_NAMED_LITERAL_STRING(kPositiveIntegerSchemaType, "positiveInteger"); static NS_NAMED_LITERAL_STRING(kPositiveIntegerSchemaType, "positiveInteger");
#define MAX_ARRAY_DIMENSIONS 100
//
// Macros to declare and implement the default encoder classes
//
#define DECLARE_ENCODER(name) \ #define DECLARE_ENCODER(name) \
class ns##name##Encoder : \ class ns##name##Encoder : \
public nsISOAPEncoder, \ public nsISOAPEncoder, \
@ -178,6 +184,7 @@ ns##name##Encoder::~ns##name##Encoder() {}
SetEncoder(encodingKey, handler); \ SetEncoder(encodingKey, handler); \
SetDecoder(encodingKey, handler); \ SetDecoder(encodingKey, handler); \
} }
#define REGISTER_SCHEMA_ENCODER(name) REGISTER_ENCODER(name,Schema,nsSOAPUtils::kXSURI) #define REGISTER_SCHEMA_ENCODER(name) REGISTER_ENCODER(name,Schema,nsSOAPUtils::kXSURI)
#define REGISTER_SOAP_ENCODER(name) REGISTER_ENCODER(name,SOAP,nsSOAPUtils::kSOAPEncURI) #define REGISTER_SOAP_ENCODER(name) REGISTER_ENCODER(name,SOAP,nsSOAPUtils::kSOAPEncURI)
@ -202,11 +209,17 @@ ns##name##Encoder::~ns##name##Encoder() {}
REGISTER_SCHEMA_ENCODER(UnsignedLong)\ REGISTER_SCHEMA_ENCODER(UnsignedLong)\
REGISTER_SCHEMA_ENCODER(UnsignedInt)\ REGISTER_SCHEMA_ENCODER(UnsignedInt)\
REGISTER_SCHEMA_ENCODER(UnsignedShort)\ REGISTER_SCHEMA_ENCODER(UnsignedShort)\
REGISTER_SCHEMA_ENCODER(UnsignedByte)\ REGISTER_SCHEMA_ENCODER(UnsignedByte)
nsDefaultSOAPEncoder_1_1::nsDefaultSOAPEncoder_1_1() : nsSOAPEncoding(nsSOAPUtils::kSOAPEncURI11, //
nsnull, // Default SOAP Encodings
nsnull) //
NS_IMPL_ADDREF(nsDefaultSOAPEncoding_1_1)
NS_IMPL_RELEASE(nsDefaultSOAPEncoding_1_1)
nsDefaultSOAPEncoding_1_1::nsDefaultSOAPEncoding_1_1()
: nsSOAPEncoding(nsSOAPUtils::kSOAPEncURI11, nsnull, nsnull)
{ {
PRUint16 version = nsISOAPMessage::VERSION_1_1; PRUint16 version = nsISOAPMessage::VERSION_1_1;
PRBool result; PRBool result;
@ -216,9 +229,11 @@ nsDefaultSOAPEncoder_1_1::nsDefaultSOAPEncoder_1_1() : nsSOAPEncoding(nsSOAPUtil
REGISTER_ENCODERS REGISTER_ENCODERS
} }
nsDefaultSOAPEncoder_1_2::nsDefaultSOAPEncoder_1_2() : nsSOAPEncoding(nsSOAPUtils::kSOAPEncURI, NS_IMPL_ADDREF(nsDefaultSOAPEncoding_1_2)
nsnull, NS_IMPL_RELEASE(nsDefaultSOAPEncoding_1_2)
nsnull)
nsDefaultSOAPEncoding_1_2::nsDefaultSOAPEncoding_1_2()
: nsSOAPEncoding(nsSOAPUtils::kSOAPEncURI, nsnull, nsnull)
{ {
PRUint16 version = nsISOAPMessage::VERSION_1_2; PRUint16 version = nsISOAPMessage::VERSION_1_2;
PRBool result; PRBool result;
@ -228,7 +243,9 @@ nsDefaultSOAPEncoder_1_2::nsDefaultSOAPEncoder_1_2() : nsSOAPEncoding(nsSOAPUtil
REGISTER_ENCODERS REGISTER_ENCODERS
} }
// Here is the implementation of the encoders. //
// Default Encoders -- static helper functions intermixed
//
// Getting the immediate supertype of any type // Getting the immediate supertype of any type
static nsresult GetSupertype(nsISOAPEncoding * aEncoding, nsISchemaType* aType, nsISchemaType** _retval) static nsresult GetSupertype(nsISOAPEncoding * aEncoding, nsISchemaType* aType, nsISchemaType** _retval)
@ -1036,17 +1053,23 @@ NS_IMETHODIMP
return rc; return rc;
// We still have to fake this one, because there is no any simple type in schema. // We still have to fake this one, because there is no any simple type in schema.
if (aName.IsEmpty() && !aSchemaType) { if (aName.IsEmpty() && !aSchemaType) {
return EncodeSimpleValue(aEncoding, value, return EncodeSimpleValue(aEncoding,
nsSOAPUtils::kSOAPEncURI, kAnySimpleTypeSchemaType, aSchemaType, aDestination, value,
nsSOAPUtils::kSOAPEncURI,
kAnySimpleTypeSchemaType,
aSchemaType,
aDestination,
aReturnValue); aReturnValue);
} }
return EncodeSimpleValue(aEncoding, value, return EncodeSimpleValue(aEncoding,
aNamespaceURI, aName, aSchemaType, aDestination, value,
aNamespaceURI,
aName,
aSchemaType,
aDestination,
aReturnValue); aReturnValue);
} }
#define MAX_ARRAY_DIMENSIONS 100
/** /**
* Recursive method used by array encoding which counts the sizes of the specified dimensions * Recursive method used by array encoding which counts the sizes of the specified dimensions
* and does a very primitive determination whether all the members of the array are of a single * and does a very primitive determination whether all the members of the array are of a single

View File

@ -36,19 +36,29 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifndef nsDefaultSOAPEncoder_h__ #ifndef nsDefaultSOAPEncoding_h__
#define nsDefaultSOAPEncoder_h__ #define nsDefaultSOAPEncoding_h__
#include "nsSOAPEncoding.h" #include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder_1_1:public nsSOAPEncoding { class nsDefaultSOAPEncoding_1_1:public nsSOAPEncoding {
public: public:
nsDefaultSOAPEncoder_1_1();
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
nsDefaultSOAPEncoding_1_1();
virtual ~nsDefaultSOAPEncoding_1_1() {}
}; };
class nsDefaultSOAPEncoder_1_2:public nsSOAPEncoding { class nsDefaultSOAPEncoding_1_2:public nsSOAPEncoding {
public: public:
nsDefaultSOAPEncoder_1_2();
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
nsDefaultSOAPEncoding_1_2();
virtual ~nsDefaultSOAPEncoding_1_2() {}
}; };
#endif #endif

View File

@ -58,7 +58,7 @@
static PRBool PR_CALLBACK static PRBool PR_CALLBACK
DeleteEncodingEntry(nsHashKey *aKey, void *aData, void *aClosure) DeleteEncodingEntry(nsHashKey *aKey, void *aData, void *aClosure)
{ {
NS_DELETEXPCOM(aData); NS_DELETEXPCOM((nsISOAPEncoding*)aData);
return PR_TRUE; return PR_TRUE;
} }
@ -73,7 +73,7 @@ nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding *aEncoding)
: mEncodings(nsnull, nsnull, DeleteEncodingEntry, nsnull, 4) : mEncodings(nsnull, nsnull, DeleteEncodingEntry, nsnull, 4)
{ {
nsAutoString style; nsAutoString style;
nsresult rc = aEncoding->GetStyleURI(style); aEncoding->GetStyleURI(style);
NS_ASSERTION(!style.IsEmpty(), "nsSOAPEncoding Regsitry constructed without style"); NS_ASSERTION(!style.IsEmpty(), "nsSOAPEncoding Regsitry constructed without style");
nsStringKey styleKey(style); nsStringKey styleKey(style);
@ -177,7 +177,7 @@ nsSOAPEncoding::nsSOAPEncoding() : mEncoders(),
{ {
mStyleURI.Assign(nsSOAPUtils::kSOAPEncURI11); mStyleURI.Assign(nsSOAPUtils::kSOAPEncURI11);
mRegistry = new nsSOAPEncodingRegistry(this); mRegistry = new nsSOAPEncodingRegistry(this);
mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODER_1_1_CONTRACTID); mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODING_1_1_CONTRACTID);
} }
nsSOAPEncoding::nsSOAPEncoding(const nsAString & aStyleURI, nsSOAPEncoding::nsSOAPEncoding(const nsAString & aStyleURI,

View File

@ -36,8 +36,8 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#ifndef nsSOAPEncodingRegistry_h__ #ifndef nsSOAPEncoding_h__
#define nsSOAPEncodingRegistry_h__ #define nsSOAPEncoding_h__
#include "nsString.h" #include "nsString.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
@ -47,7 +47,6 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsISchema.h" #include "nsISchema.h"
#include "nsWeakReference.h"
// Notes regarding the ownership model between the nsSOAPEncoding (encoding) // Notes regarding the ownership model between the nsSOAPEncoding (encoding)
// and the nsSOAPEncodingRegsitry (registry). To avoid cyclic referencing // and the nsSOAPEncodingRegsitry (registry). To avoid cyclic referencing

View File

@ -43,7 +43,6 @@
#include "nsSOAPMessage.h" #include "nsSOAPMessage.h"
#include "nsSOAPParameter.h" #include "nsSOAPParameter.h"
#include "nsSOAPHeaderBlock.h" #include "nsSOAPHeaderBlock.h"
#include "nsSOAPEncoding.h"
#include "nsSOAPException.h" #include "nsSOAPException.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMAttr.h" #include "nsIDOMAttr.h"