From d7ffc955cabb4e8537376e4b581ed66a213f8bdc Mon Sep 17 00:00:00 2001 From: "mccabe%netscape.com" Date: Fri, 12 Mar 1999 06:49:01 +0000 Subject: [PATCH] Not part of seamonkey. Removed awkward nsXPTParamInfo::GetInterface and friend, and als removed supporting nsXPTParamInfo.cpp file. Replace by nsIInterfaceInfo::GetInfoForParam and friend. Made the constructor for nsInterfaceInfo private, with nsInterfaceInfoManager as a friend class. git-svn-id: svn://10.0.0.236/trunk@23899 18797224-902f-48f8-a5cc-f745e15eee43 --- .../libxpt/xptinfo/public/nsIInterfaceInfo.h | 7 ++ mozilla/xpcom/libxpt/xptinfo/public/xpt_cpp.h | 12 -- mozilla/xpcom/libxpt/xptinfo/src/Makefile.in | 1 - mozilla/xpcom/libxpt/xptinfo/src/makefile.win | 2 - .../libxpt/xptinfo/src/nsInterfaceInfo.cpp | 71 ++++++++++++ .../libxpt/xptinfo/src/nsInterfaceInfo.h | 19 ++-- .../xptinfo/src/nsInterfaceInfoManager.h | 5 - .../libxpt/xptinfo/src/nsXPTParamInfo.cpp | 104 ------------------ .../xptinfo/tests/TestInterfaceInfo.cpp | 8 +- .../reflect/xptinfo/public/nsIInterfaceInfo.h | 7 ++ .../xpcom/reflect/xptinfo/public/xpt_cpp.h | 12 -- mozilla/xpcom/reflect/xptinfo/src/Makefile.in | 1 - .../xpcom/reflect/xptinfo/src/makefile.win | 2 - .../reflect/xptinfo/src/nsInterfaceInfo.cpp | 71 ++++++++++++ .../reflect/xptinfo/src/nsInterfaceInfo.h | 19 ++-- .../xptinfo/src/nsInterfaceInfoManager.h | 5 - .../reflect/xptinfo/src/nsXPTParamInfo.cpp | 104 ------------------ .../xptinfo/tests/TestInterfaceInfo.cpp | 8 +- 18 files changed, 190 insertions(+), 268 deletions(-) delete mode 100644 mozilla/xpcom/libxpt/xptinfo/src/nsXPTParamInfo.cpp delete mode 100644 mozilla/xpcom/reflect/xptinfo/src/nsXPTParamInfo.cpp diff --git a/mozilla/xpcom/libxpt/xptinfo/public/nsIInterfaceInfo.h b/mozilla/xpcom/libxpt/xptinfo/public/nsIInterfaceInfo.h index 1e3e723b95d..66bae058c55 100644 --- a/mozilla/xpcom/libxpt/xptinfo/public/nsIInterfaceInfo.h +++ b/mozilla/xpcom/libxpt/xptinfo/public/nsIInterfaceInfo.h @@ -26,6 +26,7 @@ // forward declaration of non-XPCOM types class nsXPTMethodInfo; class nsXPTConstant; +class nsXPTParamInfo; // {215DBE04-94A7-11d2-BA58-00805F8A5DD7} #define NS_IINTERFACEINFO_IID \ @@ -50,6 +51,12 @@ public: // There do *not* make copies ***explicit bending of XPCOM rules*** NS_IMETHOD GetMethodInfo(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 + // method in this interface. + NS_IMETHOD GetInfoForParam(nsXPTParamInfo* param, nsIInterfaceInfo** info) + = 0; + NS_IMETHOD GetIIDForParam(nsXPTParamInfo* param, nsIID** iid) = 0; }; #endif /* nsIInterfaceInfo_h___ */ diff --git a/mozilla/xpcom/libxpt/xptinfo/public/xpt_cpp.h b/mozilla/xpcom/libxpt/xptinfo/public/xpt_cpp.h index 3352bb24c57..15dc0eb8729 100644 --- a/mozilla/xpcom/libxpt/xptinfo/public/xpt_cpp.h +++ b/mozilla/xpcom/libxpt/xptinfo/public/xpt_cpp.h @@ -109,18 +109,6 @@ public: return type.type.argnum; } - // This is not inlined, it is more involved! - // If XPTInterfaceDirectoryEntry references remain indexes, then it - // may be necessary to pass in a param here indicating which typelib - // - or at least XPTInterfaceDirectoryEntry - this particular param - // is associated with so that we can find the table this index indexes - // and then find the referenced XPTInterfaceDirectoryEntry so that we can - // find (or build) the appropriate nsIInterfaceInfo. Simple :) - XPTI_EXPORT nsIInterfaceInfo* GetInterface(nsIInterfaceInfo *info) const ; - - // a *little* simpler than the above - XPTI_EXPORT const nsIID* GetInterfaceIID(nsIInterfaceInfo *info) const ; - private: nsXPTParamInfo(); // no implementation // NO DATA - this a flyweight wrapper diff --git a/mozilla/xpcom/libxpt/xptinfo/src/Makefile.in b/mozilla/xpcom/libxpt/xptinfo/src/Makefile.in index c1e52b578cd..ebfe196e81f 100644 --- a/mozilla/xpcom/libxpt/xptinfo/src/Makefile.in +++ b/mozilla/xpcom/libxpt/xptinfo/src/Makefile.in @@ -28,7 +28,6 @@ CSRCS = $(NULL) CPPSRCS = nsInterfaceInfo.cpp \ nsInterfaceInfoManager.cpp \ - nsXPTParamInfo.cpp \ $(NULL) REQUIRES = $(MODULE) diff --git a/mozilla/xpcom/libxpt/xptinfo/src/makefile.win b/mozilla/xpcom/libxpt/xptinfo/src/makefile.win index 5ec3118a25f..4d020665c78 100644 --- a/mozilla/xpcom/libxpt/xptinfo/src/makefile.win +++ b/mozilla/xpcom/libxpt/xptinfo/src/makefile.win @@ -48,14 +48,12 @@ C_OBJS = \ CPPSRCS = nsInterfaceInfoManager.cpp \ nsInterfaceInfo.cpp \ - nsXPTParamInfo.cpp \ $(NULL) CPP_OBJS = \ .\$(OBJDIR)\nsInterfaceInfoManager.obj \ .\$(OBJDIR)\nsInterfaceInfo.obj \ - .\$(OBJDIR)\nsXPTParamInfo.obj \ $(NULL) MODULE = xptinfo diff --git a/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.cpp b/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.cpp index cfd1cbc861d..05709dd9bb8 100644 --- a/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.cpp +++ b/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.cpp @@ -178,6 +178,77 @@ nsInterfaceInfo::GetConstant(uint16 index, const nsXPTConstant** constant) return NS_OK; } +NS_IMETHODIMP +nsInterfaceInfo::GetInfoForParam(nsXPTParamInfo *param, nsIInterfaceInfo** info) +{ + + NS_PRECONDITION(param->GetType().TagPart() == nsXPTType::T_INTERFACE, + "not an interface"); + + nsIInterfaceInfoManager* mgr; + if(NULL == (mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) { + *info = NULL; + return NS_ERROR_FAILURE; + } + + // what typelib did the entry come from? + XPTHeader *which_header = mInterfaceRecord->which_header; + NS_ASSERTION(which_header != NULL, "missing header info assoc'd with II"); + + // can't use IID, because it could be null for this entry. + char *interface_name; + + // offset is 1-based, so subtract 1 to use in interface_directory. + interface_name = + which_header->interface_directory[param->type.type.interface - 1].name; + + // does addref. I'll have to do addreff if I find it through a magic + // array walk. + nsresult nsr = mgr->GetInfoForName(interface_name, info); + if (NS_IS_ERROR(nsr)) { + // *info has been set to null by well-behaved GetInfoForName + NS_RELEASE(mgr); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + +NS_IMETHODIMP +nsInterfaceInfo::GetIIDForParam(nsXPTParamInfo* param, nsIID** iid) +{ + NS_PRECONDITION(param->GetType().TagPart() == nsXPTType::T_INTERFACE, + "not an interface"); + + nsIInterfaceInfoManager* mgr; + if(NULL == (mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) { + *iid = NULL; + return NS_ERROR_FAILURE; + } + + // what typelib did the entry come from? + XPTHeader *which_header = mInterfaceRecord->which_header; + NS_ASSERTION(which_header != NULL, "header missing?"); + + // can't use IID, because it could be null for this entry. + char *interface_name; + + // offset is 1-based, so subtract 1 to use in interface_directory. + interface_name = + which_header->interface_directory[param->type.type.interface - 1].name; + + nsresult nsr = mgr->GetIIDForName(interface_name, iid); + if (NS_IS_ERROR(nsr)) { + // *iid has been set to NULL by well-behaved GetIIDForName + NS_RELEASE(mgr); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + + + #ifdef DEBUG #include void diff --git a/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.h b/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.h index 4dd9f0e3ae0..6917afcb89d 100644 --- a/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.h +++ b/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfo.h @@ -27,6 +27,8 @@ #include "nsInterfaceRecord.h" +#include "nsInterfaceInfoManager.h" + #ifdef DEBUG #include #endif @@ -50,9 +52,11 @@ class nsInterfaceInfo : public nsIInterfaceInfo NS_IMETHOD GetMethodInfo(uint16 index, const nsXPTMethodInfo** info); NS_IMETHOD GetConstant(uint16 index, const nsXPTConstant** constant); - // why constructor public? - nsInterfaceInfo(nsInterfaceRecord *record, - nsInterfaceInfo *parent); + // Get the interface information or iid associated with a param of some + // method in this interface. + NS_IMETHOD GetInfoForParam(nsXPTParamInfo* param, nsIInterfaceInfo** info); + NS_IMETHOD GetIIDForParam(nsXPTParamInfo* param, nsIID** iid); + public: virtual ~nsInterfaceInfo(); @@ -61,12 +65,11 @@ public: #endif private: - friend nsIInterfaceInfo* - nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const; - friend const nsIID* - nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const; + // nsInterfaceInfoManager has access to the constructor. + friend class nsInterfaceInfoManager; + + nsInterfaceInfo(nsInterfaceRecord *record, nsInterfaceInfo *parent); - nsInterfaceRecord *getInterfaceRecord() { return mInterfaceRecord; }; nsInterfaceRecord *mInterfaceRecord; nsInterfaceInfo* mParent; diff --git a/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfoManager.h b/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfoManager.h index 1e5afbf2775..eaefd12cdb2 100644 --- a/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfoManager.h +++ b/mozilla/xpcom/libxpt/xptinfo/src/nsInterfaceInfoManager.h @@ -51,11 +51,6 @@ public: static nsIAllocator* GetAllocator(nsInterfaceInfoManager* iim = NULL); private: - friend nsIInterfaceInfo* - nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const; - friend const nsIID* - nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const; - void initInterfaceTables(); // mapping between names and records diff --git a/mozilla/xpcom/libxpt/xptinfo/src/nsXPTParamInfo.cpp b/mozilla/xpcom/libxpt/xptinfo/src/nsXPTParamInfo.cpp deleted file mode 100644 index 9aed762a915..00000000000 --- a/mozilla/xpcom/libxpt/xptinfo/src/nsXPTParamInfo.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1999 Netscape Communications Corporation. All Rights - * Reserved. - */ - -/* - * Convienence bits of nsXPTParamInfo that don't fit into xpt_cpp.h - * flyweight wrappers. - */ - -#include "nsISupports.h" -#include "nsIInterfaceInfoManager.h" -#include "nsIInterfaceInfo.h" - -#include "nsInterfaceInfoManager.h" - -#include "xpt_cpp.h" -#include "xptinfo.h" - -nsIInterfaceInfo* -nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const -{ - NS_PRECONDITION(GetType().TagPart() == nsXPTType::T_INTERFACE, - "not an interface"); - - nsInterfaceRecord *record = - ((nsInterfaceInfo *)info)->getInterfaceRecord(); - - nsIInterfaceInfoManager* mgr; - if(!(mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) - return NULL; - - // what typelib did the entry come from? - XPTHeader *which_header = record->which_header; - NS_ASSERTION(which_header != NULL, "missing header info assoc'd with II"); - - // can't use IID, because it could be null for this entry. - char *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); - if (NS_IS_ERROR(nsr)) { - NS_RELEASE(mgr); - return NULL; - } - return ii; -} - -const nsIID* -nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const -{ - NS_PRECONDITION(GetType().TagPart() == nsXPTType::T_INTERFACE, - "not an interface"); - - nsInterfaceRecord *record = - ((nsInterfaceInfo *)info)->getInterfaceRecord(); - - nsIInterfaceInfoManager* mgr; - if(!(mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) - return NULL; - - // what typelib did the entry come from? - XPTHeader *which_header = record->which_header; - NS_ASSERTION(which_header != NULL, "header missing?"); - - // can't use IID, because it could be null for this entry. - char *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); - if (NS_IS_ERROR(nsr)) { - NS_RELEASE(mgr); - return NULL; - } - return iid; -} - - - - - - - diff --git a/mozilla/xpcom/libxpt/xptinfo/tests/TestInterfaceInfo.cpp b/mozilla/xpcom/libxpt/xptinfo/tests/TestInterfaceInfo.cpp index 8be253897ba..47ff927b3da 100644 --- a/mozilla/xpcom/libxpt/xptinfo/tests/TestInterfaceInfo.cpp +++ b/mozilla/xpcom/libxpt/xptinfo/tests/TestInterfaceInfo.cpp @@ -102,7 +102,9 @@ int main (int argc, char **argv) { nsXPTParamInfo param2 = mi->GetParam(2); // should be IID for nsIShutdownListener - const nsIID *nsISL = param2.GetInterfaceIID(info5); + nsIID *nsISL; + info5->GetIIDForParam(¶m2, &nsISL); +// const 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; @@ -112,7 +114,9 @@ int main (int argc, char **argv) { fprintf(stderr, "\nhow about one defined in a different typelib\n"); nsXPTParamInfo param3 = mi->GetParam(3); // should be IID for nsIShutdownListener - const nsIID *nsISS = param3.GetInterfaceIID(info5); + nsIID *nsISS; + info5->GetIIDForParam(¶m3, &nsISS); +// const 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; diff --git a/mozilla/xpcom/reflect/xptinfo/public/nsIInterfaceInfo.h b/mozilla/xpcom/reflect/xptinfo/public/nsIInterfaceInfo.h index 1e3e723b95d..66bae058c55 100644 --- a/mozilla/xpcom/reflect/xptinfo/public/nsIInterfaceInfo.h +++ b/mozilla/xpcom/reflect/xptinfo/public/nsIInterfaceInfo.h @@ -26,6 +26,7 @@ // forward declaration of non-XPCOM types class nsXPTMethodInfo; class nsXPTConstant; +class nsXPTParamInfo; // {215DBE04-94A7-11d2-BA58-00805F8A5DD7} #define NS_IINTERFACEINFO_IID \ @@ -50,6 +51,12 @@ public: // There do *not* make copies ***explicit bending of XPCOM rules*** NS_IMETHOD GetMethodInfo(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 + // method in this interface. + NS_IMETHOD GetInfoForParam(nsXPTParamInfo* param, nsIInterfaceInfo** info) + = 0; + NS_IMETHOD GetIIDForParam(nsXPTParamInfo* param, nsIID** iid) = 0; }; #endif /* nsIInterfaceInfo_h___ */ diff --git a/mozilla/xpcom/reflect/xptinfo/public/xpt_cpp.h b/mozilla/xpcom/reflect/xptinfo/public/xpt_cpp.h index 3352bb24c57..15dc0eb8729 100644 --- a/mozilla/xpcom/reflect/xptinfo/public/xpt_cpp.h +++ b/mozilla/xpcom/reflect/xptinfo/public/xpt_cpp.h @@ -109,18 +109,6 @@ public: return type.type.argnum; } - // This is not inlined, it is more involved! - // If XPTInterfaceDirectoryEntry references remain indexes, then it - // may be necessary to pass in a param here indicating which typelib - // - or at least XPTInterfaceDirectoryEntry - this particular param - // is associated with so that we can find the table this index indexes - // and then find the referenced XPTInterfaceDirectoryEntry so that we can - // find (or build) the appropriate nsIInterfaceInfo. Simple :) - XPTI_EXPORT nsIInterfaceInfo* GetInterface(nsIInterfaceInfo *info) const ; - - // a *little* simpler than the above - XPTI_EXPORT const nsIID* GetInterfaceIID(nsIInterfaceInfo *info) const ; - private: nsXPTParamInfo(); // no implementation // NO DATA - this a flyweight wrapper diff --git a/mozilla/xpcom/reflect/xptinfo/src/Makefile.in b/mozilla/xpcom/reflect/xptinfo/src/Makefile.in index c1e52b578cd..ebfe196e81f 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/Makefile.in +++ b/mozilla/xpcom/reflect/xptinfo/src/Makefile.in @@ -28,7 +28,6 @@ CSRCS = $(NULL) CPPSRCS = nsInterfaceInfo.cpp \ nsInterfaceInfoManager.cpp \ - nsXPTParamInfo.cpp \ $(NULL) REQUIRES = $(MODULE) diff --git a/mozilla/xpcom/reflect/xptinfo/src/makefile.win b/mozilla/xpcom/reflect/xptinfo/src/makefile.win index 5ec3118a25f..4d020665c78 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/makefile.win +++ b/mozilla/xpcom/reflect/xptinfo/src/makefile.win @@ -48,14 +48,12 @@ C_OBJS = \ CPPSRCS = nsInterfaceInfoManager.cpp \ nsInterfaceInfo.cpp \ - nsXPTParamInfo.cpp \ $(NULL) CPP_OBJS = \ .\$(OBJDIR)\nsInterfaceInfoManager.obj \ .\$(OBJDIR)\nsInterfaceInfo.obj \ - .\$(OBJDIR)\nsXPTParamInfo.obj \ $(NULL) MODULE = xptinfo diff --git a/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.cpp b/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.cpp index cfd1cbc861d..05709dd9bb8 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.cpp +++ b/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.cpp @@ -178,6 +178,77 @@ nsInterfaceInfo::GetConstant(uint16 index, const nsXPTConstant** constant) return NS_OK; } +NS_IMETHODIMP +nsInterfaceInfo::GetInfoForParam(nsXPTParamInfo *param, nsIInterfaceInfo** info) +{ + + NS_PRECONDITION(param->GetType().TagPart() == nsXPTType::T_INTERFACE, + "not an interface"); + + nsIInterfaceInfoManager* mgr; + if(NULL == (mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) { + *info = NULL; + return NS_ERROR_FAILURE; + } + + // what typelib did the entry come from? + XPTHeader *which_header = mInterfaceRecord->which_header; + NS_ASSERTION(which_header != NULL, "missing header info assoc'd with II"); + + // can't use IID, because it could be null for this entry. + char *interface_name; + + // offset is 1-based, so subtract 1 to use in interface_directory. + interface_name = + which_header->interface_directory[param->type.type.interface - 1].name; + + // does addref. I'll have to do addreff if I find it through a magic + // array walk. + nsresult nsr = mgr->GetInfoForName(interface_name, info); + if (NS_IS_ERROR(nsr)) { + // *info has been set to null by well-behaved GetInfoForName + NS_RELEASE(mgr); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + +NS_IMETHODIMP +nsInterfaceInfo::GetIIDForParam(nsXPTParamInfo* param, nsIID** iid) +{ + NS_PRECONDITION(param->GetType().TagPart() == nsXPTType::T_INTERFACE, + "not an interface"); + + nsIInterfaceInfoManager* mgr; + if(NULL == (mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) { + *iid = NULL; + return NS_ERROR_FAILURE; + } + + // what typelib did the entry come from? + XPTHeader *which_header = mInterfaceRecord->which_header; + NS_ASSERTION(which_header != NULL, "header missing?"); + + // can't use IID, because it could be null for this entry. + char *interface_name; + + // offset is 1-based, so subtract 1 to use in interface_directory. + interface_name = + which_header->interface_directory[param->type.type.interface - 1].name; + + nsresult nsr = mgr->GetIIDForName(interface_name, iid); + if (NS_IS_ERROR(nsr)) { + // *iid has been set to NULL by well-behaved GetIIDForName + NS_RELEASE(mgr); + return NS_ERROR_FAILURE; + } + + return NS_OK; +} + + + #ifdef DEBUG #include void diff --git a/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.h b/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.h index 4dd9f0e3ae0..6917afcb89d 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.h +++ b/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfo.h @@ -27,6 +27,8 @@ #include "nsInterfaceRecord.h" +#include "nsInterfaceInfoManager.h" + #ifdef DEBUG #include #endif @@ -50,9 +52,11 @@ class nsInterfaceInfo : public nsIInterfaceInfo NS_IMETHOD GetMethodInfo(uint16 index, const nsXPTMethodInfo** info); NS_IMETHOD GetConstant(uint16 index, const nsXPTConstant** constant); - // why constructor public? - nsInterfaceInfo(nsInterfaceRecord *record, - nsInterfaceInfo *parent); + // Get the interface information or iid associated with a param of some + // method in this interface. + NS_IMETHOD GetInfoForParam(nsXPTParamInfo* param, nsIInterfaceInfo** info); + NS_IMETHOD GetIIDForParam(nsXPTParamInfo* param, nsIID** iid); + public: virtual ~nsInterfaceInfo(); @@ -61,12 +65,11 @@ public: #endif private: - friend nsIInterfaceInfo* - nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const; - friend const nsIID* - nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const; + // nsInterfaceInfoManager has access to the constructor. + friend class nsInterfaceInfoManager; + + nsInterfaceInfo(nsInterfaceRecord *record, nsInterfaceInfo *parent); - nsInterfaceRecord *getInterfaceRecord() { return mInterfaceRecord; }; nsInterfaceRecord *mInterfaceRecord; nsInterfaceInfo* mParent; diff --git a/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfoManager.h b/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfoManager.h index 1e5afbf2775..eaefd12cdb2 100644 --- a/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfoManager.h +++ b/mozilla/xpcom/reflect/xptinfo/src/nsInterfaceInfoManager.h @@ -51,11 +51,6 @@ public: static nsIAllocator* GetAllocator(nsInterfaceInfoManager* iim = NULL); private: - friend nsIInterfaceInfo* - nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const; - friend const nsIID* - nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const; - void initInterfaceTables(); // mapping between names and records diff --git a/mozilla/xpcom/reflect/xptinfo/src/nsXPTParamInfo.cpp b/mozilla/xpcom/reflect/xptinfo/src/nsXPTParamInfo.cpp deleted file mode 100644 index 9aed762a915..00000000000 --- a/mozilla/xpcom/reflect/xptinfo/src/nsXPTParamInfo.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * The contents of this file are subject to the Netscape Public License - * Version 1.0 (the "NPL"); you may not use this file except in - * compliance with the NPL. You may obtain a copy of the NPL at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the NPL is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL - * for the specific language governing rights and limitations under the - * NPL. - * - * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1999 Netscape Communications Corporation. All Rights - * Reserved. - */ - -/* - * Convienence bits of nsXPTParamInfo that don't fit into xpt_cpp.h - * flyweight wrappers. - */ - -#include "nsISupports.h" -#include "nsIInterfaceInfoManager.h" -#include "nsIInterfaceInfo.h" - -#include "nsInterfaceInfoManager.h" - -#include "xpt_cpp.h" -#include "xptinfo.h" - -nsIInterfaceInfo* -nsXPTParamInfo::GetInterface(nsIInterfaceInfo *info) const -{ - NS_PRECONDITION(GetType().TagPart() == nsXPTType::T_INTERFACE, - "not an interface"); - - nsInterfaceRecord *record = - ((nsInterfaceInfo *)info)->getInterfaceRecord(); - - nsIInterfaceInfoManager* mgr; - if(!(mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) - return NULL; - - // what typelib did the entry come from? - XPTHeader *which_header = record->which_header; - NS_ASSERTION(which_header != NULL, "missing header info assoc'd with II"); - - // can't use IID, because it could be null for this entry. - char *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); - if (NS_IS_ERROR(nsr)) { - NS_RELEASE(mgr); - return NULL; - } - return ii; -} - -const nsIID* -nsXPTParamInfo::GetInterfaceIID(nsIInterfaceInfo *info) const -{ - NS_PRECONDITION(GetType().TagPart() == nsXPTType::T_INTERFACE, - "not an interface"); - - nsInterfaceRecord *record = - ((nsInterfaceInfo *)info)->getInterfaceRecord(); - - nsIInterfaceInfoManager* mgr; - if(!(mgr = nsInterfaceInfoManager::GetInterfaceInfoManager())) - return NULL; - - // what typelib did the entry come from? - XPTHeader *which_header = record->which_header; - NS_ASSERTION(which_header != NULL, "header missing?"); - - // can't use IID, because it could be null for this entry. - char *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); - if (NS_IS_ERROR(nsr)) { - NS_RELEASE(mgr); - return NULL; - } - return iid; -} - - - - - - - diff --git a/mozilla/xpcom/reflect/xptinfo/tests/TestInterfaceInfo.cpp b/mozilla/xpcom/reflect/xptinfo/tests/TestInterfaceInfo.cpp index 8be253897ba..47ff927b3da 100644 --- a/mozilla/xpcom/reflect/xptinfo/tests/TestInterfaceInfo.cpp +++ b/mozilla/xpcom/reflect/xptinfo/tests/TestInterfaceInfo.cpp @@ -102,7 +102,9 @@ int main (int argc, char **argv) { nsXPTParamInfo param2 = mi->GetParam(2); // should be IID for nsIShutdownListener - const nsIID *nsISL = param2.GetInterfaceIID(info5); + nsIID *nsISL; + info5->GetIIDForParam(¶m2, &nsISL); +// const 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; @@ -112,7 +114,9 @@ int main (int argc, char **argv) { fprintf(stderr, "\nhow about one defined in a different typelib\n"); nsXPTParamInfo param3 = mi->GetParam(3); // should be IID for nsIShutdownListener - const nsIID *nsISS = param3.GetInterfaceIID(info5); + nsIID *nsISS; + info5->GetIIDForParam(¶m3, &nsISS); +// const 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;