mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Make sure to resolve place-holder-array-type. b=192141, r=rayw@netscape.com, sr=vidur@netscape.com.
The target namespace on <schema> should be applied to <element> if and only if <element> is qualified. b=192972. r=rayw@netscape.com, sr=jst@netscape.com. Fixed a few warnings. *** NOT PART OF THE BUILD ***
This commit is contained in:
parent
6e09733f45
commit
457256436b
@ -40,36 +40,6 @@
|
||||
|
||||
#include "wspprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
// SetException sets a global exception representing the given nsresult. It
|
||||
// is guaranteed to also return that nsresult. It is to be used when failing.
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// if (NS_FAILED(rv)) {
|
||||
// return SetException(rv, "got foo, expected bar", someOptionalObject);
|
||||
// }
|
||||
//
|
||||
|
||||
static nsresult SetException(nsresult aStatus, const char* aMsg,
|
||||
nsISupports* aData)
|
||||
{
|
||||
nsCOMPtr<nsIException> exception = new WSPException(aStatus, aMsg, aData);
|
||||
if (exception) {
|
||||
nsCOMPtr<nsIExceptionService> xs =
|
||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
||||
if (xs) {
|
||||
nsCOMPtr<nsIExceptionManager> xm;
|
||||
xs->GetCurrentExceptionManager(getter_AddRefs(xm));
|
||||
if (xm) {
|
||||
xm->SetCurrentException(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// IIDX is used as a way to hold and share our commone set of interface indexes.
|
||||
|
||||
@ -106,15 +76,15 @@ private:
|
||||
MAX_TOTAL = 255}; // The typelib format limits us to 255 params.
|
||||
|
||||
public:
|
||||
PRUint16 GetCount() const {return mCount;}
|
||||
PRUint16 GetCount() const {return mCount;}
|
||||
XPTParamDescriptor* GetArray() {return mArray;}
|
||||
void Clear() {mCount = 0;}
|
||||
|
||||
XPTParamDescriptor* GetNextParam();
|
||||
|
||||
ParamAccumulator()
|
||||
: mArray(mBuiltinSpace), mCount(0), mAvailable(MAX_BUILTIN) {}
|
||||
~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;}
|
||||
ParamAccumulator()
|
||||
: mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace) {}
|
||||
~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;}
|
||||
private:
|
||||
PRUint16 mCount;
|
||||
PRUint16 mAvailable;
|
||||
@ -257,10 +227,9 @@ static void BuildInterfaceName(const nsAString& qualifier,
|
||||
const nsAString& uri,
|
||||
nsACString& aCIdentifier)
|
||||
{
|
||||
nsCAutoString temp;
|
||||
WSPFactory::XML2C(qualifier, temp);
|
||||
aCIdentifier.Assign(temp);
|
||||
WSPFactory::XML2C(qualifier, aCIdentifier);
|
||||
|
||||
nsCAutoString temp;
|
||||
WSPFactory::XML2C(name, temp);
|
||||
aCIdentifier.Append(temp);
|
||||
|
||||
@ -625,7 +594,8 @@ static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (compositor != nsISchemaModelGroup::COMPOSITOR_SEQUENCE) {
|
||||
if (compositor == nsISchemaModelGroup::COMPOSITOR_CHOICE) {
|
||||
// CHOICE not supported
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
||||
// WSDL includes
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsIWSDLLoader.h"
|
||||
#include "nsIWSDLSoapBinding.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
// iix includes
|
||||
#include "nsIGenericInterfaceInfoSet.h"
|
||||
|
@ -47,19 +47,11 @@
|
||||
const PRUint8 sInt8Val = 2;
|
||||
const PRInt16 sInt16Val = 0x1234;
|
||||
const PRInt32 sInt32Val = 0x12345678;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
const PRInt64 sInt64Val = 0x1234567887654321;
|
||||
#else
|
||||
const PRInt64 sInt64Val = {0x12345678, 0x87654321};
|
||||
#endif
|
||||
const PRInt64 sInt64Val = LL_INIT(0x12345678, 0x87654321);
|
||||
const PRUint8 sUint8Val = 2;
|
||||
const PRUint16 sUint16Val = 0x1234;
|
||||
const PRUint32 sUint32Val = 0x12345678;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
const PRUint64 sUint64Val = 0x1234567887654321;
|
||||
#else
|
||||
const PRUint64 sUint64Val = {0x12345678, 0x87654321};
|
||||
#endif
|
||||
const PRUint64 sUint64Val = LL_INIT(0x12345678, 0x87654321);
|
||||
const PRBool sBoolVal = PR_TRUE;
|
||||
const float sFloatVal = 0.0;
|
||||
const double sDoubleVal = 0.03;
|
||||
|
@ -67,6 +67,7 @@ interface nsISchemaComponent : nsISupports {
|
||||
|
||||
[scriptable, uuid(3c14a021-6f4e-11d5-9b46-000064657374)]
|
||||
interface nsISchema : nsISchemaComponent {
|
||||
/* Is this necessary? */
|
||||
readonly attribute AString schemaNamespace;
|
||||
|
||||
readonly attribute PRUint32 typeCount;
|
||||
|
@ -29,11 +29,25 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchema::nsSchema(nsISchemaCollection* aCollection,
|
||||
const nsAString& aTargetNamespace,
|
||||
const nsAString& aSchemaNamespace)
|
||||
: mTargetNamespace(aTargetNamespace), mSchemaNamespace(aSchemaNamespace)
|
||||
nsIDOMElement* aSchemaElement)
|
||||
{
|
||||
mCollection = aCollection; // Weak reference
|
||||
|
||||
if (aSchemaElement) {
|
||||
aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("targetNamespace"),
|
||||
mTargetNamespace);
|
||||
mTargetNamespace.Trim(" \r\n\t");
|
||||
aSchemaElement->GetNamespaceURI(mSchemaNamespace);
|
||||
|
||||
nsAutoString elementFormDefault;
|
||||
aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("elementFormDefault"),
|
||||
elementFormDefault);
|
||||
elementFormDefault.Trim(" \r\n\t");
|
||||
mElementFormQualified =
|
||||
elementFormDefault.Equals(NS_LITERAL_STRING("qualified"));
|
||||
}
|
||||
}
|
||||
|
||||
nsSchema::~nsSchema()
|
||||
|
@ -115,6 +115,32 @@ nsSchemaComplexType::Resolve()
|
||||
}
|
||||
}
|
||||
|
||||
if (mArrayInfo) {
|
||||
nsCOMPtr<nsISchemaType> placeHolder;
|
||||
mArrayInfo->GetType(getter_AddRefs(placeHolder));
|
||||
if (placeHolder) {
|
||||
PRUint16 schemaType;
|
||||
placeHolder->GetSchemaType(&schemaType);
|
||||
if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
|
||||
rv = mSchema->ResolveTypePlaceholder(placeHolder, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = type->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
SetArrayInfo(type, mArrayInfo->GetDimension());
|
||||
}
|
||||
else {
|
||||
rv = placeHolder->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -963,26 +963,21 @@ static PRUint32 kSchemaNamespacesLength = sizeof(kSchemaNamespaces) / sizeof(con
|
||||
|
||||
/* nsISchema processSchemaElement (in nsIDOMElement element); */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element,
|
||||
nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement,
|
||||
nsISchema **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(element);
|
||||
NS_ENSURE_ARG(aElement);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get target namespace and create the schema instance
|
||||
nsAutoString targetNamespace, schemaNamespace;
|
||||
element->GetAttribute(NS_LITERAL_STRING("targetNamespace"),
|
||||
targetNamespace);
|
||||
element->GetNamespaceURI(schemaNamespace);
|
||||
nsSchema* schemaInst = new nsSchema(this, targetNamespace, schemaNamespace);
|
||||
nsSchema* schemaInst = new nsSchema(this, aElement);
|
||||
nsCOMPtr<nsISchema> schema = schemaInst;
|
||||
if (!schema) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsChildElementIterator iterator(element,
|
||||
nsChildElementIterator iterator(aElement,
|
||||
kSchemaNamespaces, kSchemaNamespacesLength);
|
||||
nsCOMPtr<nsIDOMElement> childElement;
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
@ -1056,6 +1051,8 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString targetNamespace;
|
||||
schema->GetTargetNamespace(targetNamespace);
|
||||
nsStringKey key(targetNamespace);
|
||||
mSchemas.Put(&key, schema);
|
||||
|
||||
@ -1164,11 +1161,18 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema,
|
||||
elementRef->SetMaxOccurs(maxOccurs);
|
||||
}
|
||||
else {
|
||||
nsAutoString name;
|
||||
nsAutoString value;
|
||||
nsSchemaElement* elementInst;
|
||||
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
elementInst = new nsSchemaElement(aSchema, name);
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("name"),
|
||||
value);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
value.Trim(" \r\n\t");
|
||||
elementInst = new nsSchemaElement(aSchema, value);
|
||||
if (!elementInst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -1178,15 +1182,82 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema,
|
||||
elementInst->SetMaxOccurs(maxOccurs);
|
||||
|
||||
nsAutoString defaultValue, fixedValue;
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("default"), defaultValue);
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("fixed"), fixedValue);
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("default"),
|
||||
defaultValue);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("fixed"),
|
||||
fixedValue);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
elementInst->SetConstraints(defaultValue, fixedValue);
|
||||
|
||||
nsAutoString nillable, abstract;
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("nillable"), nillable);
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("abstract"), abstract);
|
||||
elementInst->SetFlags(nillable.Equals(NS_LITERAL_STRING("true")),
|
||||
abstract.Equals(NS_LITERAL_STRING("true")));
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("nillable"), value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
value.Trim(" \r\n\t");
|
||||
|
||||
PRInt32 flags = 0;
|
||||
if (value.Equals(NS_LITERAL_STRING("true")))
|
||||
flags |= nsSchemaElement::NILLABLE;
|
||||
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("abstract"), value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
value.Trim(" \r\n\t");
|
||||
|
||||
if (value.Equals(NS_LITERAL_STRING("true")))
|
||||
flags |= nsSchemaElement::ABSTRACT;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = aElement->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
parent->GetLocalName(value);
|
||||
|
||||
// Check if the schema element's targetNamespace applies to <element>.
|
||||
// Note: If the <element> element information item has <schema> as its
|
||||
// parent,then the actual value of the targetNamespace is that of the
|
||||
// parent <schema> element information item, or absent if there is
|
||||
// none. Otherwise if the <element> element information item has
|
||||
// <schema> element as an ancestor then if "form" is present and its actual
|
||||
// value is qualified, or if "form" is absent and the actual value of
|
||||
// elementFormDefault on the <schema> ancestor is qualified, then the
|
||||
// actual value of the targetNamespace [attribute] is that of the ancestor
|
||||
// <schema> element information item, or absent if there is none.
|
||||
if (value.Equals(NS_LITERAL_STRING("schema"))) {
|
||||
flags |= nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
else {
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("form"),
|
||||
value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
value.Trim(" \r\n\t");
|
||||
if (value.IsEmpty()) {
|
||||
if (aSchema->IsElementFormQualified()) {
|
||||
flags |= nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
else {
|
||||
flags &= ~nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
}
|
||||
else if (value.Equals(NS_LITERAL_STRING("qualified"))) {
|
||||
flags |= nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
else {
|
||||
flags &= ~nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
elementInst->SetFlags(flags);
|
||||
|
||||
nsCOMPtr<nsISchemaType> schemaType;
|
||||
nsAutoString typeStr;
|
||||
|
@ -486,8 +486,7 @@ nsSchemaAnyParticle::SetNamespace(const nsAString& aNamespace)
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElement::nsSchemaElement(nsSchema* aSchema,
|
||||
const nsAString& aName)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName),
|
||||
mNillable(PR_FALSE), mAbstract(PR_FALSE)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName), mFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -595,7 +594,7 @@ nsSchemaElement::GetNillable(PRBool *aNillable)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNillable);
|
||||
|
||||
*aNillable = mNillable;
|
||||
*aNillable = mFlags & nsSchemaElement::NILLABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -606,7 +605,7 @@ nsSchemaElement::GetAbstract(PRBool *aAbstract)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAbstract);
|
||||
|
||||
*aAbstract = mAbstract;
|
||||
*aAbstract = mFlags & nsSchemaElement::ABSTRACT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -632,11 +631,19 @@ nsSchemaElement::SetConstraints(const nsAString& aDefaultValue,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaElement::SetFlags(PRBool aNillable, PRBool aAbstract)
|
||||
nsSchemaElement::SetFlags(PRInt32 aFlags)
|
||||
{
|
||||
mNillable = aNillable;
|
||||
mAbstract = aAbstract;
|
||||
mFlags = aFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaElement::GetTargetNamespace(nsAString& aTargetNamespace)
|
||||
{
|
||||
if ((mFlags & nsSchemaElement::FORM_QUALIFIED) && mSchema) {
|
||||
return mSchema->GetTargetNamespace(aTargetNamespace);
|
||||
}
|
||||
aTargetNamespace.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#define NS_SCHEMA_2001_NAMESPACE "http://www.w3.org/2001/XMLSchema"
|
||||
#define NS_SCHEMA_1999_NAMESPACE "http://www.w3.org/1999/XMLSchema"
|
||||
@ -42,9 +43,7 @@
|
||||
class nsSchema : public nsISchema
|
||||
{
|
||||
public:
|
||||
nsSchema(nsISchemaCollection* aCollection,
|
||||
const nsAString& aTargetNamespace,
|
||||
const nsAString& aSchemaNamespace);
|
||||
nsSchema(nsISchemaCollection* aCollection, nsIDOMElement* aElement);
|
||||
virtual ~nsSchema();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -59,6 +58,7 @@ public:
|
||||
void DropCollectionReference();
|
||||
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
|
||||
nsISchemaType** aType);
|
||||
PRBool IsElementFormQualified() { return mElementFormQualified; }
|
||||
|
||||
protected:
|
||||
nsString mTargetNamespace;
|
||||
@ -74,6 +74,7 @@ protected:
|
||||
nsSupportsArray mModelGroups;
|
||||
nsSupportsHashtable mModelGroupsHash;
|
||||
nsISchemaCollection* mCollection; // [WEAK] it owns me
|
||||
PRPackedBool mElementFormQualified;
|
||||
};
|
||||
|
||||
class nsSchemaComponentBase {
|
||||
@ -335,26 +336,31 @@ class nsSchemaElement : public nsSchemaParticleBase,
|
||||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
enum { NILLABLE = 1 << 1 };
|
||||
enum { ABSTRACT = 1 << 2 };
|
||||
enum { FORM_QUALIFIED = 1 << 3 };
|
||||
|
||||
nsSchemaElement(nsSchema* aSchema, const nsAString& aName);
|
||||
virtual ~nsSchemaElement();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMPL_NSISCHEMACOMPONENT_USING_BASE
|
||||
NS_IMPL_NSISCHEMAPARTICLE_USING_BASE
|
||||
NS_DECL_NSISCHEMAELEMENT
|
||||
|
||||
NS_IMETHOD GetTargetNamespace(nsAString& aTargetNamespace);
|
||||
NS_IMETHOD Resolve();
|
||||
NS_IMETHOD Clear();
|
||||
NS_IMETHOD SetType(nsISchemaType* aType);
|
||||
NS_IMETHOD SetConstraints(const nsAString& aDefaultValue,
|
||||
const nsAString& aFixedValue);
|
||||
NS_IMETHOD SetFlags(PRBool aNillable, PRBool aAbstract);
|
||||
NS_IMETHOD SetFlags(PRInt32 aFlags);
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsCOMPtr<nsISchemaType> mType;
|
||||
nsString mDefaultValue;
|
||||
nsString mFixedValue;
|
||||
PRPackedBool mNillable;
|
||||
PRPackedBool mAbstract;
|
||||
PRUint8 mFlags;
|
||||
};
|
||||
|
||||
class nsSchemaElementRef : public nsSchemaParticleBase,
|
||||
|
@ -2140,7 +2140,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement*
|
||||
rc = aElement->GetNamespaceURI(ename);
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
if (!ename.IsEmpty()) { // Only get an ename if there is a non-empty namespaceURI
|
||||
if (ename.IsEmpty()) { // Only get an ename if there is an empty namespaceURI
|
||||
rc = aElement->GetLocalName(ename);
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
@ -2204,7 +2204,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement*
|
||||
child = dont_AddRef(NS_STATIC_CAST
|
||||
(nsISchemaParticle*, all->ElementAt(i)));
|
||||
nsCOMPtr<nsIDOMElement> after;
|
||||
rc = DecodeStructParticle(aEncoding, aElement, child, aAttachments, aDestination, getter_AddRefs(after));
|
||||
rc = DecodeStructParticle(aEncoding, next, child, aAttachments, aDestination, getter_AddRefs(after));
|
||||
if (!NS_FAILED(rc)) {
|
||||
next = after;
|
||||
mangled = PR_TRUE;
|
||||
@ -2212,6 +2212,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement*
|
||||
particleCount--;
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
break;
|
||||
}
|
||||
if (rc != NS_ERROR_NOT_AVAILABLE) {
|
||||
break;
|
||||
|
@ -47,19 +47,11 @@
|
||||
const PRUint8 sInt8Val = 2;
|
||||
const PRInt16 sInt16Val = 0x1234;
|
||||
const PRInt32 sInt32Val = 0x12345678;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
const PRInt64 sInt64Val = 0x1234567887654321;
|
||||
#else
|
||||
const PRInt64 sInt64Val = {0x12345678, 0x87654321};
|
||||
#endif
|
||||
const PRInt64 sInt64Val = LL_INIT(0x12345678, 0x87654321);
|
||||
const PRUint8 sUint8Val = 2;
|
||||
const PRUint16 sUint16Val = 0x1234;
|
||||
const PRUint32 sUint32Val = 0x12345678;
|
||||
#ifdef HAVE_LONG_LONG
|
||||
const PRUint64 sUint64Val = 0x1234567887654321;
|
||||
#else
|
||||
const PRUint64 sUint64Val = {0x12345678, 0x87654321};
|
||||
#endif
|
||||
const PRUint64 sUint64Val = LL_INIT(0x12345678, 0x87654321);
|
||||
const PRBool sBoolVal = PR_TRUE;
|
||||
const float sFloatVal = 0.0;
|
||||
const double sDoubleVal = 0.03;
|
||||
|
@ -40,36 +40,6 @@
|
||||
|
||||
#include "wspprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
// SetException sets a global exception representing the given nsresult. It
|
||||
// is guaranteed to also return that nsresult. It is to be used when failing.
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// if (NS_FAILED(rv)) {
|
||||
// return SetException(rv, "got foo, expected bar", someOptionalObject);
|
||||
// }
|
||||
//
|
||||
|
||||
static nsresult SetException(nsresult aStatus, const char* aMsg,
|
||||
nsISupports* aData)
|
||||
{
|
||||
nsCOMPtr<nsIException> exception = new WSPException(aStatus, aMsg, aData);
|
||||
if (exception) {
|
||||
nsCOMPtr<nsIExceptionService> xs =
|
||||
do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
|
||||
if (xs) {
|
||||
nsCOMPtr<nsIExceptionManager> xm;
|
||||
xs->GetCurrentExceptionManager(getter_AddRefs(xm));
|
||||
if (xm) {
|
||||
xm->SetCurrentException(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// IIDX is used as a way to hold and share our commone set of interface indexes.
|
||||
|
||||
@ -106,15 +76,15 @@ private:
|
||||
MAX_TOTAL = 255}; // The typelib format limits us to 255 params.
|
||||
|
||||
public:
|
||||
PRUint16 GetCount() const {return mCount;}
|
||||
PRUint16 GetCount() const {return mCount;}
|
||||
XPTParamDescriptor* GetArray() {return mArray;}
|
||||
void Clear() {mCount = 0;}
|
||||
|
||||
XPTParamDescriptor* GetNextParam();
|
||||
|
||||
ParamAccumulator()
|
||||
: mArray(mBuiltinSpace), mCount(0), mAvailable(MAX_BUILTIN) {}
|
||||
~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;}
|
||||
ParamAccumulator()
|
||||
: mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace) {}
|
||||
~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;}
|
||||
private:
|
||||
PRUint16 mCount;
|
||||
PRUint16 mAvailable;
|
||||
@ -257,10 +227,9 @@ static void BuildInterfaceName(const nsAString& qualifier,
|
||||
const nsAString& uri,
|
||||
nsACString& aCIdentifier)
|
||||
{
|
||||
nsCAutoString temp;
|
||||
WSPFactory::XML2C(qualifier, temp);
|
||||
aCIdentifier.Assign(temp);
|
||||
WSPFactory::XML2C(qualifier, aCIdentifier);
|
||||
|
||||
nsCAutoString temp;
|
||||
WSPFactory::XML2C(name, temp);
|
||||
aCIdentifier.Append(temp);
|
||||
|
||||
@ -625,7 +594,8 @@ static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (compositor != nsISchemaModelGroup::COMPOSITOR_SEQUENCE) {
|
||||
if (compositor == nsISchemaModelGroup::COMPOSITOR_CHOICE) {
|
||||
// CHOICE not supported
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@
|
||||
// WSDL includes
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsIWSDLLoader.h"
|
||||
#include "nsIWSDLSoapBinding.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
// iix includes
|
||||
#include "nsIGenericInterfaceInfoSet.h"
|
||||
|
@ -67,6 +67,7 @@ interface nsISchemaComponent : nsISupports {
|
||||
|
||||
[scriptable, uuid(3c14a021-6f4e-11d5-9b46-000064657374)]
|
||||
interface nsISchema : nsISchemaComponent {
|
||||
/* Is this necessary? */
|
||||
readonly attribute AString schemaNamespace;
|
||||
|
||||
readonly attribute PRUint32 typeCount;
|
||||
|
@ -29,11 +29,25 @@
|
||||
//
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchema::nsSchema(nsISchemaCollection* aCollection,
|
||||
const nsAString& aTargetNamespace,
|
||||
const nsAString& aSchemaNamespace)
|
||||
: mTargetNamespace(aTargetNamespace), mSchemaNamespace(aSchemaNamespace)
|
||||
nsIDOMElement* aSchemaElement)
|
||||
{
|
||||
mCollection = aCollection; // Weak reference
|
||||
|
||||
if (aSchemaElement) {
|
||||
aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("targetNamespace"),
|
||||
mTargetNamespace);
|
||||
mTargetNamespace.Trim(" \r\n\t");
|
||||
aSchemaElement->GetNamespaceURI(mSchemaNamespace);
|
||||
|
||||
nsAutoString elementFormDefault;
|
||||
aSchemaElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("elementFormDefault"),
|
||||
elementFormDefault);
|
||||
elementFormDefault.Trim(" \r\n\t");
|
||||
mElementFormQualified =
|
||||
elementFormDefault.Equals(NS_LITERAL_STRING("qualified"));
|
||||
}
|
||||
}
|
||||
|
||||
nsSchema::~nsSchema()
|
||||
|
@ -115,6 +115,32 @@ nsSchemaComplexType::Resolve()
|
||||
}
|
||||
}
|
||||
|
||||
if (mArrayInfo) {
|
||||
nsCOMPtr<nsISchemaType> placeHolder;
|
||||
mArrayInfo->GetType(getter_AddRefs(placeHolder));
|
||||
if (placeHolder) {
|
||||
PRUint16 schemaType;
|
||||
placeHolder->GetSchemaType(&schemaType);
|
||||
if (schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
|
||||
rv = mSchema->ResolveTypePlaceholder(placeHolder, getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = type->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
SetArrayInfo(type, mArrayInfo->GetDimension());
|
||||
}
|
||||
else {
|
||||
rv = placeHolder->Resolve();
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -963,26 +963,21 @@ static PRUint32 kSchemaNamespacesLength = sizeof(kSchemaNamespaces) / sizeof(con
|
||||
|
||||
/* nsISchema processSchemaElement (in nsIDOMElement element); */
|
||||
NS_IMETHODIMP
|
||||
nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element,
|
||||
nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement,
|
||||
nsISchema **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG(element);
|
||||
NS_ENSURE_ARG(aElement);
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get target namespace and create the schema instance
|
||||
nsAutoString targetNamespace, schemaNamespace;
|
||||
element->GetAttribute(NS_LITERAL_STRING("targetNamespace"),
|
||||
targetNamespace);
|
||||
element->GetNamespaceURI(schemaNamespace);
|
||||
nsSchema* schemaInst = new nsSchema(this, targetNamespace, schemaNamespace);
|
||||
nsSchema* schemaInst = new nsSchema(this, aElement);
|
||||
nsCOMPtr<nsISchema> schema = schemaInst;
|
||||
if (!schema) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsChildElementIterator iterator(element,
|
||||
nsChildElementIterator iterator(aElement,
|
||||
kSchemaNamespaces, kSchemaNamespacesLength);
|
||||
nsCOMPtr<nsIDOMElement> childElement;
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
@ -1056,6 +1051,8 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement *element,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString targetNamespace;
|
||||
schema->GetTargetNamespace(targetNamespace);
|
||||
nsStringKey key(targetNamespace);
|
||||
mSchemas.Put(&key, schema);
|
||||
|
||||
@ -1164,11 +1161,18 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema,
|
||||
elementRef->SetMaxOccurs(maxOccurs);
|
||||
}
|
||||
else {
|
||||
nsAutoString name;
|
||||
nsAutoString value;
|
||||
nsSchemaElement* elementInst;
|
||||
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("name"), name);
|
||||
elementInst = new nsSchemaElement(aSchema, name);
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("name"),
|
||||
value);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
value.Trim(" \r\n\t");
|
||||
elementInst = new nsSchemaElement(aSchema, value);
|
||||
if (!elementInst) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -1178,15 +1182,82 @@ nsSchemaLoader::ProcessElement(nsSchema* aSchema,
|
||||
elementInst->SetMaxOccurs(maxOccurs);
|
||||
|
||||
nsAutoString defaultValue, fixedValue;
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("default"), defaultValue);
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("fixed"), fixedValue);
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("default"),
|
||||
defaultValue);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("fixed"),
|
||||
fixedValue);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
elementInst->SetConstraints(defaultValue, fixedValue);
|
||||
|
||||
nsAutoString nillable, abstract;
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("nillable"), nillable);
|
||||
aElement->GetAttribute(NS_LITERAL_STRING("abstract"), abstract);
|
||||
elementInst->SetFlags(nillable.Equals(NS_LITERAL_STRING("true")),
|
||||
abstract.Equals(NS_LITERAL_STRING("true")));
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("nillable"), value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
value.Trim(" \r\n\t");
|
||||
|
||||
PRInt32 flags = 0;
|
||||
if (value.Equals(NS_LITERAL_STRING("true")))
|
||||
flags |= nsSchemaElement::NILLABLE;
|
||||
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("abstract"), value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
value.Trim(" \r\n\t");
|
||||
|
||||
if (value.Equals(NS_LITERAL_STRING("true")))
|
||||
flags |= nsSchemaElement::ABSTRACT;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> parent;
|
||||
rv = aElement->GetParentNode(getter_AddRefs(parent));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
parent->GetLocalName(value);
|
||||
|
||||
// Check if the schema element's targetNamespace applies to <element>.
|
||||
// Note: If the <element> element information item has <schema> as its
|
||||
// parent,then the actual value of the targetNamespace is that of the
|
||||
// parent <schema> element information item, or absent if there is
|
||||
// none. Otherwise if the <element> element information item has
|
||||
// <schema> element as an ancestor then if "form" is present and its actual
|
||||
// value is qualified, or if "form" is absent and the actual value of
|
||||
// elementFormDefault on the <schema> ancestor is qualified, then the
|
||||
// actual value of the targetNamespace [attribute] is that of the ancestor
|
||||
// <schema> element information item, or absent if there is none.
|
||||
if (value.Equals(NS_LITERAL_STRING("schema"))) {
|
||||
flags |= nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
else {
|
||||
rv = aElement->GetAttributeNS(NS_LITERAL_STRING(""),
|
||||
NS_LITERAL_STRING("form"),
|
||||
value);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
value.Trim(" \r\n\t");
|
||||
if (value.IsEmpty()) {
|
||||
if (aSchema->IsElementFormQualified()) {
|
||||
flags |= nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
else {
|
||||
flags &= ~nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
}
|
||||
else if (value.Equals(NS_LITERAL_STRING("qualified"))) {
|
||||
flags |= nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
else {
|
||||
flags &= ~nsSchemaElement::FORM_QUALIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
elementInst->SetFlags(flags);
|
||||
|
||||
nsCOMPtr<nsISchemaType> schemaType;
|
||||
nsAutoString typeStr;
|
||||
|
@ -486,8 +486,7 @@ nsSchemaAnyParticle::SetNamespace(const nsAString& aNamespace)
|
||||
////////////////////////////////////////////////////////////
|
||||
nsSchemaElement::nsSchemaElement(nsSchema* aSchema,
|
||||
const nsAString& aName)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName),
|
||||
mNillable(PR_FALSE), mAbstract(PR_FALSE)
|
||||
: nsSchemaParticleBase(aSchema), mName(aName), mFlags(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -595,7 +594,7 @@ nsSchemaElement::GetNillable(PRBool *aNillable)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNillable);
|
||||
|
||||
*aNillable = mNillable;
|
||||
*aNillable = mFlags & nsSchemaElement::NILLABLE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -606,7 +605,7 @@ nsSchemaElement::GetAbstract(PRBool *aAbstract)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAbstract);
|
||||
|
||||
*aAbstract = mAbstract;
|
||||
*aAbstract = mFlags & nsSchemaElement::ABSTRACT;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -632,11 +631,19 @@ nsSchemaElement::SetConstraints(const nsAString& aDefaultValue,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaElement::SetFlags(PRBool aNillable, PRBool aAbstract)
|
||||
nsSchemaElement::SetFlags(PRInt32 aFlags)
|
||||
{
|
||||
mNillable = aNillable;
|
||||
mAbstract = aAbstract;
|
||||
mFlags = aFlags;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSchemaElement::GetTargetNamespace(nsAString& aTargetNamespace)
|
||||
{
|
||||
if ((mFlags & nsSchemaElement::FORM_QUALIFIED) && mSchema) {
|
||||
return mSchema->GetTargetNamespace(aTargetNamespace);
|
||||
}
|
||||
aTargetNamespace.Truncate();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#define NS_SCHEMA_2001_NAMESPACE "http://www.w3.org/2001/XMLSchema"
|
||||
#define NS_SCHEMA_1999_NAMESPACE "http://www.w3.org/1999/XMLSchema"
|
||||
@ -42,9 +43,7 @@
|
||||
class nsSchema : public nsISchema
|
||||
{
|
||||
public:
|
||||
nsSchema(nsISchemaCollection* aCollection,
|
||||
const nsAString& aTargetNamespace,
|
||||
const nsAString& aSchemaNamespace);
|
||||
nsSchema(nsISchemaCollection* aCollection, nsIDOMElement* aElement);
|
||||
virtual ~nsSchema();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -59,6 +58,7 @@ public:
|
||||
void DropCollectionReference();
|
||||
nsresult ResolveTypePlaceholder(nsISchemaType* aPlaceholder,
|
||||
nsISchemaType** aType);
|
||||
PRBool IsElementFormQualified() { return mElementFormQualified; }
|
||||
|
||||
protected:
|
||||
nsString mTargetNamespace;
|
||||
@ -74,6 +74,7 @@ protected:
|
||||
nsSupportsArray mModelGroups;
|
||||
nsSupportsHashtable mModelGroupsHash;
|
||||
nsISchemaCollection* mCollection; // [WEAK] it owns me
|
||||
PRPackedBool mElementFormQualified;
|
||||
};
|
||||
|
||||
class nsSchemaComponentBase {
|
||||
@ -335,26 +336,31 @@ class nsSchemaElement : public nsSchemaParticleBase,
|
||||
public nsISchemaElement
|
||||
{
|
||||
public:
|
||||
enum { NILLABLE = 1 << 1 };
|
||||
enum { ABSTRACT = 1 << 2 };
|
||||
enum { FORM_QUALIFIED = 1 << 3 };
|
||||
|
||||
nsSchemaElement(nsSchema* aSchema, const nsAString& aName);
|
||||
virtual ~nsSchemaElement();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_IMPL_NSISCHEMACOMPONENT_USING_BASE
|
||||
NS_IMPL_NSISCHEMAPARTICLE_USING_BASE
|
||||
NS_DECL_NSISCHEMAELEMENT
|
||||
|
||||
NS_IMETHOD GetTargetNamespace(nsAString& aTargetNamespace);
|
||||
NS_IMETHOD Resolve();
|
||||
NS_IMETHOD Clear();
|
||||
NS_IMETHOD SetType(nsISchemaType* aType);
|
||||
NS_IMETHOD SetConstraints(const nsAString& aDefaultValue,
|
||||
const nsAString& aFixedValue);
|
||||
NS_IMETHOD SetFlags(PRBool aNillable, PRBool aAbstract);
|
||||
NS_IMETHOD SetFlags(PRInt32 aFlags);
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsCOMPtr<nsISchemaType> mType;
|
||||
nsString mDefaultValue;
|
||||
nsString mFixedValue;
|
||||
PRPackedBool mNillable;
|
||||
PRPackedBool mAbstract;
|
||||
PRUint8 mFlags;
|
||||
};
|
||||
|
||||
class nsSchemaElementRef : public nsSchemaParticleBase,
|
||||
|
@ -2140,7 +2140,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement*
|
||||
rc = aElement->GetNamespaceURI(ename);
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
if (!ename.IsEmpty()) { // Only get an ename if there is a non-empty namespaceURI
|
||||
if (ename.IsEmpty()) { // Only get an ename if there is an empty namespaceURI
|
||||
rc = aElement->GetLocalName(ename);
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
@ -2204,7 +2204,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement*
|
||||
child = dont_AddRef(NS_STATIC_CAST
|
||||
(nsISchemaParticle*, all->ElementAt(i)));
|
||||
nsCOMPtr<nsIDOMElement> after;
|
||||
rc = DecodeStructParticle(aEncoding, aElement, child, aAttachments, aDestination, getter_AddRefs(after));
|
||||
rc = DecodeStructParticle(aEncoding, next, child, aAttachments, aDestination, getter_AddRefs(after));
|
||||
if (!NS_FAILED(rc)) {
|
||||
next = after;
|
||||
mangled = PR_TRUE;
|
||||
@ -2212,6 +2212,7 @@ static nsresult DecodeStructParticle(nsISOAPEncoding* aEncoding, nsIDOMElement*
|
||||
particleCount--;
|
||||
if (NS_FAILED(rc))
|
||||
return rc;
|
||||
break;
|
||||
}
|
||||
if (rc != NS_ERROR_NOT_AVAILABLE) {
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user