Added GetMethodInfoForName

git-svn-id: svn://10.0.0.236/trunk@25095 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
warren%netscape.com
1999-03-25 07:30:47 +00:00
parent c751dcd9b9
commit 4e8eccdd05
6 changed files with 68 additions and 0 deletions

View File

@@ -50,6 +50,8 @@ public:
// These include methods and constants of parents.
// There do *not* make copies ***explicit bending of XPCOM rules***
NS_IMETHOD GetMethodInfo(uint16 index, const nsXPTMethodInfo** info) = 0;
NS_IMETHOD GetMethodInfoForName(const char* methodName, uint16 *index,
const nsXPTMethodInfo** info) = 0;
NS_IMETHOD GetConstant(uint16 index, const nsXPTConstant** constant) = 0;
// Get the interface information or iid associated with a param of some

View File

@@ -127,6 +127,36 @@ nsInterfaceInfo::GetMethodInfo(uint16 index, const nsXPTMethodInfo** info)
return NS_OK;
}
NS_IMETHODIMP
nsInterfaceInfo::GetMethodInfoForName(const char* methodName, uint16 *index,
const nsXPTMethodInfo** result)
{
// XXX probably want to speed this up with a hashtable, or by at least interning
// the names to avoid the strcmp
nsresult rv;
for (uint16 i = mMethodBaseIndex; i < mMethodCount; i++) {
const nsXPTMethodInfo* info;
info = NS_REINTERPRET_CAST(nsXPTMethodInfo*,
&mInterfaceRecord->interfaceDescriptor->
method_descriptors[i - mMethodBaseIndex]);
if (PL_strcmp(methodName, info->name) == 0) {
#ifdef NS_DEBUG
// make sure there aren't duplicate names
for (; i < mMethodCount; i++) {
const nsXPTMethodInfo* info2;
info2 = NS_REINTERPRET_CAST(nsXPTMethodInfo*,
&mInterfaceRecord->interfaceDescriptor->
method_descriptors[i - mMethodBaseIndex]);
NS_ASSERTION(PL_strcmp(methodName, info2->name)!= 0, "duplicate names");
}
#endif
*result = info;
return NS_OK;
}
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsInterfaceInfo::GetConstant(uint16 index, const nsXPTConstant** constant)
{

View File

@@ -48,6 +48,8 @@ class nsInterfaceInfo : public nsIInterfaceInfo
// These include methods and constants of parents.
// There do *not* make copies ***explicit bending of XPCOM rules***
NS_IMETHOD GetMethodInfo(uint16 index, const nsXPTMethodInfo** info);
NS_IMETHOD GetMethodInfoForName(const char* methodName, uint16 *index,
const nsXPTMethodInfo** info);
NS_IMETHOD GetConstant(uint16 index, const nsXPTConstant** constant);
// Get the interface information or iid associated with a param of some

View File

@@ -50,6 +50,8 @@ public:
// These include methods and constants of parents.
// There do *not* make copies ***explicit bending of XPCOM rules***
NS_IMETHOD GetMethodInfo(uint16 index, const nsXPTMethodInfo** info) = 0;
NS_IMETHOD GetMethodInfoForName(const char* methodName, uint16 *index,
const nsXPTMethodInfo** info) = 0;
NS_IMETHOD GetConstant(uint16 index, const nsXPTConstant** constant) = 0;
// Get the interface information or iid associated with a param of some

View File

@@ -127,6 +127,36 @@ nsInterfaceInfo::GetMethodInfo(uint16 index, const nsXPTMethodInfo** info)
return NS_OK;
}
NS_IMETHODIMP
nsInterfaceInfo::GetMethodInfoForName(const char* methodName, uint16 *index,
const nsXPTMethodInfo** result)
{
// XXX probably want to speed this up with a hashtable, or by at least interning
// the names to avoid the strcmp
nsresult rv;
for (uint16 i = mMethodBaseIndex; i < mMethodCount; i++) {
const nsXPTMethodInfo* info;
info = NS_REINTERPRET_CAST(nsXPTMethodInfo*,
&mInterfaceRecord->interfaceDescriptor->
method_descriptors[i - mMethodBaseIndex]);
if (PL_strcmp(methodName, info->name) == 0) {
#ifdef NS_DEBUG
// make sure there aren't duplicate names
for (; i < mMethodCount; i++) {
const nsXPTMethodInfo* info2;
info2 = NS_REINTERPRET_CAST(nsXPTMethodInfo*,
&mInterfaceRecord->interfaceDescriptor->
method_descriptors[i - mMethodBaseIndex]);
NS_ASSERTION(PL_strcmp(methodName, info2->name)!= 0, "duplicate names");
}
#endif
*result = info;
return NS_OK;
}
}
return NS_ERROR_INVALID_ARG;
}
NS_IMETHODIMP
nsInterfaceInfo::GetConstant(uint16 index, const nsXPTConstant** constant)
{

View File

@@ -48,6 +48,8 @@ class nsInterfaceInfo : public nsIInterfaceInfo
// These include methods and constants of parents.
// There do *not* make copies ***explicit bending of XPCOM rules***
NS_IMETHOD GetMethodInfo(uint16 index, const nsXPTMethodInfo** info);
NS_IMETHOD GetMethodInfoForName(const char* methodName, uint16 *index,
const nsXPTMethodInfo** info);
NS_IMETHOD GetConstant(uint16 index, const nsXPTConstant** constant);
// Get the interface information or iid associated with a param of some