Added tests of getting info assoc'd with params to TestInterfaceInfo.cpp, which uncovered an off-by-one problem due to magic typelib offsets for nsXPTParamInfo. Which makes me wonder if we shouldn't have just said #define XPT_INDEX_NO_PARENT 0xFFFF.
git-svn-id: svn://10.0.0.236/trunk@23525 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
6c5b72830c
commit
ea7137976d
@ -30,8 +30,6 @@
|
||||
#include "xpt_cpp.h"
|
||||
#include "xptinfo.h"
|
||||
|
||||
// Placeholder - this implementation just returns NULL.
|
||||
|
||||
nsIInterfaceInfo*
|
||||
nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const
|
||||
{
|
||||
@ -40,7 +38,6 @@ nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const
|
||||
|
||||
nsInterfaceRecord *record =
|
||||
((nsInterfaceInfo *)info)->getInterfaceRecord();
|
||||
|
||||
|
||||
nsIInterfaceInfoManager* mgr;
|
||||
if(!(mgr = nsInterfaceInfoManager::GetInterfaceInfoManager()))
|
||||
@ -52,7 +49,10 @@ nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const
|
||||
|
||||
// can't use IID, because it could be null for this entry.
|
||||
char *interface_name;
|
||||
interface_name = which_header->interface_directory[type.type.interface].name;
|
||||
|
||||
// offset is 1-based, so subtract 1 to use in interface_directory.
|
||||
interface_name =
|
||||
which_header->interface_directory[type.type.interface - 1].name;
|
||||
|
||||
nsIInterfaceInfo *ii;
|
||||
nsresult nsr = mgr->GetInfoForName(interface_name, &ii);
|
||||
@ -82,7 +82,10 @@ nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const
|
||||
|
||||
// can't use IID, because it could be null for this entry.
|
||||
char *interface_name;
|
||||
interface_name = which_header->interface_directory[type.type.interface].name;
|
||||
|
||||
// offset is 1-based, so subtract 1 to use in interface_directory.
|
||||
interface_name =
|
||||
which_header->interface_directory[type.type.interface - 1].name;
|
||||
|
||||
nsIID* iid;
|
||||
nsresult nsr = mgr->GetIIDForName(interface_name, &iid);
|
||||
|
||||
@ -37,12 +37,14 @@ static void RegAllocator();
|
||||
// containing these files.
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int i;
|
||||
nsIID *iid1, *iid2, *iid3, *iid4, *iid5, *iid6;
|
||||
char *name1, *name2, *name3, *name4, *name5, *name6;
|
||||
nsIInterfaceInfo *info1, *info2, *info3, *info4, *info5, *info6;;
|
||||
|
||||
RegAllocator();
|
||||
|
||||
nsIInterfaceInfoManager *iim = XPTI_GetInterfaceInfoManager();
|
||||
nsIID *iid1, *iid2, *iid3, *iid4;
|
||||
char *name1, *name2, *name3, *name4;
|
||||
nsIInterfaceInfo *info1, *info2, *info3, *info4;
|
||||
|
||||
fprintf(stderr, "\ngetting iid for 'nsISupports'\n");
|
||||
iim->GetIIDForName("nsISupports", &iid1);
|
||||
@ -78,6 +80,45 @@ int main (int argc, char **argv) {
|
||||
((nsInterfaceInfo *)info4)->print(stderr);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "\nparams work?\n");
|
||||
fprintf(stderr, "\ngetting info for name 'nsIServiceManager'\n");
|
||||
iim->GetInfoForName("nsIServiceManager", &info5);
|
||||
#ifdef DEBUG
|
||||
((nsInterfaceInfo *)info5)->print(stderr);
|
||||
#endif
|
||||
|
||||
uint16 methodcount;
|
||||
info5->GetMethodCount(&methodcount);
|
||||
const nsXPTMethodInfo *mi;
|
||||
for (i = 0; i < methodcount; i++) {
|
||||
info5->GetMethodInfo(i, &mi);
|
||||
char *methodname;
|
||||
fprintf(stderr, "method %d, name %s\n", i, mi->GetName());
|
||||
}
|
||||
|
||||
// 7 is GetServiceWithListener, which has juicy params.
|
||||
info5->GetMethodInfo(7, &mi);
|
||||
uint8 paramcount = mi->GetParamCount();
|
||||
|
||||
nsXPTParamInfo param2 = mi->GetParam(2);
|
||||
// should be IID for nsIShutdownListener
|
||||
nsIID *nsISL = param2.GetInterfaceIID(info5);
|
||||
fprintf(stderr, "iid assoc'd with param 2 of method 7 of GetServiceWithListener - %s\n", nsISL->ToString());
|
||||
// if we look up the name?
|
||||
char *nsISLname;
|
||||
iim->GetNameForIID(nsISL, &nsISLname);
|
||||
fprintf(stderr, "which is called %s\n", nsISLname);
|
||||
|
||||
fprintf(stderr, "\nhow about one defined in a different typelib\n");
|
||||
nsXPTParamInfo param3 = mi->GetParam(3);
|
||||
// should be IID for nsIShutdownListener
|
||||
nsIID *nsISS = param3.GetInterfaceIID(info5);
|
||||
fprintf(stderr, "iid assoc'd with param 3 of method 7 of GetServiceWithListener - %s\n", nsISS->ToString());
|
||||
// if we look up the name?
|
||||
char *nsISSname;
|
||||
iim->GetNameForIID(nsISS, &nsISSname);
|
||||
fprintf(stderr, "which is called %s\n", nsISSname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
#include "xpt_cpp.h"
|
||||
#include "xptinfo.h"
|
||||
|
||||
// Placeholder - this implementation just returns NULL.
|
||||
|
||||
nsIInterfaceInfo*
|
||||
nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const
|
||||
{
|
||||
@ -40,7 +38,6 @@ nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const
|
||||
|
||||
nsInterfaceRecord *record =
|
||||
((nsInterfaceInfo *)info)->getInterfaceRecord();
|
||||
|
||||
|
||||
nsIInterfaceInfoManager* mgr;
|
||||
if(!(mgr = nsInterfaceInfoManager::GetInterfaceInfoManager()))
|
||||
@ -52,7 +49,10 @@ nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const
|
||||
|
||||
// can't use IID, because it could be null for this entry.
|
||||
char *interface_name;
|
||||
interface_name = which_header->interface_directory[type.type.interface].name;
|
||||
|
||||
// offset is 1-based, so subtract 1 to use in interface_directory.
|
||||
interface_name =
|
||||
which_header->interface_directory[type.type.interface - 1].name;
|
||||
|
||||
nsIInterfaceInfo *ii;
|
||||
nsresult nsr = mgr->GetInfoForName(interface_name, &ii);
|
||||
@ -82,7 +82,10 @@ nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const
|
||||
|
||||
// can't use IID, because it could be null for this entry.
|
||||
char *interface_name;
|
||||
interface_name = which_header->interface_directory[type.type.interface].name;
|
||||
|
||||
// offset is 1-based, so subtract 1 to use in interface_directory.
|
||||
interface_name =
|
||||
which_header->interface_directory[type.type.interface - 1].name;
|
||||
|
||||
nsIID* iid;
|
||||
nsresult nsr = mgr->GetIIDForName(interface_name, &iid);
|
||||
|
||||
@ -37,12 +37,14 @@ static void RegAllocator();
|
||||
// containing these files.
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
int i;
|
||||
nsIID *iid1, *iid2, *iid3, *iid4, *iid5, *iid6;
|
||||
char *name1, *name2, *name3, *name4, *name5, *name6;
|
||||
nsIInterfaceInfo *info1, *info2, *info3, *info4, *info5, *info6;;
|
||||
|
||||
RegAllocator();
|
||||
|
||||
nsIInterfaceInfoManager *iim = XPTI_GetInterfaceInfoManager();
|
||||
nsIID *iid1, *iid2, *iid3, *iid4;
|
||||
char *name1, *name2, *name3, *name4;
|
||||
nsIInterfaceInfo *info1, *info2, *info3, *info4;
|
||||
|
||||
fprintf(stderr, "\ngetting iid for 'nsISupports'\n");
|
||||
iim->GetIIDForName("nsISupports", &iid1);
|
||||
@ -78,6 +80,45 @@ int main (int argc, char **argv) {
|
||||
((nsInterfaceInfo *)info4)->print(stderr);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "\nparams work?\n");
|
||||
fprintf(stderr, "\ngetting info for name 'nsIServiceManager'\n");
|
||||
iim->GetInfoForName("nsIServiceManager", &info5);
|
||||
#ifdef DEBUG
|
||||
((nsInterfaceInfo *)info5)->print(stderr);
|
||||
#endif
|
||||
|
||||
uint16 methodcount;
|
||||
info5->GetMethodCount(&methodcount);
|
||||
const nsXPTMethodInfo *mi;
|
||||
for (i = 0; i < methodcount; i++) {
|
||||
info5->GetMethodInfo(i, &mi);
|
||||
char *methodname;
|
||||
fprintf(stderr, "method %d, name %s\n", i, mi->GetName());
|
||||
}
|
||||
|
||||
// 7 is GetServiceWithListener, which has juicy params.
|
||||
info5->GetMethodInfo(7, &mi);
|
||||
uint8 paramcount = mi->GetParamCount();
|
||||
|
||||
nsXPTParamInfo param2 = mi->GetParam(2);
|
||||
// should be IID for nsIShutdownListener
|
||||
nsIID *nsISL = param2.GetInterfaceIID(info5);
|
||||
fprintf(stderr, "iid assoc'd with param 2 of method 7 of GetServiceWithListener - %s\n", nsISL->ToString());
|
||||
// if we look up the name?
|
||||
char *nsISLname;
|
||||
iim->GetNameForIID(nsISL, &nsISLname);
|
||||
fprintf(stderr, "which is called %s\n", nsISLname);
|
||||
|
||||
fprintf(stderr, "\nhow about one defined in a different typelib\n");
|
||||
nsXPTParamInfo param3 = mi->GetParam(3);
|
||||
// should be IID for nsIShutdownListener
|
||||
nsIID *nsISS = param3.GetInterfaceIID(info5);
|
||||
fprintf(stderr, "iid assoc'd with param 3 of method 7 of GetServiceWithListener - %s\n", nsISS->ToString());
|
||||
// if we look up the name?
|
||||
char *nsISSname;
|
||||
iim->GetNameForIID(nsISS, &nsISSname);
|
||||
fprintf(stderr, "which is called %s\n", nsISSname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user