Bug 996061 - part 2 - split out a method for getting an interface's typelib index; r=bholley

The code that looks up |xptiInterfaceEntry|s starts by figuring out where in
the typelib the desired entry lives.  We want to do the same thing for the
purpose of getting shims, so we can ask the typelib for the name of the thing
at that index.  Split out a method to do this for us.
This commit is contained in:
Nathan Froyd 2014-05-16 16:49:34 -04:00
parent c788fadd6d
commit 1dacc16e2c
2 changed files with 33 additions and 7 deletions

View File

@ -304,16 +304,17 @@ xptiInterfaceEntry::GetConstant(uint16_t index, JS::MutableHandleValue constant,
// this is a private helper
nsresult
xptiInterfaceEntry::GetEntryForParam(uint16_t methodIndex,
const nsXPTParamInfo * param,
xptiInterfaceEntry** entry)
nsresult
xptiInterfaceEntry::GetInterfaceIndexForParam(uint16_t methodIndex,
const nsXPTParamInfo* param,
uint16_t* interfaceIndex)
{
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(methodIndex < mMethodBaseIndex)
return mParent->GetEntryForParam(methodIndex, param, entry);
return mParent->GetInterfaceIndexForParam(methodIndex, param,
interfaceIndex);
if(methodIndex >= mMethodBaseIndex +
mDescriptor->num_methods)
@ -333,8 +334,29 @@ xptiInterfaceEntry::GetEntryForParam(uint16_t methodIndex,
return NS_ERROR_INVALID_ARG;
}
xptiInterfaceEntry* theEntry = mTypelib->
GetEntryAt(td->type.iface - 1);
*interfaceIndex = td->type.iface;
return NS_OK;
}
nsresult
xptiInterfaceEntry::GetEntryForParam(uint16_t methodIndex,
const nsXPTParamInfo * param,
xptiInterfaceEntry** entry)
{
if(!EnsureResolved())
return NS_ERROR_UNEXPECTED;
if(methodIndex < mMethodBaseIndex)
return mParent->GetEntryForParam(methodIndex, param, entry);
uint16_t interfaceIndex = 0;
nsresult rv = GetInterfaceIndexForParam(methodIndex, param,
&interfaceIndex);
if (NS_FAILED(rv)) {
return rv;
}
xptiInterfaceEntry* theEntry = mTypelib->GetEntryAt(interfaceIndex - 1);
// This can happen if a declared interface is not available at runtime.
if(!theEntry)

View File

@ -275,6 +275,10 @@ private:
uint16_t dimension,
const XPTTypeDescriptor** type);
nsresult GetInterfaceIndexForParam(uint16_t methodIndex,
const nsXPTParamInfo* param,
uint16_t* interfaceIndex);
private:
nsID mIID;
XPTInterfaceDescriptor* mDescriptor;