зеркало из https://github.com/mozilla/pjs.git
Checking in changes that were made during the review of the WSDL code. The review was done by harishd@netscape.com, jgaunt@netscape.com, dbradley@netscape.com, and jst@netscape.com. Not part of the build yet.
This commit is contained in:
Родитель
4156090dca
Коммит
f176fffb72
|
@ -1,177 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike McCabe <mccabe@netscape.com>
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Library-private header for Interface Info extras system. */
|
||||
|
||||
#ifndef iixprivate_h___
|
||||
#define iixprivate_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsVariant.h"
|
||||
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xpt_struct.h"
|
||||
#include "xptinfo.h"
|
||||
#include "xptcall.h"
|
||||
|
||||
#include "nsIGenericInterfaceInfoSet.h"
|
||||
#include "nsIScriptableInterfaceInfo.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsGenericInterfaceInfoSet : public nsIGenericInterfaceInfoSet,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEINFOMANAGER
|
||||
NS_DECL_NSIGENERICINTERFACEINFOSET
|
||||
|
||||
nsGenericInterfaceInfoSet();
|
||||
virtual ~nsGenericInterfaceInfoSet();
|
||||
|
||||
XPTArena* GetArena() {return mArena;}
|
||||
|
||||
const XPTTypeDescriptor* GetAdditionalTypeAt(PRUint16 aIndex)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16) mAdditionalTypes.Count(), "bad index");
|
||||
return (const XPTTypeDescriptor*) mAdditionalTypes.ElementAt(aIndex);
|
||||
}
|
||||
|
||||
nsIInterfaceInfo* InfoAtNoAddRef(PRUint16 aIndex)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16) mInterfaces.Count(), "bad index");
|
||||
return (nsIInterfaceInfo*) ClearOwnedFlag(mInterfaces.ElementAt(aIndex));
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult IndexOfIID(const nsIID & aIID, PRUint16 *_retval);
|
||||
nsresult IndexOfName(const char* aName, PRUint16 *_retval);
|
||||
|
||||
void* SetOwnedFlag(void* p) {return (void*) ((long)p | 1);}
|
||||
void* ClearOwnedFlag(void* p) {return (void*) ((long)p & ~(long)1);}
|
||||
PRBool CheckOwnedFlag(void* p) {return (PRBool) ((long)p & (long)1);}
|
||||
|
||||
|
||||
private:
|
||||
nsVoidArray mInterfaces;
|
||||
nsVoidArray mAdditionalTypes;
|
||||
XPTArena* mArena;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsGenericInterfaceInfo : public nsIGenericInterfaceInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEINFO
|
||||
NS_DECL_NSIGENERICINTERFACEINFO
|
||||
|
||||
nsGenericInterfaceInfo(); // not implemented
|
||||
nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
||||
const char *aName,
|
||||
const nsIID & aIID,
|
||||
nsIInterfaceInfo* mParent,
|
||||
PRUint8 aFlags);
|
||||
virtual ~nsGenericInterfaceInfo() {}
|
||||
|
||||
private:
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const XPTParamDescriptor* param)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
while(XPT_TDP_TAG(td->prefix) == TD_ARRAY)
|
||||
td = mSet->GetAdditionalTypeAt(td->type.additional_type);
|
||||
return td;
|
||||
}
|
||||
|
||||
const XPTTypeDescriptor* GetTypeInArray(const XPTParamDescriptor* param,
|
||||
PRUint16 dimension)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
for(PRUint16 i = 0; i < dimension; i++)
|
||||
{
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_ARRAY, "bad dimension");
|
||||
td = mSet->GetAdditionalTypeAt(td->type.additional_type);
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
private:
|
||||
char* mName;
|
||||
nsIID mIID;
|
||||
nsVoidArray mMethods;
|
||||
nsVoidArray mConstants;
|
||||
nsGenericInterfaceInfoSet* mSet;
|
||||
nsIInterfaceInfo* mParent; // weak reference (it must be held in set table)
|
||||
PRUint16 mMethodBaseIndex;
|
||||
PRUint16 mConstantBaseIndex;
|
||||
PRUint8 mFlags;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsScriptableInterfaceInfo : public nsIScriptableInterfaceInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEINTERFACEINFO
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
nsIScriptableInterfaceInfo** aResult);
|
||||
|
||||
nsScriptableInterfaceInfo();
|
||||
nsScriptableInterfaceInfo(nsIInterfaceInfo* aInfo);
|
||||
virtual ~nsScriptableInterfaceInfo();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#endif /* iixprivate_h___ */
|
|
@ -1,624 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* The nsGenericInterfaceInfo/nsGenericInterfaceInfoSet implementations.*/
|
||||
|
||||
#include "iixprivate.h"
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
// implement nsGenericInterfaceInfoSet
|
||||
|
||||
#define ARENA_BLOCK_SIZE (1024 * 1)
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsGenericInterfaceInfoSet,
|
||||
nsIInterfaceInfoManager,
|
||||
nsIGenericInterfaceInfoSet,
|
||||
nsISupportsWeakReference);
|
||||
|
||||
nsGenericInterfaceInfoSet::nsGenericInterfaceInfoSet()
|
||||
{
|
||||
mArena = XPT_NewArena(ARENA_BLOCK_SIZE, sizeof(double),
|
||||
"nsGenericInterfaceInfoSet Arena");
|
||||
}
|
||||
|
||||
nsGenericInterfaceInfoSet::~nsGenericInterfaceInfoSet()
|
||||
{
|
||||
PRInt32 count = mInterfaces.Count();
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
if(CheckOwnedFlag(info))
|
||||
delete (nsGenericInterfaceInfo*) ClearOwnedFlag(info);
|
||||
else
|
||||
NS_RELEASE(info);
|
||||
}
|
||||
|
||||
if(mArena)
|
||||
XPT_DestroyArena(mArena);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
PRInt32 count = mInterfaces.Count();
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const nsID* iid;
|
||||
nsresult rv = info->GetIIDShared(&iid);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
if(iid->Equals(aIID))
|
||||
{
|
||||
*_retval = (PRUint16) i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
||||
{
|
||||
PRInt32 count = mInterfaces.Count();
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const char* name;
|
||||
nsresult rv = info->GetNameShared(&name);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
if(!strcmp(name, aName))
|
||||
{
|
||||
*_retval = (PRUint16) i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfoSet methods...
|
||||
|
||||
/* XPTParamDescriptorPtr allocateParamArray (in PRUint16 aCount); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AllocateParamArray(PRUint16 aCount, XPTParamDescriptor * *_retval)
|
||||
{
|
||||
*_retval = (XPTParamDescriptor*)
|
||||
XPT_MALLOC(GetArena(), sizeof(XPTParamDescriptor) * aCount);
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* XPTTypeDescriptorPtr allocateAdditionalType (out PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, XPTTypeDescriptor * *_retval)
|
||||
{
|
||||
*_retval = (XPTTypeDescriptor*)
|
||||
XPT_MALLOC(GetArena(), sizeof(XPTTypeDescriptor));
|
||||
if(!*_retval || !mAdditionalTypes.AppendElement(*_retval))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aIndex = (PRUint16) mAdditionalTypes.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint16 createAndAppendInterface (in string aName, in nsIIDRef aIID, in PRUint16 aParent, in PRUint8 aFlags, out nsIGenericInterfaceInfo aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::CreateAndAppendInterface(const char *aName, const nsIID & aIID, PRUint16 aParent, PRUint8 aFlags, nsIGenericInterfaceInfo **aInfo, PRUint16 *_retval)
|
||||
{
|
||||
nsGenericInterfaceInfo* info =
|
||||
new nsGenericInterfaceInfo(this, aName, aIID,
|
||||
(aParent == (PRUint16) -1) ?
|
||||
nsnull : InfoAtNoAddRef(aParent),
|
||||
aFlags);
|
||||
if(!info || !mInterfaces.AppendElement(SetOwnedFlag(info)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*_retval = (PRUint16) mInterfaces.Count()-1;
|
||||
return CallQueryInterface(info, aInfo);
|
||||
}
|
||||
|
||||
/* PRUint16 appendExternalInterface (in nsIInterfaceInfo aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AppendExternalInterface(nsIInterfaceInfo *aInfo, PRUint16 *_retval)
|
||||
{
|
||||
if(!mInterfaces.AppendElement(aInfo))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(aInfo);
|
||||
*_retval = (PRUint16) mInterfaces.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint16 indexOf (in nsIIDRef aIID); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::IndexOf(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
return IndexOfIID(aIID, _retval);
|
||||
}
|
||||
|
||||
/* PRUint16 indexOfByName (in string aName); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::IndexOfByName(const char *aName, PRUint16 *_retval)
|
||||
{
|
||||
return IndexOfName(aName, _retval);
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo interfaceInfoAt (in PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::InterfaceInfoAt(PRUint16 aIndex, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16)mInterfaces.Count(), "bad index");
|
||||
|
||||
*_retval = (nsIInterfaceInfo*) ClearOwnedFlag(mInterfaces.ElementAt(aIndex));
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIInterfaceInfoManager methods...
|
||||
|
||||
/* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfIID(*iid, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
return InterfaceInfoAt(index, _retval);
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForName (in string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForName(const char *name, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfName(name, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
return InterfaceInfoAt(index, _retval);
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForName (in string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetIIDForName(const char *name, nsIID * *_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfName(name, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIInterfaceInfo* info = InfoAtNoAddRef(index);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return info->GetInterfaceIID(_retval);
|
||||
}
|
||||
|
||||
/* string getNameForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetNameForIID(const nsIID * iid, char **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfIID(*iid, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIInterfaceInfo* info = InfoAtNoAddRef(index);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return info->GetName(_retval);
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfaces (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::EnumerateInterfaces(nsIEnumerator **_retval)
|
||||
{
|
||||
return EnumerateInterfacesWhoseNamesStartWith(nsnull, _retval);
|
||||
}
|
||||
|
||||
/* void autoRegisterInterfaces (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::AutoRegisterInterfaces()
|
||||
{
|
||||
// NOP
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfacesWhoseNamesStartWith (in string prefix); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::EnumerateInterfacesWhoseNamesStartWith(const char *prefix, nsIEnumerator **_retval)
|
||||
{
|
||||
int count = (PRUint16) mInterfaces.Count();
|
||||
int len = prefix ? PL_strlen(prefix) : 0;
|
||||
const char* name;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if(!array)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = InfoAtNoAddRef(i);
|
||||
if(!info)
|
||||
continue;
|
||||
if(!prefix ||
|
||||
(NS_SUCCEEDED(info->GetNameShared(&name)) &&
|
||||
name == PL_strnstr(name, prefix, len)))
|
||||
{
|
||||
if(!array->AppendElement(info))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return array->Enumerate(_retval);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
// implement nsGenericInterfaceInfo
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE2(nsGenericInterfaceInfo,
|
||||
nsIInterfaceInfo,
|
||||
nsIGenericInterfaceInfo);
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsGenericInterfaceInfo::AddRef()
|
||||
{
|
||||
return mSet->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsGenericInterfaceInfo::Release()
|
||||
{
|
||||
return mSet->Release();
|
||||
}
|
||||
|
||||
nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
||||
const char *aName,
|
||||
const nsIID & aIID,
|
||||
nsIInterfaceInfo* aParent,
|
||||
PRUint8 aFlags)
|
||||
: mName(nsnull),
|
||||
mIID(aIID),
|
||||
mSet(aSet),
|
||||
mParent(aParent),
|
||||
mFlags(aFlags)
|
||||
{
|
||||
if(mParent)
|
||||
{
|
||||
mParent->GetMethodCount(&mMethodBaseIndex);
|
||||
mParent->GetConstantCount(&mConstantBaseIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
mMethodBaseIndex = mConstantBaseIndex = 0;
|
||||
}
|
||||
|
||||
int len = PL_strlen(aName);
|
||||
mName = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(mName)
|
||||
memcpy(mName, aName, len);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfo methods...
|
||||
|
||||
/* PRUint16 appendMethod (in XPTMethodDescriptorPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
XPTMethodDescriptor* desc = (XPTMethodDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTMethodDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aMethod, sizeof(XPTMethodDescriptor));
|
||||
|
||||
int len = PL_strlen(aMethod->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(!desc->name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc->name, aMethod->name, len);
|
||||
|
||||
return mMethods.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRUint16 appendConst (in XPTConstDescriptorPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, PRUint16 *_retval)
|
||||
|
||||
{
|
||||
NS_ASSERTION(aConst->type.prefix.flags == TD_INT16 ||
|
||||
aConst->type.prefix.flags == TD_UINT16 ||
|
||||
aConst->type.prefix.flags == TD_INT32 ||
|
||||
aConst->type.prefix.flags == TD_UINT32,
|
||||
"unsupported const type");
|
||||
|
||||
XPTConstDescriptor* desc = (XPTConstDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTConstDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aConst, sizeof(XPTConstDescriptor));
|
||||
|
||||
int len = PL_strlen(aConst->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(!desc->name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc->name, aConst->name, len);
|
||||
|
||||
return mConstants.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIInterfaceInfo methods...
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetName(char * *aName)
|
||||
{
|
||||
*aName = (char*) nsMemory::Clone(mName, PL_strlen(mName)+1);
|
||||
return *aName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr InterfaceIID; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInterfaceIID(nsIID * *aIID)
|
||||
{
|
||||
*aIID = (nsIID*) nsMemory::Clone(&mIID, sizeof(nsIID));
|
||||
return *aIID ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRBool isScriptable (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsScriptable(PRBool *_retval)
|
||||
{
|
||||
*_retval = XPT_ID_IS_SCRIPTABLE(mFlags) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIInterfaceInfo parent; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetParent(nsIInterfaceInfo * *aParent)
|
||||
{
|
||||
*aParent = mParent;
|
||||
NS_IF_ADDREF(*aParent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 methodCount; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
|
||||
{
|
||||
*aMethodCount = mMethodBaseIndex + (PRUint16) mMethods.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 constantCount; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
||||
{
|
||||
*aConstantCount = mConstantBaseIndex + (PRUint16) mConstants.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getMethodInfo (in PRUint16 index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfo(PRUint16 index, const nsXPTMethodInfo * *info)
|
||||
{
|
||||
if(index < mMethodBaseIndex)
|
||||
return mParent->GetMethodInfo(index, info);
|
||||
*info = (const nsXPTMethodInfo *) mMethods.ElementAt(index-mMethodBaseIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getMethodInfoForName (in string methodName, out PRUint16 index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16 *index, const nsXPTMethodInfo * *info)
|
||||
{
|
||||
PRUint16 count = mMethodBaseIndex + (PRUint16) mMethods.Count();
|
||||
for(PRUint16 i = 0; i < count; i++)
|
||||
{
|
||||
const nsXPTMethodInfo* current;
|
||||
nsresult rv = GetMethodInfo(i, ¤t);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(!PL_strcmp(methodName, current->GetName()))
|
||||
{
|
||||
*index = i;
|
||||
*info = current;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*index = 0;
|
||||
*info = 0;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* void getConstant (in PRUint16 index, [shared, retval] out nsXPTConstantPtr constant); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetConstant(PRUint16 index, const nsXPTConstant * *constant)
|
||||
{
|
||||
if(index < mConstantBaseIndex)
|
||||
return mParent->GetConstant(index, constant);
|
||||
*constant = (const nsXPTConstant *) mConstants.ElementAt(index-mConstantBaseIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetInfoForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
|
||||
return mSet->InterfaceInfoAt(td->type.iface, _retval);
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID * *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetIIDForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
|
||||
nsIInterfaceInfo* info = mSet->InfoAtNoAddRef(td->type.iface);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return info->GetInterfaceIID(_retval);
|
||||
}
|
||||
|
||||
/* nsXPTType getTypeForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, nsXPTType *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetTypeForParam(methodIndex, param, dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
||||
*_retval = nsXPTType(td->prefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetSizeIsArgNumberForParam(methodIndex, param, dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
||||
*_retval = td->argnum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetLengthIsArgNumberForParam(methodIndex, param, dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
||||
*_retval = td->argnum2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetInterfaceIsArgNumberForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_IS_TYPE, "not an interface");
|
||||
|
||||
*_retval = td->argnum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool isIID (in nsIIDPtr IID); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
|
||||
{
|
||||
*_retval = mIID.Equals(*IID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getNameShared ([shared, retval] out string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetNameShared(const char **name)
|
||||
{
|
||||
*name = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getIIDShared ([shared, retval] out nsIIDPtrShared iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDShared(const nsIID * *iid)
|
||||
{
|
||||
*iid = &mIID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool isFunction (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsFunction(PRBool *_retval)
|
||||
{
|
||||
*_retval = XPT_ID_IS_FUNCTION(mFlags) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool hasAncestor (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> current = NS_STATIC_CAST(nsIInterfaceInfo*, this);
|
||||
while(current)
|
||||
{
|
||||
PRBool same;
|
||||
if(NS_SUCCEEDED(current->IsIID(iid, &same)) && same)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIInterfaceInfo> temp(current);
|
||||
temp->GetParent(getter_AddRefs(current));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [notxpcom] nsresult getIIDForParamNoAlloc (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, out nsIID iid); */
|
||||
NS_IMETHODIMP_(nsresult) nsGenericInterfaceInfo::GetIIDForParamNoAlloc(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID *iid)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetIIDForParamNoAlloc(methodIndex, param, iid);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
|
||||
nsIInterfaceInfo* info = mSet->InfoAtNoAddRef(td->type.iface);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
const nsIID* iidp;
|
||||
nsresult rv = info->GetIIDShared(&iidp);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*iid = *iidp;
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,848 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* nsIScriptableInteraceInfo family implementations. */
|
||||
|
||||
#include "iixprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
static inline nsresult CloneString(const char* inStr, char** outStr)
|
||||
{
|
||||
*outStr = (char*) nsMemory::Clone(inStr, strlen(inStr)+1);
|
||||
return *outStr ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Header file */
|
||||
class nsScriptableDataType : public nsIScriptableDataType
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEDATATYPE
|
||||
|
||||
static nsresult Create(const nsXPTType& aType,
|
||||
nsIScriptableDataType** aResult);
|
||||
|
||||
nsScriptableDataType(); // not implemented
|
||||
|
||||
nsScriptableDataType(const nsXPTType& aType)
|
||||
: mType(aType) {}
|
||||
|
||||
virtual ~nsScriptableDataType() {}
|
||||
|
||||
private:
|
||||
nsXPTType mType;
|
||||
};
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableDataType::Create(const nsXPTType& aType,
|
||||
nsIScriptableDataType** aResult)
|
||||
{
|
||||
nsScriptableDataType* obj = new nsScriptableDataType(aType);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableDataType*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableDataType, nsIScriptableDataType)
|
||||
|
||||
/* readonly attribute PRBool isPointer; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsPointer(PRBool *aIsPointer)
|
||||
{
|
||||
*aIsPointer = mType.IsPointer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isUniquePointer; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsUniquePointer(PRBool *aIsUniquePointer)
|
||||
{
|
||||
*aIsUniquePointer = mType.IsUniquePointer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isReference; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsReference(PRBool *aIsReference)
|
||||
{
|
||||
*aIsReference = mType.IsReference();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isArithmetic; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsArithmetic(PRBool *aIsArithmetic)
|
||||
{
|
||||
*aIsArithmetic = mType.IsArithmetic();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isInterfacePointer; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsInterfacePointer(PRBool *aIsInterfacePointer)
|
||||
{
|
||||
*aIsInterfacePointer = mType.IsInterfacePointer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isArray; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsArray(PRBool *aIsArray)
|
||||
{
|
||||
*aIsArray = mType.IsArray();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isDependent; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsDependent(PRBool *aIsDependent)
|
||||
{
|
||||
*aIsDependent = mType.IsDependent();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 dataType; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetDataType(PRUint16 *aDataType)
|
||||
{
|
||||
*aDataType = mType.TagPart();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsScriptableParamInfo : public nsIScriptableParamInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEPARAMINFO
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam,
|
||||
nsIScriptableParamInfo** aResult);
|
||||
|
||||
nsScriptableParamInfo(); // not implemented
|
||||
nsScriptableParamInfo(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam)
|
||||
: mInfo(aInfo), mParam(aParam) {}
|
||||
virtual ~nsScriptableParamInfo() {}
|
||||
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying param alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
nsXPTParamInfo mParam;
|
||||
};
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableParamInfo::Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam,
|
||||
nsIScriptableParamInfo** aResult)
|
||||
{
|
||||
nsScriptableParamInfo* obj = new nsScriptableParamInfo(aInfo, aParam);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableParamInfo*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableParamInfo, nsIScriptableParamInfo)
|
||||
|
||||
/* readonly attribute PRBool isIn; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsIn(PRBool *aIsIn)
|
||||
{
|
||||
*aIsIn = mParam.IsIn();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isOut; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsOut(PRBool *aIsOut)
|
||||
{
|
||||
*aIsOut = mParam.IsOut();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isRetval; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsRetval(PRBool *aIsRetval)
|
||||
{
|
||||
*aIsRetval = mParam.IsRetval();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isShared; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsShared(PRBool *aIsShared)
|
||||
{
|
||||
*aIsShared = mParam.IsShared();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isDipper; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsDipper(PRBool *aIsDipper)
|
||||
{
|
||||
*aIsDipper = mParam.IsDipper();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableDataType type; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetType(nsIScriptableDataType * *aType)
|
||||
{
|
||||
return nsScriptableDataType::Create(mParam.GetType(), aType);
|
||||
}
|
||||
|
||||
/* [noscript] void getParamInfo ([shared, const, retval] out nsXPTParamInfoPtr aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetParamInfo(const nsXPTParamInfo * *aInfo)
|
||||
{
|
||||
*aInfo = &mParam;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
class nsScriptableConstant : public nsIScriptableConstant
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLECONSTANT
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst,
|
||||
nsIScriptableConstant** aResult);
|
||||
|
||||
nsScriptableConstant(); // not implemented
|
||||
nsScriptableConstant(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst)
|
||||
: mInfo(aInfo), mConst(aConst) {}
|
||||
virtual ~nsScriptableConstant() {}
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying const alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
nsXPTConstant mConst;
|
||||
};
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableConstant::Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst,
|
||||
nsIScriptableConstant** aResult)
|
||||
{
|
||||
nsScriptableConstant* obj = new nsScriptableConstant(aInfo, aConst);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableConstant*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableConstant, nsIScriptableConstant)
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableConstant::GetName(char * *aName)
|
||||
{
|
||||
return CloneString(mConst.GetName(), aName);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableDataType type; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableConstant::GetType(nsIScriptableDataType * *aType)
|
||||
{
|
||||
return nsScriptableDataType::Create(mConst.GetType(), aType);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIVariant value; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableConstant::GetValue(nsIVariant * *aValue)
|
||||
{
|
||||
nsVariant* variant = new nsVariant();
|
||||
if(!variant)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aValue = NS_STATIC_CAST(nsIVariant*, variant);
|
||||
NS_ADDREF(*aValue);
|
||||
|
||||
const nsXPTCMiniVariant* varval = mConst.GetValue();
|
||||
nsresult rv;
|
||||
|
||||
switch(mConst.GetType())
|
||||
{
|
||||
case nsXPTType::T_I16:
|
||||
rv = variant->SetAsInt16(varval->val.i16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
rv = variant->SetAsInt32(varval->val.i32);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
rv = variant->SetAsUint16(varval->val.u16);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
rv = variant->SetAsUint32(varval->val.u32);
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("invalid const type");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
NS_RELEASE(*aValue);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsScriptableMethodInfo : public nsIScriptableMethodInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEMETHODINFO
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod,
|
||||
nsIScriptableMethodInfo** aResult);
|
||||
|
||||
nsScriptableMethodInfo(); // not implemented
|
||||
nsScriptableMethodInfo(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod)
|
||||
: mInfo(aInfo), mMethod(aMethod) {}
|
||||
virtual ~nsScriptableMethodInfo() {}
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying method alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
const nsXPTMethodInfo& mMethod;
|
||||
};
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableMethodInfo::Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod,
|
||||
nsIScriptableMethodInfo** aResult)
|
||||
{
|
||||
nsScriptableMethodInfo* obj = new nsScriptableMethodInfo(aInfo, aMethod);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableMethodInfo*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableMethodInfo, nsIScriptableMethodInfo)
|
||||
|
||||
/* readonly attribute PRBool isGetter; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsGetter(PRBool *aIsGetter)
|
||||
{
|
||||
*aIsGetter = mMethod.IsGetter();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isSetter; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsSetter(PRBool *aIsSetter)
|
||||
{
|
||||
*aIsSetter = mMethod.IsSetter();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isNotXPCOM; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsNotXPCOM(PRBool *aIsNotXPCOM)
|
||||
{
|
||||
*aIsNotXPCOM = mMethod.IsNotXPCOM();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isConstructor; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsConstructor(PRBool *aIsConstructor)
|
||||
{
|
||||
*aIsConstructor = mMethod.IsConstructor();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isHidden; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsHidden(PRBool *aIsHidden)
|
||||
{
|
||||
*aIsHidden = mMethod.IsHidden();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetName(char * *aName)
|
||||
{
|
||||
return CloneString(mMethod.GetName(), aName);
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint8 paramCount; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetParamCount(PRUint8 *aParamCount)
|
||||
{
|
||||
*aParamCount = mMethod.GetParamCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIScriptableParamInfo getParam (in PRUint8 idx); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetParam(PRUint8 idx, nsIScriptableParamInfo **_retval)
|
||||
{
|
||||
if(idx >= mMethod.GetParamCount())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return nsScriptableParamInfo::Create(mInfo, mMethod.GetParam(idx), _retval);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableParamInfo result; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetResult(nsIScriptableParamInfo * *aResult)
|
||||
{
|
||||
return nsScriptableParamInfo::Create(mInfo, mMethod.GetResult(), aResult);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableInterfaceInfo::Create(nsIInterfaceInfo* aInfo,
|
||||
nsIScriptableInterfaceInfo** aResult)
|
||||
{
|
||||
nsScriptableInterfaceInfo* obj = new nsScriptableInterfaceInfo(aInfo);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableInterfaceInfo*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableInterfaceInfo, nsIScriptableInterfaceInfo)
|
||||
|
||||
nsScriptableInterfaceInfo::nsScriptableInterfaceInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsScriptableInterfaceInfo::nsScriptableInterfaceInfo(nsIInterfaceInfo* aInfo)
|
||||
: mInfo(aInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsScriptableInterfaceInfo::~nsScriptableInterfaceInfo()
|
||||
{
|
||||
// empty;
|
||||
}
|
||||
|
||||
/* [noscript] attribute nsIInterfaceInfo info; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInfo(nsIInterfaceInfo * *aInfo)
|
||||
{
|
||||
if(mInfo)
|
||||
NS_ADDREF(*aInfo = mInfo);
|
||||
else
|
||||
*aInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::SetInfo(nsIInterfaceInfo * aInfo)
|
||||
{
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
mInfo = aInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef PRBool (*InfoTester)(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info);
|
||||
|
||||
static PRBool IIDTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
{
|
||||
return NS_SUCCEEDED(manager->GetInfoForIID((const nsIID *) data, info)) &&
|
||||
*info;
|
||||
}
|
||||
|
||||
static PRBool NameTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
{
|
||||
return NS_SUCCEEDED(manager->GetInfoForName((const char *) data, info)) &&
|
||||
*info;
|
||||
}
|
||||
|
||||
static nsresult FindInfo(InfoTester tester, const void* data, nsIInterfaceInfo** info)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
|
||||
if(!iim)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if(tester(iim, data, info))
|
||||
return NS_OK;
|
||||
|
||||
// If not found, then let's ask additional managers.
|
||||
|
||||
PRBool yes;
|
||||
nsCOMPtr<nsISimpleEnumerator> list;
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism;
|
||||
|
||||
if((nsnull != (iism = do_QueryInterface(iim))) &&
|
||||
NS_SUCCEEDED(iism->HasAdditionalManagers(&yes)) && yes &&
|
||||
NS_SUCCEEDED(iism->EnumerateAdditionalManagers(getter_AddRefs(list))) &&
|
||||
list)
|
||||
{
|
||||
PRBool more;
|
||||
nsCOMPtr<nsIInterfaceInfoManager> current;
|
||||
|
||||
while(NS_SUCCEEDED(list->HasMoreElements(&more)) && more &&
|
||||
NS_SUCCEEDED(list->GetNext(getter_AddRefs(current))) && current)
|
||||
{
|
||||
if(tester(current, data, info))
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/* void Init (in nsIIDPtr aIID); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::Init(const nsIID * aIID)
|
||||
{
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if(!aIID)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return FindInfo(IIDTester, aIID, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* void initWithName (in string name); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::InitWithName(const char *name)
|
||||
{
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if(!name)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return FindInfo(NameTester, name, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetName(char * *aName)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetName(aName);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr interfaceID; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetInterfaceIID(aInterfaceID);
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isValid; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsValid(PRBool *aIsValid)
|
||||
{
|
||||
*aIsValid = !!mInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isScriptable; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsScriptable(PRBool *aIsScriptable)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->IsScriptable(aIsScriptable);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableInterfaceInfo parent; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetParent(nsIScriptableInterfaceInfo * *aParent)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> parentInfo;
|
||||
nsresult rv = mInfo->GetParent(getter_AddRefs(parentInfo));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(parentInfo)
|
||||
return Create(parentInfo, aParent);
|
||||
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 methodCount; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetMethodCount(aMethodCount);
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 constantCount; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetConstantCount(aConstantCount);
|
||||
}
|
||||
|
||||
/* nsIScriptableMethodInfo getMethodInfo (in PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodInfo(PRUint16 index, nsIScriptableMethodInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
nsresult rv = mInfo->GetMethodInfo(index, &methodInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableMethodInfo getMethodInfoForName (in string methodName, out PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16 *index, nsIScriptableMethodInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
nsresult rv = mInfo->GetMethodInfoForName(methodName, index, &methodInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableConstant getConstant (in PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetConstant(PRUint16 index, nsIScriptableConstant **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTConstant* constant;
|
||||
nsresult rv = mInfo->GetConstant(index, &constant);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableConstant::Create(mInfo, *constant, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableInterfaceInfo getInfoForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, nsIScriptableInterfaceInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
rv = mInfo->GetInfoForParam(methodIndex, paramInfo, getter_AddRefs(info));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(info)
|
||||
return Create(info, _retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, nsIID * *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetIIDForParam(methodIndex, paramInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableDataType getTypeForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, nsIScriptableDataType **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsXPTType type;
|
||||
|
||||
rv = mInfo->GetTypeForParam(methodIndex, paramInfo, dimension, &type);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableDataType::Create(type, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetSizeIsArgNumberForParam(methodIndex, paramInfo,
|
||||
dimension, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetLengthIsArgNumberForParam(methodIndex, paramInfo,
|
||||
dimension, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetInterfaceIsArgNumberForParam(methodIndex, paramInfo,
|
||||
_retval);
|
||||
}
|
||||
|
||||
/* PRBool isIID (in nsIIDPtr IID); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->IsIID(IID, _retval);
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isFunction; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsFunction(PRBool *aIsFunction)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->IsFunction(aIsFunction);
|
||||
}
|
||||
|
||||
/* PRBool hasAncestor (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->HasAncestor(iid, _retval);
|
||||
}
|
|
@ -74,7 +74,10 @@ public:
|
|||
nsGenericInterfaceInfoSet();
|
||||
virtual ~nsGenericInterfaceInfoSet();
|
||||
|
||||
XPTArena* GetArena() {return mArena;}
|
||||
XPTArena* GetArena()
|
||||
{
|
||||
return mArena;
|
||||
}
|
||||
|
||||
const XPTTypeDescriptor* GetAdditionalTypeAt(PRUint16 aIndex)
|
||||
{
|
||||
|
@ -92,10 +95,20 @@ private:
|
|||
nsresult IndexOfIID(const nsIID & aIID, PRUint16 *_retval);
|
||||
nsresult IndexOfName(const char* aName, PRUint16 *_retval);
|
||||
|
||||
void* SetOwnedFlag(void* p) {return (void*) ((long)p | 1);}
|
||||
void* ClearOwnedFlag(void* p) {return (void*) ((long)p & ~(long)1);}
|
||||
PRBool CheckOwnedFlag(void* p) {return (PRBool) ((long)p & (long)1);}
|
||||
|
||||
void* SetOwnedFlag(void* p)
|
||||
{
|
||||
NS_ASSERTION(sizeof(void *) == sizeof(long),
|
||||
"The size of a pointer != size of long!");
|
||||
return (void*) ((long)p | 1);
|
||||
}
|
||||
void* ClearOwnedFlag(void* p)
|
||||
{
|
||||
return (void*) ((long)p & ~(long)1);
|
||||
}
|
||||
PRBool CheckOwnedFlag(void* p)
|
||||
{
|
||||
return (PRBool) ((long)p & (long)1);
|
||||
}
|
||||
|
||||
private:
|
||||
nsVoidArray mInterfaces;
|
||||
|
@ -112,15 +125,18 @@ public:
|
|||
NS_DECL_NSIINTERFACEINFO
|
||||
NS_DECL_NSIGENERICINTERFACEINFO
|
||||
|
||||
nsGenericInterfaceInfo(); // not implemented
|
||||
nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
||||
const char *aName,
|
||||
const nsIID & aIID,
|
||||
nsIInterfaceInfo* mParent,
|
||||
nsIInterfaceInfo* aParent,
|
||||
PRUint8 aFlags);
|
||||
virtual ~nsGenericInterfaceInfo() {}
|
||||
virtual ~nsGenericInterfaceInfo()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
nsGenericInterfaceInfo(); // not implemented
|
||||
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const XPTParamDescriptor* param)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
|
|
|
@ -122,7 +122,8 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
|
||||
/* XPTParamDescriptorPtr allocateParamArray (in PRUint16 aCount); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AllocateParamArray(PRUint16 aCount, XPTParamDescriptor * *_retval)
|
||||
nsGenericInterfaceInfoSet::AllocateParamArray(PRUint16 aCount,
|
||||
XPTParamDescriptor * *_retval)
|
||||
{
|
||||
*_retval = (XPTParamDescriptor*)
|
||||
XPT_MALLOC(GetArena(), sizeof(XPTParamDescriptor) * aCount);
|
||||
|
@ -131,7 +132,8 @@ nsGenericInterfaceInfoSet::AllocateParamArray(PRUint16 aCount, XPTParamDescripto
|
|||
|
||||
/* XPTTypeDescriptorPtr allocateAdditionalType (out PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, XPTTypeDescriptor * *_retval)
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex,
|
||||
XPTTypeDescriptor * *_retval)
|
||||
{
|
||||
*_retval = (XPTTypeDescriptor*)
|
||||
XPT_MALLOC(GetArena(), sizeof(XPTTypeDescriptor));
|
||||
|
@ -141,9 +143,16 @@ nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, XPTTypeDescr
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint16 createAndAppendInterface (in string aName, in nsIIDRef aIID, in PRUint16 aParent, in PRUint8 aFlags, out nsIGenericInterfaceInfo aInfo); */
|
||||
/* PRUint16 createAndAppendInterface (in string aName, in nsIIDRef
|
||||
aIID, in PRUint16 aParent, in PRUint8 aFlags, out
|
||||
nsIGenericInterfaceInfo aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::CreateAndAppendInterface(const char *aName, const nsIID & aIID, PRUint16 aParent, PRUint8 aFlags, nsIGenericInterfaceInfo **aInfo, PRUint16 *_retval)
|
||||
nsGenericInterfaceInfoSet::CreateAndAppendInterface(const char *aName,
|
||||
const nsIID & aIID,
|
||||
PRUint16 aParent,
|
||||
PRUint8 aFlags,
|
||||
nsIGenericInterfaceInfo **aInfo,
|
||||
PRUint16 *_retval)
|
||||
{
|
||||
nsGenericInterfaceInfo* info =
|
||||
new nsGenericInterfaceInfo(this, aName, aIID,
|
||||
|
@ -159,7 +168,8 @@ nsGenericInterfaceInfoSet::CreateAndAppendInterface(const char *aName, const nsI
|
|||
|
||||
/* PRUint16 appendExternalInterface (in nsIInterfaceInfo aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AppendExternalInterface(nsIInterfaceInfo *aInfo, PRUint16 *_retval)
|
||||
nsGenericInterfaceInfoSet::AppendExternalInterface(nsIInterfaceInfo *aInfo,
|
||||
PRUint16 *_retval)
|
||||
{
|
||||
if(!mInterfaces.AppendElement(aInfo))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -177,18 +187,21 @@ nsGenericInterfaceInfoSet::IndexOf(const nsIID & aIID, PRUint16 *_retval)
|
|||
}
|
||||
|
||||
/* PRUint16 indexOfByName (in string aName); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::IndexOfByName(const char *aName, PRUint16 *_retval)
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::IndexOfByName(const char *aName,
|
||||
PRUint16 *_retval)
|
||||
{
|
||||
return IndexOfName(aName, _retval);
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo interfaceInfoAt (in PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::InterfaceInfoAt(PRUint16 aIndex, nsIInterfaceInfo **_retval)
|
||||
nsGenericInterfaceInfoSet::InterfaceInfoAt(PRUint16 aIndex,
|
||||
nsIInterfaceInfo **_retval)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16)mInterfaces.Count(), "bad index");
|
||||
|
||||
*_retval = (nsIInterfaceInfo*) ClearOwnedFlag(mInterfaces.ElementAt(aIndex));
|
||||
*_retval = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(aIndex));
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -197,7 +210,9 @@ nsGenericInterfaceInfoSet::InterfaceInfoAt(PRUint16 aIndex, nsIInterfaceInfo **_
|
|||
// nsIInterfaceInfoManager methods...
|
||||
|
||||
/* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::GetInfoForIID(const nsIID * iid,
|
||||
nsIInterfaceInfo **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfIID(*iid, &index);
|
||||
|
@ -207,7 +222,9 @@ NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForIID(const nsIID * iid, nsIInt
|
|||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForName (in string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForName(const char *name, nsIInterfaceInfo **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::GetInfoForName(const char *name,
|
||||
nsIInterfaceInfo **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfName(name, &index);
|
||||
|
@ -217,7 +234,8 @@ NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForName(const char *name, nsIInt
|
|||
}
|
||||
|
||||
/* nsIIDPtr getIIDForName (in string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetIIDForName(const char *name, nsIID * *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::GetIIDForName(const char *name, nsIID **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfName(name, &index);
|
||||
|
@ -232,7 +250,8 @@ NS_IMETHODIMP nsGenericInterfaceInfoSet::GetIIDForName(const char *name, nsIID *
|
|||
}
|
||||
|
||||
/* string getNameForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetNameForIID(const nsIID * iid, char **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::GetNameForIID(const nsIID * iid, char **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfIID(*iid, &index);
|
||||
|
@ -247,22 +266,26 @@ NS_IMETHODIMP nsGenericInterfaceInfoSet::GetNameForIID(const nsIID * iid, char *
|
|||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfaces (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::EnumerateInterfaces(nsIEnumerator **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::EnumerateInterfaces(nsIEnumerator **_retval)
|
||||
{
|
||||
return EnumerateInterfacesWhoseNamesStartWith(nsnull, _retval);
|
||||
}
|
||||
|
||||
/* void autoRegisterInterfaces (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::AutoRegisterInterfaces()
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AutoRegisterInterfaces()
|
||||
{
|
||||
// NOP
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfacesWhoseNamesStartWith (in string prefix); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::EnumerateInterfacesWhoseNamesStartWith(const char *prefix, nsIEnumerator **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::EnumerateInterfacesWhoseNamesStartWith(const char *prefix,
|
||||
nsIEnumerator **_retval)
|
||||
{
|
||||
int count = (PRUint16) mInterfaces.Count();
|
||||
int count = (int) mInterfaces.Count();
|
||||
int len = prefix ? PL_strlen(prefix) : 0;
|
||||
const char* name;
|
||||
|
||||
|
@ -313,11 +336,11 @@ nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
|||
const nsIID & aIID,
|
||||
nsIInterfaceInfo* aParent,
|
||||
PRUint8 aFlags)
|
||||
: mName(nsnull),
|
||||
mIID(aIID),
|
||||
mSet(aSet),
|
||||
mParent(aParent),
|
||||
mFlags(aFlags)
|
||||
: mName(nsnull),
|
||||
mIID(aIID),
|
||||
mSet(aSet),
|
||||
mParent(aParent),
|
||||
mFlags(aFlags)
|
||||
{
|
||||
if(mParent)
|
||||
{
|
||||
|
@ -340,7 +363,8 @@ nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
|||
|
||||
/* PRUint16 appendMethod (in XPTMethodDescriptorPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_retval)
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod,
|
||||
PRUint16 *_retval)
|
||||
{
|
||||
XPTMethodDescriptor* desc = (XPTMethodDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTMethodDescriptor));
|
||||
|
@ -354,14 +378,17 @@ nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_r
|
|||
if(!desc->name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// XPT_MALLOC returns zeroed out memory, no need to copy the
|
||||
// terminating null character.
|
||||
memcpy(desc->name, aMethod->name, len);
|
||||
|
||||
return mMethods.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRUint16 appendConst (in XPTConstDescriptorPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, PRUint16 *_retval)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst,
|
||||
PRUint16 *_retval)
|
||||
{
|
||||
NS_ASSERTION(aConst->type.prefix.flags == TD_INT16 ||
|
||||
aConst->type.prefix.flags == TD_UINT16 ||
|
||||
|
@ -381,6 +408,8 @@ NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, P
|
|||
if(!desc->name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// XPT_MALLOC returns zeroed out memory, no need to copy the
|
||||
// terminating null character.
|
||||
memcpy(desc->name, aConst->name, len);
|
||||
|
||||
return mConstants.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -390,28 +419,32 @@ NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, P
|
|||
// nsIInterfaceInfo methods...
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetName(char * *aName)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetName(char * *aName)
|
||||
{
|
||||
*aName = (char*) nsMemory::Clone(mName, PL_strlen(mName)+1);
|
||||
return *aName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr InterfaceIID; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInterfaceIID(nsIID * *aIID)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetInterfaceIID(nsIID * *aIID)
|
||||
{
|
||||
*aIID = (nsIID*) nsMemory::Clone(&mIID, sizeof(nsIID));
|
||||
return *aIID ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRBool isScriptable (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsScriptable(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::IsScriptable(PRBool *_retval)
|
||||
{
|
||||
*_retval = XPT_ID_IS_SCRIPTABLE(mFlags) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIInterfaceInfo parent; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetParent(nsIInterfaceInfo * *aParent)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetParent(nsIInterfaceInfo * *aParent)
|
||||
{
|
||||
*aParent = mParent;
|
||||
NS_IF_ADDREF(*aParent);
|
||||
|
@ -419,21 +452,26 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetParent(nsIInterfaceInfo * *aParent)
|
|||
}
|
||||
|
||||
/* readonly attribute PRUint16 methodCount; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
|
||||
{
|
||||
*aMethodCount = mMethodBaseIndex + (PRUint16) mMethods.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 constantCount; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
||||
{
|
||||
*aConstantCount = mConstantBaseIndex + (PRUint16) mConstants.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getMethodInfo (in PRUint16 index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfo(PRUint16 index, const nsXPTMethodInfo * *info)
|
||||
/* void getMethodInfo (in PRUint16 index, [shared, retval] out
|
||||
nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetMethodInfo(PRUint16 index,
|
||||
const nsXPTMethodInfo * *info)
|
||||
{
|
||||
if(index < mMethodBaseIndex)
|
||||
return mParent->GetMethodInfo(index, info);
|
||||
|
@ -441,8 +479,12 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfo(PRUint16 index, const nsXPTM
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getMethodInfoForName (in string methodName, out PRUint16 index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16 *index, const nsXPTMethodInfo * *info)
|
||||
/* void getMethodInfoForName (in string methodName, out PRUint16
|
||||
index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetMethodInfoForName(const char *methodName,
|
||||
PRUint16 *index,
|
||||
const nsXPTMethodInfo * *info)
|
||||
{
|
||||
PRUint16 count = mMethodBaseIndex + (PRUint16) mMethods.Count();
|
||||
for(PRUint16 i = 0; i < count; i++)
|
||||
|
@ -464,35 +506,49 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfoForName(const char *methodNam
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* void getConstant (in PRUint16 index, [shared, retval] out nsXPTConstantPtr constant); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetConstant(PRUint16 index, const nsXPTConstant * *constant)
|
||||
/* void getConstant (in PRUint16 index, [shared, retval] out
|
||||
nsXPTConstantPtr constant); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetConstant(PRUint16 index,
|
||||
const nsXPTConstant * *constant)
|
||||
{
|
||||
if(index < mConstantBaseIndex)
|
||||
return mParent->GetConstant(index, constant);
|
||||
*constant = (const nsXPTConstant *) mConstants.ElementAt(index-mConstantBaseIndex);
|
||||
*constant = (const nsXPTConstant *)
|
||||
mConstants.ElementAt(index-mConstantBaseIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval)
|
||||
/* nsIInterfaceInfo getInfoForParam (in PRUint16 methodIndex, [const]
|
||||
in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetInfoForParam(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo * param,
|
||||
nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetInfoForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE,
|
||||
"not an interface");
|
||||
|
||||
return mSet->InterfaceInfoAt(td->type.iface, _retval);
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID * *_retval)
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, [const] in
|
||||
nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetIIDForParam(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo * param,
|
||||
nsIID * *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetIIDForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE,
|
||||
"not an interface");
|
||||
|
||||
nsIInterfaceInfo* info = mSet->InfoAtNoAddRef(td->type.iface);
|
||||
if(!info)
|
||||
|
@ -501,11 +557,16 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, const
|
|||
return info->GetInterfaceIID(_retval);
|
||||
}
|
||||
|
||||
/* nsXPTType getTypeForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, nsXPTType *_retval)
|
||||
/* nsXPTType getTypeForParam (in PRUint16 methodIndex, [const] in
|
||||
nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetTypeForParam(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo * param,
|
||||
PRUint16 dimension, nsXPTType *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetTypeForParam(methodIndex, param, dimension, _retval);
|
||||
return mParent->GetTypeForParam(methodIndex, param, dimension,
|
||||
_retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
@ -514,11 +575,17 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, cons
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval)
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex,
|
||||
[const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo *param,
|
||||
PRUint16 dimension,
|
||||
PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetSizeIsArgNumberForParam(methodIndex, param, dimension, _retval);
|
||||
return mParent->GetSizeIsArgNumberForParam(methodIndex, param,
|
||||
dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
@ -527,11 +594,17 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 method
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval)
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex,
|
||||
[const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo *param,
|
||||
PRUint16 dimension,
|
||||
PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetLengthIsArgNumberForParam(methodIndex, param, dimension, _retval);
|
||||
return mParent->GetLengthIsArgNumberForParam(methodIndex, param,
|
||||
dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
@ -540,53 +613,65 @@ NS_IMETHODIMP nsGenericInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 meth
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint8 *_retval)
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex,
|
||||
[const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo *param,
|
||||
PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetInterfaceIsArgNumberForParam(methodIndex, param, _retval);
|
||||
return mParent->GetInterfaceIsArgNumberForParam(methodIndex, param,
|
||||
_retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_IS_TYPE, "not an interface");
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_IS_TYPE,
|
||||
"not an interface");
|
||||
|
||||
*_retval = td->argnum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool isIID (in nsIIDPtr IID); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
|
||||
{
|
||||
*_retval = mIID.Equals(*IID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getNameShared ([shared, retval] out string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetNameShared(const char **name)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetNameShared(const char **name)
|
||||
{
|
||||
*name = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getIIDShared ([shared, retval] out nsIIDPtrShared iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDShared(const nsIID * *iid)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::GetIIDShared(const nsIID * *iid)
|
||||
{
|
||||
*iid = &mIID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool isFunction (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsFunction(PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::IsFunction(PRBool *_retval)
|
||||
{
|
||||
*_retval = XPT_ID_IS_FUNCTION(mFlags) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool hasAncestor (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> current = NS_STATIC_CAST(nsIInterfaceInfo*, this);
|
||||
nsCOMPtr<nsIInterfaceInfo> current =
|
||||
NS_STATIC_CAST(nsIInterfaceInfo*, this);
|
||||
while(current)
|
||||
{
|
||||
PRBool same;
|
||||
|
@ -601,14 +686,19 @@ NS_IMETHODIMP nsGenericInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_re
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [notxpcom] nsresult getIIDForParamNoAlloc (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, out nsIID iid); */
|
||||
NS_IMETHODIMP_(nsresult) nsGenericInterfaceInfo::GetIIDForParamNoAlloc(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID *iid)
|
||||
/* [notxpcom] nsresult getIIDForParamNoAlloc (in PRUint16 methodIndex,
|
||||
[const] in nsXPTParamInfoPtr param, out nsIID iid); */
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
nsGenericInterfaceInfo::GetIIDForParamNoAlloc(PRUint16 methodIndex,
|
||||
const nsXPTParamInfo * param,
|
||||
nsIID *iid)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetIIDForParamNoAlloc(methodIndex, param, iid);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE,
|
||||
"not an interface");
|
||||
|
||||
nsIInterfaceInfo* info = mSet->InfoAtNoAddRef(td->type.iface);
|
||||
if(!info)
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
#include "iixprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
static inline nsresult CloneString(const char* inStr, char** outStr)
|
||||
static inline
|
||||
nsresult CloneString(const char* inStr, char** outStr)
|
||||
{
|
||||
*outStr = (char*) nsMemory::Clone(inStr, strlen(inStr)+1);
|
||||
return *outStr ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -59,14 +60,18 @@ public:
|
|||
static nsresult Create(const nsXPTType& aType,
|
||||
nsIScriptableDataType** aResult);
|
||||
|
||||
nsScriptableDataType(); // not implemented
|
||||
|
||||
nsScriptableDataType(const nsXPTType& aType)
|
||||
: mType(aType) {}
|
||||
: mType(aType)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~nsScriptableDataType() {}
|
||||
virtual ~nsScriptableDataType()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
nsScriptableDataType(); // not implemented
|
||||
|
||||
nsXPTType mType;
|
||||
};
|
||||
|
||||
|
@ -161,13 +166,18 @@ public:
|
|||
const nsXPTParamInfo& aParam,
|
||||
nsIScriptableParamInfo** aResult);
|
||||
|
||||
nsScriptableParamInfo(); // not implemented
|
||||
nsScriptableParamInfo(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam)
|
||||
: mInfo(aInfo), mParam(aParam) {}
|
||||
virtual ~nsScriptableParamInfo() {}
|
||||
: mInfo(aInfo), mParam(aParam)
|
||||
{
|
||||
}
|
||||
virtual ~nsScriptableParamInfo()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
nsScriptableParamInfo(); // not implemented
|
||||
|
||||
// Holding onto the interface info keeps the underlying param alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
nsXPTParamInfo mParam;
|
||||
|
@ -237,7 +247,8 @@ nsScriptableParamInfo::GetType(nsIScriptableDataType * *aType)
|
|||
return nsScriptableDataType::Create(mParam.GetType(), aType);
|
||||
}
|
||||
|
||||
/* [noscript] void getParamInfo ([shared, const, retval] out nsXPTParamInfoPtr aInfo); */
|
||||
/* [noscript] void getParamInfo ([shared, const, retval] out
|
||||
nsXPTParamInfoPtr aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetParamInfo(const nsXPTParamInfo * *aInfo)
|
||||
{
|
||||
|
@ -259,8 +270,12 @@ public:
|
|||
nsScriptableConstant(); // not implemented
|
||||
nsScriptableConstant(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst)
|
||||
: mInfo(aInfo), mConst(aConst) {}
|
||||
virtual ~nsScriptableConstant() {}
|
||||
: mInfo(aInfo), mConst(aConst)
|
||||
{
|
||||
}
|
||||
virtual ~nsScriptableConstant()
|
||||
{
|
||||
}
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying const alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
|
@ -354,13 +369,19 @@ public:
|
|||
const nsXPTMethodInfo& aMethod,
|
||||
nsIScriptableMethodInfo** aResult);
|
||||
|
||||
nsScriptableMethodInfo(); // not implemented
|
||||
nsScriptableMethodInfo(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod)
|
||||
: mInfo(aInfo), mMethod(aMethod) {}
|
||||
virtual ~nsScriptableMethodInfo() {}
|
||||
: mInfo(aInfo), mMethod(aMethod)
|
||||
{
|
||||
}
|
||||
virtual ~nsScriptableMethodInfo()
|
||||
{
|
||||
}
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying method alive.
|
||||
nsScriptableMethodInfo(); // not implemented
|
||||
|
||||
// Holding onto the interface info keeps the underlying method
|
||||
// alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
const nsXPTMethodInfo& mMethod;
|
||||
};
|
||||
|
@ -442,7 +463,8 @@ nsScriptableMethodInfo::GetParam(PRUint8 idx, nsIScriptableParamInfo **_retval)
|
|||
{
|
||||
if(idx >= mMethod.GetParamCount())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return nsScriptableParamInfo::Create(mInfo, mMethod.GetParam(idx), _retval);
|
||||
return nsScriptableParamInfo::Create(mInfo, mMethod.GetParam(idx),
|
||||
_retval);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableParamInfo result; */
|
||||
|
@ -505,24 +527,27 @@ nsScriptableInterfaceInfo::SetInfo(nsIInterfaceInfo * aInfo)
|
|||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef PRBool (*InfoTester)(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info);
|
||||
typedef PRBool (*InfoTester)(nsIInterfaceInfoManager* manager,
|
||||
const void* data, nsIInterfaceInfo** info);
|
||||
|
||||
static PRBool IIDTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
static PRBool
|
||||
IIDTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
{
|
||||
return NS_SUCCEEDED(manager->GetInfoForIID((const nsIID *) data, info)) &&
|
||||
*info;
|
||||
}
|
||||
|
||||
static PRBool NameTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
static PRBool
|
||||
NameTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
{
|
||||
return NS_SUCCEEDED(manager->GetInfoForName((const char *) data, info)) &&
|
||||
*info;
|
||||
}
|
||||
|
||||
static nsresult FindInfo(InfoTester tester, const void* data, nsIInterfaceInfo** info)
|
||||
static nsresult
|
||||
FindInfo(InfoTester tester, const void* data, nsIInterfaceInfo** info)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
|
@ -666,7 +691,8 @@ nsScriptableInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
|||
|
||||
/* nsIScriptableMethodInfo getMethodInfo (in PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodInfo(PRUint16 index, nsIScriptableMethodInfo **_retval)
|
||||
nsScriptableInterfaceInfo::GetMethodInfo(PRUint16 index,
|
||||
nsIScriptableMethodInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -679,9 +705,12 @@ nsScriptableInterfaceInfo::GetMethodInfo(PRUint16 index, nsIScriptableMethodInfo
|
|||
return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableMethodInfo getMethodInfoForName (in string methodName, out PRUint16 index); */
|
||||
/* nsIScriptableMethodInfo getMethodInfoForName (in string methodName,
|
||||
out PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16 *index, nsIScriptableMethodInfo **_retval)
|
||||
nsScriptableInterfaceInfo::GetMethodInfoForName(const char *methodName,
|
||||
PRUint16 *index,
|
||||
nsIScriptableMethodInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -696,7 +725,8 @@ nsScriptableInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16
|
|||
|
||||
/* nsIScriptableConstant getConstant (in PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetConstant(PRUint16 index, nsIScriptableConstant **_retval)
|
||||
nsScriptableInterfaceInfo::GetConstant(PRUint16 index,
|
||||
nsIScriptableConstant **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -709,9 +739,12 @@ nsScriptableInterfaceInfo::GetConstant(PRUint16 index, nsIScriptableConstant **_
|
|||
return nsScriptableConstant::Create(mInfo, *constant, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableInterfaceInfo getInfoForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
/* nsIScriptableInterfaceInfo getInfoForParam (in PRUint16
|
||||
methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, nsIScriptableInterfaceInfo **_retval)
|
||||
nsScriptableInterfaceInfo::GetInfoForParam(PRUint16 methodIndex,
|
||||
nsIScriptableParamInfo *param,
|
||||
nsIScriptableInterfaceInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -733,9 +766,12 @@ nsScriptableInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, nsIScriptablePa
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, in
|
||||
nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, nsIID * *_retval)
|
||||
nsScriptableInterfaceInfo::GetIIDForParam(PRUint16 methodIndex,
|
||||
nsIScriptableParamInfo *param,
|
||||
nsIID * *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -748,9 +784,13 @@ nsScriptableInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, nsIScriptablePar
|
|||
return mInfo->GetIIDForParam(methodIndex, paramInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableDataType getTypeForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
/* nsIScriptableDataType getTypeForParam (in PRUint16 methodIndex, in
|
||||
nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, nsIScriptableDataType **_retval)
|
||||
nsScriptableInterfaceInfo::GetTypeForParam(PRUint16 methodIndex,
|
||||
nsIScriptableParamInfo *param,
|
||||
PRUint16 dimension,
|
||||
nsIScriptableDataType **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -769,9 +809,13 @@ nsScriptableInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, nsIScriptablePa
|
|||
return nsScriptableDataType::Create(type, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, in
|
||||
nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, PRUint8 *_retval)
|
||||
nsScriptableInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex,
|
||||
nsIScriptableParamInfo *param,
|
||||
PRUint16 dimension,
|
||||
PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -781,13 +825,17 @@ nsScriptableInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, nsIS
|
|||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetSizeIsArgNumberForParam(methodIndex, paramInfo,
|
||||
dimension, _retval);
|
||||
return mInfo->GetSizeIsArgNumberForParam(methodIndex, paramInfo, dimension,
|
||||
_retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, in
|
||||
nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, PRUint8 *_retval)
|
||||
nsScriptableInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex,
|
||||
nsIScriptableParamInfo *param,
|
||||
PRUint16 dimension,
|
||||
PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
@ -801,9 +849,12 @@ nsScriptableInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, ns
|
|||
dimension, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex,
|
||||
in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint8 *_retval)
|
||||
nsScriptableInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex,
|
||||
nsIScriptableParamInfo *param,
|
||||
PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
|
|
@ -45,8 +45,7 @@
|
|||
#include "nsISOAPParameter.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
WSPCallContext::WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
WSPCallContext::WSPCallContext(WSPProxy* aProxy, nsISOAPCall* aSOAPCall,
|
||||
const nsAString& aMethodName,
|
||||
nsIWSDLOperation* aOperation)
|
||||
: mProxy(aProxy), mCall(aSOAPCall), mMethodName(aMethodName),
|
||||
|
@ -145,13 +144,11 @@ WSPCallContext::GetSoapResponse(nsISOAPResponse * *aSoapResponse)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean handleResponse (in nsISOAPResponse aResponse, in nsISOAPCall aCall, in nsresult status, in boolean aLast); */
|
||||
/* boolean handleResponse (in nsISOAPResponse aResponse, in
|
||||
nsISOAPCall aCall, in nsresult status, in boolean aLast); */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::HandleResponse(nsISOAPResponse *aResponse,
|
||||
nsISOAPCall *aCall,
|
||||
nsresult status,
|
||||
PRBool aLast,
|
||||
PRBool *_retval)
|
||||
WSPCallContext::HandleResponse(nsISOAPResponse *aResponse, nsISOAPCall *aCall,
|
||||
nsresult status, PRBool aLast, PRBool *_retval)
|
||||
{
|
||||
NS_ASSERTION(aCall == mCall, "unexpected call instance");
|
||||
NS_ASSERTION(aLast, "only single response expected");
|
||||
|
@ -171,8 +168,7 @@ WSPCallContext::CallAsync(PRUint32 aListenerMethodIndex,
|
|||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params)
|
||||
WSPCallContext::CallSync(PRUint32 aMethodIndex, nsXPTCMiniVariant* params)
|
||||
{
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
nsresult rv = mCall->Invoke(getter_AddRefs(response));
|
||||
|
@ -190,13 +186,15 @@ WSPCallContext::CallCompletionListener()
|
|||
#define PARAM_BUFFER_COUNT 8 /* Never set less than 2 */
|
||||
|
||||
if (!mProxy) {
|
||||
NS_ERROR("Huh, no proxy?");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
nsXPTCVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCVariant* dispatchParams = nsnull;
|
||||
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
nsCOMPtr<nsISOAPFault> fault;
|
||||
nsCOMPtr<nsISOAPFault> fault;
|
||||
mCompletion->GetResponse(getter_AddRefs(response));
|
||||
if (response) {
|
||||
rv = response->GetFault(getter_AddRefs(fault));
|
||||
|
@ -214,7 +212,8 @@ WSPCallContext::CallCompletionListener()
|
|||
|
||||
nsCOMPtr<nsIInterfaceInfo> listenerInterfaceInfo;
|
||||
mProxy->GetListenerInterfaceInfo(getter_AddRefs(listenerInterfaceInfo));
|
||||
NS_ASSERTION(listenerInterfaceInfo, "WSPCallContext:Missing listener interface info");
|
||||
NS_ASSERTION(listenerInterfaceInfo,
|
||||
"WSPCallContext:Missing listener interface info");
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
rv = listenerInterfaceInfo->GetMethodInfo(mListenerMethodIndex,
|
||||
|
@ -266,7 +265,8 @@ WSPCallContext::CallCompletionListener()
|
|||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
@ -306,7 +306,8 @@ WSPCallContext::CallCompletionListener()
|
|||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPPartBinding> partBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPPartBinding> partBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
@ -347,30 +348,31 @@ WSPCallContext::CallCompletionListener()
|
|||
|
||||
nsCOMPtr<nsIVariant> value;
|
||||
rv = block->GetValue(getter_AddRefs(value));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv) || !value) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsXPTCVariant* vars = dispatchParams+paramIndex;
|
||||
nsXPTCVariant* vars = dispatchParams + paramIndex;
|
||||
|
||||
if (paramIndex < maxParamIndex &&
|
||||
methodInfo->GetParam((PRUint8)(paramIndex+1)).GetType().IsArray()) {
|
||||
paramIndex++;
|
||||
}
|
||||
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex, "WSDL/IInfo param count mismatch");
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
const nsXPTParamInfo& paramInfo = methodInfo->GetParam(paramIndex);
|
||||
rv = WSPProxy::VariantToInParameter(listenerInterfaceInfo,
|
||||
mListenerMethodIndex,
|
||||
¶mInfo,
|
||||
mListenerMethodIndex, ¶mInfo,
|
||||
value, vars);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(paramIndex == maxParamIndex, "WSDL/IInfo param count mismatch");
|
||||
NS_ASSERTION(paramIndex == maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
dispatchParams[paramIndex].val.p =
|
||||
NS_STATIC_CAST(nsIWebServiceCallContext*, this);
|
||||
|
@ -390,7 +392,7 @@ call_completion_end:
|
|||
if (bodyCount) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
|
||||
}
|
||||
if(dispatchParams && dispatchParams != paramBuffer) {
|
||||
if(dispatchParams != paramBuffer) {
|
||||
delete [] dispatchParams;
|
||||
}
|
||||
nsCOMPtr<nsIWebServiceCallContext> kungFuDeathGrip(this);
|
||||
|
|
|
@ -47,11 +47,13 @@
|
|||
// xpcom includes
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
class WSPComplexTypeProperty : public nsIProperty {
|
||||
class WSPComplexTypeProperty : public nsIProperty
|
||||
{
|
||||
public:
|
||||
WSPComplexTypeProperty(const nsAString& aName,
|
||||
nsIVariant* aValue);
|
||||
virtual ~WSPComplexTypeProperty() {}
|
||||
WSPComplexTypeProperty(const nsAString& aName, nsIVariant* aValue);
|
||||
virtual ~WSPComplexTypeProperty()
|
||||
{
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROPERTY
|
||||
|
@ -65,6 +67,7 @@ WSPComplexTypeProperty::WSPComplexTypeProperty(const nsAString& aName,
|
|||
nsIVariant* aValue)
|
||||
: mName(aName), mValue(aValue)
|
||||
{
|
||||
NS_ASSERTION(mValue, "Null value!");
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(WSPComplexTypeProperty, nsIProperty)
|
||||
|
@ -73,16 +76,16 @@ NS_IMPL_ISUPPORTS1(WSPComplexTypeProperty, nsIProperty)
|
|||
NS_IMETHODIMP
|
||||
WSPComplexTypeProperty::GetName(nsAString & aName)
|
||||
{
|
||||
aName.Assign(mName);
|
||||
return NS_OK;
|
||||
aName.Assign(mName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIVariant value; */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeProperty::GetValue(nsIVariant * *aValue)
|
||||
{
|
||||
NS_ADDREF(*aValue = mValue);
|
||||
return NS_OK;
|
||||
NS_ADDREF(*aValue = mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,7 +215,8 @@ NS_IMPL_ISUPPORTS2_CI(WSPComplexTypeWrapper,
|
|||
NS_IMETHODIMP
|
||||
WSPComplexTypeWrapper::GetEnumerator(nsISimpleEnumerator * *aEnumerator)
|
||||
{
|
||||
WSPComplexTypeEnumerator* enumerator = new WSPComplexTypeEnumerator(this, mInterfaceInfo);
|
||||
WSPComplexTypeEnumerator* enumerator =
|
||||
new WSPComplexTypeEnumerator(this, mInterfaceInfo);
|
||||
if (!enumerator) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -330,8 +334,8 @@ WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
|
|||
var[1].SetPtrIsData();
|
||||
var[1].ptr = &var[1].val;
|
||||
|
||||
rv = mInterfaceInfo->GetTypeForParam(aMethodIndex, ¶mInfo2,
|
||||
1, &arrayType);
|
||||
rv = mInterfaceInfo->GetTypeForParam(aMethodIndex, ¶mInfo2, 1,
|
||||
&arrayType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ WSPException::GetMessage(char * *aMessage)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aMessage);
|
||||
|
||||
nsAutoString faultString;
|
||||
*aMessage = nsnull;
|
||||
if (mFault) {
|
||||
nsAutoString faultString;
|
||||
mFault->GetFaultString(faultString);
|
||||
*aMessage = ToNewUTF8String(faultString);
|
||||
}
|
||||
|
@ -98,9 +98,9 @@ NS_IMETHODIMP
|
|||
WSPException::GetName(char * *aName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
nsAutoString faultCode;
|
||||
*aName = nsnull;
|
||||
if (mFault) {
|
||||
nsAutoString faultCode;
|
||||
mFault->GetFaultCode(faultCode);
|
||||
*aName = ToNewUTF8String(faultCode);
|
||||
}
|
||||
|
|
|
@ -53,10 +53,8 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWSDLLOADLISTENER
|
||||
|
||||
nsresult Run(const nsAString & wsdlURL,
|
||||
const nsAString & portname,
|
||||
const nsAString & qualifier,
|
||||
PRBool isAsync,
|
||||
nsresult Run(const nsAString & wsdlURL, const nsAString & portname,
|
||||
const nsAString & qualifier, PRBool isAsync,
|
||||
nsIWebServiceProxyCreationListener* aListener);
|
||||
|
||||
private:
|
||||
|
@ -79,10 +77,8 @@ WSPAsyncProxyCreator::~WSPAsyncProxyCreator()
|
|||
NS_IMPL_ISUPPORTS1(WSPAsyncProxyCreator, nsIWSDLLoadListener)
|
||||
|
||||
nsresult
|
||||
WSPAsyncProxyCreator::Run(const nsAString & wsdlURL,
|
||||
const nsAString & portname,
|
||||
const nsAString & qualifier,
|
||||
PRBool isAsync,
|
||||
WSPAsyncProxyCreator::Run(const nsAString& wsdlURL, const nsAString& portname,
|
||||
const nsAString& qualifier, PRBool isAsync,
|
||||
nsIWebServiceProxyCreationListener* aListener)
|
||||
{
|
||||
mWSDLURL = wsdlURL;
|
||||
|
@ -92,7 +88,8 @@ WSPAsyncProxyCreator::Run(const nsAString & wsdlURL,
|
|||
mListener = aListener;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWSDLLoader> loader = do_CreateInstance(NS_WSDLLOADER_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWSDLLoader> loader =
|
||||
do_CreateInstance(NS_WSDLLOADER_CONTRACTID, &rv);
|
||||
if (!loader) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -111,9 +108,11 @@ WSPAsyncProxyCreator::OnLoad(nsIWSDLPort *port)
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWSPInterfaceInfoService> iis = do_GetService(NS_WSP_INTERFACEINFOSERVICE_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWSPInterfaceInfoService> iis =
|
||||
do_GetService(NS_WSP_INTERFACEINFOSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv, NS_LITERAL_STRING("Can't get nsIWSPInterfaceInfoService"));
|
||||
return OnError(rv,
|
||||
NS_LITERAL_STRING("Can't get nsIWSPInterfaceInfoService"));
|
||||
}
|
||||
nsCOMPtr<nsIInterfaceInfoManager> manager;
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
|
@ -121,11 +120,13 @@ WSPAsyncProxyCreator::OnLoad(nsIWSDLPort *port)
|
|||
rv = iis->InfoForPort(port, mWSDLURL, mQualifier, mIsAsync,
|
||||
getter_AddRefs(manager), getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv, NS_LITERAL_STRING("Couldn't find interface info for port"));
|
||||
return OnError(rv,
|
||||
NS_LITERAL_STRING("Couldn't find interface info for port"));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebServiceProxy> proxy(do_CreateInstance(NS_WEBSERVICEPROXY_CONTRACTID, &rv));
|
||||
if (!proxy) {
|
||||
nsCOMPtr<nsIWebServiceProxy> proxy =
|
||||
do_CreateInstance(NS_WEBSERVICEPROXY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv, NS_LITERAL_STRING("Couldn't create proxy"));
|
||||
}
|
||||
|
||||
|
@ -148,6 +149,9 @@ WSPAsyncProxyCreator::OnError(nsresult status, const nsAString & statusMessage)
|
|||
|
||||
nsCAutoString temp(ToNewUTF8String(statusMessage));
|
||||
nsCOMPtr<nsIException> e = new WSPException(status, temp.get(), nsnull);
|
||||
if (!e) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mListener->OnError(e);
|
||||
return NS_OK;
|
||||
|
@ -179,12 +183,16 @@ WSPFactory::CreateProxy(const nsAString & wsdlURL,
|
|||
|
||||
/* void createProxyAsync (in AString wsdlURL, in AString portname, in AString qualifier, in boolean isAsync, in nsIWebServiceProxyCreationListener listener); */
|
||||
NS_IMETHODIMP
|
||||
WSPFactory::CreateProxyAsync(const nsAString & wsdlURL,
|
||||
const nsAString & portname,
|
||||
const nsAString & qualifier,
|
||||
PRBool isAsync,
|
||||
WSPFactory::CreateProxyAsync(const nsAString& wsdlURL,
|
||||
const nsAString& portname,
|
||||
const nsAString& qualifier, PRBool isAsync,
|
||||
nsIWebServiceProxyCreationListener *listener)
|
||||
{
|
||||
if (!listener) {
|
||||
// A listener is required.
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsCOMPtr<WSPAsyncProxyCreator> creator = new WSPAsyncProxyCreator();
|
||||
if(!creator)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
#include "wspprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
// IIDX is used as a way to hold and share our commone set of interface indexes.
|
||||
// IIDX is used as a way to hold and share our common set of interface
|
||||
// indexes.
|
||||
|
||||
class IIDX {
|
||||
public:
|
||||
|
@ -55,10 +56,18 @@ public:
|
|||
IDX_Count // Just a count of the above.
|
||||
};
|
||||
|
||||
PRUint16 Get(IndexID id) const {NS_ASSERTION(id<IDX_Count, "bad");
|
||||
return mData[id];}
|
||||
PRUint16* GetAddr(IndexID id) {NS_ASSERTION(id<IDX_Count, "bad");
|
||||
return &mData[id];}
|
||||
PRUint16 Get(IndexID id) const
|
||||
{
|
||||
NS_ASSERTION(id < IDX_Count, "bad");
|
||||
return mData[id];
|
||||
}
|
||||
|
||||
PRUint16* GetAddr(IndexID id)
|
||||
{
|
||||
NS_ASSERTION(id < IDX_Count, "bad");
|
||||
return &mData[id];
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint16 mData[IDX_Count];
|
||||
};
|
||||
|
@ -71,20 +80,38 @@ private:
|
|||
class ParamAccumulator
|
||||
{
|
||||
private:
|
||||
enum {MAX_BUILTIN = 8,
|
||||
ALLOCATION_INCREMENT = 16,
|
||||
MAX_TOTAL = 255}; // The typelib format limits us to 255 params.
|
||||
enum {
|
||||
MAX_BUILTIN = 8,
|
||||
ALLOCATION_INCREMENT = 16,
|
||||
MAX_TOTAL = 255
|
||||
}; // The typelib format limits us to 255 params.
|
||||
|
||||
public:
|
||||
PRUint16 GetCount() const {return mCount;}
|
||||
XPTParamDescriptor* GetArray() {return mArray;}
|
||||
void Clear() {mCount = 0;}
|
||||
PRUint16 GetCount() const
|
||||
{
|
||||
return mCount;
|
||||
}
|
||||
XPTParamDescriptor* GetArray()
|
||||
{
|
||||
return mArray;
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
XPTParamDescriptor* GetNextParam();
|
||||
|
||||
ParamAccumulator()
|
||||
: mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace) {}
|
||||
~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;}
|
||||
: mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace)
|
||||
{
|
||||
}
|
||||
|
||||
~ParamAccumulator()
|
||||
{
|
||||
if(mArray != mBuiltinSpace)
|
||||
delete [] mArray;
|
||||
}
|
||||
private:
|
||||
PRUint16 mCount;
|
||||
PRUint16 mAvailable;
|
||||
|
@ -92,7 +119,8 @@ private:
|
|||
XPTParamDescriptor mBuiltinSpace[MAX_BUILTIN];
|
||||
};
|
||||
|
||||
XPTParamDescriptor* ParamAccumulator::GetNextParam()
|
||||
XPTParamDescriptor*
|
||||
ParamAccumulator::GetNextParam()
|
||||
{
|
||||
if (mCount == MAX_TOTAL) {
|
||||
NS_WARNING("Too many params!");
|
||||
|
@ -106,6 +134,13 @@ XPTParamDescriptor* ParamAccumulator::GetNextParam()
|
|||
}
|
||||
|
||||
memcpy(newArray, mArray, newAvailable * sizeof(XPTParamDescriptor));
|
||||
|
||||
if (mArray != mBuiltinSpace) {
|
||||
// The old array was heap allocated, delete so that we don't
|
||||
// leak it.
|
||||
delete [] mArray;
|
||||
}
|
||||
|
||||
mArray = newArray;
|
||||
mAvailable = newAvailable;
|
||||
}
|
||||
|
@ -120,7 +155,8 @@ XPTParamDescriptor* ParamAccumulator::GetNextParam()
|
|||
// life of the process. These uuids should not be shared with other processes
|
||||
// or persisted.
|
||||
|
||||
static nsresult NewUniqueID(nsID *aID)
|
||||
static nsresult
|
||||
NewUniqueID(nsID *aID)
|
||||
{
|
||||
// XXX Hack Alert. This was generated on jband's 'bugsfree' machine and
|
||||
// *ought* not to conflict with any existing guids. We should find a
|
||||
|
@ -142,10 +178,9 @@ static nsresult NewUniqueID(nsID *aID)
|
|||
// FindInterfaceByName finds an interface info keyed by interface name. It
|
||||
// searches the super manager and any additional managers
|
||||
|
||||
static nsresult FindInterfaceByName(const char* aName,
|
||||
nsIInterfaceInfoSuperManager* iism,
|
||||
nsIInterfaceInfoManager **aSet,
|
||||
nsIInterfaceInfo **_retval)
|
||||
static nsresult
|
||||
FindInterfaceByName(const char* aName, nsIInterfaceInfoSuperManager* iism,
|
||||
nsIInterfaceInfoManager **aSet, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if (NS_SUCCEEDED(iism->GetInfoForName(aName, _retval)) && *_retval) {
|
||||
NS_ADDREF(*aSet = iism);
|
||||
|
@ -164,7 +199,7 @@ static nsresult FindInterfaceByName(const char* aName,
|
|||
while (NS_SUCCEEDED(list->HasMoreElements(&more)) && more &&
|
||||
NS_SUCCEEDED(list->GetNext(getter_AddRefs(current))) && current) {
|
||||
if (NS_SUCCEEDED(current->GetInfoForName(aName, _retval)) &&
|
||||
*_retval) {
|
||||
*_retval) {
|
||||
NS_ADDREF(*aSet = current.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -178,10 +213,9 @@ static nsresult FindInterfaceByName(const char* aName,
|
|||
// FindInterfaceByName finds the *index* of an interface info in the given
|
||||
// generic info set keyed by interface name.
|
||||
|
||||
static nsresult FindInterfaceIndexByName(const char* aName,
|
||||
nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
PRUint16* aIndex)
|
||||
static nsresult
|
||||
FindInterfaceIndexByName(const char* aName, nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet, PRUint16* aIndex)
|
||||
{
|
||||
nsresult rv = aSet->IndexOfByName(aName, aIndex);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -202,10 +236,9 @@ static nsresult FindInterfaceIndexByName(const char* aName,
|
|||
// specific interface info that we expect to find in the super manager keyed
|
||||
// by interface id.
|
||||
|
||||
static nsresult AppendStandardInterface(const nsIID& iid,
|
||||
nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* set,
|
||||
PRUint16* aIndex)
|
||||
static nsresult
|
||||
AppendStandardInterface(const nsIID& iid, nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* set, PRUint16* aIndex)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInterfaceInfo> tempInfo;
|
||||
|
@ -222,10 +255,9 @@ static nsresult AppendStandardInterface(const nsIID& iid,
|
|||
// BuildInterfaceName is used to construct the name of an interface
|
||||
// based on three AStrings.
|
||||
|
||||
static void BuildInterfaceName(const nsAString& qualifier,
|
||||
const nsAString& name,
|
||||
const nsAString& uri,
|
||||
nsACString& aCIdentifier)
|
||||
static void
|
||||
BuildInterfaceName(const nsAString& qualifier, const nsAString& name,
|
||||
const nsAString& uri, nsACString& aCIdentifier)
|
||||
{
|
||||
WSPFactory::XML2C(qualifier, aCIdentifier);
|
||||
|
||||
|
@ -240,23 +272,22 @@ static void BuildInterfaceName(const nsAString& qualifier,
|
|||
/***************************************************************************/
|
||||
// Forward declaration...
|
||||
|
||||
static nsresult AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModuleGroup,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier);
|
||||
static nsresult
|
||||
AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModelGroup,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier);
|
||||
|
||||
// Forward declaration...
|
||||
static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaType* aType,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint32 depth,
|
||||
ParamAccumulator* aParams);
|
||||
static nsresult
|
||||
GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaType* aType, const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier, PRUint32 depth,
|
||||
ParamAccumulator* aParams);
|
||||
|
||||
/***************************************************************************/
|
||||
// AppendMethodForParticle appends a method to a 'struct' interface
|
||||
|
@ -264,13 +295,13 @@ static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
|||
// particles that are themselves modelgroups (by recurring into
|
||||
// AppendMethodsForModelGroup). At also knows how to deal with arrays.
|
||||
|
||||
static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaParticle* aParticle,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
static nsresult
|
||||
AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaParticle* aParticle, const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
{
|
||||
nsresult rv;
|
||||
XPTMethodDescriptor methodDesc;
|
||||
|
@ -280,7 +311,7 @@ static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
|||
ParamAccumulator params;
|
||||
PRUint16 i;
|
||||
|
||||
// If the particle is itself a moduleGroup, then flatten in its methods.
|
||||
// If the particle is itself a modelGroup, then flatten in its methods.
|
||||
nsCOMPtr<nsISchemaModelGroup> modelGroup(do_QueryInterface(aParticle));
|
||||
if (modelGroup) {
|
||||
return AppendMethodsForModelGroup(iism, aSet, modelGroup, iidx,
|
||||
|
@ -302,14 +333,13 @@ static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCAutoString identifierName;
|
||||
nsAutoString name;
|
||||
|
||||
rv = aParticle->GetName(name);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCAutoString identifierName;
|
||||
WSPFactory::XML2C(name, identifierName);
|
||||
|
||||
rv = GetParamDescOfType(iism, aSet, schemaType, iidx, defaultResult,
|
||||
|
@ -361,24 +391,24 @@ static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
|||
// AppendMethodsForModelGroup iterates the group's particles and calls
|
||||
// AppendMethodForParticle for each.
|
||||
|
||||
static nsresult AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModuleGroup,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
static nsresult
|
||||
AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModelGroup,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 particleCount;
|
||||
rv = aModuleGroup->GetParticleCount(&particleCount);
|
||||
rv = aModelGroup->GetParticleCount(&particleCount);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < particleCount; i++) {
|
||||
nsCOMPtr<nsISchemaParticle> particle;
|
||||
rv = aModuleGroup->GetParticle(i, getter_AddRefs(particle));
|
||||
rv = aModelGroup->GetParticle(i, getter_AddRefs(particle));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -398,14 +428,14 @@ static nsresult AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
|||
// create one. In our world these 'struct' interfaces are discovered by
|
||||
// name: qualifier+typename+typetargetnamespace.
|
||||
|
||||
static nsresult FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaComplexType* aComplexType,
|
||||
nsISchemaModelGroup* aModuleGroup,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint16* aTypeIndex)
|
||||
static nsresult
|
||||
FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaComplexType* aComplexType,
|
||||
nsISchemaModelGroup* aModelGroup,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint16* aTypeIndex)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCAutoString qualifiedName;
|
||||
|
@ -445,7 +475,7 @@ static nsresult FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
|||
return rv;
|
||||
}
|
||||
|
||||
return AppendMethodsForModelGroup(iism, aSet, aModuleGroup, iidx,
|
||||
return AppendMethodsForModelGroup(iism, aSet, aModelGroup, iidx,
|
||||
defaultResult, newInfo, qualifier);
|
||||
}
|
||||
|
||||
|
@ -458,14 +488,12 @@ static nsresult FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
|||
// Note that the flags that control param passing (such as XPT_PD_IN,
|
||||
// XPT_PD_OUT, XPT_PD_DIPPER, and XPT_PD_RETVAL) are *not* set by this method.
|
||||
|
||||
static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaType* aType,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint32 depth,
|
||||
ParamAccumulator* aParams)
|
||||
static nsresult
|
||||
GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet, nsISchemaType* aType,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier, PRUint32 depth,
|
||||
ParamAccumulator* aParams)
|
||||
{
|
||||
XPTTypeDescriptor* additionalType;
|
||||
PRUint16 typeIndex;
|
||||
|
@ -723,15 +751,9 @@ do_simple:
|
|||
case nsISchemaBuiltinType::BUILTIN_TYPE_BOOLEAN:
|
||||
paramDesc->type.prefix.flags = TD_BOOL;
|
||||
return NS_OK;
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_TIME:
|
||||
paramDesc->type.prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER;
|
||||
return NS_OK;
|
||||
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_DATETIME:
|
||||
// XXX date type?
|
||||
paramDesc->type.prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER;
|
||||
return NS_OK;
|
||||
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_TIME:
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_DURATION:
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_DATE:
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_GMONTH:
|
||||
|
@ -795,13 +817,11 @@ do_simple:
|
|||
// appropriate schema type so that it can call GetParamDescOfType to do the
|
||||
// rest of the work of filliung in a param descriptor.
|
||||
|
||||
static nsresult GetParamDescOfPart(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsIWSDLPart* aPart,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
ParamAccumulator* aParams)
|
||||
static nsresult
|
||||
GetParamDescOfPart(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet, nsIWSDLPart* aPart,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier, ParamAccumulator* aParams)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -841,32 +861,30 @@ static nsresult GetParamDescOfPart(nsIInterfaceInfoSuperManager* iism,
|
|||
nsCOMPtr<nsISchemaElement> element(do_QueryInterface(schemaComponent));
|
||||
if (element) {
|
||||
rv = element->GetType(getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = do_QueryInterface(schemaComponent, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return GetParamDescOfType(iism, aSet, type, iidx, defaultResult,
|
||||
qualifier, 0, aParams);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return GetParamDescOfType(iism, aSet, type, iidx, defaultResult, qualifier,
|
||||
0, aParams);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// AccumulateParamsForMessage iterates the parts of a given message and
|
||||
// accumulates the param descriptors.
|
||||
|
||||
static nsresult AccumulateParamsForMessage(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsIWSDLMessage* aMsg,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
ParamAccumulator* aParams)
|
||||
static nsresult
|
||||
AccumulateParamsForMessage(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsIWSDLMessage* aMsg, const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
ParamAccumulator* aParams)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 partCount;
|
||||
|
@ -887,7 +905,8 @@ static nsresult AccumulateParamsForMessage(nsIInterfaceInfoSuperManager* iism,
|
|||
// constructing a nested set of compound types and adding them
|
||||
// to the set.
|
||||
|
||||
rv = GetParamDescOfPart(iism, aSet, part, iidx, defaultResult, qualifier, aParams);
|
||||
rv = GetParamDescOfPart(iism, aSet, part, iidx, defaultResult, qualifier,
|
||||
aParams);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -915,46 +934,28 @@ nsWSPInterfaceInfoService::~nsWSPInterfaceInfoService()
|
|||
// It returns the interface info and optionally the interface info set -
|
||||
// which allows the caller to gather information on the referenced interfaces.
|
||||
|
||||
/* nsIInterfaceInfo infoForPort (in nsIWSDLPort aPort, in AString aPortURL, in AString aQualifier, in PRBool aIsAsync, out nsIInterfaceInfoManager aSet); */
|
||||
NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const nsAString & aPortURL, const nsAString & aQualifier, PRBool aIsAsync, nsIInterfaceInfoManager **aSet, nsIInterfaceInfo **_retval)
|
||||
/* nsIInterfaceInfo infoForPort (in nsIWSDLPort aPort, in AString
|
||||
aPortURL, in AString aQualifier, in PRBool aIsAsync, out
|
||||
nsIInterfaceInfoManager aSet); */
|
||||
NS_IMETHODIMP
|
||||
nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort,
|
||||
const nsAString & aPortURL,
|
||||
const nsAString & aQualifier,
|
||||
PRBool aIsAsync,
|
||||
nsIInterfaceInfoManager **aSet,
|
||||
nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if (!aPort) {
|
||||
// aPort can't be null.
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString primaryName;
|
||||
nsCAutoString primaryAsyncName;
|
||||
nsAutoString portName;
|
||||
|
||||
IIDX iidx;
|
||||
PRUint16 listenerIndex;
|
||||
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryAsyncInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> listenerInfo;
|
||||
|
||||
ParamAccumulator inParams;
|
||||
ParamAccumulator outParams;
|
||||
|
||||
XPTParamDescriptor* tempParamArray;
|
||||
XPTParamDescriptor* defaultResult;
|
||||
|
||||
XPTParamDescriptor* primaryParamArray;
|
||||
XPTParamDescriptor* primaryAsyncParamArray;
|
||||
XPTParamDescriptor* listenerParamArray;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tempInfo;
|
||||
nsID tempID;
|
||||
nsCAutoString tempCString;
|
||||
nsAutoString tempString;
|
||||
|
||||
XPTMethodDescriptor methodDesc;
|
||||
XPTParamDescriptor paramDesc;
|
||||
XPTParamDescriptor* pparamDesc;
|
||||
|
||||
PRUint16 ignoredIndex;
|
||||
|
||||
PRUint32 i;
|
||||
PRUint32 k;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism =
|
||||
do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID);
|
||||
if (!iism) {
|
||||
|
@ -983,6 +984,31 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
|
||||
// No, we need to build all the stuff...
|
||||
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryAsyncInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> listenerInfo;
|
||||
|
||||
ParamAccumulator inParams;
|
||||
ParamAccumulator outParams;
|
||||
|
||||
XPTParamDescriptor* tempParamArray;
|
||||
XPTParamDescriptor* defaultResult;
|
||||
|
||||
XPTParamDescriptor* primaryParamArray;
|
||||
XPTParamDescriptor* primaryAsyncParamArray;
|
||||
XPTParamDescriptor* listenerParamArray;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tempInfo;
|
||||
nsCAutoString tempCString;
|
||||
nsAutoString tempString;
|
||||
|
||||
IIDX iidx;
|
||||
PRUint16 listenerIndex;
|
||||
|
||||
XPTMethodDescriptor methodDesc;
|
||||
XPTParamDescriptor paramDesc;
|
||||
XPTParamDescriptor* pparamDesc;
|
||||
|
||||
// Create a new info set.
|
||||
|
||||
nsCOMPtr<nsIGenericInterfaceInfoSet> set =
|
||||
|
@ -1025,6 +1051,9 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
|
||||
// Create and add the primary interface.
|
||||
|
||||
PRUint16 ignoredIndex;
|
||||
nsID tempID;
|
||||
|
||||
::NewUniqueID(&tempID);
|
||||
rv = set->CreateAndAppendInterface(primaryName.get(), tempID,
|
||||
iidx.Get(IIDX::IDX_nsISupports),
|
||||
|
@ -1107,7 +1136,8 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
tempParamArray[0].flags = XPT_PD_IN;
|
||||
|
||||
tempParamArray[1].type.prefix.flags = TD_INTERFACE_TYPE | XPT_TDP_POINTER;
|
||||
tempParamArray[1].type.type.iface = iidx.Get(IIDX::IDX_nsIWebServiceCallContext);
|
||||
tempParamArray[1].type.type.iface =
|
||||
iidx.Get(IIDX::IDX_nsIWebServiceCallContext);
|
||||
tempParamArray[1].flags = XPT_PD_IN;
|
||||
|
||||
methodDesc.name = "onError";
|
||||
|
@ -1129,6 +1159,7 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
return rv;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < methodCount; i++)
|
||||
{
|
||||
nsCOMPtr<nsIWSDLOperation> op;
|
||||
|
@ -1178,7 +1209,8 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
}
|
||||
|
||||
PRUint16 primaryAsyncParamCount = inParams.GetCount() + 1;
|
||||
rv = set->AllocateParamArray(primaryAsyncParamCount, &primaryAsyncParamArray);
|
||||
rv = set->AllocateParamArray(primaryAsyncParamCount,
|
||||
&primaryAsyncParamArray);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1195,7 +1227,8 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
// primary and primaryAsync.
|
||||
|
||||
pparamDesc = inParams.GetArray();
|
||||
for (k = 0; k < inParams.GetCount(); pparamDesc++, k++) {
|
||||
|
||||
for (PRUint32 k = 0; k < inParams.GetCount(); pparamDesc++, k++) {
|
||||
// set direction flag
|
||||
pparamDesc->flags |= XPT_PD_IN;
|
||||
|
||||
|
@ -1263,7 +1296,6 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
pparamDesc->type.argnum =
|
||||
pparamDesc->type.argnum2 = k; // not '-1' because of leading arg
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
memcpy(listenerParamArray,
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
// XPCOM includes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsIPropertyBag.h"
|
||||
#include "nsIException.h"
|
||||
#include "nsIExceptionService.h"
|
||||
|
@ -168,7 +168,7 @@ protected:
|
|||
nsCOMPtr<nsIInterfaceInfoManager> mInterfaceInfoManager;
|
||||
nsString mQualifier;
|
||||
PRBool mIsAsync;
|
||||
nsSupportsArray mPendingCalls;
|
||||
nsCOMArray<nsIWebServiceCallContext> mPendingCalls;
|
||||
const nsIID* mIID;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
nsCOMPtr<nsIInterfaceInfo> mListenerInterfaceInfo;
|
||||
|
|
|
@ -86,21 +86,18 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
{
|
||||
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIWebServicePropertyBagWrapper))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIWebServicePropertyBagWrapper*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIClassInfo*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -116,77 +113,74 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
NS_ERROR("WSPPropertyBagWrapper: bad method index");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()),
|
||||
propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mPropertyBag->GetProperty(propName, getter_AddRefs(val));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()), propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (info->IsGetter()) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(0);
|
||||
const nsXPTType& type = paramInfo.GetType();
|
||||
uint8 type_tag = type.TagPart();
|
||||
rv = mPropertyBag->GetProperty(propName, getter_AddRefs(val));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (type_tag == nsXPTType::T_INTERFACE) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (info->IsGetter()) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(0);
|
||||
const nsXPTType& type = paramInfo.GetType();
|
||||
uint8 type_tag = type.TagPart();
|
||||
|
||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||
}
|
||||
else if (info->GetParamCount() == 2) {
|
||||
// If it's not an explicit getter, it has to be an array
|
||||
// getter method.
|
||||
|
||||
// The first parameter should be the array length out param
|
||||
const nsXPTParamInfo& paramInfo1 = info->GetParam(0);
|
||||
const nsXPTType& type1 = paramInfo1.GetType();
|
||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// The second parameter should be the array out pointer
|
||||
// itself.
|
||||
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
|
||||
const nsXPTType& type2 = paramInfo2.GetType();
|
||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTType arrayType;
|
||||
rv = mInterfaceInfo->GetTypeForParam(methodIndex, ¶mInfo2,
|
||||
1, &arrayType);
|
||||
if (type_tag == nsXPTType::T_INTERFACE) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (arrayType.IsInterfacePointer()) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo2,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rv = WSPProxy::VariantToArrayValue(arrayType.TagPart(), params,
|
||||
iinfo, val);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected method signature for property bag wrapper");
|
||||
|
||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||
}
|
||||
else if (info->GetParamCount() == 2) {
|
||||
// If it's not an explicit getter, it has to be an array getter
|
||||
// method.
|
||||
|
||||
// The first parameter should be the array length out param
|
||||
const nsXPTParamInfo& paramInfo1 = info->GetParam(0);
|
||||
const nsXPTType& type1 = paramInfo1.GetType();
|
||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// The second parameter should be the array out pointer itself.
|
||||
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
|
||||
const nsXPTType& type2 = paramInfo2.GetType();
|
||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTType arrayType;
|
||||
rv = mInterfaceInfo->GetTypeForParam(methodIndex, ¶mInfo2,
|
||||
1, &arrayType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (arrayType.IsInterfacePointer()) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo2,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rv = WSPProxy::VariantToArrayValue(arrayType.TagPart(), params, iinfo,
|
||||
val);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected method signature for property bag wrapper");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -209,7 +203,8 @@ WSPPropertyBagWrapper::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] out nsIIDPtr array); */
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count),
|
||||
retval] out nsIIDPtr array); */
|
||||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::GetInterfaces(PRUint32 *count, nsIID * **array)
|
||||
{
|
||||
|
@ -220,8 +215,18 @@ WSPPropertyBagWrapper::GetInterfaces(PRUint32 *count, nsIID * **array)
|
|||
}
|
||||
|
||||
iids[0] = NS_STATIC_CAST(nsIID *, nsMemory::Clone(mIID, sizeof(nsIID)));
|
||||
if (!iids[0]) {
|
||||
nsMemory::Free(iids);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
const nsIID& wsiid = NS_GET_IID(nsIWebServicePropertyBagWrapper);
|
||||
iids[1] = NS_STATIC_CAST(nsIID *, nsMemory::Clone(&wsiid, sizeof(nsIID)));
|
||||
if (!iids[1]) {
|
||||
nsMemory::Free(iids[0]);
|
||||
nsMemory::Free(iids);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*array = iids;
|
||||
|
||||
|
@ -241,7 +246,13 @@ WSPPropertyBagWrapper::GetHelperForLanguage(PRUint32 language,
|
|||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::GetContractID(char * *aContractID)
|
||||
{
|
||||
*aContractID = ToNewUTF8String(NS_LITERAL_STRING(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID));
|
||||
*aContractID = (char *)
|
||||
nsMemory::Clone(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID,
|
||||
sizeof(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID));
|
||||
if (!*aContractID) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "wspprivate.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
#include "nsISchema.h"
|
||||
|
@ -63,11 +64,9 @@ WSPProxy::~WSPProxy()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WSPProxy::Init(nsIWSDLPort* aPort,
|
||||
nsIInterfaceInfo* aPrimaryInterface,
|
||||
WSPProxy::Init(nsIWSDLPort* aPort, nsIInterfaceInfo* aPrimaryInterface,
|
||||
nsIInterfaceInfoManager* aInterfaceInfoManager,
|
||||
const nsAString& aQualifier,
|
||||
PRBool aIsAsync)
|
||||
const nsAString& aQualifier, PRBool aIsAsync)
|
||||
{
|
||||
NS_ENSURE_ARG(aPort);
|
||||
NS_ENSURE_ARG(aPrimaryInterface);
|
||||
|
@ -209,20 +208,22 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPEncoding> encoding = do_CreateInstance(NS_SOAPENCODING_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsISOAPEncoding> encoding =
|
||||
do_CreateInstance(NS_SOAPENCODING_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
call->SetEncoding(encoding);
|
||||
|
||||
// Get the method name and target object uri
|
||||
nsAutoString methodName, targetObjectURI, address;
|
||||
nsAutoString methodName, targetObjectURI;
|
||||
rv = operation->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -237,7 +238,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsISOAPMessageBinding> messageBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPMessageBinding> messageBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -253,6 +255,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString address;
|
||||
portBinding->GetAddress(address);
|
||||
rv = call->SetTransportURI(address);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -275,15 +279,13 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
// body vs. header blocks
|
||||
nsCOMPtr<nsIWSDLPart> part;
|
||||
PRUint32 headerCount = 0, bodyCount = 0;
|
||||
|
||||
for (i = 0; i < partCount; i++) {
|
||||
rv = input->GetPart(i, getter_AddRefs(part));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString paramName;
|
||||
part->GetName(paramName);
|
||||
|
||||
rv = part->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
@ -316,6 +318,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
rv = CallCreateInstance(NS_SOAPPARAMETER_CONTRACTID, &bodyBlocks[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, bodyBlocks);
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +341,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
|
||||
}
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, headerBlocks);
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,9 +356,6 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
PRUint16 location;
|
||||
partBinding->GetLocation(&location);
|
||||
|
||||
nsAutoString paramName;
|
||||
part->GetName(paramName);
|
||||
|
||||
nsCOMPtr<nsISOAPBlock> block;
|
||||
if (location == nsISOAPPartBinding::LOCATION_HEADER) {
|
||||
block = do_QueryInterface(headerBlocks[headerEntry++]);
|
||||
|
@ -393,6 +396,9 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
else {
|
||||
type = do_QueryInterface(schemaComponent);
|
||||
|
||||
nsAutoString paramName;
|
||||
part->GetName(paramName);
|
||||
|
||||
blockName.Assign(paramName);
|
||||
partBinding->GetNamespace(blockNamespace);
|
||||
}
|
||||
|
@ -424,14 +430,15 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
PRUint32 arrayLength;
|
||||
|
||||
if (paramIndex < maxParamIndex &&
|
||||
info->GetParam((PRUint8)(paramIndex+1)).GetType().IsArray()) {
|
||||
info->GetParam((PRUint8)(paramIndex + 1)).GetType().IsArray()) {
|
||||
arrayLength = params[paramIndex++].val.u32;
|
||||
}
|
||||
else {
|
||||
arrayLength = 0;
|
||||
}
|
||||
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex, "WSDL/IInfo param count mismatch");
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(paramIndex);
|
||||
|
||||
|
@ -488,8 +495,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
#endif
|
||||
|
||||
nsIWebServiceCallContext** retval = NS_STATIC_CAST(nsIWebServiceCallContext**,
|
||||
params[pcount-1].val.p);
|
||||
nsIWebServiceCallContext** retval =
|
||||
NS_STATIC_CAST(nsIWebServiceCallContext**, params[pcount-1].val.p);
|
||||
if (!retval) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto call_method_end;
|
||||
|
@ -502,8 +509,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
goto call_method_end;
|
||||
}
|
||||
|
||||
mPendingCalls.AppendElement(NS_STATIC_CAST(nsIWebServiceSOAPCallContext*,
|
||||
ccInst));
|
||||
mPendingCalls.AppendObject(ccInst);
|
||||
}
|
||||
else {
|
||||
rv = ccInst->CallSync(methodIndex, params);
|
||||
|
@ -524,8 +530,7 @@ WSPProxy::ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
|||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsXPTCMiniVariant aMiniVariant,
|
||||
PRUint32 aArrayLength,
|
||||
nsIVariant** aVariant)
|
||||
PRUint32 aArrayLength, nsIVariant** aVariant)
|
||||
{
|
||||
nsXPTType type;
|
||||
nsresult rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
|
||||
|
@ -533,6 +538,7 @@ WSPProxy::ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
uint8 type_tag = type.TagPart();
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (type.IsArray()) {
|
||||
|
@ -550,20 +556,21 @@ WSPProxy::ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
|||
return rv;
|
||||
}
|
||||
}
|
||||
return ArrayXPTCMiniVariantToVariant(arrayType.TagPart(),
|
||||
aMiniVariant, aArrayLength,
|
||||
iinfo, aVariant);
|
||||
return ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), aMiniVariant,
|
||||
aArrayLength, iinfo, aVariant);
|
||||
}
|
||||
else {
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// else
|
||||
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return XPTCMiniVariantToVariant(type_tag, aMiniVariant, iinfo, aVariant);
|
||||
}
|
||||
|
||||
return XPTCMiniVariantToVariant(type_tag, aMiniVariant, iinfo, aVariant);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -573,7 +580,8 @@ WSPProxy::WrapInPropertyBag(nsISupports* aInstance,
|
|||
{
|
||||
*aPropertyBag = nsnull;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper(do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper =
|
||||
do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -581,13 +589,11 @@ WSPProxy::WrapInPropertyBag(nsISupports* aInstance,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
CallQueryInterface(wrapper, aPropertyBag);
|
||||
return NS_OK;
|
||||
return CallQueryInterface(wrapper, aPropertyBag);
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPProxy::XPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
WSPProxy::XPTCMiniVariantToVariant(uint8 aTypeTag, nsXPTCMiniVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant)
|
||||
{
|
||||
|
@ -604,8 +610,8 @@ WSPProxy::XPTCMiniVariantToVariant(uint8 aTypeTag,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> var = do_CreateInstance(NS_VARIANT_CONTRACTID,
|
||||
&rv);
|
||||
nsCOMPtr<nsIWritableVariant> var =
|
||||
do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -698,7 +704,8 @@ WSPProxy::ArrayXPTCMiniVariantToVariant(uint8 aTypeTag,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> retvar = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWritableVariant> retvar =
|
||||
do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -869,17 +876,15 @@ WSPProxy::VariantToOutParameter(nsIInterfaceInfo* aInterfaceInfo,
|
|||
return VariantToArrayValue(arrayType.TagPart(), aMiniVariant,
|
||||
iinfo, aVariant);
|
||||
}
|
||||
else {
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// else
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return VariantToValue(type_tag, aMiniVariant->val.p, iinfo, aVariant);
|
||||
}
|
||||
return NS_OK;
|
||||
return VariantToValue(type_tag, aMiniVariant->val.p, iinfo, aVariant);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -888,24 +893,20 @@ WSPProxy::WrapInComplexType(nsIPropertyBag* aPropertyBag,
|
|||
nsISupports** aComplexType)
|
||||
{
|
||||
*aComplexType = nsnull;
|
||||
WSPPropertyBagWrapper* wrapper = new WSPPropertyBagWrapper();
|
||||
nsRefPtr<WSPPropertyBagWrapper> wrapper = new WSPPropertyBagWrapper();
|
||||
if (!wrapper) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(wrapper);
|
||||
nsresult rv = wrapper->Init(aPropertyBag, aInterfaceInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(wrapper);
|
||||
return rv;
|
||||
}
|
||||
wrapper->QueryInterface(NS_GET_IID(nsISupports), (void**)aComplexType);
|
||||
NS_RELEASE(wrapper);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPProxy::VariantToValue(uint8 aTypeTag,
|
||||
void* aValue,
|
||||
WSPProxy::VariantToValue(uint8 aTypeTag, void* aValue,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
|
@ -1003,8 +1004,7 @@ WSPProxy::VariantToValue(uint8 aTypeTag,
|
|||
}
|
||||
|
||||
nsresult
|
||||
WSPProxy::VariantToArrayValue(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
WSPProxy::VariantToArrayValue(uint8 aTypeTag, nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
|
@ -1044,12 +1044,13 @@ WSPProxy::VariantToArrayValue(uint8 aTypeTag,
|
|||
*((void**)aResult[1].val.p) = array;
|
||||
}
|
||||
else if (!arrayIID.Equals(NS_GET_IID(nsIPropertyBag))) {
|
||||
NS_ERROR("Array of complex types should be represented by property bags");
|
||||
NS_ERROR("Array of complex types should be represented by property "
|
||||
"bags");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
nsISupports** outptr = (nsISupports**)nsMemory::Alloc(count *
|
||||
sizeof(nsISupports*));
|
||||
nsISupports** outptr =
|
||||
(nsISupports**)nsMemory::Alloc(count * sizeof(nsISupports*));
|
||||
if (!outptr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1143,7 +1144,8 @@ WSPProxy::GetPendingCalls(nsISimpleEnumerator * *aPendingCalls)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult WSPProxy::GetInterfaceName(PRBool listener, char** retval)
|
||||
nsresult
|
||||
WSPProxy::GetInterfaceName(PRBool listener, char** retval)
|
||||
{
|
||||
if (!mPrimaryInterface) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1203,7 +1205,8 @@ WSPProxy::GetInterfaces(nsIScriptableInterfaces * *aInterfaces)
|
|||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] out nsIIDPtr array); */
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count),
|
||||
retval] out nsIIDPtr array); */
|
||||
NS_IMETHODIMP
|
||||
WSPProxy::GetInterfaces(PRUint32 *count, nsIID * **array)
|
||||
{
|
||||
|
@ -1287,6 +1290,5 @@ WSPProxy::GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo)
|
|||
void
|
||||
WSPProxy::CallCompleted(WSPCallContext* aContext)
|
||||
{
|
||||
mPendingCalls.RemoveElement(NS_STATIC_CAST(nsIWebServiceCallContext*,
|
||||
aContext));
|
||||
mPendingCalls.RemoveObject(aContext);
|
||||
}
|
||||
|
|
|
@ -50,11 +50,11 @@
|
|||
[scriptable, uuid(8c7bf4bc-d3fe-4524-b213-ce578bfe936e)]
|
||||
interface nsIWSPInterfaceInfoService : nsISupports
|
||||
{
|
||||
nsIInterfaceInfo infoForPort(in nsIWSDLPort aPort,
|
||||
in AString aPortURL,
|
||||
in AString aQualifier,
|
||||
in PRBool aIsAsync,
|
||||
out nsIInterfaceInfoManager aSet);
|
||||
nsIInterfaceInfo infoForPort(in nsIWSDLPort aPort,
|
||||
in AString aPortURL,
|
||||
in AString aQualifier,
|
||||
in PRBool aIsAsync,
|
||||
out nsIInterfaceInfoManager aSet);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -182,7 +182,6 @@ interface nsIWebServiceProxy : nsISupports {
|
|||
*/
|
||||
readonly attribute AString qualifier;
|
||||
|
||||
|
||||
/**
|
||||
* An enumerator that returns the set of pending calls for the
|
||||
* service proxy. Each call is an instance of the
|
||||
|
@ -192,7 +191,6 @@ interface nsIWebServiceProxy : nsISupports {
|
|||
*/
|
||||
readonly attribute nsISimpleEnumerator pendingCalls;
|
||||
|
||||
|
||||
/**
|
||||
* The name of the primary interface for this proxy. This may or may not be
|
||||
* the async version depending on whether or not this is an async proxy.
|
||||
|
|
|
@ -425,7 +425,9 @@ NS_IMETHODIMP
|
|||
rv = mRequest->GetResponseXML(getter_AddRefs(document));
|
||||
if (NS_SUCCEEDED(rv) && document) {
|
||||
rv = mResponse->SetMessage(document);
|
||||
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)} else {
|
||||
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)
|
||||
}
|
||||
else {
|
||||
mResponse = nsnull;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1,177 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike McCabe <mccabe@netscape.com>
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* Library-private header for Interface Info extras system. */
|
||||
|
||||
#ifndef iixprivate_h___
|
||||
#define iixprivate_h___
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsVariant.h"
|
||||
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "nsIInterfaceInfoManager.h"
|
||||
#include "xpt_struct.h"
|
||||
#include "xptinfo.h"
|
||||
#include "xptcall.h"
|
||||
|
||||
#include "nsIGenericInterfaceInfoSet.h"
|
||||
#include "nsIScriptableInterfaceInfo.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsGenericInterfaceInfoSet : public nsIGenericInterfaceInfoSet,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEINFOMANAGER
|
||||
NS_DECL_NSIGENERICINTERFACEINFOSET
|
||||
|
||||
nsGenericInterfaceInfoSet();
|
||||
virtual ~nsGenericInterfaceInfoSet();
|
||||
|
||||
XPTArena* GetArena() {return mArena;}
|
||||
|
||||
const XPTTypeDescriptor* GetAdditionalTypeAt(PRUint16 aIndex)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16) mAdditionalTypes.Count(), "bad index");
|
||||
return (const XPTTypeDescriptor*) mAdditionalTypes.ElementAt(aIndex);
|
||||
}
|
||||
|
||||
nsIInterfaceInfo* InfoAtNoAddRef(PRUint16 aIndex)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16) mInterfaces.Count(), "bad index");
|
||||
return (nsIInterfaceInfo*) ClearOwnedFlag(mInterfaces.ElementAt(aIndex));
|
||||
}
|
||||
|
||||
private:
|
||||
nsresult IndexOfIID(const nsIID & aIID, PRUint16 *_retval);
|
||||
nsresult IndexOfName(const char* aName, PRUint16 *_retval);
|
||||
|
||||
void* SetOwnedFlag(void* p) {return (void*) ((long)p | 1);}
|
||||
void* ClearOwnedFlag(void* p) {return (void*) ((long)p & ~(long)1);}
|
||||
PRBool CheckOwnedFlag(void* p) {return (PRBool) ((long)p & (long)1);}
|
||||
|
||||
|
||||
private:
|
||||
nsVoidArray mInterfaces;
|
||||
nsVoidArray mAdditionalTypes;
|
||||
XPTArena* mArena;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsGenericInterfaceInfo : public nsIGenericInterfaceInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEINFO
|
||||
NS_DECL_NSIGENERICINTERFACEINFO
|
||||
|
||||
nsGenericInterfaceInfo(); // not implemented
|
||||
nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
||||
const char *aName,
|
||||
const nsIID & aIID,
|
||||
nsIInterfaceInfo* mParent,
|
||||
PRUint8 aFlags);
|
||||
virtual ~nsGenericInterfaceInfo() {}
|
||||
|
||||
private:
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const XPTParamDescriptor* param)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
while(XPT_TDP_TAG(td->prefix) == TD_ARRAY)
|
||||
td = mSet->GetAdditionalTypeAt(td->type.additional_type);
|
||||
return td;
|
||||
}
|
||||
|
||||
const XPTTypeDescriptor* GetTypeInArray(const XPTParamDescriptor* param,
|
||||
PRUint16 dimension)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
for(PRUint16 i = 0; i < dimension; i++)
|
||||
{
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_ARRAY, "bad dimension");
|
||||
td = mSet->GetAdditionalTypeAt(td->type.additional_type);
|
||||
}
|
||||
return td;
|
||||
}
|
||||
|
||||
private:
|
||||
char* mName;
|
||||
nsIID mIID;
|
||||
nsVoidArray mMethods;
|
||||
nsVoidArray mConstants;
|
||||
nsGenericInterfaceInfoSet* mSet;
|
||||
nsIInterfaceInfo* mParent; // weak reference (it must be held in set table)
|
||||
PRUint16 mMethodBaseIndex;
|
||||
PRUint16 mConstantBaseIndex;
|
||||
PRUint8 mFlags;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsScriptableInterfaceInfo : public nsIScriptableInterfaceInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEINTERFACEINFO
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
nsIScriptableInterfaceInfo** aResult);
|
||||
|
||||
nsScriptableInterfaceInfo();
|
||||
nsScriptableInterfaceInfo(nsIInterfaceInfo* aInfo);
|
||||
virtual ~nsScriptableInterfaceInfo();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#endif /* iixprivate_h___ */
|
|
@ -1,624 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* The nsGenericInterfaceInfo/nsGenericInterfaceInfoSet implementations.*/
|
||||
|
||||
#include "iixprivate.h"
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
// implement nsGenericInterfaceInfoSet
|
||||
|
||||
#define ARENA_BLOCK_SIZE (1024 * 1)
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsGenericInterfaceInfoSet,
|
||||
nsIInterfaceInfoManager,
|
||||
nsIGenericInterfaceInfoSet,
|
||||
nsISupportsWeakReference);
|
||||
|
||||
nsGenericInterfaceInfoSet::nsGenericInterfaceInfoSet()
|
||||
{
|
||||
mArena = XPT_NewArena(ARENA_BLOCK_SIZE, sizeof(double),
|
||||
"nsGenericInterfaceInfoSet Arena");
|
||||
}
|
||||
|
||||
nsGenericInterfaceInfoSet::~nsGenericInterfaceInfoSet()
|
||||
{
|
||||
PRInt32 count = mInterfaces.Count();
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
if(CheckOwnedFlag(info))
|
||||
delete (nsGenericInterfaceInfo*) ClearOwnedFlag(info);
|
||||
else
|
||||
NS_RELEASE(info);
|
||||
}
|
||||
|
||||
if(mArena)
|
||||
XPT_DestroyArena(mArena);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
PRInt32 count = mInterfaces.Count();
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const nsID* iid;
|
||||
nsresult rv = info->GetIIDShared(&iid);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
if(iid->Equals(aIID))
|
||||
{
|
||||
*_retval = (PRUint16) i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
||||
{
|
||||
PRInt32 count = mInterfaces.Count();
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const char* name;
|
||||
nsresult rv = info->GetNameShared(&name);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
if(!strcmp(name, aName))
|
||||
{
|
||||
*_retval = (PRUint16) i;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfoSet methods...
|
||||
|
||||
/* XPTParamDescriptorPtr allocateParamArray (in PRUint16 aCount); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AllocateParamArray(PRUint16 aCount, XPTParamDescriptor * *_retval)
|
||||
{
|
||||
*_retval = (XPTParamDescriptor*)
|
||||
XPT_MALLOC(GetArena(), sizeof(XPTParamDescriptor) * aCount);
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* XPTTypeDescriptorPtr allocateAdditionalType (out PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, XPTTypeDescriptor * *_retval)
|
||||
{
|
||||
*_retval = (XPTTypeDescriptor*)
|
||||
XPT_MALLOC(GetArena(), sizeof(XPTTypeDescriptor));
|
||||
if(!*_retval || !mAdditionalTypes.AppendElement(*_retval))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aIndex = (PRUint16) mAdditionalTypes.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint16 createAndAppendInterface (in string aName, in nsIIDRef aIID, in PRUint16 aParent, in PRUint8 aFlags, out nsIGenericInterfaceInfo aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::CreateAndAppendInterface(const char *aName, const nsIID & aIID, PRUint16 aParent, PRUint8 aFlags, nsIGenericInterfaceInfo **aInfo, PRUint16 *_retval)
|
||||
{
|
||||
nsGenericInterfaceInfo* info =
|
||||
new nsGenericInterfaceInfo(this, aName, aIID,
|
||||
(aParent == (PRUint16) -1) ?
|
||||
nsnull : InfoAtNoAddRef(aParent),
|
||||
aFlags);
|
||||
if(!info || !mInterfaces.AppendElement(SetOwnedFlag(info)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*_retval = (PRUint16) mInterfaces.Count()-1;
|
||||
return CallQueryInterface(info, aInfo);
|
||||
}
|
||||
|
||||
/* PRUint16 appendExternalInterface (in nsIInterfaceInfo aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::AppendExternalInterface(nsIInterfaceInfo *aInfo, PRUint16 *_retval)
|
||||
{
|
||||
if(!mInterfaces.AppendElement(aInfo))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(aInfo);
|
||||
*_retval = (PRUint16) mInterfaces.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint16 indexOf (in nsIIDRef aIID); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::IndexOf(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
return IndexOfIID(aIID, _retval);
|
||||
}
|
||||
|
||||
/* PRUint16 indexOfByName (in string aName); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::IndexOfByName(const char *aName, PRUint16 *_retval)
|
||||
{
|
||||
return IndexOfName(aName, _retval);
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo interfaceInfoAt (in PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfoSet::InterfaceInfoAt(PRUint16 aIndex, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
NS_ASSERTION(aIndex < (PRUint16)mInterfaces.Count(), "bad index");
|
||||
|
||||
*_retval = (nsIInterfaceInfo*) ClearOwnedFlag(mInterfaces.ElementAt(aIndex));
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIInterfaceInfoManager methods...
|
||||
|
||||
/* nsIInterfaceInfo getInfoForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForIID(const nsIID * iid, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfIID(*iid, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
return InterfaceInfoAt(index, _retval);
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForName (in string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetInfoForName(const char *name, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfName(name, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
return InterfaceInfoAt(index, _retval);
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForName (in string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetIIDForName(const char *name, nsIID * *_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfName(name, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIInterfaceInfo* info = InfoAtNoAddRef(index);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return info->GetInterfaceIID(_retval);
|
||||
}
|
||||
|
||||
/* string getNameForIID (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::GetNameForIID(const nsIID * iid, char **_retval)
|
||||
{
|
||||
PRUint16 index;
|
||||
nsresult rv = IndexOfIID(*iid, &index);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsIInterfaceInfo* info = InfoAtNoAddRef(index);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return info->GetName(_retval);
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfaces (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::EnumerateInterfaces(nsIEnumerator **_retval)
|
||||
{
|
||||
return EnumerateInterfacesWhoseNamesStartWith(nsnull, _retval);
|
||||
}
|
||||
|
||||
/* void autoRegisterInterfaces (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::AutoRegisterInterfaces()
|
||||
{
|
||||
// NOP
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIEnumerator enumerateInterfacesWhoseNamesStartWith (in string prefix); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfoSet::EnumerateInterfacesWhoseNamesStartWith(const char *prefix, nsIEnumerator **_retval)
|
||||
{
|
||||
int count = (PRUint16) mInterfaces.Count();
|
||||
int len = prefix ? PL_strlen(prefix) : 0;
|
||||
const char* name;
|
||||
|
||||
nsCOMPtr<nsISupportsArray> array;
|
||||
NS_NewISupportsArray(getter_AddRefs(array));
|
||||
if(!array)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = InfoAtNoAddRef(i);
|
||||
if(!info)
|
||||
continue;
|
||||
if(!prefix ||
|
||||
(NS_SUCCEEDED(info->GetNameShared(&name)) &&
|
||||
name == PL_strnstr(name, prefix, len)))
|
||||
{
|
||||
if(!array->AppendElement(info))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return array->Enumerate(_retval);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/***************************************************************************/
|
||||
// implement nsGenericInterfaceInfo
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE2(nsGenericInterfaceInfo,
|
||||
nsIInterfaceInfo,
|
||||
nsIGenericInterfaceInfo);
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsGenericInterfaceInfo::AddRef()
|
||||
{
|
||||
return mSet->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
nsGenericInterfaceInfo::Release()
|
||||
{
|
||||
return mSet->Release();
|
||||
}
|
||||
|
||||
nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
||||
const char *aName,
|
||||
const nsIID & aIID,
|
||||
nsIInterfaceInfo* aParent,
|
||||
PRUint8 aFlags)
|
||||
: mName(nsnull),
|
||||
mIID(aIID),
|
||||
mSet(aSet),
|
||||
mParent(aParent),
|
||||
mFlags(aFlags)
|
||||
{
|
||||
if(mParent)
|
||||
{
|
||||
mParent->GetMethodCount(&mMethodBaseIndex);
|
||||
mParent->GetConstantCount(&mConstantBaseIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
mMethodBaseIndex = mConstantBaseIndex = 0;
|
||||
}
|
||||
|
||||
int len = PL_strlen(aName);
|
||||
mName = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(mName)
|
||||
memcpy(mName, aName, len);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfo methods...
|
||||
|
||||
/* PRUint16 appendMethod (in XPTMethodDescriptorPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
XPTMethodDescriptor* desc = (XPTMethodDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTMethodDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aMethod, sizeof(XPTMethodDescriptor));
|
||||
|
||||
int len = PL_strlen(aMethod->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(!desc->name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc->name, aMethod->name, len);
|
||||
|
||||
return mMethods.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRUint16 appendConst (in XPTConstDescriptorPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, PRUint16 *_retval)
|
||||
|
||||
{
|
||||
NS_ASSERTION(aConst->type.prefix.flags == TD_INT16 ||
|
||||
aConst->type.prefix.flags == TD_UINT16 ||
|
||||
aConst->type.prefix.flags == TD_INT32 ||
|
||||
aConst->type.prefix.flags == TD_UINT32,
|
||||
"unsupported const type");
|
||||
|
||||
XPTConstDescriptor* desc = (XPTConstDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTConstDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aConst, sizeof(XPTConstDescriptor));
|
||||
|
||||
int len = PL_strlen(aConst->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(!desc->name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc->name, aConst->name, len);
|
||||
|
||||
return mConstants.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIInterfaceInfo methods...
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetName(char * *aName)
|
||||
{
|
||||
*aName = (char*) nsMemory::Clone(mName, PL_strlen(mName)+1);
|
||||
return *aName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr InterfaceIID; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInterfaceIID(nsIID * *aIID)
|
||||
{
|
||||
*aIID = (nsIID*) nsMemory::Clone(&mIID, sizeof(nsIID));
|
||||
return *aIID ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRBool isScriptable (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsScriptable(PRBool *_retval)
|
||||
{
|
||||
*_retval = XPT_ID_IS_SCRIPTABLE(mFlags) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIInterfaceInfo parent; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetParent(nsIInterfaceInfo * *aParent)
|
||||
{
|
||||
*aParent = mParent;
|
||||
NS_IF_ADDREF(*aParent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 methodCount; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
|
||||
{
|
||||
*aMethodCount = mMethodBaseIndex + (PRUint16) mMethods.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 constantCount; */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
||||
{
|
||||
*aConstantCount = mConstantBaseIndex + (PRUint16) mConstants.Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getMethodInfo (in PRUint16 index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfo(PRUint16 index, const nsXPTMethodInfo * *info)
|
||||
{
|
||||
if(index < mMethodBaseIndex)
|
||||
return mParent->GetMethodInfo(index, info);
|
||||
*info = (const nsXPTMethodInfo *) mMethods.ElementAt(index-mMethodBaseIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getMethodInfoForName (in string methodName, out PRUint16 index, [shared, retval] out nsXPTMethodInfoPtr info); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16 *index, const nsXPTMethodInfo * *info)
|
||||
{
|
||||
PRUint16 count = mMethodBaseIndex + (PRUint16) mMethods.Count();
|
||||
for(PRUint16 i = 0; i < count; i++)
|
||||
{
|
||||
const nsXPTMethodInfo* current;
|
||||
nsresult rv = GetMethodInfo(i, ¤t);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(!PL_strcmp(methodName, current->GetName()))
|
||||
{
|
||||
*index = i;
|
||||
*info = current;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
*index = 0;
|
||||
*info = 0;
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* void getConstant (in PRUint16 index, [shared, retval] out nsXPTConstantPtr constant); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetConstant(PRUint16 index, const nsXPTConstant * *constant)
|
||||
{
|
||||
if(index < mConstantBaseIndex)
|
||||
return mParent->GetConstant(index, constant);
|
||||
*constant = (const nsXPTConstant *) mConstants.ElementAt(index-mConstantBaseIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIInterfaceInfo getInfoForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetInfoForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
|
||||
return mSet->InterfaceInfoAt(td->type.iface, _retval);
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID * *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetIIDForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
|
||||
nsIInterfaceInfo* info = mSet->InfoAtNoAddRef(td->type.iface);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return info->GetInterfaceIID(_retval);
|
||||
}
|
||||
|
||||
/* nsXPTType getTypeForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, nsXPTType *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetTypeForParam(methodIndex, param, dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
||||
*_retval = nsXPTType(td->prefix);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetSizeIsArgNumberForParam(methodIndex, param, dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
||||
*_retval = td->argnum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetLengthIsArgNumberForParam(methodIndex, param, dimension, _retval);
|
||||
|
||||
const XPTTypeDescriptor *td =
|
||||
dimension ? GetTypeInArray(param, dimension) : ¶m->type;
|
||||
|
||||
*_retval = td->argnum2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, const nsXPTParamInfo * param, PRUint8 *_retval)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetInterfaceIsArgNumberForParam(methodIndex, param, _retval);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_IS_TYPE, "not an interface");
|
||||
|
||||
*_retval = td->argnum;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool isIID (in nsIIDPtr IID); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
|
||||
{
|
||||
*_retval = mIID.Equals(*IID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getNameShared ([shared, retval] out string name); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetNameShared(const char **name)
|
||||
{
|
||||
*name = mName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void getIIDShared ([shared, retval] out nsIIDPtrShared iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::GetIIDShared(const nsIID * *iid)
|
||||
{
|
||||
*iid = &mIID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool isFunction (); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::IsFunction(PRBool *_retval)
|
||||
{
|
||||
*_retval = XPT_ID_IS_FUNCTION(mFlags) != 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PRBool hasAncestor (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> current = NS_STATIC_CAST(nsIInterfaceInfo*, this);
|
||||
while(current)
|
||||
{
|
||||
PRBool same;
|
||||
if(NS_SUCCEEDED(current->IsIID(iid, &same)) && same)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIInterfaceInfo> temp(current);
|
||||
temp->GetParent(getter_AddRefs(current));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [notxpcom] nsresult getIIDForParamNoAlloc (in PRUint16 methodIndex, [const] in nsXPTParamInfoPtr param, out nsIID iid); */
|
||||
NS_IMETHODIMP_(nsresult) nsGenericInterfaceInfo::GetIIDForParamNoAlloc(PRUint16 methodIndex, const nsXPTParamInfo * param, nsIID *iid)
|
||||
{
|
||||
if(methodIndex < mMethodBaseIndex)
|
||||
return mParent->GetIIDForParamNoAlloc(methodIndex, param, iid);
|
||||
|
||||
const XPTTypeDescriptor* td = GetPossiblyNestedType(param);
|
||||
NS_ASSERTION(XPT_TDP_TAG(td->prefix) == TD_INTERFACE_TYPE, "not an interface");
|
||||
|
||||
nsIInterfaceInfo* info = mSet->InfoAtNoAddRef(td->type.iface);
|
||||
if(!info)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
const nsIID* iidp;
|
||||
nsresult rv = info->GetIIDShared(&iidp);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
*iid = *iidp;
|
||||
return NS_OK;
|
||||
}
|
|
@ -1,848 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer <jband@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* nsIScriptableInteraceInfo family implementations. */
|
||||
|
||||
#include "iixprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
static inline nsresult CloneString(const char* inStr, char** outStr)
|
||||
{
|
||||
*outStr = (char*) nsMemory::Clone(inStr, strlen(inStr)+1);
|
||||
return *outStr ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Header file */
|
||||
class nsScriptableDataType : public nsIScriptableDataType
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEDATATYPE
|
||||
|
||||
static nsresult Create(const nsXPTType& aType,
|
||||
nsIScriptableDataType** aResult);
|
||||
|
||||
nsScriptableDataType(); // not implemented
|
||||
|
||||
nsScriptableDataType(const nsXPTType& aType)
|
||||
: mType(aType) {}
|
||||
|
||||
virtual ~nsScriptableDataType() {}
|
||||
|
||||
private:
|
||||
nsXPTType mType;
|
||||
};
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableDataType::Create(const nsXPTType& aType,
|
||||
nsIScriptableDataType** aResult)
|
||||
{
|
||||
nsScriptableDataType* obj = new nsScriptableDataType(aType);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableDataType*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableDataType, nsIScriptableDataType)
|
||||
|
||||
/* readonly attribute PRBool isPointer; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsPointer(PRBool *aIsPointer)
|
||||
{
|
||||
*aIsPointer = mType.IsPointer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isUniquePointer; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsUniquePointer(PRBool *aIsUniquePointer)
|
||||
{
|
||||
*aIsUniquePointer = mType.IsUniquePointer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isReference; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsReference(PRBool *aIsReference)
|
||||
{
|
||||
*aIsReference = mType.IsReference();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isArithmetic; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsArithmetic(PRBool *aIsArithmetic)
|
||||
{
|
||||
*aIsArithmetic = mType.IsArithmetic();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isInterfacePointer; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsInterfacePointer(PRBool *aIsInterfacePointer)
|
||||
{
|
||||
*aIsInterfacePointer = mType.IsInterfacePointer();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isArray; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsArray(PRBool *aIsArray)
|
||||
{
|
||||
*aIsArray = mType.IsArray();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isDependent; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetIsDependent(PRBool *aIsDependent)
|
||||
{
|
||||
*aIsDependent = mType.IsDependent();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 dataType; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableDataType::GetDataType(PRUint16 *aDataType)
|
||||
{
|
||||
*aDataType = mType.TagPart();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsScriptableParamInfo : public nsIScriptableParamInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEPARAMINFO
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam,
|
||||
nsIScriptableParamInfo** aResult);
|
||||
|
||||
nsScriptableParamInfo(); // not implemented
|
||||
nsScriptableParamInfo(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam)
|
||||
: mInfo(aInfo), mParam(aParam) {}
|
||||
virtual ~nsScriptableParamInfo() {}
|
||||
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying param alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
nsXPTParamInfo mParam;
|
||||
};
|
||||
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableParamInfo::Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTParamInfo& aParam,
|
||||
nsIScriptableParamInfo** aResult)
|
||||
{
|
||||
nsScriptableParamInfo* obj = new nsScriptableParamInfo(aInfo, aParam);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableParamInfo*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableParamInfo, nsIScriptableParamInfo)
|
||||
|
||||
/* readonly attribute PRBool isIn; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsIn(PRBool *aIsIn)
|
||||
{
|
||||
*aIsIn = mParam.IsIn();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isOut; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsOut(PRBool *aIsOut)
|
||||
{
|
||||
*aIsOut = mParam.IsOut();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isRetval; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsRetval(PRBool *aIsRetval)
|
||||
{
|
||||
*aIsRetval = mParam.IsRetval();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isShared; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsShared(PRBool *aIsShared)
|
||||
{
|
||||
*aIsShared = mParam.IsShared();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isDipper; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetIsDipper(PRBool *aIsDipper)
|
||||
{
|
||||
*aIsDipper = mParam.IsDipper();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableDataType type; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetType(nsIScriptableDataType * *aType)
|
||||
{
|
||||
return nsScriptableDataType::Create(mParam.GetType(), aType);
|
||||
}
|
||||
|
||||
/* [noscript] void getParamInfo ([shared, const, retval] out nsXPTParamInfoPtr aInfo); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableParamInfo::GetParamInfo(const nsXPTParamInfo * *aInfo)
|
||||
{
|
||||
*aInfo = &mParam;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
class nsScriptableConstant : public nsIScriptableConstant
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLECONSTANT
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst,
|
||||
nsIScriptableConstant** aResult);
|
||||
|
||||
nsScriptableConstant(); // not implemented
|
||||
nsScriptableConstant(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst)
|
||||
: mInfo(aInfo), mConst(aConst) {}
|
||||
virtual ~nsScriptableConstant() {}
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying const alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
nsXPTConstant mConst;
|
||||
};
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableConstant::Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTConstant& aConst,
|
||||
nsIScriptableConstant** aResult)
|
||||
{
|
||||
nsScriptableConstant* obj = new nsScriptableConstant(aInfo, aConst);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableConstant*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableConstant, nsIScriptableConstant)
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableConstant::GetName(char * *aName)
|
||||
{
|
||||
return CloneString(mConst.GetName(), aName);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableDataType type; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableConstant::GetType(nsIScriptableDataType * *aType)
|
||||
{
|
||||
return nsScriptableDataType::Create(mConst.GetType(), aType);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIVariant value; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableConstant::GetValue(nsIVariant * *aValue)
|
||||
{
|
||||
nsVariant* variant = new nsVariant();
|
||||
if(!variant)
|
||||
{
|
||||
*aValue = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
*aValue = NS_STATIC_CAST(nsIVariant*, variant);
|
||||
NS_ADDREF(*aValue);
|
||||
|
||||
const nsXPTCMiniVariant* varval = mConst.GetValue();
|
||||
nsresult rv;
|
||||
|
||||
switch(mConst.GetType())
|
||||
{
|
||||
case nsXPTType::T_I16:
|
||||
rv = variant->SetAsInt16(varval->val.i16);
|
||||
break;
|
||||
case nsXPTType::T_I32:
|
||||
rv = variant->SetAsInt32(varval->val.i32);
|
||||
break;
|
||||
case nsXPTType::T_U16:
|
||||
rv = variant->SetAsUint16(varval->val.u16);
|
||||
break;
|
||||
case nsXPTType::T_U32:
|
||||
rv = variant->SetAsUint32(varval->val.u32);
|
||||
break;
|
||||
default:
|
||||
NS_ERROR("invalid const type");
|
||||
rv = NS_ERROR_UNEXPECTED;
|
||||
break;
|
||||
}
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
{
|
||||
NS_RELEASE(*aValue);
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class nsScriptableMethodInfo : public nsIScriptableMethodInfo
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCRIPTABLEMETHODINFO
|
||||
|
||||
static nsresult Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod,
|
||||
nsIScriptableMethodInfo** aResult);
|
||||
|
||||
nsScriptableMethodInfo(); // not implemented
|
||||
nsScriptableMethodInfo(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod)
|
||||
: mInfo(aInfo), mMethod(aMethod) {}
|
||||
virtual ~nsScriptableMethodInfo() {}
|
||||
private:
|
||||
// Holding onto the interface info keeps the underlying method alive.
|
||||
nsCOMPtr<nsIInterfaceInfo> mInfo;
|
||||
const nsXPTMethodInfo& mMethod;
|
||||
};
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableMethodInfo::Create(nsIInterfaceInfo* aInfo,
|
||||
const nsXPTMethodInfo& aMethod,
|
||||
nsIScriptableMethodInfo** aResult)
|
||||
{
|
||||
nsScriptableMethodInfo* obj = new nsScriptableMethodInfo(aInfo, aMethod);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableMethodInfo*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableMethodInfo, nsIScriptableMethodInfo)
|
||||
|
||||
/* readonly attribute PRBool isGetter; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsGetter(PRBool *aIsGetter)
|
||||
{
|
||||
*aIsGetter = mMethod.IsGetter();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isSetter; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsSetter(PRBool *aIsSetter)
|
||||
{
|
||||
*aIsSetter = mMethod.IsSetter();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isNotXPCOM; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsNotXPCOM(PRBool *aIsNotXPCOM)
|
||||
{
|
||||
*aIsNotXPCOM = mMethod.IsNotXPCOM();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isConstructor; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsConstructor(PRBool *aIsConstructor)
|
||||
{
|
||||
*aIsConstructor = mMethod.IsConstructor();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isHidden; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetIsHidden(PRBool *aIsHidden)
|
||||
{
|
||||
*aIsHidden = mMethod.IsHidden();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetName(char * *aName)
|
||||
{
|
||||
return CloneString(mMethod.GetName(), aName);
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint8 paramCount; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetParamCount(PRUint8 *aParamCount)
|
||||
{
|
||||
*aParamCount = mMethod.GetParamCount();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIScriptableParamInfo getParam (in PRUint8 idx); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetParam(PRUint8 idx, nsIScriptableParamInfo **_retval)
|
||||
{
|
||||
if(idx >= mMethod.GetParamCount())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
return nsScriptableParamInfo::Create(mInfo, mMethod.GetParam(idx), _retval);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableParamInfo result; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableMethodInfo::GetResult(nsIScriptableParamInfo * *aResult)
|
||||
{
|
||||
return nsScriptableParamInfo::Create(mInfo, mMethod.GetResult(), aResult);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsScriptableInterfaceInfo::Create(nsIInterfaceInfo* aInfo,
|
||||
nsIScriptableInterfaceInfo** aResult)
|
||||
{
|
||||
nsScriptableInterfaceInfo* obj = new nsScriptableInterfaceInfo(aInfo);
|
||||
if(!obj)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aResult = NS_STATIC_CAST(nsIScriptableInterfaceInfo*, obj);
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsScriptableInterfaceInfo, nsIScriptableInterfaceInfo)
|
||||
|
||||
nsScriptableInterfaceInfo::nsScriptableInterfaceInfo()
|
||||
{
|
||||
}
|
||||
|
||||
nsScriptableInterfaceInfo::nsScriptableInterfaceInfo(nsIInterfaceInfo* aInfo)
|
||||
: mInfo(aInfo)
|
||||
{
|
||||
}
|
||||
|
||||
nsScriptableInterfaceInfo::~nsScriptableInterfaceInfo()
|
||||
{
|
||||
// empty;
|
||||
}
|
||||
|
||||
/* [noscript] attribute nsIInterfaceInfo info; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInfo(nsIInterfaceInfo * *aInfo)
|
||||
{
|
||||
if(mInfo)
|
||||
NS_ADDREF(*aInfo = mInfo);
|
||||
else
|
||||
*aInfo = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::SetInfo(nsIInterfaceInfo * aInfo)
|
||||
{
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
mInfo = aInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef PRBool (*InfoTester)(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info);
|
||||
|
||||
static PRBool IIDTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
{
|
||||
return NS_SUCCEEDED(manager->GetInfoForIID((const nsIID *) data, info)) &&
|
||||
*info;
|
||||
}
|
||||
|
||||
static PRBool NameTester(nsIInterfaceInfoManager* manager, const void* data,
|
||||
nsIInterfaceInfo** info)
|
||||
{
|
||||
return NS_SUCCEEDED(manager->GetInfoForName((const char *) data, info)) &&
|
||||
*info;
|
||||
}
|
||||
|
||||
static nsresult FindInfo(InfoTester tester, const void* data, nsIInterfaceInfo** info)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
|
||||
if(!iim)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
if(tester(iim, data, info))
|
||||
return NS_OK;
|
||||
|
||||
// If not found, then let's ask additional managers.
|
||||
|
||||
PRBool yes;
|
||||
nsCOMPtr<nsISimpleEnumerator> list;
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism;
|
||||
|
||||
if((nsnull != (iism = do_QueryInterface(iim))) &&
|
||||
NS_SUCCEEDED(iism->HasAdditionalManagers(&yes)) && yes &&
|
||||
NS_SUCCEEDED(iism->EnumerateAdditionalManagers(getter_AddRefs(list))) &&
|
||||
list)
|
||||
{
|
||||
PRBool more;
|
||||
nsCOMPtr<nsIInterfaceInfoManager> current;
|
||||
|
||||
while(NS_SUCCEEDED(list->HasMoreElements(&more)) && more &&
|
||||
NS_SUCCEEDED(list->GetNext(getter_AddRefs(current))) && current)
|
||||
{
|
||||
if(tester(current, data, info))
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/* void Init (in nsIIDPtr aIID); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::Init(const nsIID * aIID)
|
||||
{
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if(!aIID)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return FindInfo(IIDTester, aIID, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* void initWithName (in string name); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::InitWithName(const char *name)
|
||||
{
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
if(!name)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return FindInfo(NameTester, name, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetName(char * *aName)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetName(aName);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIIDPtr interfaceID; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetInterfaceIID(aInterfaceID);
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isValid; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsValid(PRBool *aIsValid)
|
||||
{
|
||||
*aIsValid = !!mInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isScriptable; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsScriptable(PRBool *aIsScriptable)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->IsScriptable(aIsScriptable);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIScriptableInterfaceInfo parent; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetParent(nsIScriptableInterfaceInfo * *aParent)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> parentInfo;
|
||||
nsresult rv = mInfo->GetParent(getter_AddRefs(parentInfo));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(parentInfo)
|
||||
return Create(parentInfo, aParent);
|
||||
|
||||
*aParent = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 methodCount; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodCount(PRUint16 *aMethodCount)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetMethodCount(aMethodCount);
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint16 constantCount; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetConstantCount(PRUint16 *aConstantCount)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->GetConstantCount(aConstantCount);
|
||||
}
|
||||
|
||||
/* nsIScriptableMethodInfo getMethodInfo (in PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodInfo(PRUint16 index, nsIScriptableMethodInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
nsresult rv = mInfo->GetMethodInfo(index, &methodInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableMethodInfo getMethodInfoForName (in string methodName, out PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetMethodInfoForName(const char *methodName, PRUint16 *index, nsIScriptableMethodInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
nsresult rv = mInfo->GetMethodInfoForName(methodName, index, &methodInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableMethodInfo::Create(mInfo, *methodInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableConstant getConstant (in PRUint16 index); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetConstant(PRUint16 index, nsIScriptableConstant **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTConstant* constant;
|
||||
nsresult rv = mInfo->GetConstant(index, &constant);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableConstant::Create(mInfo, *constant, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableInterfaceInfo getInfoForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInfoForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, nsIScriptableInterfaceInfo **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> info;
|
||||
rv = mInfo->GetInfoForParam(methodIndex, paramInfo, getter_AddRefs(info));
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if(info)
|
||||
return Create(info, _retval);
|
||||
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIIDPtr getIIDForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIIDForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, nsIID * *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetIIDForParam(methodIndex, paramInfo, _retval);
|
||||
}
|
||||
|
||||
/* nsIScriptableDataType getTypeForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetTypeForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, nsIScriptableDataType **_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsXPTType type;
|
||||
|
||||
rv = mInfo->GetTypeForParam(methodIndex, paramInfo, dimension, &type);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return nsScriptableDataType::Create(type, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getSizeIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetSizeIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetSizeIsArgNumberForParam(methodIndex, paramInfo,
|
||||
dimension, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getLengthIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param, in PRUint16 dimension); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetLengthIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint16 dimension, PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetLengthIsArgNumberForParam(methodIndex, paramInfo,
|
||||
dimension, _retval);
|
||||
}
|
||||
|
||||
/* PRUint8 getInterfaceIsArgNumberForParam (in PRUint16 methodIndex, in nsIScriptableParamInfo param); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceIsArgNumberForParam(PRUint16 methodIndex, nsIScriptableParamInfo *param, PRUint8 *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
const nsXPTParamInfo* paramInfo;
|
||||
nsresult rv = param->GetParamInfo(¶mInfo);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
return mInfo->GetInterfaceIsArgNumberForParam(methodIndex, paramInfo,
|
||||
_retval);
|
||||
}
|
||||
|
||||
/* PRBool isIID (in nsIIDPtr IID); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::IsIID(const nsIID * IID, PRBool *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->IsIID(IID, _retval);
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isFunction; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsFunction(PRBool *aIsFunction)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->IsFunction(aIsFunction);
|
||||
}
|
||||
|
||||
/* PRBool hasAncestor (in nsIIDPtr iid); */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::HasAncestor(const nsIID * iid, PRBool *_retval)
|
||||
{
|
||||
if(!mInfo)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
return mInfo->HasAncestor(iid, _retval);
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer (jband@netscape.com)
|
||||
* Vidur Apparao (vidur@netscape.com)
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIInterfaceInfo.idl"
|
||||
#include "nsIInterfaceInfoManager.idl"
|
||||
#include "nsIWSDL.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsAString.h"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(8c7bf4bc-d3fe-4524-b213-ce578bfe936e)]
|
||||
interface nsIWSPInterfaceInfoService : nsISupports
|
||||
{
|
||||
nsIInterfaceInfo infoForPort(in nsIWSDLPort aPort,
|
||||
in AString aPortURL,
|
||||
in AString aQualifier,
|
||||
in PRBool aIsAsync,
|
||||
out nsIInterfaceInfoManager aSet);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_WSP_INTERFACEINFOSERVICE_CONTRACTID "@mozilla.org/xmlextras/proxy/interfaceinfoservice;1"
|
||||
%}
|
|
@ -1,333 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* John Bandhauer (jband@netscape.com)
|
||||
* Vidur Apparao (vidur@netscape.com)
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIWSDL.idl"
|
||||
#include "nsISimpleEnumerator.idl"
|
||||
#include "nsIException.idl"
|
||||
#include "nsISOAPResponse.idl"
|
||||
#include "nsISOAPBlock.idl"
|
||||
#include "nsIScriptableInterfaces.idl"
|
||||
|
||||
%{ C++
|
||||
#include "nsAString.h"
|
||||
%}
|
||||
|
||||
interface nsIWebServiceProxy;
|
||||
interface nsIWebServiceProxyCreationListener;
|
||||
interface nsIInterfaceInfo;
|
||||
interface nsIPropertyBag;
|
||||
|
||||
[scriptable, uuid(693611be-bb38-40e0-a98e-b46ff8a5bcca)]
|
||||
interface nsIWebServiceProxyFactory : nsISupports {
|
||||
/**
|
||||
* Create a service proxy. Loading of the WSDL URL will occur
|
||||
* in a synchronous manner. Calls to web service can be made as
|
||||
* soon as this method completes.
|
||||
*
|
||||
* @param wsdlURL The URL of the WSDL service description. This
|
||||
* description will be loaded and used as the basis
|
||||
* for the service proxy.
|
||||
* @param portname The name of the port of the service that this
|
||||
* service proxy represents. Currently the port
|
||||
* must represent a SOAP binding.
|
||||
* @param qualifier The user-specified qualifier is incorporated into
|
||||
* the names of XPCOM interfaces created for the
|
||||
* service proxy. For C++ callers, this qualifier
|
||||
* should be the same one used in creating the IDL
|
||||
* used at compile time. Script callers need not
|
||||
* specify a qualifier.
|
||||
* @param isAsync If PR_TRUE, the method signatures of the service
|
||||
* proxy represent an asynchronous calling convention.
|
||||
* A callback instance must be registered with the proxy.
|
||||
* A method call to a web service is only completed when
|
||||
* the corresponding callback method is invoked.
|
||||
* If PR_FALSE, the method signatures of the service
|
||||
* proxy represent a synchronous callling convention.
|
||||
* A method call to a web service is completed when the
|
||||
* method call to the proxy returns.
|
||||
*/
|
||||
nsIWebServiceProxy createProxy(in AString wsdlURL, in AString portname,
|
||||
in AString qualifier, in boolean isAsync);
|
||||
|
||||
/**
|
||||
* Create a service proxy. Loading of the WSDL URL will occur
|
||||
* in an asynchronous manner. Methods on the listener instance will
|
||||
* be invoked when the proxy has been created. Any method invocations
|
||||
* on the service proxy prior to asynchronous completion of the
|
||||
* intialization step will fail. The caller is guaranteed that this
|
||||
* method will return before the listener is invoked.
|
||||
*
|
||||
* @param wsdlURL The URL of the WSDL service description. This
|
||||
* description will be loaded and used as the basis
|
||||
* for the service proxy.
|
||||
* @param portname The name of the port of the service that this
|
||||
* service proxy represents. Currently the port
|
||||
* must represent a SOAP binding.
|
||||
* @param qualifier The user-specified qualifier is incorporated into
|
||||
* the names of XPCOM interfaces created for the
|
||||
* service proxy. For C++ callers, this qualifier
|
||||
* should be the same one used in creating the IDL
|
||||
* used at compile time. Script callers need not
|
||||
* specify a qualifier.
|
||||
* @param isAsync If PR_TRUE, the method signatures of the service
|
||||
* proxy represent an asynchronous calling convention.
|
||||
* A callback instance must be registered with the proxy.
|
||||
* A method call to a web service is only completed when
|
||||
* the corresponding callback method is invoked.
|
||||
* If PR_FALSE, the method signatures of the service
|
||||
* proxy represent a synchronous callling convention.
|
||||
* A method call to a web service is completed when the
|
||||
* method call to the proxy returns.
|
||||
* @param listener The callback instance which will be invoked when
|
||||
* the proxy is completely initialized.
|
||||
*/
|
||||
void createProxyAsync(in AString wsdlURL, in AString portname,
|
||||
in AString qualifier, in boolean isAsync,
|
||||
in nsIWebServiceProxyCreationListener listener);
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface should be implemented by a user who creates
|
||||
* a web service proxy in an asynchronous manner. An instance
|
||||
* of this interface is passed into the <code>initAsync</code>
|
||||
* method of the proxy.
|
||||
*/
|
||||
[scriptable, uuid(a711250b-47da-4f16-a1fd-593de16375a1)]
|
||||
interface nsIWebServiceProxyCreationListener : nsISupports {
|
||||
/**
|
||||
* Invoked when the proxy is completely initialized. Method
|
||||
* calls on the proxy can be made once this method is called.
|
||||
*
|
||||
* @param proxy The initialized web service proxy
|
||||
*/
|
||||
void onLoad(in nsIWebServiceProxy proxy);
|
||||
|
||||
/**
|
||||
* Invoked if an error occurs during web service proxy
|
||||
* initialization. This error code be a result of attempting
|
||||
* to load the specified WSDL URL or a result of processing
|
||||
* the WSDL and creating the interface information for the
|
||||
* proxy.
|
||||
*
|
||||
* @param error The exception generated as a result of the
|
||||
* error. This object can be introspected
|
||||
* for further information.
|
||||
*/
|
||||
void onError(in nsIException error);
|
||||
};
|
||||
|
||||
[scriptable, uuid(2122421c-1326-41db-87f8-25519d8a12cb)]
|
||||
interface nsIWebServiceProxy : nsISupports {
|
||||
|
||||
[noscript] void Init(in nsIWSDLPort aPort,
|
||||
in nsIInterfaceInfo aPrimaryInterface,
|
||||
in nsIInterfaceInfoManager aInterfaceInfoManager,
|
||||
in AString aQualifier,
|
||||
in boolean aIsAsync);
|
||||
|
||||
/**
|
||||
* The WSDL port that this service proxy represents.
|
||||
*
|
||||
* @see nsIWSDLPort
|
||||
*/
|
||||
readonly attribute nsIWSDLPort port;
|
||||
|
||||
/**
|
||||
* PR_TRUE if the service proxy methods represent an asynchronous
|
||||
* calling convention. PR_FALSE if the methods are synchronous.
|
||||
*/
|
||||
readonly attribute boolean isAsync;
|
||||
|
||||
/**
|
||||
* The qualifier used for interface names related to
|
||||
* this service proxy.
|
||||
*/
|
||||
readonly attribute AString qualifier;
|
||||
|
||||
|
||||
/**
|
||||
* An enumerator that returns the set of pending calls for the
|
||||
* service proxy. Each call is an instance of the
|
||||
* <code>nsIWebServiceCallContext</code> interface.
|
||||
*
|
||||
* @see nsIWebServiceCallContext
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator pendingCalls;
|
||||
|
||||
|
||||
/**
|
||||
* The name of the primary interface for this proxy. This may or may not be
|
||||
* the async version depending on whether or not this is an async proxy.
|
||||
*/
|
||||
readonly attribute string primaryInterfaceName;
|
||||
|
||||
/**
|
||||
* The name of the primary async listener interface for this proxy.
|
||||
* This will be null if this is not an async proxy.
|
||||
*/
|
||||
readonly attribute string primaryAsyncListenerInterfaceName;
|
||||
|
||||
/**
|
||||
* The collection of interfaces related to this service proxy. This
|
||||
* will include the primary interface implemented by the service
|
||||
* proxy as well as any listener or complex type interfaces required
|
||||
* for method parameters and return values.
|
||||
* NOTE: only interesting from JavaScript.
|
||||
*/
|
||||
readonly attribute nsIScriptableInterfaces interfaces;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A representation of a method invocation on a web service.
|
||||
* An instance of this interface is returned as a result of making
|
||||
* an asynchronous call and can be queried for status of the
|
||||
* call.
|
||||
*/
|
||||
[scriptable, uuid(87d87900-f102-4a15-b345-7b77a49d2df2)]
|
||||
interface nsIWebServiceCallContext : nsISupports {
|
||||
|
||||
/**
|
||||
* Possible values of the <code>status</code> attribute. A pending
|
||||
* call has a status of PENDING. A completed call has a status of
|
||||
* SUCCEEDED or FAILED depending on the result of the call.
|
||||
*/
|
||||
const PRUint32 PENDING = 0;
|
||||
const PRUint32 SUCCEEDED = 1;
|
||||
const PRUint32 FAILED = 2;
|
||||
const PRUint32 ABORTED = 3;
|
||||
|
||||
/**
|
||||
* The proxy object on which the call was made.
|
||||
*
|
||||
* @see nsIWebServiceProxy
|
||||
*/
|
||||
readonly attribute nsIWebServiceProxy proxy;
|
||||
|
||||
/**
|
||||
* The name of the method that was invoked.
|
||||
*/
|
||||
readonly attribute AString methodName;
|
||||
|
||||
/**
|
||||
* The status of the call, whether pending, completed successfully
|
||||
* or completed with a fault.
|
||||
*/
|
||||
readonly attribute PRUint32 status;
|
||||
|
||||
/**
|
||||
* The exception generated by the call if the status is FAILURE.
|
||||
* The exception object can be introspected for more information.
|
||||
* The <code>data</code> member can be QIed to a
|
||||
* <code>nsISOAPFault</code> instance for calls that use a
|
||||
* SOAP binding.
|
||||
*/
|
||||
readonly attribute nsIException pendingException;
|
||||
|
||||
/**
|
||||
* The WSDL operation that correpsonds to the method being invoked.
|
||||
*
|
||||
* @see nsIWSDLOperation
|
||||
*/
|
||||
readonly attribute nsIWSDLOperation operation;
|
||||
|
||||
/**
|
||||
* Called to abort a pending call. If the call is still pending,
|
||||
* its callback instance's <code>onError</code> will be invoked,
|
||||
* passing in the specified exception.
|
||||
*
|
||||
* @param error The exception passed to the callback instance's
|
||||
* <code>onError</code> method.
|
||||
*/
|
||||
void abort(in nsIException error);
|
||||
};
|
||||
|
||||
[scriptable, uuid(1ef83ece-b645-4b55-a501-df42c3333b47)]
|
||||
interface nsIWebServiceSOAPCallContext : nsIWebServiceCallContext {
|
||||
/**
|
||||
* For users who want access to the lower-level constructs that
|
||||
* are used for the method invocation, this attributes provides
|
||||
* the SOAP response once the call has completed.
|
||||
*
|
||||
* @see nsISOAPResponse
|
||||
*/
|
||||
readonly attribute nsISOAPResponse soapResponse;
|
||||
};
|
||||
|
||||
[uuid(b16b15bc-bfad-43cf-b374-2e4651acbc3c)]
|
||||
interface nsIWebServiceComplexTypeWrapper : nsISupports {
|
||||
void Init(in nsISupports aComplexTypeInstance,
|
||||
in nsIInterfaceInfo aInterfaceInfo);
|
||||
};
|
||||
|
||||
[uuid(e0b1765e-c0be-4a28-aca3-b292c5c3788b)]
|
||||
interface nsIWebServicePropertyBagWrapper : nsISupports {
|
||||
void Init(in nsIPropertyBag aPropertyBag,
|
||||
in nsIInterfaceInfo aInterfaceInfo);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
||||
#define NS_WEBSERVICEPROXYFACTORY_CLASSID \
|
||||
{ /* 4E557E69-CCE0-47da-A7D3-2A7ED666F566 */ \
|
||||
0x4e557e69, 0xcce0, 0x47da, \
|
||||
{0xa7, 0xd3, 0x2a, 0x7e, 0xd6, 0x66, 0xf5, 0x66}}
|
||||
#define NS_WEBSERVICEPROXYFACTORY_CONTRACTID "@mozilla.org/xmlextras/proxy/webserviceproxyfactory;1"
|
||||
|
||||
#define NS_WEBSERVICEPROXY_CLASSID \
|
||||
{ /* 1220efd4-8018-45b0-bfc1-0c0716ee0bfb */ \
|
||||
0x1220efd4, 0x8018, 0x45b0, \
|
||||
{0xbf, 0xc1, 0x0c, 0x07, 0x16, 0xee, 0x0b, 0xfb}}
|
||||
#define NS_WEBSERVICEPROXY_CONTRACTID "@mozilla.org/xmlextras/proxy/webserviceproxy;1"
|
||||
|
||||
#define NS_WEBSERVICECOMPLEXTYPEWRAPPER_CLASSID \
|
||||
{ /* 615272eb-3908-4fcc-b8f6-94d5a146e2bc */ \
|
||||
0x615272eb, 0x3908, 0x4fcc, \
|
||||
{0xb8, 0xf6, 0x94, 0xd5, 0xa1, 0x46, 0xe2, 0xbc}}
|
||||
#define NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID "@mozilla.org/xmlextras/proxy/webservicecomplextypewrapper;1"
|
||||
|
||||
#define NS_WEBSERVICEPROPERTYBAGWRAPPER_CLASSID \
|
||||
{ /* 1c76aea3-0810-45b7-bce9-03abc209eb8c */ \
|
||||
0x1c76aea3, 0x0810, 0x45b7, \
|
||||
{0xbc, 0xe9, 0x03, 0xab, 0xc2, 0x09, 0xeb, 0x8c}}
|
||||
#define NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID "@mozilla.org/xmlextras/proxy/webservicepropertybagwrapper;1"
|
||||
|
||||
%}
|
|
@ -45,8 +45,7 @@
|
|||
#include "nsISOAPParameter.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
WSPCallContext::WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
WSPCallContext::WSPCallContext(WSPProxy* aProxy, nsISOAPCall* aSOAPCall,
|
||||
const nsAString& aMethodName,
|
||||
nsIWSDLOperation* aOperation)
|
||||
: mProxy(aProxy), mCall(aSOAPCall), mMethodName(aMethodName),
|
||||
|
@ -145,13 +144,11 @@ WSPCallContext::GetSoapResponse(nsISOAPResponse * *aSoapResponse)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean handleResponse (in nsISOAPResponse aResponse, in nsISOAPCall aCall, in nsresult status, in boolean aLast); */
|
||||
/* boolean handleResponse (in nsISOAPResponse aResponse, in
|
||||
nsISOAPCall aCall, in nsresult status, in boolean aLast); */
|
||||
NS_IMETHODIMP
|
||||
WSPCallContext::HandleResponse(nsISOAPResponse *aResponse,
|
||||
nsISOAPCall *aCall,
|
||||
nsresult status,
|
||||
PRBool aLast,
|
||||
PRBool *_retval)
|
||||
WSPCallContext::HandleResponse(nsISOAPResponse *aResponse, nsISOAPCall *aCall,
|
||||
nsresult status, PRBool aLast, PRBool *_retval)
|
||||
{
|
||||
NS_ASSERTION(aCall == mCall, "unexpected call instance");
|
||||
NS_ASSERTION(aLast, "only single response expected");
|
||||
|
@ -171,8 +168,7 @@ WSPCallContext::CallAsync(PRUint32 aListenerMethodIndex,
|
|||
}
|
||||
|
||||
nsresult
|
||||
WSPCallContext::CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params)
|
||||
WSPCallContext::CallSync(PRUint32 aMethodIndex, nsXPTCMiniVariant* params)
|
||||
{
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
nsresult rv = mCall->Invoke(getter_AddRefs(response));
|
||||
|
@ -190,13 +186,15 @@ WSPCallContext::CallCompletionListener()
|
|||
#define PARAM_BUFFER_COUNT 8 /* Never set less than 2 */
|
||||
|
||||
if (!mProxy) {
|
||||
NS_ERROR("Huh, no proxy?");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
nsXPTCVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
nsXPTCVariant* dispatchParams = nsnull;
|
||||
|
||||
nsCOMPtr<nsISOAPResponse> response;
|
||||
nsCOMPtr<nsISOAPFault> fault;
|
||||
nsCOMPtr<nsISOAPFault> fault;
|
||||
mCompletion->GetResponse(getter_AddRefs(response));
|
||||
if (response) {
|
||||
rv = response->GetFault(getter_AddRefs(fault));
|
||||
|
@ -214,7 +212,8 @@ WSPCallContext::CallCompletionListener()
|
|||
|
||||
nsCOMPtr<nsIInterfaceInfo> listenerInterfaceInfo;
|
||||
mProxy->GetListenerInterfaceInfo(getter_AddRefs(listenerInterfaceInfo));
|
||||
NS_ASSERTION(listenerInterfaceInfo, "WSPCallContext:Missing listener interface info");
|
||||
NS_ASSERTION(listenerInterfaceInfo,
|
||||
"WSPCallContext:Missing listener interface info");
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
rv = listenerInterfaceInfo->GetMethodInfo(mListenerMethodIndex,
|
||||
|
@ -266,7 +265,8 @@ WSPCallContext::CallCompletionListener()
|
|||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
@ -306,7 +306,8 @@ WSPCallContext::CallCompletionListener()
|
|||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPPartBinding> partBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPPartBinding> partBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
@ -347,30 +348,31 @@ WSPCallContext::CallCompletionListener()
|
|||
|
||||
nsCOMPtr<nsIVariant> value;
|
||||
rv = block->GetValue(getter_AddRefs(value));
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(rv) || !value) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
|
||||
nsXPTCVariant* vars = dispatchParams+paramIndex;
|
||||
nsXPTCVariant* vars = dispatchParams + paramIndex;
|
||||
|
||||
if (paramIndex < maxParamIndex &&
|
||||
methodInfo->GetParam((PRUint8)(paramIndex+1)).GetType().IsArray()) {
|
||||
paramIndex++;
|
||||
}
|
||||
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex, "WSDL/IInfo param count mismatch");
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
const nsXPTParamInfo& paramInfo = methodInfo->GetParam(paramIndex);
|
||||
rv = WSPProxy::VariantToInParameter(listenerInterfaceInfo,
|
||||
mListenerMethodIndex,
|
||||
¶mInfo,
|
||||
mListenerMethodIndex, ¶mInfo,
|
||||
value, vars);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto call_completion_end;
|
||||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(paramIndex == maxParamIndex, "WSDL/IInfo param count mismatch");
|
||||
NS_ASSERTION(paramIndex == maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
dispatchParams[paramIndex].val.p =
|
||||
NS_STATIC_CAST(nsIWebServiceCallContext*, this);
|
||||
|
@ -390,7 +392,7 @@ call_completion_end:
|
|||
if (bodyCount) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
|
||||
}
|
||||
if(dispatchParams && dispatchParams != paramBuffer) {
|
||||
if(dispatchParams != paramBuffer) {
|
||||
delete [] dispatchParams;
|
||||
}
|
||||
nsCOMPtr<nsIWebServiceCallContext> kungFuDeathGrip(this);
|
||||
|
|
|
@ -1,365 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao (vidur@netscape.com) (Original author)
|
||||
* John Bandhauer (jband@netscape.com)
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "wspprivate.h"
|
||||
|
||||
// xtpcall includes
|
||||
#include "xptcall.h"
|
||||
#include "xptinfo.h"
|
||||
|
||||
// xpcom includes
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
class WSPComplexTypeProperty : public nsIProperty {
|
||||
public:
|
||||
WSPComplexTypeProperty(const nsAString& aName,
|
||||
nsIVariant* aValue);
|
||||
virtual ~WSPComplexTypeProperty() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROPERTY
|
||||
|
||||
protected:
|
||||
nsString mName;
|
||||
nsCOMPtr<nsIVariant> mValue;
|
||||
};
|
||||
|
||||
WSPComplexTypeProperty::WSPComplexTypeProperty(const nsAString& aName,
|
||||
nsIVariant* aValue)
|
||||
: mName(aName), mValue(aValue)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(WSPComplexTypeProperty, nsIProperty)
|
||||
|
||||
/* readonly attribute AString name; */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeProperty::GetName(nsAString & aName)
|
||||
{
|
||||
aName.Assign(mName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIVariant value; */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeProperty::GetValue(nsIVariant * *aValue)
|
||||
{
|
||||
NS_ADDREF(*aValue = mValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
class WSPComplexTypeEnumerator : public nsISimpleEnumerator {
|
||||
public:
|
||||
WSPComplexTypeEnumerator(WSPComplexTypeWrapper* aWrapper,
|
||||
nsIInterfaceInfo* aInterfaceInfo);
|
||||
virtual ~WSPComplexTypeEnumerator();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISIMPLEENUMERATOR
|
||||
|
||||
protected:
|
||||
WSPComplexTypeWrapper* mWrapper;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
PRUint16 mIndex;
|
||||
PRUint16 mCount;
|
||||
};
|
||||
|
||||
WSPComplexTypeEnumerator::WSPComplexTypeEnumerator(WSPComplexTypeWrapper* aWrapper, nsIInterfaceInfo* aInterfaceInfo)
|
||||
: mInterfaceInfo(aInterfaceInfo), mIndex(3)
|
||||
{
|
||||
mWrapper = aWrapper;
|
||||
NS_ADDREF(mWrapper);
|
||||
if (mInterfaceInfo) {
|
||||
mInterfaceInfo->GetMethodCount(&mCount);
|
||||
}
|
||||
}
|
||||
|
||||
WSPComplexTypeEnumerator::~WSPComplexTypeEnumerator()
|
||||
{
|
||||
NS_RELEASE(mWrapper);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(WSPComplexTypeEnumerator, nsISimpleEnumerator)
|
||||
|
||||
/* boolean hasMoreElements (); */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeEnumerator::HasMoreElements(PRBool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = mIndex < mCount;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsISupports getNext (); */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeEnumerator::GetNext(nsISupports **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
if (mIndex >= mCount) {
|
||||
NS_ERROR("Bad nsISimpleEnumerator caller!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
nsresult rv = mInterfaceInfo->GetMethodInfo(mIndex, &methodInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIVariant> var;
|
||||
rv = mWrapper->GetPropertyValue(mIndex++, methodInfo, getter_AddRefs(var));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString propName;
|
||||
rv = WSPFactory::C2XML(nsDependentCString(methodInfo->GetName()), propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
WSPComplexTypeProperty* prop = new WSPComplexTypeProperty(propName, var);
|
||||
if (!prop) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*_retval = prop;
|
||||
NS_ADDREF(*_retval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
WSPComplexTypeWrapper::WSPComplexTypeWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
WSPComplexTypeWrapper::~WSPComplexTypeWrapper()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPComplexTypeWrapper::Init(nsISupports* aComplexTypeInstance,
|
||||
nsIInterfaceInfo* aInterfaceInfo)
|
||||
{
|
||||
mComplexTypeInstance = aComplexTypeInstance;
|
||||
mInterfaceInfo = aInterfaceInfo;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
WSPComplexTypeWrapper::Create(nsISupports* outer, const nsIID& aIID,
|
||||
void* *aInstancePtr)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInstancePtr);
|
||||
NS_ENSURE_NO_AGGREGATION(outer);
|
||||
|
||||
WSPComplexTypeWrapper* wrapper = new WSPComplexTypeWrapper();
|
||||
if (!wrapper) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(wrapper);
|
||||
nsresult rv = wrapper->QueryInterface(aIID, aInstancePtr);
|
||||
NS_RELEASE(wrapper);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2_CI(WSPComplexTypeWrapper,
|
||||
nsIWebServiceComplexTypeWrapper,
|
||||
nsIPropertyBag)
|
||||
|
||||
/* readonly attribute nsISimpleEnumerator enumerator; */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeWrapper::GetEnumerator(nsISimpleEnumerator * *aEnumerator)
|
||||
{
|
||||
WSPComplexTypeEnumerator* enumerator = new WSPComplexTypeEnumerator(this, mInterfaceInfo);
|
||||
if (!enumerator) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*aEnumerator = enumerator;
|
||||
NS_ADDREF(*aEnumerator);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* nsIVariant getProperty (in AString name); */
|
||||
NS_IMETHODIMP
|
||||
WSPComplexTypeWrapper::GetProperty(const nsAString & name,
|
||||
nsIVariant **_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
|
||||
nsCAutoString methodName;
|
||||
WSPFactory::XML2C(name, methodName);
|
||||
|
||||
const nsXPTMethodInfo* methodInfo;
|
||||
PRUint16 methodIndex;
|
||||
nsresult rv = mInterfaceInfo->GetMethodInfoForName(methodName.get(),
|
||||
&methodIndex,
|
||||
&methodInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return GetPropertyValue(methodIndex, methodInfo, _retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPComplexTypeWrapper::GetPropertyValue(PRUint32 aMethodIndex,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
nsIVariant** _retval)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString outstr;
|
||||
PRUint32 numParams;
|
||||
nsXPTCVariant var[2];
|
||||
uint8 type_tag;
|
||||
nsXPTType arrayType;
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
|
||||
var[0].ClearFlags();
|
||||
var[1].ClearFlags();
|
||||
|
||||
// There are two possibilities here: a getter or a
|
||||
// method that returns array and array size out parameters.
|
||||
if (aMethodInfo->IsGetter()) {
|
||||
// If it's a getter make sure that it takes just a single (out) param
|
||||
if (aMethodInfo->GetParamCount() != 1) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsXPTParamInfo& paramInfo = aMethodInfo->GetParam(0);
|
||||
const nsXPTType& type = paramInfo.GetType();
|
||||
type_tag = type.TagPart();
|
||||
|
||||
numParams = 1;
|
||||
var[0].type = type_tag;
|
||||
if (paramInfo.IsOut()) {
|
||||
var[0].SetPtrIsData();
|
||||
var[0].ptr = &var[0].val;
|
||||
}
|
||||
else if (paramInfo.IsDipper() && type.IsPointer() &&
|
||||
(type_tag == nsXPTType::T_DOMSTRING)) {
|
||||
var[0].val.p = &outstr;
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (type_tag == nsXPTType::T_INTERFACE) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(aMethodIndex, ¶mInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If it isn't a getter, then it has to be an array
|
||||
// getter method
|
||||
else {
|
||||
// It must take two parameters for this to work
|
||||
if (aMethodInfo->GetParamCount() != 2) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
numParams = 2;
|
||||
|
||||
// The first parameter must be "out PRUint32"
|
||||
const nsXPTParamInfo& paramInfo1 = aMethodInfo->GetParam(0);
|
||||
const nsXPTType& type1 = paramInfo1.GetType();
|
||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
var[0].type = nsXPTType::T_U32;
|
||||
var[0].SetPtrIsData();
|
||||
var[0].ptr = &var[0].val;
|
||||
|
||||
// The second parameter must be "[array] out"
|
||||
const nsXPTParamInfo& paramInfo2 = aMethodInfo->GetParam(1);
|
||||
const nsXPTType& type2 = paramInfo2.GetType();
|
||||
type_tag = type2.TagPart();
|
||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
var[1].type = type_tag;
|
||||
var[1].SetPtrIsData();
|
||||
var[1].ptr = &var[1].val;
|
||||
|
||||
rv = mInterfaceInfo->GetTypeForParam(aMethodIndex, ¶mInfo2,
|
||||
1, &arrayType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (arrayType.IsInterfacePointer()) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(aMethodIndex, ¶mInfo2,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rv = XPTC_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
|
||||
numParams, var);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (type_tag == nsXPTType::T_ARRAY) {
|
||||
rv = WSPProxy::ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), var[1],
|
||||
var[0].val.u32, iinfo,
|
||||
_retval);
|
||||
}
|
||||
else {
|
||||
rv = WSPProxy::XPTCMiniVariantToVariant(type_tag, var[0], iinfo, _retval);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
|
@ -1,184 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao (vidur@netscape.com) (Original author)
|
||||
* John Bandhauer (jband@netscape.com)
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "wspprivate.h"
|
||||
|
||||
WSPException::WSPException(nsISOAPFault* aFault, nsresult aStatus)
|
||||
: mFault(aFault), mData(nsnull), mStatus(aStatus), mMsg(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
WSPException::WSPException(nsresult aStatus, const char* aMsg,
|
||||
nsISupports* aData)
|
||||
: mFault(nsnull), mData(aData), mStatus(aStatus), mMsg(nsnull)
|
||||
{
|
||||
if (aMsg) {
|
||||
mMsg = (char*) nsMemory::Clone(aMsg, strlen(aMsg)+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WSPException::~WSPException()
|
||||
{
|
||||
if (mMsg) {
|
||||
nsMemory::Free(mMsg);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1_CI(WSPException, nsIException)
|
||||
|
||||
/* readonly attribute string message; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetMessage(char * *aMessage)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aMessage);
|
||||
|
||||
nsAutoString faultString;
|
||||
*aMessage = nsnull;
|
||||
if (mFault) {
|
||||
mFault->GetFaultString(faultString);
|
||||
*aMessage = ToNewUTF8String(faultString);
|
||||
}
|
||||
else if (mMsg) {
|
||||
*aMessage = (char*) nsMemory::Clone(mMsg, strlen(mMsg)+1);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
/* readonly attribute nsresult result; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetResult(nsresult *aResult)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetName(char * *aName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
nsAutoString faultCode;
|
||||
*aName = nsnull;
|
||||
if (mFault) {
|
||||
mFault->GetFaultCode(faultCode);
|
||||
*aName = ToNewUTF8String(faultCode);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute string filename; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetFilename(char * *aFilename)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFilename);
|
||||
*aFilename = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint32 lineNumber; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetLineNumber(PRUint32 *aLineNumber)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLineNumber);
|
||||
*aLineNumber = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute PRUint32 columnNumber; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetColumnNumber(PRUint32 *aColumnNumber)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aColumnNumber);
|
||||
*aColumnNumber = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIStackFrame location; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetLocation(nsIStackFrame * *aLocation)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLocation);
|
||||
*aLocation = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIException inner; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetInner(nsIException * *aInner)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInner);
|
||||
*aInner = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute nsISupports data; */
|
||||
NS_IMETHODIMP
|
||||
WSPException::GetData(nsISupports * *aData)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aData);
|
||||
if (mFault) {
|
||||
*aData = mFault;
|
||||
}
|
||||
else if (mData) {
|
||||
*aData = mData;
|
||||
}
|
||||
else {
|
||||
*aData = nsnull;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* string toString (); */
|
||||
NS_IMETHODIMP
|
||||
WSPException::ToString(char **_retval)
|
||||
{
|
||||
if (mFault) {
|
||||
return GetName(_retval);
|
||||
}
|
||||
// else
|
||||
return GetMessage(_retval);
|
||||
}
|
||||
|
|
@ -53,10 +53,8 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWSDLLOADLISTENER
|
||||
|
||||
nsresult Run(const nsAString & wsdlURL,
|
||||
const nsAString & portname,
|
||||
const nsAString & qualifier,
|
||||
PRBool isAsync,
|
||||
nsresult Run(const nsAString & wsdlURL, const nsAString & portname,
|
||||
const nsAString & qualifier, PRBool isAsync,
|
||||
nsIWebServiceProxyCreationListener* aListener);
|
||||
|
||||
private:
|
||||
|
@ -79,10 +77,8 @@ WSPAsyncProxyCreator::~WSPAsyncProxyCreator()
|
|||
NS_IMPL_ISUPPORTS1(WSPAsyncProxyCreator, nsIWSDLLoadListener)
|
||||
|
||||
nsresult
|
||||
WSPAsyncProxyCreator::Run(const nsAString & wsdlURL,
|
||||
const nsAString & portname,
|
||||
const nsAString & qualifier,
|
||||
PRBool isAsync,
|
||||
WSPAsyncProxyCreator::Run(const nsAString& wsdlURL, const nsAString& portname,
|
||||
const nsAString& qualifier, PRBool isAsync,
|
||||
nsIWebServiceProxyCreationListener* aListener)
|
||||
{
|
||||
mWSDLURL = wsdlURL;
|
||||
|
@ -92,7 +88,8 @@ WSPAsyncProxyCreator::Run(const nsAString & wsdlURL,
|
|||
mListener = aListener;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWSDLLoader> loader = do_CreateInstance(NS_WSDLLOADER_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWSDLLoader> loader =
|
||||
do_CreateInstance(NS_WSDLLOADER_CONTRACTID, &rv);
|
||||
if (!loader) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -111,9 +108,11 @@ WSPAsyncProxyCreator::OnLoad(nsIWSDLPort *port)
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWSPInterfaceInfoService> iis = do_GetService(NS_WSP_INTERFACEINFOSERVICE_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWSPInterfaceInfoService> iis =
|
||||
do_GetService(NS_WSP_INTERFACEINFOSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv, NS_LITERAL_STRING("Can't get nsIWSPInterfaceInfoService"));
|
||||
return OnError(rv,
|
||||
NS_LITERAL_STRING("Can't get nsIWSPInterfaceInfoService"));
|
||||
}
|
||||
nsCOMPtr<nsIInterfaceInfoManager> manager;
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
|
@ -121,11 +120,13 @@ WSPAsyncProxyCreator::OnLoad(nsIWSDLPort *port)
|
|||
rv = iis->InfoForPort(port, mWSDLURL, mQualifier, mIsAsync,
|
||||
getter_AddRefs(manager), getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv, NS_LITERAL_STRING("Couldn't find interface info for port"));
|
||||
return OnError(rv,
|
||||
NS_LITERAL_STRING("Couldn't find interface info for port"));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebServiceProxy> proxy(do_CreateInstance(NS_WEBSERVICEPROXY_CONTRACTID, &rv));
|
||||
if (!proxy) {
|
||||
nsCOMPtr<nsIWebServiceProxy> proxy =
|
||||
do_CreateInstance(NS_WEBSERVICEPROXY_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv, NS_LITERAL_STRING("Couldn't create proxy"));
|
||||
}
|
||||
|
||||
|
@ -148,6 +149,9 @@ WSPAsyncProxyCreator::OnError(nsresult status, const nsAString & statusMessage)
|
|||
|
||||
nsCAutoString temp(ToNewUTF8String(statusMessage));
|
||||
nsCOMPtr<nsIException> e = new WSPException(status, temp.get(), nsnull);
|
||||
if (!e) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mListener->OnError(e);
|
||||
return NS_OK;
|
||||
|
@ -179,12 +183,16 @@ WSPFactory::CreateProxy(const nsAString & wsdlURL,
|
|||
|
||||
/* void createProxyAsync (in AString wsdlURL, in AString portname, in AString qualifier, in boolean isAsync, in nsIWebServiceProxyCreationListener listener); */
|
||||
NS_IMETHODIMP
|
||||
WSPFactory::CreateProxyAsync(const nsAString & wsdlURL,
|
||||
const nsAString & portname,
|
||||
const nsAString & qualifier,
|
||||
PRBool isAsync,
|
||||
WSPFactory::CreateProxyAsync(const nsAString& wsdlURL,
|
||||
const nsAString& portname,
|
||||
const nsAString& qualifier, PRBool isAsync,
|
||||
nsIWebServiceProxyCreationListener *listener)
|
||||
{
|
||||
if (!listener) {
|
||||
// A listener is required.
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsCOMPtr<WSPAsyncProxyCreator> creator = new WSPAsyncProxyCreator();
|
||||
if(!creator)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
#include "wspprivate.h"
|
||||
|
||||
/***************************************************************************/
|
||||
// IIDX is used as a way to hold and share our commone set of interface indexes.
|
||||
// IIDX is used as a way to hold and share our common set of interface
|
||||
// indexes.
|
||||
|
||||
class IIDX {
|
||||
public:
|
||||
|
@ -55,10 +56,18 @@ public:
|
|||
IDX_Count // Just a count of the above.
|
||||
};
|
||||
|
||||
PRUint16 Get(IndexID id) const {NS_ASSERTION(id<IDX_Count, "bad");
|
||||
return mData[id];}
|
||||
PRUint16* GetAddr(IndexID id) {NS_ASSERTION(id<IDX_Count, "bad");
|
||||
return &mData[id];}
|
||||
PRUint16 Get(IndexID id) const
|
||||
{
|
||||
NS_ASSERTION(id < IDX_Count, "bad");
|
||||
return mData[id];
|
||||
}
|
||||
|
||||
PRUint16* GetAddr(IndexID id)
|
||||
{
|
||||
NS_ASSERTION(id < IDX_Count, "bad");
|
||||
return &mData[id];
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint16 mData[IDX_Count];
|
||||
};
|
||||
|
@ -71,20 +80,38 @@ private:
|
|||
class ParamAccumulator
|
||||
{
|
||||
private:
|
||||
enum {MAX_BUILTIN = 8,
|
||||
ALLOCATION_INCREMENT = 16,
|
||||
MAX_TOTAL = 255}; // The typelib format limits us to 255 params.
|
||||
enum {
|
||||
MAX_BUILTIN = 8,
|
||||
ALLOCATION_INCREMENT = 16,
|
||||
MAX_TOTAL = 255
|
||||
}; // The typelib format limits us to 255 params.
|
||||
|
||||
public:
|
||||
PRUint16 GetCount() const {return mCount;}
|
||||
XPTParamDescriptor* GetArray() {return mArray;}
|
||||
void Clear() {mCount = 0;}
|
||||
PRUint16 GetCount() const
|
||||
{
|
||||
return mCount;
|
||||
}
|
||||
XPTParamDescriptor* GetArray()
|
||||
{
|
||||
return mArray;
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
mCount = 0;
|
||||
}
|
||||
|
||||
XPTParamDescriptor* GetNextParam();
|
||||
|
||||
ParamAccumulator()
|
||||
: mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace) {}
|
||||
~ParamAccumulator() {if(mArray != mBuiltinSpace) delete [] mArray;}
|
||||
: mCount(0), mAvailable(MAX_BUILTIN), mArray(mBuiltinSpace)
|
||||
{
|
||||
}
|
||||
|
||||
~ParamAccumulator()
|
||||
{
|
||||
if(mArray != mBuiltinSpace)
|
||||
delete [] mArray;
|
||||
}
|
||||
private:
|
||||
PRUint16 mCount;
|
||||
PRUint16 mAvailable;
|
||||
|
@ -92,7 +119,8 @@ private:
|
|||
XPTParamDescriptor mBuiltinSpace[MAX_BUILTIN];
|
||||
};
|
||||
|
||||
XPTParamDescriptor* ParamAccumulator::GetNextParam()
|
||||
XPTParamDescriptor*
|
||||
ParamAccumulator::GetNextParam()
|
||||
{
|
||||
if (mCount == MAX_TOTAL) {
|
||||
NS_WARNING("Too many params!");
|
||||
|
@ -106,6 +134,13 @@ XPTParamDescriptor* ParamAccumulator::GetNextParam()
|
|||
}
|
||||
|
||||
memcpy(newArray, mArray, newAvailable * sizeof(XPTParamDescriptor));
|
||||
|
||||
if (mArray != mBuiltinSpace) {
|
||||
// The old array was heap allocated, delete so that we don't
|
||||
// leak it.
|
||||
delete [] mArray;
|
||||
}
|
||||
|
||||
mArray = newArray;
|
||||
mAvailable = newAvailable;
|
||||
}
|
||||
|
@ -120,7 +155,8 @@ XPTParamDescriptor* ParamAccumulator::GetNextParam()
|
|||
// life of the process. These uuids should not be shared with other processes
|
||||
// or persisted.
|
||||
|
||||
static nsresult NewUniqueID(nsID *aID)
|
||||
static nsresult
|
||||
NewUniqueID(nsID *aID)
|
||||
{
|
||||
// XXX Hack Alert. This was generated on jband's 'bugsfree' machine and
|
||||
// *ought* not to conflict with any existing guids. We should find a
|
||||
|
@ -142,10 +178,9 @@ static nsresult NewUniqueID(nsID *aID)
|
|||
// FindInterfaceByName finds an interface info keyed by interface name. It
|
||||
// searches the super manager and any additional managers
|
||||
|
||||
static nsresult FindInterfaceByName(const char* aName,
|
||||
nsIInterfaceInfoSuperManager* iism,
|
||||
nsIInterfaceInfoManager **aSet,
|
||||
nsIInterfaceInfo **_retval)
|
||||
static nsresult
|
||||
FindInterfaceByName(const char* aName, nsIInterfaceInfoSuperManager* iism,
|
||||
nsIInterfaceInfoManager **aSet, nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if (NS_SUCCEEDED(iism->GetInfoForName(aName, _retval)) && *_retval) {
|
||||
NS_ADDREF(*aSet = iism);
|
||||
|
@ -164,7 +199,7 @@ static nsresult FindInterfaceByName(const char* aName,
|
|||
while (NS_SUCCEEDED(list->HasMoreElements(&more)) && more &&
|
||||
NS_SUCCEEDED(list->GetNext(getter_AddRefs(current))) && current) {
|
||||
if (NS_SUCCEEDED(current->GetInfoForName(aName, _retval)) &&
|
||||
*_retval) {
|
||||
*_retval) {
|
||||
NS_ADDREF(*aSet = current.get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -178,10 +213,9 @@ static nsresult FindInterfaceByName(const char* aName,
|
|||
// FindInterfaceByName finds the *index* of an interface info in the given
|
||||
// generic info set keyed by interface name.
|
||||
|
||||
static nsresult FindInterfaceIndexByName(const char* aName,
|
||||
nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
PRUint16* aIndex)
|
||||
static nsresult
|
||||
FindInterfaceIndexByName(const char* aName, nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet, PRUint16* aIndex)
|
||||
{
|
||||
nsresult rv = aSet->IndexOfByName(aName, aIndex);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -202,10 +236,9 @@ static nsresult FindInterfaceIndexByName(const char* aName,
|
|||
// specific interface info that we expect to find in the super manager keyed
|
||||
// by interface id.
|
||||
|
||||
static nsresult AppendStandardInterface(const nsIID& iid,
|
||||
nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* set,
|
||||
PRUint16* aIndex)
|
||||
static nsresult
|
||||
AppendStandardInterface(const nsIID& iid, nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* set, PRUint16* aIndex)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIInterfaceInfo> tempInfo;
|
||||
|
@ -222,10 +255,9 @@ static nsresult AppendStandardInterface(const nsIID& iid,
|
|||
// BuildInterfaceName is used to construct the name of an interface
|
||||
// based on three AStrings.
|
||||
|
||||
static void BuildInterfaceName(const nsAString& qualifier,
|
||||
const nsAString& name,
|
||||
const nsAString& uri,
|
||||
nsACString& aCIdentifier)
|
||||
static void
|
||||
BuildInterfaceName(const nsAString& qualifier, const nsAString& name,
|
||||
const nsAString& uri, nsACString& aCIdentifier)
|
||||
{
|
||||
WSPFactory::XML2C(qualifier, aCIdentifier);
|
||||
|
||||
|
@ -240,23 +272,22 @@ static void BuildInterfaceName(const nsAString& qualifier,
|
|||
/***************************************************************************/
|
||||
// Forward declaration...
|
||||
|
||||
static nsresult AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModuleGroup,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier);
|
||||
static nsresult
|
||||
AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModelGroup,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier);
|
||||
|
||||
// Forward declaration...
|
||||
static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaType* aType,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint32 depth,
|
||||
ParamAccumulator* aParams);
|
||||
static nsresult
|
||||
GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaType* aType, const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier, PRUint32 depth,
|
||||
ParamAccumulator* aParams);
|
||||
|
||||
/***************************************************************************/
|
||||
// AppendMethodForParticle appends a method to a 'struct' interface
|
||||
|
@ -264,13 +295,13 @@ static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
|||
// particles that are themselves modelgroups (by recurring into
|
||||
// AppendMethodsForModelGroup). At also knows how to deal with arrays.
|
||||
|
||||
static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaParticle* aParticle,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
static nsresult
|
||||
AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaParticle* aParticle, const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
{
|
||||
nsresult rv;
|
||||
XPTMethodDescriptor methodDesc;
|
||||
|
@ -280,7 +311,7 @@ static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
|||
ParamAccumulator params;
|
||||
PRUint16 i;
|
||||
|
||||
// If the particle is itself a moduleGroup, then flatten in its methods.
|
||||
// If the particle is itself a modelGroup, then flatten in its methods.
|
||||
nsCOMPtr<nsISchemaModelGroup> modelGroup(do_QueryInterface(aParticle));
|
||||
if (modelGroup) {
|
||||
return AppendMethodsForModelGroup(iism, aSet, modelGroup, iidx,
|
||||
|
@ -302,14 +333,13 @@ static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCAutoString identifierName;
|
||||
nsAutoString name;
|
||||
|
||||
rv = aParticle->GetName(name);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCAutoString identifierName;
|
||||
WSPFactory::XML2C(name, identifierName);
|
||||
|
||||
rv = GetParamDescOfType(iism, aSet, schemaType, iidx, defaultResult,
|
||||
|
@ -361,24 +391,24 @@ static nsresult AppendMethodForParticle(nsIInterfaceInfoSuperManager* iism,
|
|||
// AppendMethodsForModelGroup iterates the group's particles and calls
|
||||
// AppendMethodForParticle for each.
|
||||
|
||||
static nsresult AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModuleGroup,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
static nsresult
|
||||
AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaModelGroup* aModelGroup,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
nsIGenericInterfaceInfo* aInfo,
|
||||
const nsAString& qualifier)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 particleCount;
|
||||
rv = aModuleGroup->GetParticleCount(&particleCount);
|
||||
rv = aModelGroup->GetParticleCount(&particleCount);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (PRUint32 i = 0; i < particleCount; i++) {
|
||||
nsCOMPtr<nsISchemaParticle> particle;
|
||||
rv = aModuleGroup->GetParticle(i, getter_AddRefs(particle));
|
||||
rv = aModelGroup->GetParticle(i, getter_AddRefs(particle));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -398,14 +428,14 @@ static nsresult AppendMethodsForModelGroup(nsIInterfaceInfoSuperManager* iism,
|
|||
// create one. In our world these 'struct' interfaces are discovered by
|
||||
// name: qualifier+typename+typetargetnamespace.
|
||||
|
||||
static nsresult FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaComplexType* aComplexType,
|
||||
nsISchemaModelGroup* aModuleGroup,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint16* aTypeIndex)
|
||||
static nsresult
|
||||
FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaComplexType* aComplexType,
|
||||
nsISchemaModelGroup* aModelGroup,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint16* aTypeIndex)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCAutoString qualifiedName;
|
||||
|
@ -445,7 +475,7 @@ static nsresult FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
|||
return rv;
|
||||
}
|
||||
|
||||
return AppendMethodsForModelGroup(iism, aSet, aModuleGroup, iidx,
|
||||
return AppendMethodsForModelGroup(iism, aSet, aModelGroup, iidx,
|
||||
defaultResult, newInfo, qualifier);
|
||||
}
|
||||
|
||||
|
@ -458,14 +488,12 @@ static nsresult FindOrConstructInterface(nsIInterfaceInfoSuperManager* iism,
|
|||
// Note that the flags that control param passing (such as XPT_PD_IN,
|
||||
// XPT_PD_OUT, XPT_PD_DIPPER, and XPT_PD_RETVAL) are *not* set by this method.
|
||||
|
||||
static nsresult GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsISchemaType* aType,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
PRUint32 depth,
|
||||
ParamAccumulator* aParams)
|
||||
static nsresult
|
||||
GetParamDescOfType(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet, nsISchemaType* aType,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier, PRUint32 depth,
|
||||
ParamAccumulator* aParams)
|
||||
{
|
||||
XPTTypeDescriptor* additionalType;
|
||||
PRUint16 typeIndex;
|
||||
|
@ -723,15 +751,9 @@ do_simple:
|
|||
case nsISchemaBuiltinType::BUILTIN_TYPE_BOOLEAN:
|
||||
paramDesc->type.prefix.flags = TD_BOOL;
|
||||
return NS_OK;
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_TIME:
|
||||
paramDesc->type.prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER;
|
||||
return NS_OK;
|
||||
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_DATETIME:
|
||||
// XXX date type?
|
||||
paramDesc->type.prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER;
|
||||
return NS_OK;
|
||||
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_TIME:
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_DURATION:
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_DATE:
|
||||
case nsISchemaBuiltinType::BUILTIN_TYPE_GMONTH:
|
||||
|
@ -795,13 +817,11 @@ do_simple:
|
|||
// appropriate schema type so that it can call GetParamDescOfType to do the
|
||||
// rest of the work of filliung in a param descriptor.
|
||||
|
||||
static nsresult GetParamDescOfPart(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsIWSDLPart* aPart,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
ParamAccumulator* aParams)
|
||||
static nsresult
|
||||
GetParamDescOfPart(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet, nsIWSDLPart* aPart,
|
||||
const IIDX& iidx, XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier, ParamAccumulator* aParams)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -841,32 +861,30 @@ static nsresult GetParamDescOfPart(nsIInterfaceInfoSuperManager* iism,
|
|||
nsCOMPtr<nsISchemaElement> element(do_QueryInterface(schemaComponent));
|
||||
if (element) {
|
||||
rv = element->GetType(getter_AddRefs(type));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
type = do_QueryInterface(schemaComponent, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return GetParamDescOfType(iism, aSet, type, iidx, defaultResult,
|
||||
qualifier, 0, aParams);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
return GetParamDescOfType(iism, aSet, type, iidx, defaultResult, qualifier,
|
||||
0, aParams);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
// AccumulateParamsForMessage iterates the parts of a given message and
|
||||
// accumulates the param descriptors.
|
||||
|
||||
static nsresult AccumulateParamsForMessage(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsIWSDLMessage* aMsg,
|
||||
const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
ParamAccumulator* aParams)
|
||||
static nsresult
|
||||
AccumulateParamsForMessage(nsIInterfaceInfoSuperManager* iism,
|
||||
nsIGenericInterfaceInfoSet* aSet,
|
||||
nsIWSDLMessage* aMsg, const IIDX& iidx,
|
||||
XPTParamDescriptor* defaultResult,
|
||||
const nsAString& qualifier,
|
||||
ParamAccumulator* aParams)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 partCount;
|
||||
|
@ -887,7 +905,8 @@ static nsresult AccumulateParamsForMessage(nsIInterfaceInfoSuperManager* iism,
|
|||
// constructing a nested set of compound types and adding them
|
||||
// to the set.
|
||||
|
||||
rv = GetParamDescOfPart(iism, aSet, part, iidx, defaultResult, qualifier, aParams);
|
||||
rv = GetParamDescOfPart(iism, aSet, part, iidx, defaultResult, qualifier,
|
||||
aParams);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -915,46 +934,28 @@ nsWSPInterfaceInfoService::~nsWSPInterfaceInfoService()
|
|||
// It returns the interface info and optionally the interface info set -
|
||||
// which allows the caller to gather information on the referenced interfaces.
|
||||
|
||||
/* nsIInterfaceInfo infoForPort (in nsIWSDLPort aPort, in AString aPortURL, in AString aQualifier, in PRBool aIsAsync, out nsIInterfaceInfoManager aSet); */
|
||||
NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const nsAString & aPortURL, const nsAString & aQualifier, PRBool aIsAsync, nsIInterfaceInfoManager **aSet, nsIInterfaceInfo **_retval)
|
||||
/* nsIInterfaceInfo infoForPort (in nsIWSDLPort aPort, in AString
|
||||
aPortURL, in AString aQualifier, in PRBool aIsAsync, out
|
||||
nsIInterfaceInfoManager aSet); */
|
||||
NS_IMETHODIMP
|
||||
nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort,
|
||||
const nsAString & aPortURL,
|
||||
const nsAString & aQualifier,
|
||||
PRBool aIsAsync,
|
||||
nsIInterfaceInfoManager **aSet,
|
||||
nsIInterfaceInfo **_retval)
|
||||
{
|
||||
if (!aPort) {
|
||||
// aPort can't be null.
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCAutoString primaryName;
|
||||
nsCAutoString primaryAsyncName;
|
||||
nsAutoString portName;
|
||||
|
||||
IIDX iidx;
|
||||
PRUint16 listenerIndex;
|
||||
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryAsyncInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> listenerInfo;
|
||||
|
||||
ParamAccumulator inParams;
|
||||
ParamAccumulator outParams;
|
||||
|
||||
XPTParamDescriptor* tempParamArray;
|
||||
XPTParamDescriptor* defaultResult;
|
||||
|
||||
XPTParamDescriptor* primaryParamArray;
|
||||
XPTParamDescriptor* primaryAsyncParamArray;
|
||||
XPTParamDescriptor* listenerParamArray;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tempInfo;
|
||||
nsID tempID;
|
||||
nsCAutoString tempCString;
|
||||
nsAutoString tempString;
|
||||
|
||||
XPTMethodDescriptor methodDesc;
|
||||
XPTParamDescriptor paramDesc;
|
||||
XPTParamDescriptor* pparamDesc;
|
||||
|
||||
PRUint16 ignoredIndex;
|
||||
|
||||
PRUint32 i;
|
||||
PRUint32 k;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism =
|
||||
do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID);
|
||||
if (!iism) {
|
||||
|
@ -983,6 +984,31 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
|
||||
// No, we need to build all the stuff...
|
||||
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> primaryAsyncInfo;
|
||||
nsCOMPtr<nsIGenericInterfaceInfo> listenerInfo;
|
||||
|
||||
ParamAccumulator inParams;
|
||||
ParamAccumulator outParams;
|
||||
|
||||
XPTParamDescriptor* tempParamArray;
|
||||
XPTParamDescriptor* defaultResult;
|
||||
|
||||
XPTParamDescriptor* primaryParamArray;
|
||||
XPTParamDescriptor* primaryAsyncParamArray;
|
||||
XPTParamDescriptor* listenerParamArray;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> tempInfo;
|
||||
nsCAutoString tempCString;
|
||||
nsAutoString tempString;
|
||||
|
||||
IIDX iidx;
|
||||
PRUint16 listenerIndex;
|
||||
|
||||
XPTMethodDescriptor methodDesc;
|
||||
XPTParamDescriptor paramDesc;
|
||||
XPTParamDescriptor* pparamDesc;
|
||||
|
||||
// Create a new info set.
|
||||
|
||||
nsCOMPtr<nsIGenericInterfaceInfoSet> set =
|
||||
|
@ -1025,6 +1051,9 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
|
||||
// Create and add the primary interface.
|
||||
|
||||
PRUint16 ignoredIndex;
|
||||
nsID tempID;
|
||||
|
||||
::NewUniqueID(&tempID);
|
||||
rv = set->CreateAndAppendInterface(primaryName.get(), tempID,
|
||||
iidx.Get(IIDX::IDX_nsISupports),
|
||||
|
@ -1107,7 +1136,8 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
tempParamArray[0].flags = XPT_PD_IN;
|
||||
|
||||
tempParamArray[1].type.prefix.flags = TD_INTERFACE_TYPE | XPT_TDP_POINTER;
|
||||
tempParamArray[1].type.type.iface = iidx.Get(IIDX::IDX_nsIWebServiceCallContext);
|
||||
tempParamArray[1].type.type.iface =
|
||||
iidx.Get(IIDX::IDX_nsIWebServiceCallContext);
|
||||
tempParamArray[1].flags = XPT_PD_IN;
|
||||
|
||||
methodDesc.name = "onError";
|
||||
|
@ -1129,6 +1159,7 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
return rv;
|
||||
}
|
||||
|
||||
PRUint32 i;
|
||||
for (i = 0; i < methodCount; i++)
|
||||
{
|
||||
nsCOMPtr<nsIWSDLOperation> op;
|
||||
|
@ -1178,7 +1209,8 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
}
|
||||
|
||||
PRUint16 primaryAsyncParamCount = inParams.GetCount() + 1;
|
||||
rv = set->AllocateParamArray(primaryAsyncParamCount, &primaryAsyncParamArray);
|
||||
rv = set->AllocateParamArray(primaryAsyncParamCount,
|
||||
&primaryAsyncParamArray);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1195,7 +1227,8 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
// primary and primaryAsync.
|
||||
|
||||
pparamDesc = inParams.GetArray();
|
||||
for (k = 0; k < inParams.GetCount(); pparamDesc++, k++) {
|
||||
|
||||
for (PRUint32 k = 0; k < inParams.GetCount(); pparamDesc++, k++) {
|
||||
// set direction flag
|
||||
pparamDesc->flags |= XPT_PD_IN;
|
||||
|
||||
|
@ -1263,7 +1296,6 @@ NS_IMETHODIMP nsWSPInterfaceInfoService::InfoForPort(nsIWSDLPort *aPort, const n
|
|||
pparamDesc->type.argnum =
|
||||
pparamDesc->type.argnum2 = k; // not '-1' because of leading arg
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
memcpy(listenerParamArray,
|
||||
|
|
|
@ -1,301 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Vidur Apparao (vidur@netscape.com) (Original author)
|
||||
* John Bandhauer (jband@netscape.com)
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the NPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __wspprivate_h__
|
||||
#define __wspprivate_h__
|
||||
|
||||
// XPCOM includes
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsSupportsArray.h"
|
||||
#include "nsIPropertyBag.h"
|
||||
#include "nsIException.h"
|
||||
#include "nsIExceptionService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsAString.h"
|
||||
|
||||
// SOAP includes
|
||||
#include "nsISOAPCall.h"
|
||||
#include "nsISOAPResponse.h"
|
||||
#include "nsISOAPResponseListener.h"
|
||||
#include "nsISOAPCallCompletion.h"
|
||||
#include "nsISOAPFault.h"
|
||||
#include "nsSOAPUtils.h"
|
||||
|
||||
// interface info includes
|
||||
#include "xptcall.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
|
||||
// WSDL includes
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsIWSDLLoader.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
|
||||
// iix includes
|
||||
#include "nsIGenericInterfaceInfoSet.h"
|
||||
|
||||
// Proxy includes
|
||||
#include "nsIWebServiceProxy.h"
|
||||
#include "nsIWSPInterfaceInfoService.h"
|
||||
|
||||
// Forward decls
|
||||
class WSPCallContext;
|
||||
|
||||
class WSPFactory : public nsIWebServiceProxyFactory
|
||||
{
|
||||
public:
|
||||
WSPFactory();
|
||||
virtual ~WSPFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICEPROXYFACTORY
|
||||
|
||||
static nsresult C2XML(const nsACString& aCIdentifier,
|
||||
nsAString& aXMLIdentifier);
|
||||
static void XML2C(const nsAString& aXMLIndentifier,
|
||||
nsACString& aCIdentifier);
|
||||
};
|
||||
|
||||
class WSPProxy : public nsXPTCStubBase,
|
||||
public nsIWebServiceProxy,
|
||||
public nsIClassInfo
|
||||
{
|
||||
public:
|
||||
WSPProxy();
|
||||
virtual ~WSPProxy();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICEPROXY
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
|
||||
void CallCompleted(WSPCallContext* aContext);
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
||||
static nsresult XPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
static nsresult ArrayXPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
PRUint32 aLength,
|
||||
nsIInterfaceInfo* aIfaceInfo,
|
||||
nsIVariant** aVariant);
|
||||
|
||||
static nsresult VariantToValue(uint8 aTypeTag,
|
||||
void* aValue,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
static nsresult VariantToArrayValue(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty);
|
||||
|
||||
static nsresult ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsXPTCMiniVariant aMiniVariant,
|
||||
PRUint32 aArrayLength,
|
||||
nsIVariant** aVariant);
|
||||
static nsresult VariantToInParameter(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsIVariant* aVariant,
|
||||
nsXPTCVariant* aXPTCVariant);
|
||||
static nsresult VariantToOutParameter(nsIInterfaceInfo* aInterfaceInfo,
|
||||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsIVariant* aVariant,
|
||||
nsXPTCMiniVariant* aMiniVariant);
|
||||
static nsresult WrapInPropertyBag(nsISupports* aInstance,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIPropertyBag** aPropertyBag);
|
||||
static nsresult WrapInComplexType(nsIPropertyBag* aPropertyBag,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsISupports** aComplexType);
|
||||
|
||||
|
||||
protected:
|
||||
nsresult GetInterfaceName(PRBool listener, char** retval);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIWSDLPort> mPort;
|
||||
nsCOMPtr<nsIInterfaceInfo> mPrimaryInterface;
|
||||
nsCOMPtr<nsIInterfaceInfoManager> mInterfaceInfoManager;
|
||||
nsString mQualifier;
|
||||
PRBool mIsAsync;
|
||||
nsSupportsArray mPendingCalls;
|
||||
const nsIID* mIID;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
nsCOMPtr<nsIInterfaceInfo> mListenerInterfaceInfo;
|
||||
nsCOMPtr<nsIScriptableInterfaces> mInterfaces;
|
||||
};
|
||||
|
||||
class WSPCallContext : public nsIWebServiceSOAPCallContext,
|
||||
public nsISOAPResponseListener
|
||||
{
|
||||
public:
|
||||
WSPCallContext(WSPProxy* aProxy,
|
||||
nsISOAPCall* aSOAPCall,
|
||||
const nsAString& aMethodName,
|
||||
nsIWSDLOperation* aOperation);
|
||||
virtual ~WSPCallContext();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICECALLCONTEXT
|
||||
NS_DECL_NSIWEBSERVICESOAPCALLCONTEXT
|
||||
NS_DECL_NSISOAPRESPONSELISTENER
|
||||
|
||||
nsresult CallAsync(PRUint32 aListenerMethodIndex,
|
||||
nsISupports* aListener);
|
||||
nsresult CallSync(PRUint32 aMethodIndex,
|
||||
nsXPTCMiniVariant* params);
|
||||
|
||||
protected:
|
||||
nsresult CallCompletionListener();
|
||||
|
||||
protected:
|
||||
WSPProxy* mProxy;
|
||||
nsCOMPtr<nsISOAPCall> mCall;
|
||||
nsString mMethodName;
|
||||
nsCOMPtr<nsIWSDLOperation> mOperation;
|
||||
nsCOMPtr<nsISOAPCallCompletion> mCompletion;
|
||||
nsresult mStatus;
|
||||
nsCOMPtr<nsIException> mException;
|
||||
nsCOMPtr<nsISupports> mAsyncListener;
|
||||
PRUint32 mListenerMethodIndex;
|
||||
};
|
||||
|
||||
class WSPException : public nsIException
|
||||
{
|
||||
public:
|
||||
WSPException(nsISOAPFault* aFault, nsresult aStatus);
|
||||
WSPException(nsresult aStatus, const char* aMsg, nsISupports* aData);
|
||||
virtual ~WSPException();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIEXCEPTION
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISOAPFault> mFault;
|
||||
nsCOMPtr<nsISupports> mData;
|
||||
nsresult mStatus;
|
||||
char* mMsg;
|
||||
};
|
||||
|
||||
class WSPComplexTypeWrapper : public nsIWebServiceComplexTypeWrapper,
|
||||
public nsIPropertyBag
|
||||
{
|
||||
public:
|
||||
WSPComplexTypeWrapper();
|
||||
virtual ~WSPComplexTypeWrapper();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROPERTYBAG
|
||||
NS_DECL_NSIWEBSERVICECOMPLEXTYPEWRAPPER
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
||||
nsresult GetPropertyValue(PRUint32 aMethodIndex,
|
||||
const nsXPTMethodInfo* aMethodInfo,
|
||||
nsIVariant** _retval);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsISupports> mComplexTypeInstance;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
};
|
||||
|
||||
class WSPPropertyBagWrapper : public nsXPTCStubBase,
|
||||
public nsIWebServicePropertyBagWrapper,
|
||||
public nsIClassInfo
|
||||
{
|
||||
public:
|
||||
WSPPropertyBagWrapper();
|
||||
virtual ~WSPPropertyBagWrapper();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBSERVICEPROPERTYBAGWRAPPER
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
// Would be nice to have a NS_DECL_NSXPTCSTUBBASE
|
||||
NS_IMETHOD CallMethod(PRUint16 methodIndex,
|
||||
const nsXPTMethodInfo* info,
|
||||
nsXPTCMiniVariant* params);
|
||||
NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
|
||||
|
||||
static NS_METHOD
|
||||
Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIPropertyBag> mPropertyBag;
|
||||
nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
|
||||
const nsIID* mIID;
|
||||
};
|
||||
|
||||
class nsWSPInterfaceInfoService : public nsIWSPInterfaceInfoService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWSPINTERFACEINFOSERVICE
|
||||
|
||||
nsWSPInterfaceInfoService();
|
||||
virtual ~nsWSPInterfaceInfoService();
|
||||
};
|
||||
|
||||
#define NS_WEBSERVICECALLCONTEXT_CLASSID \
|
||||
{ /* a42e9bf3-6bae-4c59-8f76-9dc175eec5b1 */ \
|
||||
0xa42e9bf3, 0x6bae, 0x4c59, \
|
||||
{0x8f, 0x76, 0x9d, 0xc1, 0x75, 0xee, 0xc5, 0xb1}}
|
||||
#define NS_WEBSERVICECALLCONTEXT_CONTRACTID "@mozilla.org/xmlextras/proxy/webservicecallcontext;1"
|
||||
#define NS_WEBSERVICEEXCEPTION_CLASSID \
|
||||
{ /* 07c2bf7b-376e-4629-b9c0-dbb17630b98d */ \
|
||||
0x07c2bf7b, 0x376e, 0x4629, \
|
||||
{0xb9, 0xc0, 0xdb, 0xb1, 0x76, 0x30, 0xb9, 0x8d}}
|
||||
#define NS_WEBSERVICEEXCEPTION_CONTRACTID "@mozilla.org/xmlextras/proxy/webserviceexception;1"
|
||||
|
||||
#endif // __wspprivate_h__
|
|
@ -86,21 +86,18 @@ WSPPropertyBagWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
|||
{
|
||||
if((mIID && aIID.Equals(*mIID)) || aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsXPTCStubBase*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIWebServicePropertyBagWrapper))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIWebServicePropertyBagWrapper*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIClassInfo*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
} else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -116,77 +113,74 @@ WSPPropertyBagWrapper::CallMethod(PRUint16 methodIndex,
|
|||
NS_ERROR("WSPPropertyBagWrapper: bad method index");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()),
|
||||
propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mPropertyBag->GetProperty(propName, getter_AddRefs(val));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = WSPFactory::C2XML(nsDependentCString(info->GetName()), propName);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (info->IsGetter()) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(0);
|
||||
const nsXPTType& type = paramInfo.GetType();
|
||||
uint8 type_tag = type.TagPart();
|
||||
rv = mPropertyBag->GetProperty(propName, getter_AddRefs(val));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (type_tag == nsXPTType::T_INTERFACE) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (info->IsGetter()) {
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(0);
|
||||
const nsXPTType& type = paramInfo.GetType();
|
||||
uint8 type_tag = type.TagPart();
|
||||
|
||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||
}
|
||||
else if (info->GetParamCount() == 2) {
|
||||
// If it's not an explicit getter, it has to be an array
|
||||
// getter method.
|
||||
|
||||
// The first parameter should be the array length out param
|
||||
const nsXPTParamInfo& paramInfo1 = info->GetParam(0);
|
||||
const nsXPTType& type1 = paramInfo1.GetType();
|
||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// The second parameter should be the array out pointer
|
||||
// itself.
|
||||
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
|
||||
const nsXPTType& type2 = paramInfo2.GetType();
|
||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTType arrayType;
|
||||
rv = mInterfaceInfo->GetTypeForParam(methodIndex, ¶mInfo2,
|
||||
1, &arrayType);
|
||||
if (type_tag == nsXPTType::T_INTERFACE) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (arrayType.IsInterfacePointer()) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo2,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rv = WSPProxy::VariantToArrayValue(arrayType.TagPart(), params,
|
||||
iinfo, val);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected method signature for property bag wrapper");
|
||||
|
||||
rv = WSPProxy::VariantToValue(type_tag, params[0].val.p, iinfo, val);
|
||||
}
|
||||
else if (info->GetParamCount() == 2) {
|
||||
// If it's not an explicit getter, it has to be an array getter
|
||||
// method.
|
||||
|
||||
// The first parameter should be the array length out param
|
||||
const nsXPTParamInfo& paramInfo1 = info->GetParam(0);
|
||||
const nsXPTType& type1 = paramInfo1.GetType();
|
||||
if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// The second parameter should be the array out pointer itself.
|
||||
const nsXPTParamInfo& paramInfo2 = info->GetParam(1);
|
||||
const nsXPTType& type2 = paramInfo2.GetType();
|
||||
if (!paramInfo2.IsOut() || !type2.IsArray()) {
|
||||
NS_ERROR("Unexpected parameter type for getter");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTType arrayType;
|
||||
rv = mInterfaceInfo->GetTypeForParam(methodIndex, ¶mInfo2,
|
||||
1, &arrayType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (arrayType.IsInterfacePointer()) {
|
||||
rv = mInterfaceInfo->GetInfoForParam(methodIndex, ¶mInfo2,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
rv = WSPProxy::VariantToArrayValue(arrayType.TagPart(), params, iinfo,
|
||||
val);
|
||||
}
|
||||
else {
|
||||
NS_ERROR("Unexpected method signature for property bag wrapper");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -209,7 +203,8 @@ WSPPropertyBagWrapper::GetInterfaceInfo(nsIInterfaceInfo** info)
|
|||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] out nsIIDPtr array); */
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count),
|
||||
retval] out nsIIDPtr array); */
|
||||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::GetInterfaces(PRUint32 *count, nsIID * **array)
|
||||
{
|
||||
|
@ -220,8 +215,18 @@ WSPPropertyBagWrapper::GetInterfaces(PRUint32 *count, nsIID * **array)
|
|||
}
|
||||
|
||||
iids[0] = NS_STATIC_CAST(nsIID *, nsMemory::Clone(mIID, sizeof(nsIID)));
|
||||
if (!iids[0]) {
|
||||
nsMemory::Free(iids);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
const nsIID& wsiid = NS_GET_IID(nsIWebServicePropertyBagWrapper);
|
||||
iids[1] = NS_STATIC_CAST(nsIID *, nsMemory::Clone(&wsiid, sizeof(nsIID)));
|
||||
if (!iids[1]) {
|
||||
nsMemory::Free(iids[0]);
|
||||
nsMemory::Free(iids);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*array = iids;
|
||||
|
||||
|
@ -241,7 +246,13 @@ WSPPropertyBagWrapper::GetHelperForLanguage(PRUint32 language,
|
|||
NS_IMETHODIMP
|
||||
WSPPropertyBagWrapper::GetContractID(char * *aContractID)
|
||||
{
|
||||
*aContractID = ToNewUTF8String(NS_LITERAL_STRING(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID));
|
||||
*aContractID = (char *)
|
||||
nsMemory::Clone(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID,
|
||||
sizeof(NS_WEBSERVICEPROPERTYBAGWRAPPER_CONTRACTID));
|
||||
if (!*aContractID) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "wspprivate.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIWSDL.h"
|
||||
#include "nsIWSDLSOAPBinding.h"
|
||||
#include "nsISchema.h"
|
||||
|
@ -63,11 +64,9 @@ WSPProxy::~WSPProxy()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WSPProxy::Init(nsIWSDLPort* aPort,
|
||||
nsIInterfaceInfo* aPrimaryInterface,
|
||||
WSPProxy::Init(nsIWSDLPort* aPort, nsIInterfaceInfo* aPrimaryInterface,
|
||||
nsIInterfaceInfoManager* aInterfaceInfoManager,
|
||||
const nsAString& aQualifier,
|
||||
PRBool aIsAsync)
|
||||
const nsAString& aQualifier, PRBool aIsAsync)
|
||||
{
|
||||
NS_ENSURE_ARG(aPort);
|
||||
NS_ENSURE_ARG(aPrimaryInterface);
|
||||
|
@ -209,20 +208,22 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPEncoding> encoding = do_CreateInstance(NS_SOAPENCODING_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsISOAPEncoding> encoding =
|
||||
do_CreateInstance(NS_SOAPENCODING_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
call->SetEncoding(encoding);
|
||||
|
||||
// Get the method name and target object uri
|
||||
nsAutoString methodName, targetObjectURI, address;
|
||||
nsAutoString methodName, targetObjectURI;
|
||||
rv = operation->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPOperationBinding> operationBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -237,7 +238,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsISOAPMessageBinding> messageBinding = do_QueryInterface(binding, &rv);
|
||||
nsCOMPtr<nsISOAPMessageBinding> messageBinding =
|
||||
do_QueryInterface(binding, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -253,6 +255,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString address;
|
||||
portBinding->GetAddress(address);
|
||||
rv = call->SetTransportURI(address);
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -275,15 +279,13 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
// body vs. header blocks
|
||||
nsCOMPtr<nsIWSDLPart> part;
|
||||
PRUint32 headerCount = 0, bodyCount = 0;
|
||||
|
||||
for (i = 0; i < partCount; i++) {
|
||||
rv = input->GetPart(i, getter_AddRefs(part));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsAutoString paramName;
|
||||
part->GetName(paramName);
|
||||
|
||||
rv = part->GetBinding(getter_AddRefs(binding));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
@ -316,6 +318,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
rv = CallCreateInstance(NS_SOAPPARAMETER_CONTRACTID, &bodyBlocks[i]);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, bodyBlocks);
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +341,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(bodyCount, bodyBlocks);
|
||||
}
|
||||
NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(i, headerBlocks);
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -350,9 +356,6 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
PRUint16 location;
|
||||
partBinding->GetLocation(&location);
|
||||
|
||||
nsAutoString paramName;
|
||||
part->GetName(paramName);
|
||||
|
||||
nsCOMPtr<nsISOAPBlock> block;
|
||||
if (location == nsISOAPPartBinding::LOCATION_HEADER) {
|
||||
block = do_QueryInterface(headerBlocks[headerEntry++]);
|
||||
|
@ -393,6 +396,9 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
else {
|
||||
type = do_QueryInterface(schemaComponent);
|
||||
|
||||
nsAutoString paramName;
|
||||
part->GetName(paramName);
|
||||
|
||||
blockName.Assign(paramName);
|
||||
partBinding->GetNamespace(blockNamespace);
|
||||
}
|
||||
|
@ -424,14 +430,15 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
PRUint32 arrayLength;
|
||||
|
||||
if (paramIndex < maxParamIndex &&
|
||||
info->GetParam((PRUint8)(paramIndex+1)).GetType().IsArray()) {
|
||||
info->GetParam((PRUint8)(paramIndex + 1)).GetType().IsArray()) {
|
||||
arrayLength = params[paramIndex++].val.u32;
|
||||
}
|
||||
else {
|
||||
arrayLength = 0;
|
||||
}
|
||||
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex, "WSDL/IInfo param count mismatch");
|
||||
NS_ASSERTION(paramIndex <= maxParamIndex,
|
||||
"WSDL/IInfo param count mismatch");
|
||||
|
||||
const nsXPTParamInfo& paramInfo = info->GetParam(paramIndex);
|
||||
|
||||
|
@ -488,8 +495,8 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
}
|
||||
#endif
|
||||
|
||||
nsIWebServiceCallContext** retval = NS_STATIC_CAST(nsIWebServiceCallContext**,
|
||||
params[pcount-1].val.p);
|
||||
nsIWebServiceCallContext** retval =
|
||||
NS_STATIC_CAST(nsIWebServiceCallContext**, params[pcount-1].val.p);
|
||||
if (!retval) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto call_method_end;
|
||||
|
@ -502,8 +509,7 @@ WSPProxy::CallMethod(PRUint16 methodIndex,
|
|||
goto call_method_end;
|
||||
}
|
||||
|
||||
mPendingCalls.AppendElement(NS_STATIC_CAST(nsIWebServiceSOAPCallContext*,
|
||||
ccInst));
|
||||
mPendingCalls.AppendObject(ccInst);
|
||||
}
|
||||
else {
|
||||
rv = ccInst->CallSync(methodIndex, params);
|
||||
|
@ -524,8 +530,7 @@ WSPProxy::ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
|||
PRUint32 aMethodIndex,
|
||||
const nsXPTParamInfo* aParamInfo,
|
||||
nsXPTCMiniVariant aMiniVariant,
|
||||
PRUint32 aArrayLength,
|
||||
nsIVariant** aVariant)
|
||||
PRUint32 aArrayLength, nsIVariant** aVariant)
|
||||
{
|
||||
nsXPTType type;
|
||||
nsresult rv = aInterfaceInfo->GetTypeForParam(aMethodIndex, aParamInfo,
|
||||
|
@ -533,6 +538,7 @@ WSPProxy::ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
uint8 type_tag = type.TagPart();
|
||||
nsCOMPtr<nsIInterfaceInfo> iinfo;
|
||||
if (type.IsArray()) {
|
||||
|
@ -550,20 +556,21 @@ WSPProxy::ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
|
|||
return rv;
|
||||
}
|
||||
}
|
||||
return ArrayXPTCMiniVariantToVariant(arrayType.TagPart(),
|
||||
aMiniVariant, aArrayLength,
|
||||
iinfo, aVariant);
|
||||
return ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), aMiniVariant,
|
||||
aArrayLength, iinfo, aVariant);
|
||||
}
|
||||
else {
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// else
|
||||
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return XPTCMiniVariantToVariant(type_tag, aMiniVariant, iinfo, aVariant);
|
||||
}
|
||||
|
||||
return XPTCMiniVariantToVariant(type_tag, aMiniVariant, iinfo, aVariant);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -573,7 +580,8 @@ WSPProxy::WrapInPropertyBag(nsISupports* aInstance,
|
|||
{
|
||||
*aPropertyBag = nsnull;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper(do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv));
|
||||
nsCOMPtr<nsIWebServiceComplexTypeWrapper> wrapper =
|
||||
do_CreateInstance(NS_WEBSERVICECOMPLEXTYPEWRAPPER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -581,13 +589,11 @@ WSPProxy::WrapInPropertyBag(nsISupports* aInstance,
|
|||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
CallQueryInterface(wrapper, aPropertyBag);
|
||||
return NS_OK;
|
||||
return CallQueryInterface(wrapper, aPropertyBag);
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPProxy::XPTCMiniVariantToVariant(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant aResult,
|
||||
WSPProxy::XPTCMiniVariantToVariant(uint8 aTypeTag, nsXPTCMiniVariant aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant** aVariant)
|
||||
{
|
||||
|
@ -604,8 +610,8 @@ WSPProxy::XPTCMiniVariantToVariant(uint8 aTypeTag,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> var = do_CreateInstance(NS_VARIANT_CONTRACTID,
|
||||
&rv);
|
||||
nsCOMPtr<nsIWritableVariant> var =
|
||||
do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -698,7 +704,8 @@ WSPProxy::ArrayXPTCMiniVariantToVariant(uint8 aTypeTag,
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIWritableVariant> retvar = do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIWritableVariant> retvar =
|
||||
do_CreateInstance(NS_VARIANT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -869,17 +876,15 @@ WSPProxy::VariantToOutParameter(nsIInterfaceInfo* aInterfaceInfo,
|
|||
return VariantToArrayValue(arrayType.TagPart(), aMiniVariant,
|
||||
iinfo, aVariant);
|
||||
}
|
||||
else {
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
// else
|
||||
if (type.IsInterfacePointer()) {
|
||||
rv = aInterfaceInfo->GetInfoForParam(aMethodIndex, aParamInfo,
|
||||
getter_AddRefs(iinfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
return VariantToValue(type_tag, aMiniVariant->val.p, iinfo, aVariant);
|
||||
}
|
||||
return NS_OK;
|
||||
return VariantToValue(type_tag, aMiniVariant->val.p, iinfo, aVariant);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -888,24 +893,20 @@ WSPProxy::WrapInComplexType(nsIPropertyBag* aPropertyBag,
|
|||
nsISupports** aComplexType)
|
||||
{
|
||||
*aComplexType = nsnull;
|
||||
WSPPropertyBagWrapper* wrapper = new WSPPropertyBagWrapper();
|
||||
nsRefPtr<WSPPropertyBagWrapper> wrapper = new WSPPropertyBagWrapper();
|
||||
if (!wrapper) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(wrapper);
|
||||
nsresult rv = wrapper->Init(aPropertyBag, aInterfaceInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(wrapper);
|
||||
return rv;
|
||||
}
|
||||
wrapper->QueryInterface(NS_GET_IID(nsISupports), (void**)aComplexType);
|
||||
NS_RELEASE(wrapper);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WSPProxy::VariantToValue(uint8 aTypeTag,
|
||||
void* aValue,
|
||||
WSPProxy::VariantToValue(uint8 aTypeTag, void* aValue,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
|
@ -1003,8 +1004,7 @@ WSPProxy::VariantToValue(uint8 aTypeTag,
|
|||
}
|
||||
|
||||
nsresult
|
||||
WSPProxy::VariantToArrayValue(uint8 aTypeTag,
|
||||
nsXPTCMiniVariant* aResult,
|
||||
WSPProxy::VariantToArrayValue(uint8 aTypeTag, nsXPTCMiniVariant* aResult,
|
||||
nsIInterfaceInfo* aInterfaceInfo,
|
||||
nsIVariant* aProperty)
|
||||
{
|
||||
|
@ -1044,12 +1044,13 @@ WSPProxy::VariantToArrayValue(uint8 aTypeTag,
|
|||
*((void**)aResult[1].val.p) = array;
|
||||
}
|
||||
else if (!arrayIID.Equals(NS_GET_IID(nsIPropertyBag))) {
|
||||
NS_ERROR("Array of complex types should be represented by property bags");
|
||||
NS_ERROR("Array of complex types should be represented by property "
|
||||
"bags");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
else {
|
||||
nsISupports** outptr = (nsISupports**)nsMemory::Alloc(count *
|
||||
sizeof(nsISupports*));
|
||||
nsISupports** outptr =
|
||||
(nsISupports**)nsMemory::Alloc(count * sizeof(nsISupports*));
|
||||
if (!outptr) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1143,7 +1144,8 @@ WSPProxy::GetPendingCalls(nsISimpleEnumerator * *aPendingCalls)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsresult WSPProxy::GetInterfaceName(PRBool listener, char** retval)
|
||||
nsresult
|
||||
WSPProxy::GetInterfaceName(PRBool listener, char** retval)
|
||||
{
|
||||
if (!mPrimaryInterface) {
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -1203,7 +1205,8 @@ WSPProxy::GetInterfaces(nsIScriptableInterfaces * *aInterfaces)
|
|||
//
|
||||
///////////////////////////////////////////////////
|
||||
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count), retval] out nsIIDPtr array); */
|
||||
/* void getInterfaces (out PRUint32 count, [array, size_is (count),
|
||||
retval] out nsIIDPtr array); */
|
||||
NS_IMETHODIMP
|
||||
WSPProxy::GetInterfaces(PRUint32 *count, nsIID * **array)
|
||||
{
|
||||
|
@ -1287,6 +1290,5 @@ WSPProxy::GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo)
|
|||
void
|
||||
WSPProxy::CallCompleted(WSPCallContext* aContext)
|
||||
{
|
||||
mPendingCalls.RemoveElement(NS_STATIC_CAST(nsIWebServiceCallContext*,
|
||||
aContext));
|
||||
mPendingCalls.RemoveObject(aContext);
|
||||
}
|
||||
|
|
|
@ -425,7 +425,9 @@ NS_IMETHODIMP
|
|||
rv = mRequest->GetResponseXML(getter_AddRefs(document));
|
||||
if (NS_SUCCEEDED(rv) && document) {
|
||||
rv = mResponse->SetMessage(document);
|
||||
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)} else {
|
||||
DEBUG_DUMP_DOCUMENT("Asynchronous Response", document)
|
||||
}
|
||||
else {
|
||||
mResponse = nsnull;
|
||||
}
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче