Added untested code for decoding untyped complex objects. Didn't break

isprimenumber.

SOAP is not part of default build.
This commit is contained in:
rayw%netscape.com 2002-01-17 05:39:57 +00:00
Родитель 623ec9212c
Коммит 8c331348be
2 изменённых файлов: 88 добавлений и 4 удалений

Просмотреть файл

@ -44,6 +44,8 @@
#include "nsIDOMNamedNodeMap.h" #include "nsIDOMNamedNodeMap.h"
#include "nsIDOMAttr.h" #include "nsIDOMAttr.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "nsISOAPPropertyBagMutator.h"
#include "nsIPropertyBag.h"
NS_NAMED_LITERAL_STRING(kEmpty, ""); NS_NAMED_LITERAL_STRING(kEmpty, "");
@ -1213,8 +1215,48 @@ NS_IMETHODIMP
return NS_OK; return NS_OK;
} }
} }
// Here we have a complex value, hopefully a property bag. Implement it later.
return NS_ERROR_NOT_IMPLEMENTED; // Here we have a complex value, so produce a property bag. Implement type-driven
// decoding later.
nsresult rc;
nsCOMPtr<nsISOAPPropertyBagMutator> c = do_CreateInstance(NS_SOAPPROPERTYBAGMUTATOR_CONTRACTID, &rc);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMElement> child;
nsSOAPUtils::GetFirstChildElement(aSource, getter_AddRefs(child));
while (child != nsnull) {
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsIVariant>value;
rc = child->GetLocalName(name);
if (NS_FAILED(rc))
return rc;
rc = child->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc))
return rc;
if (!namespaceURI.IsEmpty()) {
return NS_ERROR_ILLEGAL_VALUE; // We only know how to put local values into structures.
}
rc = aEncoding->Decode(child, nsnull, aAttachments, getter_AddRefs(value));
if (NS_FAILED(rc))
return rc;
rc = c->AddProperty(name, value);
if (NS_FAILED(rc))
return rc;
}
nsCOMPtr<nsIPropertyBag> pb;
c->GetPropertyBag(getter_AddRefs(pb));
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIWritableVariant > p =
do_CreateInstance(NS_VARIANT_CONTRACTID, &rc);
if (NS_FAILED(rc))
return rc;
p->SetAsInterface(NS_GET_IID(nsIPropertyBag), pb);
*_retval = p;
NS_ADDREF(*_retval);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

Просмотреть файл

@ -44,6 +44,8 @@
#include "nsIDOMNamedNodeMap.h" #include "nsIDOMNamedNodeMap.h"
#include "nsIDOMAttr.h" #include "nsIDOMAttr.h"
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "nsISOAPPropertyBagMutator.h"
#include "nsIPropertyBag.h"
NS_NAMED_LITERAL_STRING(kEmpty, ""); NS_NAMED_LITERAL_STRING(kEmpty, "");
@ -1213,8 +1215,48 @@ NS_IMETHODIMP
return NS_OK; return NS_OK;
} }
} }
// Here we have a complex value, hopefully a property bag. Implement it later.
return NS_ERROR_NOT_IMPLEMENTED; // Here we have a complex value, so produce a property bag. Implement type-driven
// decoding later.
nsresult rc;
nsCOMPtr<nsISOAPPropertyBagMutator> c = do_CreateInstance(NS_SOAPPROPERTYBAGMUTATOR_CONTRACTID, &rc);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMElement> child;
nsSOAPUtils::GetFirstChildElement(aSource, getter_AddRefs(child));
while (child != nsnull) {
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsIVariant>value;
rc = child->GetLocalName(name);
if (NS_FAILED(rc))
return rc;
rc = child->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rc))
return rc;
if (!namespaceURI.IsEmpty()) {
return NS_ERROR_ILLEGAL_VALUE; // We only know how to put local values into structures.
}
rc = aEncoding->Decode(child, nsnull, aAttachments, getter_AddRefs(value));
if (NS_FAILED(rc))
return rc;
rc = c->AddProperty(name, value);
if (NS_FAILED(rc))
return rc;
}
nsCOMPtr<nsIPropertyBag> pb;
c->GetPropertyBag(getter_AddRefs(pb));
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIWritableVariant > p =
do_CreateInstance(NS_VARIANT_CONTRACTID, &rc);
if (NS_FAILED(rc))
return rc;
p->SetAsInterface(NS_GET_IID(nsIPropertyBag), pb);
*_retval = p;
NS_ADDREF(*_retval);
return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP