зеркало из https://github.com/mozilla/pjs.git
Commiting accumulated interface info extensions changes. NOT PART OF THE BUILD
This commit is contained in:
Родитель
fb27bd29a0
Коммит
188047365b
|
@ -1,90 +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 nsIGenericInterfaceInfo/nsIGenericInterfaceInfoSet public declarations.*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIInterfaceInfo.idl"
|
||||
#include "nsIInterfaceInfoManager.idl"
|
||||
|
||||
[ptr] native nsXPTTypePtr(nsXPTType);
|
||||
|
||||
/* this is NOT intended to be scriptable */
|
||||
[uuid(8344a200-18ed-4538-8d44-e50b5156b564)]
|
||||
interface nsIGenericInterfaceInfo : nsIInterfaceInfo
|
||||
{
|
||||
/**
|
||||
* Caller might allocate one more than the actual param count in
|
||||
* order to have a location for the result pointer used in the methodinfo.
|
||||
*/
|
||||
nsXPTParamInfoPtr allocateParamArray(in PRUint16 aCount);
|
||||
|
||||
/**
|
||||
* Used for arrays.
|
||||
*/
|
||||
nsXPTTypePtr allocateAdditionalType(out PRUint16 aIndex);
|
||||
|
||||
/**
|
||||
* All members except params* and result* copied
|
||||
*/
|
||||
|
||||
PRUint16 appendMethod(in nsXPTMethodInfoPtr aMethod);
|
||||
|
||||
/**
|
||||
* All members copied
|
||||
*/
|
||||
PRUint16 appendConst(in nsXPTConstantPtr aConst);
|
||||
};
|
||||
|
||||
/* this is NOT intended to be scriptable */
|
||||
[uuid(8cc674ee-52ba-45fa-b897-bb88d35eaa91)]
|
||||
interface nsIGenericInterfaceInfoSet : nsIInterfaceInfoManager
|
||||
{
|
||||
PRUint16 createAndAppendInterface(in string aName, in nsIIDRef aIID,
|
||||
in PRUint16 aParent, in PRUint8 aFlags,
|
||||
out nsIGenericInterfaceInfo aInfo);
|
||||
PRUint16 appendExternalInterface(in nsIInterfaceInfo aInfo);
|
||||
PRUint16 indexOf(in nsIIDRef aIID);
|
||||
nsIInterfaceInfo interfaceInfoAt(in PRUint16 aIndex);
|
||||
};
|
||||
|
||||
%{C++
|
||||
// The contractID for the implementation built into iiextras
|
||||
#define NS_GENERIC_INTERFACE_INFO_SET_CONTRACTID "@mozilla.org/genericInterfaceInfoSet;1"
|
||||
%}
|
||||
|
|
@ -1,47 +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 nsIInterfaceInfoToIDL public declaration.*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(b01eb40c-026b-49c9-af55-25e8c9d034c8)]
|
||||
interface nsIInterfaceInfoToIDL : nsISupports
|
||||
{
|
||||
string generateIDL(in nsIIDRef aIID);
|
||||
};
|
||||
|
|
@ -101,13 +101,11 @@ interface nsIScriptableInterfaceInfo : nsISupports
|
|||
[noscript] attribute nsIInterfaceInfo info;
|
||||
|
||||
void init(in nsIIDPtr aIID);
|
||||
void initWithName(in string name);
|
||||
|
||||
readonly attribute string name;
|
||||
|
||||
/**
|
||||
* Setting interfaceID will set what interface info this object wraps.
|
||||
*/
|
||||
attribute nsIIDPtr interfaceID;
|
||||
readonly attribute nsIIDPtr interfaceID;
|
||||
|
||||
/**
|
||||
* True if this object has been sucessfully set to wrap an interface info.
|
||||
|
|
|
@ -74,7 +74,6 @@ public:
|
|||
virtual ~nsGenericInterfaceInfoSet();
|
||||
|
||||
XPTArena* GetArena() {return mArena;}
|
||||
nsresult AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval);
|
||||
|
||||
const XPTTypeDescriptor* GetAdditionalTypeAt(PRUint16 aIndex)
|
||||
{
|
||||
|
@ -121,7 +120,7 @@ public:
|
|||
virtual ~nsGenericInterfaceInfo() {}
|
||||
|
||||
private:
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const nsXPTParamInfo* param)
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const XPTParamDescriptor* param)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
while(XPT_TDP_TAG(td->prefix) == TD_ARRAY)
|
||||
|
@ -129,7 +128,7 @@ private:
|
|||
return td;
|
||||
}
|
||||
|
||||
const XPTTypeDescriptor* GetTypeInArray(const nsXPTParamInfo* param,
|
||||
const XPTTypeDescriptor* GetTypeInArray(const XPTParamDescriptor* param,
|
||||
PRUint16 dimension)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
|
|
|
@ -74,17 +74,6 @@ nsGenericInterfaceInfoSet::~nsGenericInterfaceInfoSet()
|
|||
XPT_DestroyArena(mArena);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval)
|
||||
{
|
||||
*_retval = (nsXPTType*)
|
||||
XPT_MALLOC(GetArena(), sizeof(nsXPTType));
|
||||
if(!*_retval || !mAdditionalTypes.AppendElement(*_retval))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aIndex = (PRUint16) mAdditionalTypes.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
|
@ -92,7 +81,8 @@ nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
|||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const nsID* iid;
|
||||
nsresult rv = info->GetIIDShared(&iid);
|
||||
if(NS_FAILED(rv))
|
||||
|
@ -113,7 +103,8 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const char* name;
|
||||
nsresult rv = info->GetNameShared(&name);
|
||||
if(NS_FAILED(rv))
|
||||
|
@ -130,6 +121,27 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
/************************************************/
|
||||
// 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)
|
||||
|
@ -165,6 +177,12 @@ 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)
|
||||
|
@ -311,37 +329,26 @@ nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
|||
{
|
||||
mMethodBaseIndex = mConstantBaseIndex = 0;
|
||||
}
|
||||
|
||||
int len = PL_strlen(aName);
|
||||
mName = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(mName)
|
||||
memcpy(mName, aName, len);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfo methods...
|
||||
|
||||
/* nsXPTParamInfoPtr allocateParamArray (in PRUint16 aCount); */
|
||||
/* PRUint16 appendMethod (in XPTMethodDescriptorPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AllocateParamArray(PRUint16 aCount, nsXPTParamInfo * *_retval)
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
*_retval = (nsXPTParamInfo*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(nsXPTParamInfo) * aCount);
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* nsXPTTypePtr allocateAdditionalType (out PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval)
|
||||
{
|
||||
return mSet->AllocateAdditionalType(aIndex, _retval);
|
||||
}
|
||||
|
||||
/* PRUint16 appendMethod (in nsXPTMethodInfoPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendMethod(nsXPTMethodInfo * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
nsXPTMethodInfo* desc = (nsXPTMethodInfo*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(nsXPTMethodInfo));
|
||||
XPTMethodDescriptor* desc = (XPTMethodDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTMethodDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aMethod, sizeof(nsXPTMethodInfo));
|
||||
memcpy(desc, aMethod, sizeof(XPTMethodDescriptor));
|
||||
|
||||
int len = PL_strlen(aMethod->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
|
@ -353,8 +360,8 @@ nsGenericInterfaceInfo::AppendMethod(nsXPTMethodInfo * aMethod, PRUint16 *_retva
|
|||
return mMethods.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRUint16 appendConst (in nsXPTConstantPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(nsXPTConstant * aConst, PRUint16 *_retval)
|
||||
/* PRUint16 appendConst (in XPTConstDescriptorPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, PRUint16 *_retval)
|
||||
|
||||
{
|
||||
NS_ASSERTION(aConst->type.prefix.flags == TD_INT16 ||
|
||||
|
|
|
@ -415,9 +415,29 @@ function doForwardDeclarations(out, iid)
|
|||
prev = cur;
|
||||
}
|
||||
}
|
||||
out.writeln("");
|
||||
}
|
||||
|
||||
function buildForwardDeclarationsList(iid)
|
||||
{
|
||||
var i, cur, prev;
|
||||
var list = [];
|
||||
var outList = [];
|
||||
appendForwardDeclarations(list, new IInfo(iid));
|
||||
list.sort();
|
||||
|
||||
for(i = 0; i < list.length; i++)
|
||||
{
|
||||
cur = list[i];
|
||||
if(cur != prev && cur != "nsISupports")
|
||||
{
|
||||
if(cur != MISSING_INTERFACE)
|
||||
outList.push(cur);
|
||||
prev = cur;
|
||||
}
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
/* Our Componenent ctor */
|
||||
|
@ -427,18 +447,42 @@ function nsInterfaceInfoToIDL() {}
|
|||
nsInterfaceInfoToIDL.prototype =
|
||||
{
|
||||
// nsIInterfaceInfoToIDL methods...
|
||||
generateIDL : function (iid) {
|
||||
|
||||
// string generateIDL(in nsIIDRef aIID,
|
||||
// in PRBool withIncludes,
|
||||
// in PRBool withForwardDeclarations);
|
||||
generateIDL : function(aIID, withIncludes, withForwardDeclarations) {
|
||||
var out = new Buffer;
|
||||
out.writeln();
|
||||
out.writeln('#include "nsISupports.idl"');
|
||||
out.writeln();
|
||||
|
||||
doForwardDeclarations(out, iid)
|
||||
doInterface(out, iid);
|
||||
if(withIncludes)
|
||||
{
|
||||
out.writeln('#include "nsISupports.idl"');
|
||||
out.writeln();
|
||||
}
|
||||
|
||||
if(withForwardDeclarations)
|
||||
{
|
||||
doForwardDeclarations(out, aIID);
|
||||
out.writeln("");
|
||||
}
|
||||
|
||||
doInterface(out, aIID);
|
||||
|
||||
return out.buffer;
|
||||
},
|
||||
|
||||
// void getReferencedInterfaceNames(in nsIIDRef aIID,
|
||||
// out PRUint32 aArrayLength,
|
||||
// [retval, array, size_is(aArrayLength)]
|
||||
// out string aNames);
|
||||
|
||||
getReferencedInterfaceNames : function(aIID, aArrayLength) {
|
||||
var list = buildForwardDeclarationsList(aIID);
|
||||
aArrayLength.value = list.length;
|
||||
return list;
|
||||
},
|
||||
|
||||
// nsISupports methods...
|
||||
QueryInterface: function (iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIInterfaceInfoToIDL) &&
|
||||
|
@ -484,9 +528,9 @@ GenericModule.prototype = {
|
|||
* unmolested.
|
||||
*/
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
|
||||
compMgr.registerComponentWithType(this.CID, this.name, this.contractID,
|
||||
fileSpec, location, true, true, type);
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
compMgr.registerFactoryLocation(this.CID, this.name, this.contractID,
|
||||
fileSpec, location, type);
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
@ -499,15 +499,88 @@ nsScriptableInterfaceInfo::GetInfo(nsIInterfaceInfo * *aInfo)
|
|||
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)
|
||||
{
|
||||
return SetInterfaceID(aIID);
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
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;
|
||||
|
||||
return FindInfo(NameTester, name, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
|
@ -520,7 +593,7 @@ nsScriptableInterfaceInfo::GetName(char * *aName)
|
|||
return mInfo->GetName(aName);
|
||||
}
|
||||
|
||||
/* attribute nsIIDPtr interfaceID; */
|
||||
/* readonly attribute nsIIDPtr interfaceID; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
||||
{
|
||||
|
@ -530,47 +603,6 @@ nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
|||
return mInfo->GetIID(aInterfaceID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::SetInterfaceID(const nsIID * aInterfaceID)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
if(!iim)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
mInfo = nsnull;
|
||||
iim->GetInfoForIID(aInterfaceID, getter_AddRefs(mInfo));
|
||||
|
||||
// If not found, then let's ask additional managers.
|
||||
|
||||
// This entire block assumes the additional manager support from:
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=103805
|
||||
// Disable it by setting '#if 0'.
|
||||
#if 0
|
||||
PRBool yes;
|
||||
nsCOMPtr<nsISimpleEnumerator> list;
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism;
|
||||
|
||||
if(!mInfo && (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)
|
||||
{
|
||||
current->GetInfoForIID(aInterfaceID, getter_AddRefs(mInfo));
|
||||
if(mInfo)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return mInfo ? NS_OK : NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isValid; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsValid(PRBool *aIsValid)
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Type Explorer</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3><center>Type Explorer</center></h3>
|
||||
|
||||
<script>
|
||||
|
||||
function selectedInterface(event) {
|
||||
var index = event.target.selectedIndex;
|
||||
if(0 == index)
|
||||
return;
|
||||
var text = event.target.options[index].text;
|
||||
writeContent(Components.interfaces[text].number);
|
||||
}
|
||||
|
||||
function enteredID() {
|
||||
var text = document.getElementById("id_input").value;
|
||||
|
||||
var iface = Components.interfaces[text];
|
||||
if(iface) {
|
||||
writeContent(iface.number);
|
||||
return;
|
||||
}
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
try {
|
||||
var id = Components.ID(text);
|
||||
if(id) {
|
||||
writeContent(id);
|
||||
return;
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
alert("No interface with that name or iid found");
|
||||
}
|
||||
|
||||
function writeContent(id) {
|
||||
var text;
|
||||
var success = true;
|
||||
try {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const IDL_GENERATOR =
|
||||
new Components.Constructor("@mozilla.org/interfaceinfotoidl;1",
|
||||
"nsIInterfaceInfoToIDL");
|
||||
var gen = new IDL_GENERATOR();
|
||||
text = gen.generateIDL(Components.ID(id));
|
||||
} catch(e) {
|
||||
text = e;
|
||||
success = false;
|
||||
}
|
||||
var out = document.getElementById("out").contentDocument;
|
||||
out.open();
|
||||
if(success)
|
||||
out.write("<pre>");
|
||||
out.write(text);
|
||||
if(success)
|
||||
out.write("</pre>");
|
||||
out.close();
|
||||
return 0;
|
||||
}
|
||||
</script>
|
||||
|
||||
<form>
|
||||
Choose interface:<br>
|
||||
<select id="iface_list" onchange="selectedInterface(event);">
|
||||
<option>{choose}</option>
|
||||
</select>
|
||||
<br>Or enter name or iid:<br>
|
||||
<input type=text id="id_input" size=50 value=""></input>
|
||||
<input type=button value="Go" onclick="enteredID()"></input>
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
var iface_list = document.getElementById("iface_list");
|
||||
var names = [];
|
||||
|
||||
for(var n in Components.interfaces)
|
||||
names.push(n);
|
||||
|
||||
names.sort();
|
||||
|
||||
for(var i = 0; i < names.length; i++)
|
||||
iface_list.add(new Option(names[i]), null);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<hr>
|
||||
<div>
|
||||
<iframe id="out" height="70%" width="100%">
|
||||
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -74,7 +74,6 @@ public:
|
|||
virtual ~nsGenericInterfaceInfoSet();
|
||||
|
||||
XPTArena* GetArena() {return mArena;}
|
||||
nsresult AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval);
|
||||
|
||||
const XPTTypeDescriptor* GetAdditionalTypeAt(PRUint16 aIndex)
|
||||
{
|
||||
|
@ -121,7 +120,7 @@ public:
|
|||
virtual ~nsGenericInterfaceInfo() {}
|
||||
|
||||
private:
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const nsXPTParamInfo* param)
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const XPTParamDescriptor* param)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
while(XPT_TDP_TAG(td->prefix) == TD_ARRAY)
|
||||
|
@ -129,7 +128,7 @@ private:
|
|||
return td;
|
||||
}
|
||||
|
||||
const XPTTypeDescriptor* GetTypeInArray(const nsXPTParamInfo* param,
|
||||
const XPTTypeDescriptor* GetTypeInArray(const XPTParamDescriptor* param,
|
||||
PRUint16 dimension)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
|
|
|
@ -74,17 +74,6 @@ nsGenericInterfaceInfoSet::~nsGenericInterfaceInfoSet()
|
|||
XPT_DestroyArena(mArena);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval)
|
||||
{
|
||||
*_retval = (nsXPTType*)
|
||||
XPT_MALLOC(GetArena(), sizeof(nsXPTType));
|
||||
if(!*_retval || !mAdditionalTypes.AppendElement(*_retval))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aIndex = (PRUint16) mAdditionalTypes.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
|
@ -92,7 +81,8 @@ nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
|||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const nsID* iid;
|
||||
nsresult rv = info->GetIIDShared(&iid);
|
||||
if(NS_FAILED(rv))
|
||||
|
@ -113,7 +103,8 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const char* name;
|
||||
nsresult rv = info->GetNameShared(&name);
|
||||
if(NS_FAILED(rv))
|
||||
|
@ -130,6 +121,27 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
/************************************************/
|
||||
// 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)
|
||||
|
@ -165,6 +177,12 @@ 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)
|
||||
|
@ -311,37 +329,26 @@ nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
|||
{
|
||||
mMethodBaseIndex = mConstantBaseIndex = 0;
|
||||
}
|
||||
|
||||
int len = PL_strlen(aName);
|
||||
mName = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(mName)
|
||||
memcpy(mName, aName, len);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfo methods...
|
||||
|
||||
/* nsXPTParamInfoPtr allocateParamArray (in PRUint16 aCount); */
|
||||
/* PRUint16 appendMethod (in XPTMethodDescriptorPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AllocateParamArray(PRUint16 aCount, nsXPTParamInfo * *_retval)
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
*_retval = (nsXPTParamInfo*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(nsXPTParamInfo) * aCount);
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* nsXPTTypePtr allocateAdditionalType (out PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval)
|
||||
{
|
||||
return mSet->AllocateAdditionalType(aIndex, _retval);
|
||||
}
|
||||
|
||||
/* PRUint16 appendMethod (in nsXPTMethodInfoPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendMethod(nsXPTMethodInfo * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
nsXPTMethodInfo* desc = (nsXPTMethodInfo*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(nsXPTMethodInfo));
|
||||
XPTMethodDescriptor* desc = (XPTMethodDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTMethodDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aMethod, sizeof(nsXPTMethodInfo));
|
||||
memcpy(desc, aMethod, sizeof(XPTMethodDescriptor));
|
||||
|
||||
int len = PL_strlen(aMethod->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
|
@ -353,8 +360,8 @@ nsGenericInterfaceInfo::AppendMethod(nsXPTMethodInfo * aMethod, PRUint16 *_retva
|
|||
return mMethods.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRUint16 appendConst (in nsXPTConstantPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(nsXPTConstant * aConst, PRUint16 *_retval)
|
||||
/* PRUint16 appendConst (in XPTConstDescriptorPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, PRUint16 *_retval)
|
||||
|
||||
{
|
||||
NS_ASSERTION(aConst->type.prefix.flags == TD_INT16 ||
|
||||
|
|
|
@ -415,9 +415,29 @@ function doForwardDeclarations(out, iid)
|
|||
prev = cur;
|
||||
}
|
||||
}
|
||||
out.writeln("");
|
||||
}
|
||||
|
||||
function buildForwardDeclarationsList(iid)
|
||||
{
|
||||
var i, cur, prev;
|
||||
var list = [];
|
||||
var outList = [];
|
||||
appendForwardDeclarations(list, new IInfo(iid));
|
||||
list.sort();
|
||||
|
||||
for(i = 0; i < list.length; i++)
|
||||
{
|
||||
cur = list[i];
|
||||
if(cur != prev && cur != "nsISupports")
|
||||
{
|
||||
if(cur != MISSING_INTERFACE)
|
||||
outList.push(cur);
|
||||
prev = cur;
|
||||
}
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
/* Our Componenent ctor */
|
||||
|
@ -427,18 +447,42 @@ function nsInterfaceInfoToIDL() {}
|
|||
nsInterfaceInfoToIDL.prototype =
|
||||
{
|
||||
// nsIInterfaceInfoToIDL methods...
|
||||
generateIDL : function (iid) {
|
||||
|
||||
// string generateIDL(in nsIIDRef aIID,
|
||||
// in PRBool withIncludes,
|
||||
// in PRBool withForwardDeclarations);
|
||||
generateIDL : function(aIID, withIncludes, withForwardDeclarations) {
|
||||
var out = new Buffer;
|
||||
out.writeln();
|
||||
out.writeln('#include "nsISupports.idl"');
|
||||
out.writeln();
|
||||
|
||||
doForwardDeclarations(out, iid)
|
||||
doInterface(out, iid);
|
||||
if(withIncludes)
|
||||
{
|
||||
out.writeln('#include "nsISupports.idl"');
|
||||
out.writeln();
|
||||
}
|
||||
|
||||
if(withForwardDeclarations)
|
||||
{
|
||||
doForwardDeclarations(out, aIID);
|
||||
out.writeln("");
|
||||
}
|
||||
|
||||
doInterface(out, aIID);
|
||||
|
||||
return out.buffer;
|
||||
},
|
||||
|
||||
// void getReferencedInterfaceNames(in nsIIDRef aIID,
|
||||
// out PRUint32 aArrayLength,
|
||||
// [retval, array, size_is(aArrayLength)]
|
||||
// out string aNames);
|
||||
|
||||
getReferencedInterfaceNames : function(aIID, aArrayLength) {
|
||||
var list = buildForwardDeclarationsList(aIID);
|
||||
aArrayLength.value = list.length;
|
||||
return list;
|
||||
},
|
||||
|
||||
// nsISupports methods...
|
||||
QueryInterface: function (iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIInterfaceInfoToIDL) &&
|
||||
|
@ -484,9 +528,9 @@ GenericModule.prototype = {
|
|||
* unmolested.
|
||||
*/
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
|
||||
compMgr.registerComponentWithType(this.CID, this.name, this.contractID,
|
||||
fileSpec, location, true, true, type);
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
compMgr.registerFactoryLocation(this.CID, this.name, this.contractID,
|
||||
fileSpec, location, type);
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
@ -499,15 +499,88 @@ nsScriptableInterfaceInfo::GetInfo(nsIInterfaceInfo * *aInfo)
|
|||
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)
|
||||
{
|
||||
return SetInterfaceID(aIID);
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
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;
|
||||
|
||||
return FindInfo(NameTester, name, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
|
@ -520,7 +593,7 @@ nsScriptableInterfaceInfo::GetName(char * *aName)
|
|||
return mInfo->GetName(aName);
|
||||
}
|
||||
|
||||
/* attribute nsIIDPtr interfaceID; */
|
||||
/* readonly attribute nsIIDPtr interfaceID; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
||||
{
|
||||
|
@ -530,47 +603,6 @@ nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
|||
return mInfo->GetIID(aInterfaceID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::SetInterfaceID(const nsIID * aInterfaceID)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
if(!iim)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
mInfo = nsnull;
|
||||
iim->GetInfoForIID(aInterfaceID, getter_AddRefs(mInfo));
|
||||
|
||||
// If not found, then let's ask additional managers.
|
||||
|
||||
// This entire block assumes the additional manager support from:
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=103805
|
||||
// Disable it by setting '#if 0'.
|
||||
#if 0
|
||||
PRBool yes;
|
||||
nsCOMPtr<nsISimpleEnumerator> list;
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism;
|
||||
|
||||
if(!mInfo && (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)
|
||||
{
|
||||
current->GetInfoForIID(aInterfaceID, getter_AddRefs(mInfo));
|
||||
if(mInfo)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return mInfo ? NS_OK : NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isValid; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsValid(PRBool *aIsValid)
|
||||
|
|
|
@ -46,7 +46,7 @@ function writeContent(id) {
|
|||
new Components.Constructor("@mozilla.org/interfaceinfotoidl;1",
|
||||
"nsIInterfaceInfoToIDL");
|
||||
var gen = new IDL_GENERATOR();
|
||||
text = gen.generateIDL(Components.ID(id));
|
||||
text = gen.generateIDL(Components.ID(id), true, true);
|
||||
} catch(e) {
|
||||
text = e;
|
||||
success = false;
|
||||
|
|
|
@ -42,44 +42,49 @@
|
|||
#include "nsIInterfaceInfo.idl"
|
||||
#include "nsIInterfaceInfoManager.idl"
|
||||
|
||||
[ptr] native nsXPTTypePtr(nsXPTType);
|
||||
// forward declaration of non-XPCOM types
|
||||
|
||||
[ptr] native XPTMethodDescriptorPtr(XPTMethodDescriptor);
|
||||
[ptr] native XPTConstDescriptorPtr(XPTConstDescriptor);
|
||||
[ptr] native XPTParamDescriptorPtr(XPTParamDescriptor);
|
||||
[ptr] native XPTTypeDescriptorPtr(XPTTypeDescriptor);
|
||||
|
||||
/* this is NOT intended to be scriptable */
|
||||
[uuid(8344a200-18ed-4538-8d44-e50b5156b564)]
|
||||
interface nsIGenericInterfaceInfo : nsIInterfaceInfo
|
||||
{
|
||||
/**
|
||||
* Caller might allocate one more than the actual param count in
|
||||
* order to have a location for the result pointer used in the methodinfo.
|
||||
*/
|
||||
nsXPTParamInfoPtr allocateParamArray(in PRUint16 aCount);
|
||||
|
||||
/**
|
||||
* Used for arrays.
|
||||
*/
|
||||
nsXPTTypePtr allocateAdditionalType(out PRUint16 aIndex);
|
||||
|
||||
/**
|
||||
* All members except params* and result* copied
|
||||
*/
|
||||
|
||||
PRUint16 appendMethod(in nsXPTMethodInfoPtr aMethod);
|
||||
PRUint16 appendMethod(in XPTMethodDescriptorPtr aMethod);
|
||||
|
||||
/**
|
||||
* All members copied
|
||||
*/
|
||||
PRUint16 appendConst(in nsXPTConstantPtr aConst);
|
||||
PRUint16 appendConst(in XPTConstDescriptorPtr aConst);
|
||||
};
|
||||
|
||||
/* this is NOT intended to be scriptable */
|
||||
[uuid(8cc674ee-52ba-45fa-b897-bb88d35eaa91)]
|
||||
interface nsIGenericInterfaceInfoSet : nsIInterfaceInfoManager
|
||||
{
|
||||
/**
|
||||
* Methods include pointers to param arrays allocated here.
|
||||
*/
|
||||
XPTParamDescriptorPtr allocateParamArray(in PRUint16 aCount);
|
||||
|
||||
/**
|
||||
* Used for type that is in an array.
|
||||
*/
|
||||
XPTTypeDescriptorPtr allocateAdditionalType(out PRUint16 aIndex);
|
||||
|
||||
PRUint16 createAndAppendInterface(in string aName, in nsIIDRef aIID,
|
||||
in PRUint16 aParent, in PRUint8 aFlags,
|
||||
out nsIGenericInterfaceInfo aInfo);
|
||||
PRUint16 appendExternalInterface(in nsIInterfaceInfo aInfo);
|
||||
PRUint16 indexOf(in nsIIDRef aIID);
|
||||
PRUint16 indexOfByName(in string aName);
|
||||
nsIInterfaceInfo interfaceInfoAt(in PRUint16 aIndex);
|
||||
};
|
||||
|
||||
|
|
|
@ -42,6 +42,13 @@
|
|||
[scriptable, uuid(b01eb40c-026b-49c9-af55-25e8c9d034c8)]
|
||||
interface nsIInterfaceInfoToIDL : nsISupports
|
||||
{
|
||||
string generateIDL(in nsIIDRef aIID);
|
||||
string generateIDL(in nsIIDRef aIID,
|
||||
in PRBool withIncludes,
|
||||
in PRBool withForwardDeclarations);
|
||||
|
||||
void getReferencedInterfaceNames(in nsIIDRef aIID,
|
||||
out PRUint32 aArrayLength,
|
||||
[retval, array, size_is(aArrayLength)]
|
||||
out string aNames);
|
||||
};
|
||||
|
||||
|
|
|
@ -101,13 +101,11 @@ interface nsIScriptableInterfaceInfo : nsISupports
|
|||
[noscript] attribute nsIInterfaceInfo info;
|
||||
|
||||
void init(in nsIIDPtr aIID);
|
||||
void initWithName(in string name);
|
||||
|
||||
readonly attribute string name;
|
||||
|
||||
/**
|
||||
* Setting interfaceID will set what interface info this object wraps.
|
||||
*/
|
||||
attribute nsIIDPtr interfaceID;
|
||||
readonly attribute nsIIDPtr interfaceID;
|
||||
|
||||
/**
|
||||
* True if this object has been sucessfully set to wrap an interface info.
|
||||
|
|
|
@ -1,90 +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 nsIGenericInterfaceInfo/nsIGenericInterfaceInfoSet public declarations.*/
|
||||
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIInterfaceInfo.idl"
|
||||
#include "nsIInterfaceInfoManager.idl"
|
||||
|
||||
[ptr] native nsXPTTypePtr(nsXPTType);
|
||||
|
||||
/* this is NOT intended to be scriptable */
|
||||
[uuid(8344a200-18ed-4538-8d44-e50b5156b564)]
|
||||
interface nsIGenericInterfaceInfo : nsIInterfaceInfo
|
||||
{
|
||||
/**
|
||||
* Caller might allocate one more than the actual param count in
|
||||
* order to have a location for the result pointer used in the methodinfo.
|
||||
*/
|
||||
nsXPTParamInfoPtr allocateParamArray(in PRUint16 aCount);
|
||||
|
||||
/**
|
||||
* Used for arrays.
|
||||
*/
|
||||
nsXPTTypePtr allocateAdditionalType(out PRUint16 aIndex);
|
||||
|
||||
/**
|
||||
* All members except params* and result* copied
|
||||
*/
|
||||
|
||||
PRUint16 appendMethod(in nsXPTMethodInfoPtr aMethod);
|
||||
|
||||
/**
|
||||
* All members copied
|
||||
*/
|
||||
PRUint16 appendConst(in nsXPTConstantPtr aConst);
|
||||
};
|
||||
|
||||
/* this is NOT intended to be scriptable */
|
||||
[uuid(8cc674ee-52ba-45fa-b897-bb88d35eaa91)]
|
||||
interface nsIGenericInterfaceInfoSet : nsIInterfaceInfoManager
|
||||
{
|
||||
PRUint16 createAndAppendInterface(in string aName, in nsIIDRef aIID,
|
||||
in PRUint16 aParent, in PRUint8 aFlags,
|
||||
out nsIGenericInterfaceInfo aInfo);
|
||||
PRUint16 appendExternalInterface(in nsIInterfaceInfo aInfo);
|
||||
PRUint16 indexOf(in nsIIDRef aIID);
|
||||
nsIInterfaceInfo interfaceInfoAt(in PRUint16 aIndex);
|
||||
};
|
||||
|
||||
%{C++
|
||||
// The contractID for the implementation built into iiextras
|
||||
#define NS_GENERIC_INTERFACE_INFO_SET_CONTRACTID "@mozilla.org/genericInterfaceInfoSet;1"
|
||||
%}
|
||||
|
|
@ -1,47 +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 nsIInterfaceInfoToIDL public declaration.*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(b01eb40c-026b-49c9-af55-25e8c9d034c8)]
|
||||
interface nsIInterfaceInfoToIDL : nsISupports
|
||||
{
|
||||
string generateIDL(in nsIIDRef aIID);
|
||||
};
|
||||
|
|
@ -101,13 +101,11 @@ interface nsIScriptableInterfaceInfo : nsISupports
|
|||
[noscript] attribute nsIInterfaceInfo info;
|
||||
|
||||
void init(in nsIIDPtr aIID);
|
||||
void initWithName(in string name);
|
||||
|
||||
readonly attribute string name;
|
||||
|
||||
/**
|
||||
* Setting interfaceID will set what interface info this object wraps.
|
||||
*/
|
||||
attribute nsIIDPtr interfaceID;
|
||||
readonly attribute nsIIDPtr interfaceID;
|
||||
|
||||
/**
|
||||
* True if this object has been sucessfully set to wrap an interface info.
|
||||
|
|
|
@ -74,7 +74,6 @@ public:
|
|||
virtual ~nsGenericInterfaceInfoSet();
|
||||
|
||||
XPTArena* GetArena() {return mArena;}
|
||||
nsresult AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval);
|
||||
|
||||
const XPTTypeDescriptor* GetAdditionalTypeAt(PRUint16 aIndex)
|
||||
{
|
||||
|
@ -121,7 +120,7 @@ public:
|
|||
virtual ~nsGenericInterfaceInfo() {}
|
||||
|
||||
private:
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const nsXPTParamInfo* param)
|
||||
const XPTTypeDescriptor* GetPossiblyNestedType(const XPTParamDescriptor* param)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
while(XPT_TDP_TAG(td->prefix) == TD_ARRAY)
|
||||
|
@ -129,7 +128,7 @@ private:
|
|||
return td;
|
||||
}
|
||||
|
||||
const XPTTypeDescriptor* GetTypeInArray(const nsXPTParamInfo* param,
|
||||
const XPTTypeDescriptor* GetTypeInArray(const XPTParamDescriptor* param,
|
||||
PRUint16 dimension)
|
||||
{
|
||||
const XPTTypeDescriptor* td = ¶m->type;
|
||||
|
|
|
@ -74,17 +74,6 @@ nsGenericInterfaceInfoSet::~nsGenericInterfaceInfoSet()
|
|||
XPT_DestroyArena(mArena);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval)
|
||||
{
|
||||
*_retval = (nsXPTType*)
|
||||
XPT_MALLOC(GetArena(), sizeof(nsXPTType));
|
||||
if(!*_retval || !mAdditionalTypes.AppendElement(*_retval))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
*aIndex = (PRUint16) mAdditionalTypes.Count()-1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
||||
{
|
||||
|
@ -92,7 +81,8 @@ nsGenericInterfaceInfoSet::IndexOfIID(const nsIID & aIID, PRUint16 *_retval)
|
|||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const nsID* iid;
|
||||
nsresult rv = info->GetIIDShared(&iid);
|
||||
if(NS_FAILED(rv))
|
||||
|
@ -113,7 +103,8 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
|
||||
for(PRInt32 i = 0; i < count; i++)
|
||||
{
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*) mInterfaces.ElementAt(i);
|
||||
nsIInterfaceInfo* info = (nsIInterfaceInfo*)
|
||||
ClearOwnedFlag(mInterfaces.ElementAt(i));
|
||||
const char* name;
|
||||
nsresult rv = info->GetNameShared(&name);
|
||||
if(NS_FAILED(rv))
|
||||
|
@ -130,6 +121,27 @@ nsGenericInterfaceInfoSet::IndexOfName(const char* aName, PRUint16 *_retval)
|
|||
/************************************************/
|
||||
// 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)
|
||||
|
@ -165,6 +177,12 @@ 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)
|
||||
|
@ -311,37 +329,26 @@ nsGenericInterfaceInfo::nsGenericInterfaceInfo(nsGenericInterfaceInfoSet* aSet,
|
|||
{
|
||||
mMethodBaseIndex = mConstantBaseIndex = 0;
|
||||
}
|
||||
|
||||
int len = PL_strlen(aName);
|
||||
mName = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
if(mName)
|
||||
memcpy(mName, aName, len);
|
||||
}
|
||||
|
||||
/************************************************/
|
||||
// nsIGenericInterfaceInfo methods...
|
||||
|
||||
/* nsXPTParamInfoPtr allocateParamArray (in PRUint16 aCount); */
|
||||
/* PRUint16 appendMethod (in XPTMethodDescriptorPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AllocateParamArray(PRUint16 aCount, nsXPTParamInfo * *_retval)
|
||||
nsGenericInterfaceInfo::AppendMethod(XPTMethodDescriptor * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
*_retval = (nsXPTParamInfo*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(nsXPTParamInfo) * aCount);
|
||||
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* nsXPTTypePtr allocateAdditionalType (out PRUint16 aIndex); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AllocateAdditionalType(PRUint16 *aIndex, nsXPTType * *_retval)
|
||||
{
|
||||
return mSet->AllocateAdditionalType(aIndex, _retval);
|
||||
}
|
||||
|
||||
/* PRUint16 appendMethod (in nsXPTMethodInfoPtr aMethod); */
|
||||
NS_IMETHODIMP
|
||||
nsGenericInterfaceInfo::AppendMethod(nsXPTMethodInfo * aMethod, PRUint16 *_retval)
|
||||
{
|
||||
nsXPTMethodInfo* desc = (nsXPTMethodInfo*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(nsXPTMethodInfo));
|
||||
XPTMethodDescriptor* desc = (XPTMethodDescriptor*)
|
||||
XPT_MALLOC(mSet->GetArena(), sizeof(XPTMethodDescriptor));
|
||||
if(!desc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
memcpy(desc, aMethod, sizeof(nsXPTMethodInfo));
|
||||
memcpy(desc, aMethod, sizeof(XPTMethodDescriptor));
|
||||
|
||||
int len = PL_strlen(aMethod->name);
|
||||
desc->name = (char*) XPT_MALLOC(mSet->GetArena(), len+1);
|
||||
|
@ -353,8 +360,8 @@ nsGenericInterfaceInfo::AppendMethod(nsXPTMethodInfo * aMethod, PRUint16 *_retva
|
|||
return mMethods.AppendElement(desc) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/* PRUint16 appendConst (in nsXPTConstantPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(nsXPTConstant * aConst, PRUint16 *_retval)
|
||||
/* PRUint16 appendConst (in XPTConstDescriptorPtr aConst); */
|
||||
NS_IMETHODIMP nsGenericInterfaceInfo::AppendConst(XPTConstDescriptor * aConst, PRUint16 *_retval)
|
||||
|
||||
{
|
||||
NS_ASSERTION(aConst->type.prefix.flags == TD_INT16 ||
|
||||
|
|
|
@ -415,9 +415,29 @@ function doForwardDeclarations(out, iid)
|
|||
prev = cur;
|
||||
}
|
||||
}
|
||||
out.writeln("");
|
||||
}
|
||||
|
||||
function buildForwardDeclarationsList(iid)
|
||||
{
|
||||
var i, cur, prev;
|
||||
var list = [];
|
||||
var outList = [];
|
||||
appendForwardDeclarations(list, new IInfo(iid));
|
||||
list.sort();
|
||||
|
||||
for(i = 0; i < list.length; i++)
|
||||
{
|
||||
cur = list[i];
|
||||
if(cur != prev && cur != "nsISupports")
|
||||
{
|
||||
if(cur != MISSING_INTERFACE)
|
||||
outList.push(cur);
|
||||
prev = cur;
|
||||
}
|
||||
}
|
||||
return outList;
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
/* Our Componenent ctor */
|
||||
|
@ -427,18 +447,42 @@ function nsInterfaceInfoToIDL() {}
|
|||
nsInterfaceInfoToIDL.prototype =
|
||||
{
|
||||
// nsIInterfaceInfoToIDL methods...
|
||||
generateIDL : function (iid) {
|
||||
|
||||
// string generateIDL(in nsIIDRef aIID,
|
||||
// in PRBool withIncludes,
|
||||
// in PRBool withForwardDeclarations);
|
||||
generateIDL : function(aIID, withIncludes, withForwardDeclarations) {
|
||||
var out = new Buffer;
|
||||
out.writeln();
|
||||
out.writeln('#include "nsISupports.idl"');
|
||||
out.writeln();
|
||||
|
||||
doForwardDeclarations(out, iid)
|
||||
doInterface(out, iid);
|
||||
if(withIncludes)
|
||||
{
|
||||
out.writeln('#include "nsISupports.idl"');
|
||||
out.writeln();
|
||||
}
|
||||
|
||||
if(withForwardDeclarations)
|
||||
{
|
||||
doForwardDeclarations(out, aIID);
|
||||
out.writeln("");
|
||||
}
|
||||
|
||||
doInterface(out, aIID);
|
||||
|
||||
return out.buffer;
|
||||
},
|
||||
|
||||
// void getReferencedInterfaceNames(in nsIIDRef aIID,
|
||||
// out PRUint32 aArrayLength,
|
||||
// [retval, array, size_is(aArrayLength)]
|
||||
// out string aNames);
|
||||
|
||||
getReferencedInterfaceNames : function(aIID, aArrayLength) {
|
||||
var list = buildForwardDeclarationsList(aIID);
|
||||
aArrayLength.value = list.length;
|
||||
return list;
|
||||
},
|
||||
|
||||
// nsISupports methods...
|
||||
QueryInterface: function (iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIInterfaceInfoToIDL) &&
|
||||
|
@ -484,9 +528,9 @@ GenericModule.prototype = {
|
|||
* unmolested.
|
||||
*/
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentManagerObsolete);
|
||||
compMgr.registerComponentWithType(this.CID, this.name, this.contractID,
|
||||
fileSpec, location, true, true, type);
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
compMgr.registerFactoryLocation(this.CID, this.name, this.contractID,
|
||||
fileSpec, location, type);
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
|
@ -499,15 +499,88 @@ nsScriptableInterfaceInfo::GetInfo(nsIInterfaceInfo * *aInfo)
|
|||
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)
|
||||
{
|
||||
return SetInterfaceID(aIID);
|
||||
if(mInfo)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
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;
|
||||
|
||||
return FindInfo(NameTester, name, getter_AddRefs(mInfo));
|
||||
}
|
||||
|
||||
/* readonly attribute string name; */
|
||||
|
@ -520,7 +593,7 @@ nsScriptableInterfaceInfo::GetName(char * *aName)
|
|||
return mInfo->GetName(aName);
|
||||
}
|
||||
|
||||
/* attribute nsIIDPtr interfaceID; */
|
||||
/* readonly attribute nsIIDPtr interfaceID; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
||||
{
|
||||
|
@ -530,47 +603,6 @@ nsScriptableInterfaceInfo::GetInterfaceID(nsIID * *aInterfaceID)
|
|||
return mInfo->GetIID(aInterfaceID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::SetInterfaceID(const nsIID * aInterfaceID)
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
||||
if(!iim)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
mInfo = nsnull;
|
||||
iim->GetInfoForIID(aInterfaceID, getter_AddRefs(mInfo));
|
||||
|
||||
// If not found, then let's ask additional managers.
|
||||
|
||||
// This entire block assumes the additional manager support from:
|
||||
// http://bugzilla.mozilla.org/show_bug.cgi?id=103805
|
||||
// Disable it by setting '#if 0'.
|
||||
#if 0
|
||||
PRBool yes;
|
||||
nsCOMPtr<nsISimpleEnumerator> list;
|
||||
nsCOMPtr<nsIInterfaceInfoSuperManager> iism;
|
||||
|
||||
if(!mInfo && (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)
|
||||
{
|
||||
current->GetInfoForIID(aInterfaceID, getter_AddRefs(mInfo));
|
||||
if(mInfo)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return mInfo ? NS_OK : NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
/* readonly attribute PRBool isValid; */
|
||||
NS_IMETHODIMP
|
||||
nsScriptableInterfaceInfo::GetIsValid(PRBool *aIsValid)
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Type Explorer</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3><center>Type Explorer</center></h3>
|
||||
|
||||
<script>
|
||||
|
||||
function selectedInterface(event) {
|
||||
var index = event.target.selectedIndex;
|
||||
if(0 == index)
|
||||
return;
|
||||
var text = event.target.options[index].text;
|
||||
writeContent(Components.interfaces[text].number);
|
||||
}
|
||||
|
||||
function enteredID() {
|
||||
var text = document.getElementById("id_input").value;
|
||||
|
||||
var iface = Components.interfaces[text];
|
||||
if(iface) {
|
||||
writeContent(iface.number);
|
||||
return;
|
||||
}
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
try {
|
||||
var id = Components.ID(text);
|
||||
if(id) {
|
||||
writeContent(id);
|
||||
return;
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
alert("No interface with that name or iid found");
|
||||
}
|
||||
|
||||
function writeContent(id) {
|
||||
var text;
|
||||
var success = true;
|
||||
try {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
const IDL_GENERATOR =
|
||||
new Components.Constructor("@mozilla.org/interfaceinfotoidl;1",
|
||||
"nsIInterfaceInfoToIDL");
|
||||
var gen = new IDL_GENERATOR();
|
||||
text = gen.generateIDL(Components.ID(id));
|
||||
} catch(e) {
|
||||
text = e;
|
||||
success = false;
|
||||
}
|
||||
var out = document.getElementById("out").contentDocument;
|
||||
out.open();
|
||||
if(success)
|
||||
out.write("<pre>");
|
||||
out.write(text);
|
||||
if(success)
|
||||
out.write("</pre>");
|
||||
out.close();
|
||||
return 0;
|
||||
}
|
||||
</script>
|
||||
|
||||
<form>
|
||||
Choose interface:<br>
|
||||
<select id="iface_list" onchange="selectedInterface(event);">
|
||||
<option>{choose}</option>
|
||||
</select>
|
||||
<br>Or enter name or iid:<br>
|
||||
<input type=text id="id_input" size=50 value=""></input>
|
||||
<input type=button value="Go" onclick="enteredID()"></input>
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
var iface_list = document.getElementById("iface_list");
|
||||
var names = [];
|
||||
|
||||
for(var n in Components.interfaces)
|
||||
names.push(n);
|
||||
|
||||
names.sort();
|
||||
|
||||
for(var i = 0; i < names.length; i++)
|
||||
iface_list.add(new Option(names[i]), null);
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<hr>
|
||||
<div>
|
||||
<iframe id="out" height="70%" width="100%">
|
||||
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче