Commiting accumulated interface info extensions changes. NOT PART OF THE BUILD
git-svn-id: svn://10.0.0.236/trunk@113538 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user