From 432ff728c74c77f2485e46edee37707d17f46af9 Mon Sep 17 00:00:00 2001 From: "benjamin%smedbergs.us" Date: Fri, 25 Jan 2008 17:14:53 +0000 Subject: [PATCH] Bug 412320 - Try code-generation for QI impls, r=roc+luser --- config/config.mk | 2 +- config/rules.mk | 7 + content/base/src/Makefile.in | 2 + content/base/src/contentbase.gqi | 99 +++ content/base/src/nsDocument.cpp | 48 -- content/base/src/nsDocument.h | 2 +- content/base/src/nsGenericElement.cpp | 22 - .../html/content/public/nsIFrameSetElement.h | 1 + content/html/content/src/Makefile.in | 2 + content/html/content/src/htmlcontent.gqi | 0 .../html/content/src/htmlgenericelement.gqi | 0 .../html/content/src/nsGenericHTMLElement.cpp | 31 - .../html/content/src/nsGenericHTMLElement.h | 29 +- .../html/content/src/nsHTMLAnchorElement.cpp | 83 +- .../html/content/src/nsHTMLAnchorElement.h | 0 content/html/content/src/nsHTMLDivElement.cpp | 43 +- content/html/content/src/nsHTMLDivElement.h | 0 .../html/content/src/nsHTMLFrameElement.cpp | 46 +- content/html/content/src/nsHTMLFrameElement.h | 0 .../content/src/nsHTMLFrameSetElement.cpp | 89 +- .../html/content/src/nsHTMLFrameSetElement.h | 0 .../html/content/src/nsHTMLIFrameElement.cpp | 45 +- .../html/content/src/nsHTMLIFrameElement.h | 0 .../html/content/src/nsHTMLSpanElement.cpp | 37 +- content/html/content/src/nsHTMLSpanElement.h | 0 content/html/document/src/Makefile.in | 2 + content/html/document/src/htmldocument.gqi | 17 + content/html/document/src/nsHTMLDocument.cpp | 12 - xpcom/base/gqi.py | 788 ++++++++++++++++++ xpcom/components/Makefile.in | 4 + xpcom/components/nsCategoryManager.cpp | 55 -- xpcom/components/nsCategoryManager.h | 52 ++ xpcom/components/nsComponentManager.cpp | 55 -- xpcom/components/nsComponentManager.h | 42 + xpcom/components/nsNativeComponentLoader.cpp | 3 - xpcom/components/xpcomcomponents.gqi | 0 xpcom/ds/Makefile.in | 4 + xpcom/ds/nsArray.cpp | 3 - xpcom/ds/nsAtomTable.cpp | 43 - xpcom/ds/nsByteBuffer.cpp | 2 - xpcom/ds/nsHashPropertyBag.cpp | 23 - xpcom/ds/nsHashPropertyBag.h | 15 + xpcom/ds/nsIByteBuffer.h | 3 - xpcom/ds/nsINIParserImpl.cpp | 22 - xpcom/ds/nsINIParserImpl.h | 16 + xpcom/ds/nsIUnicharBuffer.h | 1 + xpcom/ds/nsObserverList.cpp | 2 - xpcom/ds/nsPersistentProperties.cpp | 4 - xpcom/ds/nsStaticAtom.h | 38 + xpcom/ds/nsStringEnumerator.cpp | 67 -- xpcom/ds/nsStringEnumerator.h | 64 ++ xpcom/ds/nsSupportsArray.cpp | 25 - xpcom/ds/nsSupportsArray.h | 21 + xpcom/ds/nsSupportsArrayEnumerator.cpp | 2 - xpcom/ds/nsSupportsPrimitives.cpp | 53 -- xpcom/ds/nsUnicharBuffer.cpp | 2 - xpcom/ds/nsVariant.cpp | 2 - xpcom/ds/xpcomds.gqi | 135 +++ 58 files changed, 1351 insertions(+), 814 deletions(-) create mode 100644 content/base/src/contentbase.gqi create mode 100644 content/html/content/src/htmlcontent.gqi create mode 100644 content/html/content/src/htmlgenericelement.gqi create mode 100644 content/html/content/src/nsHTMLAnchorElement.h create mode 100644 content/html/content/src/nsHTMLDivElement.h create mode 100644 content/html/content/src/nsHTMLFrameElement.h create mode 100644 content/html/content/src/nsHTMLFrameSetElement.h create mode 100644 content/html/content/src/nsHTMLIFrameElement.h create mode 100644 content/html/content/src/nsHTMLSpanElement.h create mode 100644 content/html/document/src/htmldocument.gqi create mode 100644 xpcom/base/gqi.py create mode 100644 xpcom/components/xpcomcomponents.gqi create mode 100644 xpcom/ds/xpcomds.gqi diff --git a/config/config.mk b/config/config.mk index 58f59b500cb..77b66f1d843 100644 --- a/config/config.mk +++ b/config/config.mk @@ -520,7 +520,7 @@ JAVA_GEN_DIR = _javagen JAVA_DIST_DIR = $(DEPTH)/$(JAVA_GEN_DIR) JAVA_IFACES_PKG_NAME = org/mozilla/interfaces -REQ_INCLUDES = $(foreach d,$(REQUIRES),-I$(DIST)/include/$d) -I$(DIST)/include +REQ_INCLUDES = -I$(srcdir) -I. $(foreach d,$(REQUIRES),-I$(DIST)/include/$d) -I$(DIST)/include ifdef LIBXUL_SDK REQ_INCLUDES_SDK = $(foreach d,$(REQUIRES),-I$(LIBXUL_SDK)/include/$d) -I$(LIBXUL_SDK)/include endif diff --git a/config/rules.mk b/config/rules.mk index 59869faf68c..d305cdd2037 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -117,6 +117,10 @@ ifdef EXTRA_DSO_LIBS EXTRA_DSO_LIBS := $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS)) endif +ifdef GQI_SRCS +CPPSRCS += $(GQI_SRCS:.gqi=QI.cpp) +endif + # # Library rules # @@ -1188,6 +1192,9 @@ endif # COMPILER_DEPEND endif # MOZ_AUTO_DEPS +%QI.cpp: %.gqi $(topsrcdir)/xpcom/base/gqi.py + $(PYTHON) $(topsrcdir)/xpcom/base/gqi.py $(INCLUDES) -I $(IDL_DIR) -o $@ -D $(MDDEPDIR)/$(@F).pp $< + # Rules for building native targets must come first because of the host_ prefix host_%.$(OBJ_SUFFIX): %.c Makefile Makefile.in $(REPORT_BUILD) diff --git a/content/base/src/Makefile.in b/content/base/src/Makefile.in index 85013822430..3b9d3be20cb 100644 --- a/content/base/src/Makefile.in +++ b/content/base/src/Makefile.in @@ -165,6 +165,8 @@ CPPSRCS = \ nsXMLNameSpaceMap.cpp \ $(NULL) +GQI_SRCS = contentbase.gqi + # we don't want the shared lib, but we want to force the creation of a # static lib. FORCE_STATIC_LIB = 1 diff --git a/content/base/src/contentbase.gqi b/content/base/src/contentbase.gqi new file mode 100644 index 00000000000..231f4bb1cc6 --- /dev/null +++ b/content/base/src/contentbase.gqi @@ -0,0 +1,99 @@ +%import-idl "nsIDOM3Node.idl" +%import-idl "nsIDOMNSElement.idl" +%import-idl "nsIDOMEventTarget.idl" +%import-idl "nsIDOM3EventTarget.idl" +%import-idl "nsIDOMNSEventTarget.idl" +%import-idl "nsIWeakReference.idl" +%import-idl "nsIDOMDocument.idl" +%import-idl "nsIDOM3Document.idl" +%import-idl "nsIDOMNSDocument.idl" +%import-idl "nsIDOMDocumentEvent.idl" +%import-idl "nsIDOM3DocumentEvent.idl" +%import-idl "nsIDOMDocumentStyle.idl" +%import-idl "nsIDOMNSDocumentStyle.idl" +%import-idl "nsIDOMDocumentView.idl" +%import-idl "nsIDOMDocumentRange.idl" +%import-idl "nsIDOMDocumentTraversal.idl" +%import-idl "nsIDOMDocumentXBL.idl" +%import-idl "nsIDOMXPathEvaluator.idl" + +%pseudo-iid nsIContent fba9aa39-016e-4d5d-ab62-22a1b84a3c7b +%pseudo-iid nsINode cf677826-d7f1-4ec5-bf3a-d41811ac5846 +%pseudo-iid nsPIDOMEventTarget 44a6597b-9fc3-4a8d-b7a4-d9009abf9d15 +%pseudo-iid nsIDocument 626d86d2-615f-4a12-94d8-e3db3a298372 +%pseudo-iid nsIScriptObjectPrincipal 3eedba38-8d22-41e1-817a-0e43e165b664 +%pseudo-iid nsIMutationObserver 32e68316-67d4-44a5-8d35-0d390fa9df11 +%pseudo-iid nsIXPathEvaluatorInternal b4b72daa-65d6-440f-b608-e2ee9a82f313 +%pseudo-iid nsIRadioGroupContainer 06de7839-d0db-47d3-8290-3cb8622ed966 + +%{C++ +#include "nsGenericElement.h" +#include "nsDocument.h" +#include "nsIXPathEvaluatorInternal.h" +#include "nsDOMCID.h" +#include "nsComponentManagerUtils.h" +%} + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericElement) + NS_INTERFACE_MAP_ENTRY(nsIContent) + NS_INTERFACE_MAP_ENTRY(nsINode) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) + NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this)) + NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this)) + NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget, + nsDOMEventRTTearoff::Create(this)) + NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget, + nsDOMEventRTTearoff::Create(this)) + NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget, + nsDOMEventRTTearoff::Create(this)) + NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference, + new nsNodeSupportsWeakRefTearoff(this)) + // nsNodeSH::PreCreate() depends on the identity pointer being the + // same as nsINode (which nsIContent inherits), so if you change the + // below line, make sure nsNodeSH::PreCreate() still does the right + // thing! + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent) +NS_INTERFACE_MAP_END + +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDocument) + NS_INTERFACE_MAP_ENTRY(nsINode) + NS_INTERFACE_MAP_ENTRY(nsIDocument) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocument) + NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocument) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentEvent) + NS_INTERFACE_MAP_ENTRY(nsIDOM3DocumentEvent) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentStyle) + NS_INTERFACE_MAP_ENTRY(nsIDOMNSDocumentStyle) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentView) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentRange) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentTraversal) + NS_INTERFACE_MAP_ENTRY(nsIDOMDocumentXBL) + NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) + NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) + NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget) + NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget) + NS_INTERFACE_MAP_ENTRY(nsIDOMNode) + NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) + NS_INTERFACE_MAP_ENTRY(nsIDOM3Node) + NS_INTERFACE_MAP_ENTRY(nsIDOM3Document) + NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) + NS_INTERFACE_MAP_ENTRY(nsIRadioGroupContainer) + NS_INTERFACE_MAP_ENTRY(nsIMutationObserver) + // nsNodeSH::PreCreate() depends on the identity pointer being the + // same as nsINode (which nsIDocument inherits), so if you change + // the below line, make sure nsNodeSH::PreCreate() still does the + // right thing! + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocument) + + NS_INTERFACE_MAP_ENTRY_LITERAL(nsIDOMXPathEvaluator, nsIXPathEvaluatorInternal) + if (!mXPathEvaluatorTearoff) { + nsresult rv; + mXPathEvaluatorTearoff = + do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID, + static_cast(this), &rv); + NS_ENSURE_SUCCESS(rv, rv); + } + + return mXPathEvaluatorTearoff->QueryInterface(aIID, aResult); + END +NS_INTERFACE_MAP_END diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 6b8df78cc54..6e011a25753 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -883,54 +883,6 @@ nsDocument::~nsDocument() NS_IMPL_CYCLE_COLLECTION_CLASS(nsDocument) -NS_INTERFACE_TABLE_HEAD(nsDocument) - NS_INTERFACE_TABLE_BEGIN - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsINode) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDocument) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocument) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocument) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentEvent) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3DocumentEvent) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentStyle) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSDocumentStyle) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentView) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentRange) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentTraversal) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocumentXBL) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMEventTarget) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3EventTarget) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNSEventTarget) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNode) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsPIDOMEventTarget) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3Node) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOM3Document) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsISupportsWeakReference) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIMutationObserver) - // nsNodeSH::PreCreate() depends on the identity pointer being the - // same as nsINode (which nsIDocument inherits), so if you change - // the below line, make sure nsNodeSH::PreCreate() still does the - // right thing! - NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(nsDocument, nsISupports, nsIDocument) - NS_INTERFACE_TABLE_END - NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsDocument) - if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator)) || - aIID.Equals(NS_GET_IID(nsIXPathEvaluatorInternal))) { - if (!mXPathEvaluatorTearoff) { - nsresult rv; - mXPathEvaluatorTearoff = - do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID, - static_cast(this), &rv); - NS_ENSURE_SUCCESS(rv, rv); - } - - return mXPathEvaluatorTearoff->QueryInterface(aIID, aInstancePtr); - } - else -NS_INTERFACE_MAP_END - - NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsDocument, nsIDocument) NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS_WITH_DESTROY(nsDocument, nsIDocument, diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 528bd2ed06d..815cc7b9dff 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -798,7 +798,7 @@ protected: // Our update nesting level PRUint32 mUpdateNestLevel; -private: +protected: friend class nsUnblockOnloadEvent; void PostUnblockOnloadEvent(); diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index e2d3037edbc..9822268cbac 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -3449,28 +3449,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGenericElement) } NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGenericElement) - NS_INTERFACE_MAP_ENTRY(nsIContent) - NS_INTERFACE_MAP_ENTRY(nsINode) - NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3Node, new nsNode3Tearoff(this)) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSElement, new nsNSElementTearoff(this)) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMEventTarget, - nsDOMEventRTTearoff::Create(this)) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOM3EventTarget, - nsDOMEventRTTearoff::Create(this)) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsIDOMNSEventTarget, - nsDOMEventRTTearoff::Create(this)) - NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference, - new nsNodeSupportsWeakRefTearoff(this)) - // nsNodeSH::PreCreate() depends on the identity pointer being the - // same as nsINode (which nsIContent inherits), so if you change the - // below line, make sure nsNodeSH::PreCreate() still does the right - // thing! - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent) -NS_INTERFACE_MAP_END - NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGenericElement, nsIContent) NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS_WITH_DESTROY(nsGenericElement, nsIContent, diff --git a/content/html/content/public/nsIFrameSetElement.h b/content/html/content/public/nsIFrameSetElement.h index 9a90820b787..5050a4c3a58 100644 --- a/content/html/content/public/nsIFrameSetElement.h +++ b/content/html/content/public/nsIFrameSetElement.h @@ -40,6 +40,7 @@ #define nsIFramesetElement_h___ #include "nsISupports.h" +#include "nsCoord.h" // IID for the nsIFramesetElement interface #define NS_IFRAMESETELEMENT_IID \ diff --git a/content/html/content/src/Makefile.in b/content/html/content/src/Makefile.in index 8bae404ce80..0050f232ba9 100644 --- a/content/html/content/src/Makefile.in +++ b/content/html/content/src/Makefile.in @@ -133,6 +133,8 @@ CPPSRCS = \ nsTextRectangle.cpp \ $(NULL) +GQI_SRCS = htmlcontent.gqi + # we don't want the shared lib, but we want to force the creation of a static lib. FORCE_STATIC_LIB = 1 diff --git a/content/html/content/src/htmlcontent.gqi b/content/html/content/src/htmlcontent.gqi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/htmlgenericelement.gqi b/content/html/content/src/htmlgenericelement.gqi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp index d357e586b11..69c339508c7 100644 --- a/content/html/content/src/nsGenericHTMLElement.cpp +++ b/content/html/content/src/nsGenericHTMLElement.cpp @@ -179,30 +179,6 @@ nsGenericHTMLElement::Init(nsINodeInfo *aNodeInfo) #endif -class nsGenericHTMLElementTearoff : public nsIDOMNSHTMLElement, - public nsIDOMElementCSSInlineStyle -{ - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - - nsGenericHTMLElementTearoff(nsGenericHTMLElement *aElement) - : mElement(aElement) - { - } - - virtual ~nsGenericHTMLElementTearoff() - { - } - - NS_FORWARD_NSIDOMNSHTMLELEMENT(mElement->) - NS_FORWARD_NSIDOMELEMENTCSSINLINESTYLE(mElement->) - - NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGenericHTMLElementTearoff, - nsIDOMNSHTMLElement) - -private: - nsCOMPtr mElement; -}; - NS_IMPL_CYCLE_COLLECTION_1(nsGenericHTMLElementTearoff, mElement) NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGenericHTMLElementTearoff, @@ -2879,13 +2855,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGenericHTMLFrameElement, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mFrameLoader) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_INTERFACE_TABLE_HEAD(nsGenericHTMLFrameElement) - NS_INTERFACE_TABLE_INHERITED2(nsGenericHTMLFrameElement, - nsIDOMNSHTMLFrameElement, - nsIFrameLoaderOwner) - NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsGenericHTMLFrameElement) -NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement) - nsresult nsGenericHTMLFrameElement::GetContentDocument(nsIDOMDocument** aContentDocument) { diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h index 15befa464f6..5bec70702a2 100644 --- a/content/html/content/src/nsGenericHTMLElement.h +++ b/content/html/content/src/nsGenericHTMLElement.h @@ -45,6 +45,8 @@ #include "nsIDOMNSHTMLFrameElement.h" #include "nsFrameLoader.h" #include "nsGkAtoms.h" +#include "nsIDOMElementCSSInlineStyle.h" +#include "nsIDOMNSHTMLElement.h" class nsIDOMAttr; class nsIDOMEventListener; @@ -897,9 +899,6 @@ public: } virtual ~nsGenericHTMLFrameElement(); - // nsISupports - NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr); - // nsIDOMNSHTMLFrameElement NS_DECL_NSIDOMNSHTMLFRAMEELEMENT @@ -940,6 +939,30 @@ protected: nsCOMPtr mFrameLoader; }; +class nsGenericHTMLElementTearoff : public nsIDOMNSHTMLElement, + public nsIDOMElementCSSInlineStyle +{ + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + + nsGenericHTMLElementTearoff(nsGenericHTMLElement *aElement) + : mElement(aElement) + { + } + + virtual ~nsGenericHTMLElementTearoff() + { + } + + NS_FORWARD_NSIDOMNSHTMLELEMENT(mElement->) + NS_FORWARD_NSIDOMELEMENTCSSINLINESTYLE(mElement->) + + NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsGenericHTMLElementTearoff, + nsIDOMNSHTMLElement) + +private: + nsCOMPtr mElement; +}; + //---------------------------------------------------------------------- /** diff --git a/content/html/content/src/nsHTMLAnchorElement.cpp b/content/html/content/src/nsHTMLAnchorElement.cpp index 84ade688e5e..7702e5ef387 100644 --- a/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/content/html/content/src/nsHTMLAnchorElement.cpp @@ -36,6 +36,8 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ + +#include "nsHTMLAnchorElement.h" #include "nsCOMPtr.h" #include "nsReadableUtils.h" #include "nsUnicharUtils.h" @@ -63,78 +65,10 @@ #include "nsCOMPtr.h" #include "nsIPresShell.h" #include "nsIDocument.h" +#include "nsHTMLAnchorElement.h" nsresult NS_NewContentIterator(nsIContentIterator** aInstancePtrResult); -class nsHTMLAnchorElement : public nsGenericHTMLElement, - public nsIDOMHTMLAnchorElement, - public nsIDOMNSHTMLAnchorElement2, - public nsILink -{ -public: - nsHTMLAnchorElement(nsINodeInfo *aNodeInfo); - virtual ~nsHTMLAnchorElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLAnchorElement - NS_DECL_NSIDOMHTMLANCHORELEMENT - - // nsIDOMNSHTMLAnchorElement - NS_DECL_NSIDOMNSHTMLANCHORELEMENT - - // nsIDOMNSHTMLAnchorElement2 - NS_DECL_NSIDOMNSHTMLANCHORELEMENT2 - - // nsILink - NS_IMETHOD GetLinkState(nsLinkState &aState); - NS_IMETHOD SetLinkState(nsLinkState aState); - NS_IMETHOD GetHrefURI(nsIURI** aURI); - NS_IMETHOD LinkAdded() { return NS_OK; } - NS_IMETHOD LinkRemoved() { return NS_OK; } - - virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, - nsIContent* aBindingParent, - PRBool aCompileEventHandlers); - virtual void UnbindFromTree(PRBool aDeep = PR_TRUE, - PRBool aNullParent = PR_TRUE); - virtual void SetFocus(nsPresContext* aPresContext); - virtual PRBool IsFocusable(PRBool *aTabIndex = nsnull); - - virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor); - virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor); - virtual PRBool IsLink(nsIURI** aURI) const; - virtual void GetLinkTarget(nsAString& aTarget); - - nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, PRBool aNotify) - { - return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify); - } - virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - PRBool aNotify); - virtual nsresult UnsetAttr(PRInt32 aNameSpaceID, nsIAtom* aAttribute, - PRBool aNotify); - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - -protected: - // The cached visited state - nsLinkState mLinkState; -}; - - NS_IMPL_NS_NEW_HTML_ELEMENT(Anchor) @@ -153,19 +87,8 @@ NS_IMPL_ADDREF_INHERITED(nsHTMLAnchorElement, nsGenericElement) NS_IMPL_RELEASE_INHERITED(nsHTMLAnchorElement, nsGenericElement) -// QueryInterface implementation for nsHTMLAnchorElement -NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLAnchorElement, nsGenericHTMLElement) - NS_INTERFACE_TABLE_INHERITED4(nsHTMLAnchorElement, - nsIDOMHTMLAnchorElement, - nsIDOMNSHTMLAnchorElement, - nsIDOMNSHTMLAnchorElement2, - nsILink) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLAnchorElement) - - NS_IMPL_ELEMENT_CLONE(nsHTMLAnchorElement) - NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Charset, charset) NS_IMPL_STRING_ATTR(nsHTMLAnchorElement, Coords, coords) NS_IMPL_URI_ATTR(nsHTMLAnchorElement, Href, href) diff --git a/content/html/content/src/nsHTMLAnchorElement.h b/content/html/content/src/nsHTMLAnchorElement.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/nsHTMLDivElement.cpp b/content/html/content/src/nsHTMLDivElement.cpp index c4e2bfebd8d..57e6acd6068 100644 --- a/content/html/content/src/nsHTMLDivElement.cpp +++ b/content/html/content/src/nsHTMLDivElement.cpp @@ -34,46 +34,14 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMHTMLDivElement.h" + +#include "nsHTMLDivElement.h" #include "nsIDOMEventTarget.h" -#include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" #include "nsPresContext.h" #include "nsMappedAttributes.h" -class nsHTMLDivElement : public nsGenericHTMLElement, - public nsIDOMHTMLDivElement -{ -public: - nsHTMLDivElement(nsINodeInfo *aNodeInfo); - virtual ~nsHTMLDivElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLDivElement - NS_DECL_NSIDOMHTMLDIVELEMENT - - virtual PRBool ParseAttribute(PRInt32 aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; -}; - - NS_IMPL_NS_NEW_HTML_ELEMENT(Div) @@ -90,13 +58,6 @@ nsHTMLDivElement::~nsHTMLDivElement() NS_IMPL_ADDREF_INHERITED(nsHTMLDivElement, nsGenericElement) NS_IMPL_RELEASE_INHERITED(nsHTMLDivElement, nsGenericElement) - - -// QueryInterface implementation for nsHTMLDivElement -NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLDivElement, nsGenericHTMLElement) - NS_INTERFACE_TABLE_INHERITED1(nsHTMLDivElement, nsIDOMHTMLDivElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLDivElement) - NS_IMPL_ELEMENT_CLONE(nsHTMLDivElement) diff --git a/content/html/content/src/nsHTMLDivElement.h b/content/html/content/src/nsHTMLDivElement.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/nsHTMLFrameElement.cpp b/content/html/content/src/nsHTMLFrameElement.cpp index d13dcf3bd17..d8f01162b3f 100644 --- a/content/html/content/src/nsHTMLFrameElement.cpp +++ b/content/html/content/src/nsHTMLFrameElement.cpp @@ -34,48 +34,14 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMHTMLFrameElement.h" -#include "nsGenericHTMLElement.h" + +#include "nsHTMLFrameElement.h" #include "nsGkAtoms.h" #include "nsIPresShell.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsDOMError.h" - -class nsHTMLFrameElement : public nsGenericHTMLFrameElement, - public nsIDOMHTMLFrameElement -{ -public: - nsHTMLFrameElement(nsINodeInfo *aNodeInfo); - virtual ~nsHTMLFrameElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::) - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::) - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::) - - // nsIDOMHTMLFrameElement - NS_DECL_NSIDOMHTMLFRAMEELEMENT - - // nsIContent - virtual PRBool ParseAttribute(PRInt32 aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; - nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; -}; - - NS_IMPL_NS_NEW_HTML_ELEMENT(Frame) @@ -92,14 +58,6 @@ nsHTMLFrameElement::~nsHTMLFrameElement() NS_IMPL_ADDREF_INHERITED(nsHTMLFrameElement, nsGenericElement) NS_IMPL_RELEASE_INHERITED(nsHTMLFrameElement, nsGenericElement) - -// QueryInterface implementation for nsHTMLFrameElement -NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLFrameElement, - nsGenericHTMLFrameElement) - NS_INTERFACE_TABLE_INHERITED1(nsHTMLFrameElement, nsIDOMHTMLFrameElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFrameElement) - - NS_IMPL_ELEMENT_CLONE(nsHTMLFrameElement) diff --git a/content/html/content/src/nsHTMLFrameElement.h b/content/html/content/src/nsHTMLFrameElement.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/nsHTMLFrameSetElement.cpp b/content/html/content/src/nsHTMLFrameSetElement.cpp index 9b119680a99..7d41e2e31da 100644 --- a/content/html/content/src/nsHTMLFrameSetElement.cpp +++ b/content/html/content/src/nsHTMLFrameSetElement.cpp @@ -34,91 +34,15 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMHTMLFrameSetElement.h" + +#include "nsHTMLFrameSetElement.h" #include "nsIDOMEventTarget.h" -#include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" #include "nsPresContext.h" -#include "nsIFrameSetElement.h" #include "nsIHTMLDocument.h" #include "nsIDocument.h" -class nsHTMLFrameSetElement : public nsGenericHTMLElement, - public nsIDOMHTMLFrameSetElement, - public nsIFrameSetElement -{ -public: - nsHTMLFrameSetElement(nsINodeInfo *aNodeInfo); - virtual ~nsHTMLFrameSetElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLFrameSetElement - NS_DECL_NSIDOMHTMLFRAMESETELEMENT - - // These override the SetAttr methods in nsGenericHTMLElement (need - // both here to silence compiler warnings). - nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, PRBool aNotify) - { - return SetAttr(aNameSpaceID, aName, nsnull, aValue, aNotify); - } - virtual nsresult SetAttr(PRInt32 aNameSpaceID, nsIAtom* aName, - nsIAtom* aPrefix, const nsAString& aValue, - PRBool aNotify); - - // nsIFramesetElement - NS_IMETHOD GetRowSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs); - NS_IMETHOD GetColSpec(PRInt32 *aNumValues, const nsFramesetSpec** aSpecs); - - virtual PRBool ParseAttribute(PRInt32 aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute, - PRInt32 aModType) const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; - -private: - nsresult ParseRowCol(const nsAString& aValue, - PRInt32& aNumSpecs, - nsFramesetSpec** aSpecs); - - /** - * The number of size specs in our "rows" attr - */ - PRInt32 mNumRows; - /** - * The number of size specs in our "cols" attr - */ - PRInt32 mNumCols; - /** - * The style hint to return for the rows/cols attrs in - * GetAttributeChangeHint - */ - nsChangeHint mCurrentRowColHint; - /** - * The parsed representation of the "rows" attribute - */ - nsAutoArrayPtr mRowSpecs; // parsed, non-computed dimensions - /** - * The parsed representation of the "cols" attribute - */ - nsAutoArrayPtr mColSpecs; // parsed, non-computed dimensions -}; - NS_IMPL_NS_NEW_HTML_ELEMENT(FrameSet) @@ -137,15 +61,6 @@ NS_IMPL_ADDREF_INHERITED(nsHTMLFrameSetElement, nsGenericElement) NS_IMPL_RELEASE_INHERITED(nsHTMLFrameSetElement, nsGenericElement) -// QueryInterface implementation for nsHTMLFrameSetElement -NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLFrameSetElement, - nsGenericHTMLElement) - NS_INTERFACE_TABLE_INHERITED2(nsHTMLFrameSetElement, - nsIDOMHTMLFrameSetElement, - nsIFrameSetElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLFrameSetElement) - - NS_IMPL_ELEMENT_CLONE(nsHTMLFrameSetElement) diff --git a/content/html/content/src/nsHTMLFrameSetElement.h b/content/html/content/src/nsHTMLFrameSetElement.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/nsHTMLIFrameElement.cpp b/content/html/content/src/nsHTMLIFrameElement.cpp index f7cc484c507..f5abfbdfb4f 100644 --- a/content/html/content/src/nsHTMLIFrameElement.cpp +++ b/content/html/content/src/nsHTMLIFrameElement.cpp @@ -34,8 +34,8 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMHTMLIFrameElement.h" -#include "nsGenericHTMLElement.h" + +#include "nsHTMLIFrameElement.h" #include "nsGkAtoms.h" #include "nsPresContext.h" #include "nsIPresShell.h" @@ -45,43 +45,9 @@ #include "nsRuleData.h" #include "nsStyleConsts.h" -class nsHTMLIFrameElement : public nsGenericHTMLFrameElement, - public nsIDOMHTMLIFrameElement -{ -public: - nsHTMLIFrameElement(nsINodeInfo *aNodeInfo); - virtual ~nsHTMLIFrameElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE(nsGenericHTMLFrameElement::) - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLFrameElement::) - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLFrameElement::) - - // nsIDOMHTMLIFrameElement - NS_DECL_NSIDOMHTMLIFRAMEELEMENT - - // nsIContent - virtual PRBool ParseAttribute(PRInt32 aNamespaceID, - nsIAtom* aAttribute, - const nsAString& aValue, - nsAttrValue& aResult); - NS_IMETHOD_(PRBool) IsAttributeMapped(const nsIAtom* aAttribute) const; - virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const; - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; -}; - NS_IMPL_NS_NEW_HTML_ELEMENT(IFrame) - nsHTMLIFrameElement::nsHTMLIFrameElement(nsINodeInfo *aNodeInfo) : nsGenericHTMLFrameElement(aNodeInfo) { @@ -95,13 +61,6 @@ nsHTMLIFrameElement::~nsHTMLIFrameElement() NS_IMPL_ADDREF_INHERITED(nsHTMLIFrameElement,nsGenericElement) NS_IMPL_RELEASE_INHERITED(nsHTMLIFrameElement,nsGenericElement) -// QueryInterface implementation for nsHTMLIFrameElement -NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLIFrameElement, - nsGenericHTMLFrameElement) - NS_INTERFACE_TABLE_INHERITED1(nsHTMLIFrameElement, nsIDOMHTMLIFrameElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLIFrameElement) - - NS_IMPL_ELEMENT_CLONE(nsHTMLIFrameElement) diff --git a/content/html/content/src/nsHTMLIFrameElement.h b/content/html/content/src/nsHTMLIFrameElement.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/content/src/nsHTMLSpanElement.cpp b/content/html/content/src/nsHTMLSpanElement.cpp index 7b02961358f..6c7c646b4e7 100644 --- a/content/html/content/src/nsHTMLSpanElement.cpp +++ b/content/html/content/src/nsHTMLSpanElement.cpp @@ -34,44 +34,17 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "nsIDOMHTMLElement.h" + +#include "nsHTMLSpanElement.h" #include "nsIDOMEventTarget.h" -#include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" #include "nsStyleConsts.h" #include "nsPresContext.h" #include "nsIAtom.h" #include "nsRuleData.h" -class nsHTMLSpanElement : public nsGenericHTMLElement, - public nsIDOMHTMLElement -{ -public: - nsHTMLSpanElement(nsINodeInfo *aNodeInfo); - virtual ~nsHTMLSpanElement(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE(nsGenericHTMLElement::) - - // nsIDOMElement - NS_FORWARD_NSIDOMELEMENT(nsGenericHTMLElement::) - - // nsIDOMHTMLElement - NS_FORWARD_NSIDOMHTMLELEMENT(nsGenericHTMLElement::) - - virtual nsresult GetInnerHTML(nsAString& aInnerHTML); - virtual nsresult SetInnerHTML(const nsAString& aInnerHTML); - - virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const; -}; - - NS_IMPL_NS_NEW_HTML_ELEMENT(Span) - nsHTMLSpanElement::nsHTMLSpanElement(nsINodeInfo *aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { @@ -85,12 +58,6 @@ nsHTMLSpanElement::~nsHTMLSpanElement() NS_IMPL_ADDREF_INHERITED(nsHTMLSpanElement, nsGenericElement) NS_IMPL_RELEASE_INHERITED(nsHTMLSpanElement, nsGenericElement) - -// QueryInterface implementation for nsHTMLSpanElement -NS_HTML_CONTENT_INTERFACE_TABLE_HEAD(nsHTMLSpanElement, nsGenericHTMLElement) -NS_HTML_CONTENT_INTERFACE_TABLE_TAIL_CLASSINFO(HTMLSpanElement) - - NS_IMPL_ELEMENT_CLONE(nsHTMLSpanElement) diff --git a/content/html/content/src/nsHTMLSpanElement.h b/content/html/content/src/nsHTMLSpanElement.h new file mode 100644 index 00000000000..e69de29bb2d diff --git a/content/html/document/src/Makefile.in b/content/html/document/src/Makefile.in index 51dfe3013a0..a9b8b592304 100644 --- a/content/html/document/src/Makefile.in +++ b/content/html/document/src/Makefile.in @@ -91,6 +91,8 @@ CPPSRCS = \ nsWyciwygProtocolHandler.cpp \ $(NULL) +GQI_SRCS = htmldocument.gqi + EXPORTS = \ nsIHTMLDocument.h \ $(NULL) diff --git a/content/html/document/src/htmldocument.gqi b/content/html/document/src/htmldocument.gqi new file mode 100644 index 00000000000..b08a1c0858f --- /dev/null +++ b/content/html/document/src/htmldocument.gqi @@ -0,0 +1,17 @@ +%import "contentbase.gqi" + +%import-idl "nsIDOMHTMLDocument.idl" +%import-idl "nsIDOMNSHTMLDocument.idl" + +%{C++ +#include "nsHTMLDocument.h" +%} + +%pseudo-iid nsIHTMLDocument 61e989a8-70cd-4582-845e-6e5e12559a83 + +NS_INTERFACE_MAP_BEGIN(nsHTMLDocument, nsDocument) + NS_INTERFACE_MAP_ENTRY(nsIHTMLDocument) + NS_INTERFACE_MAP_ENTRY(nsIDOMHTMLDocument) + NS_INTERFACE_MAP_ENTRY(nsIDOMNSHTMLDocument) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(HTMLDocument) +NS_INTERFACE_MAP_END diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 35482a9012c..8bc1657b1be 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -416,18 +416,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_ADDREF_INHERITED(nsHTMLDocument, nsDocument) NS_IMPL_RELEASE_INHERITED(nsHTMLDocument, nsDocument) - -// QueryInterface implementation for nsHTMLDocument -NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLDocument) - NS_INTERFACE_TABLE_INHERITED3(nsHTMLDocument, - nsIHTMLDocument, - nsIDOMHTMLDocument, - nsIDOMNSHTMLDocument) - NS_INTERFACE_TABLE_TO_MAP_SEGUE - NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(HTMLDocument) -NS_INTERFACE_MAP_END_INHERITING(nsDocument) - - nsresult nsHTMLDocument::Init() { diff --git a/xpcom/base/gqi.py b/xpcom/base/gqi.py new file mode 100644 index 00000000000..51e697dce90 --- /dev/null +++ b/xpcom/base/gqi.py @@ -0,0 +1,788 @@ +# -*- Mode: Python: tab-width: 8; indent-tabs-mode: nil; python-indent: 4 -*- + +"""Implement QueryInterface using optimized generated code.""" + +import os, errno, re, sys, sets + +# Global controlling debug output to sys.stderr +debug = False + +def findfile(f, curfile, includedirs): + """Find a file 'f' by looking in the directory of the current file + and then in all directories specified by -I until it is found. Returns + the path of the file that was found. + + @raises IOError is the file is not found.""" + + sdirs = [os.path.dirname(curfile)] + sdirs.extend(includedirs) + + for dir in sdirs: + t = os.path.join(dir, f) + if os.path.exists(t): + return t + + raise IOError(errno.ENOENT, "File not found", f) + +# Giant parsing loop: parse input files into the internal representation, +# keeping track of file/line numbering information. This iterator automatically +# skips blank lines and lines beginning with // + +class IterFile(object): + def __init__(self, file): + self._file = file + self._iter = open(file) + self._lineno = 0 + + def __iter__(self): + return self + + def next(self): + self._lineno += 1 + line = self._iter.next().strip() + if line == '' or line.startswith('//'): + return self.next() + return line + + def loc(self): + return "%s:%i" % (self._file, self._lineno) + +class uniqdict(dict): + """A subclass of dict that will throw an error if you attempt to set the same key to different values.""" + def __setitem__(self, key, value): + if key in self and not value == self[key]: + raise IndexError('Key "%s" already present in uniqdict' % key) + + dict.__setitem__(self, key, value) + + def update(self, d): + for key, value in d.iteritems(): + if key in self and not value == self[key]: + raise IndexError('Key "%s" already present in uniqdict' % key) + + dict.update(self, d) + +def dump_hex_tuple(t): + return "(%s)" % ", ".join(["%#x" % i for i in t]) + +class UUID(object): + def __init__(self, name, iidstr, pseudo=False, base=None): + """This method *assumes* that the UUID is validly formed.""" + self.name = name + self.pseudo = pseudo + self.base = base + + # iid is in 32-16-16-8*8 format, as hex *strings* + iid = (iidstr[0:8], iidstr[9:13], iidstr[14:18], + iidstr[19:21], iidstr[21:23], iidstr[24:26], iidstr[26:28], + iidstr[28:30], iidstr[30:32], iidstr[32:34], iidstr[34:36]) + + self.iid = iid + + # (big_endian_words, little_endian_words) + self.words = ( + (int(iid[0], 16), + int(iid[1] + iid[2], 16), + int("".join([iid[i] for i in xrange(3, 7)]), 16), + int("".join([iid[i] for i in xrange(7, 11)]), 16)), + (int(iid[0], 16), + int(iid[2] + iid[1], 16), + int("".join([iid[i] for i in xrange(6, 2, -1)]), 16), + int("".join([iid[i] for i in xrange(10, 6, -1)]), 16))) + + if debug: + print >>sys.stderr, "%r" % self + print >>sys.stderr, " bigendian: %s" % dump_hex_tuple(self.words[False]) + print >>sys.stderr, " littleendian: %r" % dump_hex_tuple(self.words[True]) + + def __eq__(self, uuid): + return self.iid == uuid.iid and self.name == uuid.name + + def __repr__(self): + return """UUID(%r, "%s-%s-%s-%s-%s", pseudo=%r, base=%r)""" % ( + self.name, self.iid[0], self.iid[1], self.iid[2], self.iid[3] + self.iid[4], + "".join([self.iid[i] for i in xrange(5, 11)]), self.pseudo, self.base) + + def asstruct(self): + return "{ 0x%s, 0x%s, 0x%s, { 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s } }" % self.iid + + def runtime_assertion(self): + if self.pseudo: + return """ + static const nsID kGQI_%(iname)s = %(struct)s; + NS_ASSERTION(NS_GET_IID(%(iname)s).Equals(kGQI_%(iname)s), + "GQI pseudo-IID doesn't match reality."); + """ % { + 'iname': self.name, + 'struct': self.asstruct() + } + else: + return "" + +_uuid_pattern_string = r'[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}' + +_includefinder = re.compile(r'#include\s+(?:"|\<)(?P[a-z\.\-\_0-9]+)(?:"|\>)\s*$', re.I) +_uuidfinder = re.compile(r'uuid\((?P' + _uuid_pattern_string + r')\)', re.I) +_namefinder = re.compile(r'interface\s+(?P[A-Za-z_0-9]+)\s+:\s+(?P[A-Za-z]+)') + +def importidl(file, includedirs): + """Parse an IDL file. Returns (mapofiids, setofdeps)""" + + iids = {} + deps = sets.Set() + deps.add(file) + + f = IterFile(file) + for line in f: + if line.startswith('%{'): + # Skip literal IDL blocks such as %{C++ %} + for line in f: + if line.startswith('%}'): + break + continue + + m = _includefinder.match(line) + if m is not None: + importediids, importeddeps = importidl(findfile(m.group('filename'), file, includedirs), includedirs) + iids.update(importediids) + deps |= importeddeps + continue + + m = _uuidfinder.search(line) + if m is not None: + iid = m.group('iid') + line = f.next() + if line == 'interface nsISupports {': + iids['nsISupports'] = UUID('nsISupports', iid) + else: + m = _namefinder.match(line) + if m is None: + raise Exception("%s: expected interface" % f.loc()) + + iids[m.group('interface')] = \ + UUID(m.group('interface'), iid, base=m.group('base')) + + return iids, deps + +def gqi(ifaces, endian): + """Find an algorithm that uniquely identifies interfaces by a single + word. Returns (indexfunction, table)""" + for bits in xrange(3, 10): + bitmask = (1 << bits) - 1 + for word in xrange(0, 4): + for sh in xrange(0, 33 - bits): + shmask = bitmask << sh + + # print "Trying word: %i, bits: %i, shift: %i" % (word, bits, sh) + # print "Bitmask: %x" % (bitmask) + # print "Shifter mask: %x" % (shmask) + + l = list([None for i in xrange(0, 1 << bits)]) + try: + for i in xrange(0, len(ifaces)): + n = (ifaces[i].uuid.words[endian][word] & shmask) >> sh + if l[n] is not None: + # print "found conflict, index %i" % n + # print "old iface: %s" % l[n].uuid + # print "new iface: %s" % i.uuid + raise IndexError() + + l[n] = i + + except IndexError: + continue + + # If we got here, we're ok... create the table we want + indexfunc = "(reinterpret_cast(&aIID)[%i] & 0x%x) >> %i" % (word, shmask, sh) + return indexfunc, l + + raise Exception("No run of 9 bits within a word was unique!: interfaces: %s" % [i.uuid for i in ifaces]) + +def basecast(item, baselist): + """Returns a string where an item is static_cast through a list of bases.""" + for base in baselist: + item = "static_cast<%s*>(%s)" % (base, item) + + return item + +class QIImpl(object): + _default_unfound = """ + *aResult = nsnull; + return NS_NOINTERFACE; + """ + + _qiimpl = """ + enum %(cname)s_QIActionType { + %(actionenums)s + }; + + struct %(cname)s_QIAction { + const nsID *iid; + %(actiontype)s + union { + void *ptr; + %(actiondata)s + } data; + }; + + NS_IMETHODIMP %(cname)s::QueryInterface(REFNSIID aIID, void **aResult) + { +#ifdef DEBUG + %(pseudoassertions)s +#endif + + static const PRUint8 kLookupTable[] = { +#ifdef IS_BIG_ENDIAN + %(biglookup)s +#else + %(littlelookup)s +#endif + }; + + static const %(cname)s_QIAction kActionTable[] = { + %(actiontable)s + }; + + nsISupports* found = nsnull; + const %(cname)s_QIAction *entry; + PRUint32 index = +#ifdef IS_BIG_ENDIAN + %(bigindexfunc)s; +#else + %(littleindexfunc)s; +#endif + + PRUint8 action = kLookupTable[index]; + if (action == 0xFF) + goto unfound; + + entry = kActionTable + action; + if (!entry->iid->Equals(aIID)) + goto unfound; + + %(actioncode)s + + NS_NOTREACHED("Unhandled case?"); + + %(nullcheck)s + + exit_addref: + NS_ASSERTION(found, "Interface should have been found by now."); + found->AddRef(); + *aResult = found; + return NS_OK; + + unfound: + %(unfound)s + }""" + + _datatypes = """ + %(type)s %(name)s; + """ + + _actiontable_entry = """ + { + &NS_GET_IID(%(iname)s), + %(enumtype)s + %(emitTable)s + }, + """ + + _actioncode_multi = """ + switch (entry->action) { + %s + } + """ + + _actioncode_multi_entry = """ + case %(cname)s_%(enumtype)s: + %(setResult)s + """ + + _nullcheck = """ + exit_nullcheck_addref: + if (!found) + return NS_ERROR_OUT_OF_MEMORY; + """ + + _refcounting = """ + NS_IMPL_%(threadsafe)sADDREF(%(cname)s) + NS_IMPL_%(threadsafe)sRELEASE(%(cname)s) + """ + + def __init__(self, cname, ifaces, emitrefcount=False, + threadsafe="", unfound=None, base=None): + self.cname = cname + self.emitrefcount = emitrefcount + self.threadsafe = threadsafe + self.base = base + self.ifaces = ifaces + self.unfound = unfound + + # ensure that interfaces are not duplicated + ifdict = uniqdict() + for i, baselist in self.iter_all_ifaces(): + ifdict[i.uuid.name] = i + + def iter_self_and_bases(self): + """yields (impl, baselist) for all bases""" + impl = self + baselist = [] + + while impl is not None: + baselist = list(baselist) + baselist.append(impl.cname) + yield impl, baselist + impl = impl.base + + def iter_all_ifaces(self): + """yields (iface, baselist) for all interfaces""" + for impl, baselist in self.iter_self_and_bases(): + for i in impl.ifaces: + yield i, baselist + + def output(self, fd): + unfound = None + for impl, baselist in self.iter_self_and_bases(): + if impl.unfound is not None: + unfound = impl.unfound + break + + if unfound is None: + unfound = self._default_unfound + + needsnullcheck = False + actions = sets.Set() + types = uniqdict() + for i, baselist in self.iter_all_ifaces(): + action = i.action + actions.add(action) + if action.needsnullcheck: + needsnullcheck = True + + if action.datatype: + types[action.varname] = action.datatype + + actionenums = ", ".join(["%s_%s" % (self.cname, action.enumtype) + for action in actions]) + + # types.ptr is explicitly first (for initialization), so delete it + types.pop('ptr', None) + + actiondata = "".join([self._datatypes % {'type': type, + 'name': name} + for name, type in types.iteritems()]) + + # list of (i, baselist) + ilist = [i for i in self.iter_all_ifaces()] + + pseudoassertions = "".join([i.uuid.runtime_assertion() + for i, baselist in ilist]) + + bigindexfunc, bigitable = gqi([iface for iface, baselist in ilist], False) + littleindexfunc, littleitable = gqi([iface for iface, baselist in ilist], True) + + # (falseval, trueval)[conditional expression] is the python + # ternary operator + biglookup = ",\n".join([(str(i), "0xFF")[i is None] + for i in bigitable]) + littlelookup = ",\n".join([(str(i), "0xFF")[i is None] + for i in littleitable]) + + if len(actions) > 1: + actiontype = "%s_QIActionType action;" % self.cname + enumtype = "%(cname)s_%(enumtype)s," + else: + actiontype = "" + enumtype = "" + + actiontable = "".join([self._actiontable_entry % + {'enumtype': enumtype % {'cname': self.cname, + 'enumtype': iface.action.enumtype}, + 'iname': iface.uuid.name, + 'emitTable': iface.emitTable(self.cname, baselist)} + for iface, baselist in ilist]) + + if len(actions) == 1: + actioncode = iter(actions).next().setResult % { + 'classname': self.cname + } + else: + actioncode = self._actioncode_multi % ( + "".join([self._actioncode_multi_entry % { + 'cname': self.cname, + 'enumtype': action.enumtype, + 'setResult': action.setResult % {'classname': self.cname}} + for action in actions]) + ) + + if needsnullcheck: + nullcheck = self._nullcheck + else: + nullcheck = "" + + print >>fd, self._qiimpl % { + 'cname': self.cname, + 'actionenums': actionenums, + 'actiontype': actiontype, + 'actiondata': actiondata, + 'pseudoassertions': pseudoassertions, + 'biglookup': biglookup, + 'littlelookup': littlelookup, + 'actiontable': actiontable, + 'bigindexfunc': bigindexfunc, + 'littleindexfunc': littleindexfunc, + 'actioncode': actioncode, + 'nullcheck': nullcheck, + 'unfound': unfound + } + + if self.emitrefcount: + print >>fd, self._refcounting % { + 'threadsafe': self.threadsafe, + 'cname': self.cname + } + +class PointerAction(object): + enumtype = "STATIC_POINTER" + datatype = "void*" + varname = "ptr" + setResult = """*aResult = entry->data.ptr; + return NS_OK;""" + needsnullcheck = False + +nsCycleCollectionParticipant = UUID("nsCycleCollectionParticipant", "9674489b-1f6f-4550-a730-ccaedd104cf9", pseudo=True) + +class CCParticipantResponse(object): + action = PointerAction + + def __init__(self, classname): + self.classname = classname + self.uuid = nsCycleCollectionParticipant + + def emitTable(self, classname, baselist): + return "{ &NS_CYCLE_COLLECTION_NAME(%s) }" % classname + +class TearoffResponse(object): + """Because each tearoff is different, this response is its own action.""" + datatype = None + needsnullcheck = True + + def __init__(self, uuid, allocator): + self.setResult = """ + found = static_cast<%s*>(%s); + goto exit_nullcheck_addref; + """ % (uuid.name, allocator) + self.uuid = uuid + self.action = self + self.enumtype = "NS_TEAROFF_%s" % uuid.name + + def emitTable(self, classname, baselist): + return "{0}" + +nsCycleCollectionISupports = UUID("nsCycleCollectionISupports", "c61eac14-5f7a-4481-965e-7eaa6effa85f", pseudo=True) + +class CCSupportsAction(object): + enumtype = "CC_ISUPPORTS" + datatype = None + setResult = """ + found = NS_CYCLE_COLLECTION_CLASSNAME(%(classname)s)::Upcast(this); + goto exit_nullcheck_addref; + """ + needsnullcheck = True + +class CCISupportsResponse(object): + action = CCSupportsAction + + def __init__(self, classname): + self.classname = classname + self.uuid = nsCycleCollectionISupports + + def emitTable(self, classname, baselist): + return "{ 0 }" + +nsIClassInfo = UUID("nsIClassInfo", "986c11d0-f340-11d4-9075-0010a4e73d9a", pseudo=True) + +class DOMCIResult(object): + datatype = None + enumtype = "DOMCI" + needsnullcheck = True + + def __init__(self, domciname): + self.action = self + self.uuid = nsIClassInfo + self.setResult = """ + found = NS_GetDOMClassInfoInstance(eDOMClassInfo_%s_id); + goto exit_nullcheck_addref; + """ % domciname + + def emitTable(self, classname, baselist): + return "{ 0 }" + +class OffsetAction(object): + enumtype = "OFFSET_THIS_ADDREF" + datatype = "PRUint32" + varname = "offset" + setResult = """ + found = reinterpret_cast(reinterpret_cast(this) + entry->data.offset); + goto exit_addref; + """ + needsnullcheck = False + +class OffsetThisQIResponse(object): + action = OffsetAction + + def __init__(self, uuid): + self.uuid = uuid + + def emitTable(self, classname, baselist): + casted = basecast("((%s*) 0x1000)" % classname, baselist) + + return """ + { reinterpret_cast( + reinterpret_cast( + static_cast<%(iname)s*>(%(casted)s)) - + reinterpret_cast(%(casted)s)) + }""" % { 'casted': casted, + 'iname': self.uuid.name } + +class OffsetFutureThisQIResponse(OffsetThisQIResponse): + action = OffsetAction + + def __init__(self, uuid): + self.uuid = uuid + + def emitTable(self, classname, baselist): + casted = "((%s*) 0x1000)" % classname + + return """ + { reinterpret_cast( + reinterpret_cast( + static_cast<%(iname)s*>(%(casted)s)) - + reinterpret_cast(%(casted)s)) + }""" % { 'casted': casted, + 'iname': self.uuid.name } + +class OffsetThisQIResponseAmbiguous(OffsetThisQIResponse): + def __init__(self, uuid, intermediate): + self.intermediate = intermediate + OffsetThisQIResponse.__init__(self, uuid) + + def emitTable(self, classname, baselist): + casted = basecast("((%s*) 0x1000)" % classname, baselist) + + return """ + { reinterpret_cast( + reinterpret_cast( + static_cast<%(iname)s*>( + static_cast<%(intermediate)s*>(%(casted)s))) - + reinterpret_cast(%(casted)s)) + }""" % \ + { 'casted': casted, + 'iname': self.uuid.name, + 'intermediate': self.intermediate.name } + +class LiteralAction(object): + datatype = None + def __init__(self, uname, code): + self.enumtype = "LITERAL_CODE_%s" % uname + self.setResult = code + self.needsnullcheck = code.find('exit_nullcheck_addref') != -1 + +class LiteralResponse(object): + def __init__(self, action, uuid): + self.action = action + self.uuid = uuid + + def emitTable(self, cname, baselist): + return "{0}" + +_map_entry = re.compile(r'(?P[A-Z_]+)\((?P.*)\)$') +_split_commas = re.compile(r'\s*,\s*') + +def build_map(f, cname, iids): + """Parse the body of an NS_INTERFACE_MAP and return (members, unfound)""" + unfound = None + members = [] + for line in f: + if line == 'NS_INTERFACE_MAP_END': + return (members, unfound) + + if line == 'NS_INTERFACE_MAP_UNFOUND': + unfound = '' + for line in f: + if line == 'END': + break + unfound += line + continue + + if line.find(')') == -1: + for line2 in f: + line += line2 + if line.find(')') != -1: + break + + m = _map_entry.match(line) + if m is None: + raise Exception("%s: Unparseable interface map entry" % f.loc()) + + items = _split_commas.split(m.group('list')) + + action = m.group('action') + if action == 'NS_INTERFACE_MAP_ENTRY': + iname, = items + members.append(OffsetThisQIResponse(iids[iname])) + elif action == 'NS_FUTURE_INTERFACE_MAP_ENTRY': + iname, = items + members.append(OffsetFutureThisQIResponse(iids[iname])) + elif action == 'NS_INTERFACE_MAP_ENTRY_AMBIGUOUS': + iname, intermediate = items + members.append(OffsetThisQIResponseAmbiguous(iids[iname], iids[intermediate])) + elif action == 'NS_INTERFACE_MAP_ENTRY_TEAROFF': + iname, allocator = items + members.append(TearoffResponse(iids[iname], allocator)) + elif action == 'NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO': + domciname, = items + members.append(DOMCIResult(domciname)) + elif action == 'NS_INTERFACE_MAP_ENTRY_LITERAL': + code = '' + for line in f: + if line == 'END': + break + code += line + + a = LiteralAction(items[0], code) + for iname in items: + iface = iids[iname] + members.append(LiteralResponse(a, iface)) + else: + raise Exception("%s: Unexpected interface map entry" % f.loc()) + + raise Exception("%s: Unexpected EOF" % f.loc()) + +_import = re.compile(r'%(?Pimport|import-idl)\s+(?:"|\<)(?P[a-z\.\-\_0-9]+)(?:"|\>)\s*$', re.I) +_impl_qi = re.compile(r'NS_IMPL_(?PTHREADSAFE_)?(?PQUERY_INTERFACE|ISUPPORTS)(?:\d+)\((?P.*)\)\s*$') +_pseudoiid = re.compile(r'%pseudo-iid\s+(?P[a-z_0-9]+)\s+(?P' + _uuid_pattern_string + r')\s*$', re.I) +_map_begin = re.compile(r'NS_INTERFACE_MAP_BEGIN(?P_CYCLE_COLLECTION)?\((?P[A-Za-z0-9+]+)(?:\s*,\s*(?P[A-Za-z0-9+]+))?\)$') + +def parsefile(file, fd, includedirs): + """Parse a file, returning a (map of name->QIImpls, set of deps) + %{C++ blocks are printed immediately to fd.""" + + iids = uniqdict() + impls = uniqdict() + imported = uniqdict() + deps = sets.Set() + deps.add(file) + + f = IterFile(file) + for line in f: + if len(line) == 0: + continue + + if line == "%{C++": + for line in f: + if line == "%}": + break + print >>fd, line + continue + + m = _pseudoiid.match(line) + if m is not None: + uuid = UUID(m.group('name'), m.group('iid'), pseudo=True) + iids[m.group('name')] = uuid + continue + + m = _import.match(line) + if m is not None: + if m.group('type') == 'import': + newimpls, newdeps = parsefile(findfile(m.group('filename'), file, includedirs), fd, includedirs) + imported.update(newimpls) + deps |= newdeps + else: + newiids, newdeps = importidl(findfile(m.group('filename'), file, includedirs), includedirs) + iids.update(newiids) + deps |= newdeps + print >>fd, '#include "%s"' % m.group('filename').replace('.idl', '.h') + continue + + if line.find('NS_IMPL_') != -1: + if line.find(')') == -1: + for follow in f: + line += follow + if follow.find(')') != -1: + break + + if line.find(')') == -1: + raise Exception("%s: Unterminated NS_IMPL_ call" % f.loc()) + + m = _impl_qi.match(line) + if m is None: + raise Exception("%s: Unparseable NS_IMPL_ call" % f.loc()) + + bases = _split_commas.split(m.group('bases')) + cname = bases.pop(0) + baseuuids = [iids[name] for name in bases] + ifaces = [OffsetThisQIResponse(uuid) for uuid in baseuuids] + ifaces.append(OffsetThisQIResponseAmbiguous(iids['nsISupports'], ifaces[0].uuid)) + q = QIImpl(cname, ifaces, + emitrefcount=(m.group('type') == 'ISUPPORTS'), + threadsafe=m.group('threadsafe') or '') + impls[cname] = q + continue + + m = _map_begin.match(line) + if m is not None: + members, unfound = build_map(f, m.group('classname'), iids) + if m.group('cc') is not None: + members.append(CCParticipantResponse(m.group('classname'))) + members.append(CCISupportsResponse(m.group('classname'))) + base = None + if m.group('base') is not None: + if m.group('base') in impls: + base = impls[m.group('base')] + else: + base = imported[m.group('base')] + q = QIImpl(m.group('classname'), members, unfound=unfound, base=base) + impls[m.group('classname')] = q + continue + + raise Exception("%s: unexpected input line" % f.loc()) + + return impls, deps + +def main(): + from optparse import OptionParser + + o = OptionParser() + o.add_option("-I", action="append", dest="include_dirs", default=[], + help="Directory to search for included files.") + o.add_option("-D", dest="deps_file", + help="Write dependencies to a file") + o.add_option("-o", dest="out_file", + help="Write output to file. Required") + + (options, files) = o.parse_args() + + if options.out_file is None: + o.print_help() + sys.exit(1) + + outfd = open(options.out_file, 'w') + + deps = sets.Set() + + for file in files: + impls, newdeps = parsefile(file, outfd, options.include_dirs) + for q in impls.itervalues(): + q.output(outfd) + deps |= newdeps + + if options.deps_file is not None: + depsfd = open(options.deps_file, 'w') + print >>depsfd, "%s: %s" % (options.out_file, + " \\\n ".join(deps)) + +if __name__ == '__main__': + main() + diff --git a/xpcom/components/Makefile.in b/xpcom/components/Makefile.in index 3bcc7b20038..191df9007a2 100644 --- a/xpcom/components/Makefile.in +++ b/xpcom/components/Makefile.in @@ -59,6 +59,10 @@ CPPSRCS = \ nsServiceManagerObsolete.cpp \ $(NULL) +GQI_SRCS = \ + xpcomcomponents.gqi \ + $(NULL) + EXPORTS = \ nsCategoryManagerUtils.h \ nsIServiceManagerObsolete.h \ diff --git a/xpcom/components/nsCategoryManager.cpp b/xpcom/components/nsCategoryManager.cpp index 8e36191f486..4eb2c953c1a 100644 --- a/xpcom/components/nsCategoryManager.cpp +++ b/xpcom/components/nsCategoryManager.cpp @@ -80,48 +80,6 @@ class nsIComponentLoaderManager; // pulled in from nsComponentManager.cpp char* ArenaStrdup(const char* s, PLArenaPool* aArena); -// -// BaseStringEnumerator is subclassed by EntryEnumerator and -// CategoryEnumerator -// -class BaseStringEnumerator - : public nsISimpleEnumerator, - nsIUTF8StringEnumerator -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSISIMPLEENUMERATOR - NS_DECL_NSIUTF8STRINGENUMERATOR - -protected: - // Callback function for NS_QuickSort to sort mArray - static int SortCallback(const void *, const void *, void *); - - BaseStringEnumerator() - : mArray(nsnull), - mCount(0), - mSimpleCurItem(0), - mStringCurItem(0) { } - - // A virtual destructor is needed here because subclasses of - // BaseStringEnumerator do not implement their own Release() method. - - virtual ~BaseStringEnumerator() - { - if (mArray) - delete[] mArray; - } - - void Sort(); - - const char** mArray; - PRUint32 mCount; - PRUint32 mSimpleCurItem; - PRUint32 mStringCurItem; -}; - -NS_IMPL_ISUPPORTS2(BaseStringEnumerator, nsISimpleEnumerator, nsIUTF8StringEnumerator) - NS_IMETHODIMP BaseStringEnumerator::HasMoreElements(PRBool *_retval) { @@ -483,8 +441,6 @@ CategoryEnumerator::enumfunc_createenumerator(const char* aStr, CategoryNode* aN // nsCategoryManager implementations // -NS_IMPL_THREADSAFE_ISUPPORTS1(nsCategoryManager, nsICategoryManager) - nsCategoryManager* nsCategoryManager::Create() { @@ -786,17 +742,6 @@ nsCategoryManager::SuppressNotifications(PRBool aSuppress) return NS_OK; } -class nsCategoryManagerFactory : public nsIFactory - { - public: - nsCategoryManagerFactory() { } - - NS_DECL_ISUPPORTS - NS_DECL_NSIFACTORY - }; - -NS_IMPL_ISUPPORTS1(nsCategoryManagerFactory, nsIFactory) - NS_IMETHODIMP nsCategoryManagerFactory::CreateInstance( nsISupports* aOuter, const nsIID& aIID, void** aResult ) { diff --git a/xpcom/components/nsCategoryManager.h b/xpcom/components/nsCategoryManager.h index 4b6dc475373..2df1ea431c7 100644 --- a/xpcom/components/nsCategoryManager.h +++ b/xpcom/components/nsCategoryManager.h @@ -44,6 +44,9 @@ #include "plarena.h" #include "nsClassHashtable.h" #include "nsICategoryManager.h" +#include "nsIFactory.h" +#include "nsISimpleEnumerator.h" +#include "nsIStringEnumerator.h" #define NS_CATEGORYMANAGER_CLASSNAME "Category Manager" @@ -168,4 +171,53 @@ private: PRBool mSuppressNotifications; }; +class nsCategoryManagerFactory : public nsIFactory + { + public: + nsCategoryManagerFactory() { } + + NS_DECL_ISUPPORTS + NS_DECL_NSIFACTORY + }; + +// +// BaseStringEnumerator is subclassed by EntryEnumerator and +// CategoryEnumerator +// +class BaseStringEnumerator + : public nsISimpleEnumerator, + nsIUTF8StringEnumerator +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSISIMPLEENUMERATOR + NS_DECL_NSIUTF8STRINGENUMERATOR + +protected: + // Callback function for NS_QuickSort to sort mArray + static int SortCallback(const void *, const void *, void *); + + BaseStringEnumerator() + : mArray(nsnull), + mCount(0), + mSimpleCurItem(0), + mStringCurItem(0) { } + + // A virtual destructor is needed here because subclasses of + // BaseStringEnumerator do not implement their own Release() method. + + virtual ~BaseStringEnumerator() + { + if (mArray) + delete[] mArray; + } + + void Sort(); + + const char** mArray; + PRUint32 mCount; + PRUint32 mSimpleCurItem; + PRUint32 mStringCurItem; +}; + #endif diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index ecba74ad080..4a6cbd8fd3e 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -303,46 +303,6 @@ static const PLDHashTableOps contractID_DHashTableOps = { //////////////////////////////////////////////////////////////////////////////// // Hashtable Enumeration //////////////////////////////////////////////////////////////////////////////// -typedef NS_CALLBACK(EnumeratorConverter)(PLDHashTable *table, - const PLDHashEntryHdr *hdr, - void *data, - nsISupports **retval); - -class PLDHashTableEnumeratorImpl : public nsIBidirectionalEnumerator, - public nsISimpleEnumerator -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIENUMERATOR - NS_DECL_NSIBIDIRECTIONALENUMERATOR - NS_DECL_NSISIMPLEENUMERATOR - - PLDHashTableEnumeratorImpl(PLDHashTable *table, - EnumeratorConverter converter, - void *converterData); - PRInt32 Count() { return mCount; } -private: - PLDHashTableEnumeratorImpl(); /* no implementation */ - - ~PLDHashTableEnumeratorImpl(); - void ReleaseElements(); - - nsVoidArray mElements; - PRInt32 mCount, mCurrent; - PRMonitor* mMonitor; - - struct Closure { - PRBool succeeded; - EnumeratorConverter converter; - void *data; - PLDHashTableEnumeratorImpl *impl; - }; - - static PLDHashOperator PR_CALLBACK Enumerator(PLDHashTable *table, - PLDHashEntryHdr *hdr, - PRUint32 number, - void *data); -}; // static PLDHashOperator PR_CALLBACK @@ -381,11 +341,6 @@ PLDHashTableEnumeratorImpl::PLDHashTableEnumeratorImpl(PLDHashTable *table, } } -NS_IMPL_ISUPPORTS3(PLDHashTableEnumeratorImpl, - nsIBidirectionalEnumerator, - nsIEnumerator, - nsISimpleEnumerator) - PLDHashTableEnumeratorImpl::~PLDHashTableEnumeratorImpl() { ReleaseElements(); @@ -769,16 +724,6 @@ nsComponentManagerImpl::~nsComponentManagerImpl() PR_LOG(nsComponentManagerLog, PR_LOG_DEBUG, ("nsComponentManager: Destroyed.")); } -NS_IMPL_THREADSAFE_ISUPPORTS7(nsComponentManagerImpl, - nsIComponentManager, - nsIServiceManager, - nsISupportsWeakReference, - nsIInterfaceRequestor, - nsIComponentRegistrar, - nsIServiceManagerObsolete, - nsIComponentManagerObsolete) - - nsresult nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result) { diff --git a/xpcom/components/nsComponentManager.h b/xpcom/components/nsComponentManager.h index 2407658582b..313279eb98f 100644 --- a/xpcom/components/nsComponentManager.h +++ b/xpcom/components/nsComponentManager.h @@ -64,6 +64,7 @@ #include "nsCOMArray.h" #include "nsDataHashtable.h" #include "nsTArray.h" +#include "nsIEnumerator.h" struct nsFactoryEntry; class nsIServiceManager; @@ -334,5 +335,46 @@ struct nsContractIDTableEntry : public PLDHashEntryHdr { nsFactoryEntry *mFactoryEntry; }; +typedef NS_CALLBACK(EnumeratorConverter)(PLDHashTable *table, + const PLDHashEntryHdr *hdr, + void *data, + nsISupports **retval); + +class PLDHashTableEnumeratorImpl : public nsIBidirectionalEnumerator, + public nsISimpleEnumerator +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIENUMERATOR + NS_DECL_NSIBIDIRECTIONALENUMERATOR + NS_DECL_NSISIMPLEENUMERATOR + + PLDHashTableEnumeratorImpl(PLDHashTable *table, + EnumeratorConverter converter, + void *converterData); + PRInt32 Count() { return mCount; } +private: + PLDHashTableEnumeratorImpl(); /* no implementation */ + + ~PLDHashTableEnumeratorImpl(); + void ReleaseElements(); + + nsVoidArray mElements; + PRInt32 mCount, mCurrent; + PRMonitor* mMonitor; + + struct Closure { + PRBool succeeded; + EnumeratorConverter converter; + void *data; + PLDHashTableEnumeratorImpl *impl; + }; + + static PLDHashOperator PR_CALLBACK Enumerator(PLDHashTable *table, + PLDHashEntryHdr *hdr, + PRUint32 number, + void *data); +}; + #endif // nsComponentManager_h__ diff --git a/xpcom/components/nsNativeComponentLoader.cpp b/xpcom/components/nsNativeComponentLoader.cpp index 21cf42f2294..f06dbb7012d 100644 --- a/xpcom/components/nsNativeComponentLoader.cpp +++ b/xpcom/components/nsNativeComponentLoader.cpp @@ -87,9 +87,6 @@ static PRLogModuleInfo *nsNativeModuleLoaderLog = #define LOG(level, args) PR_LOG(nsNativeModuleLoaderLog, level, args) -NS_IMPL_QUERY_INTERFACE1(nsNativeModuleLoader, - nsIModuleLoader) - NS_IMPL_ADDREF_USING_AGGREGATOR(nsNativeModuleLoader, nsComponentManagerImpl::gComponentManager) NS_IMPL_RELEASE_USING_AGGREGATOR(nsNativeModuleLoader, diff --git a/xpcom/components/xpcomcomponents.gqi b/xpcom/components/xpcomcomponents.gqi new file mode 100644 index 00000000000..e69de29bb2d diff --git a/xpcom/ds/Makefile.in b/xpcom/ds/Makefile.in index 658e9fdf563..2bcfbf52f86 100644 --- a/xpcom/ds/Makefile.in +++ b/xpcom/ds/Makefile.in @@ -79,6 +79,10 @@ CPPSRCS = \ nsHashPropertyBag.cpp \ $(NULL) +GQI_SRCS = \ + xpcomds.gqi \ + $(NULL) + EXPORTS = \ nsAtomService.h \ nsCheapSets.h \ diff --git a/xpcom/ds/nsArray.cpp b/xpcom/ds/nsArray.cpp index c1292927d9a..91cbb21a165 100644 --- a/xpcom/ds/nsArray.cpp +++ b/xpcom/ds/nsArray.cpp @@ -50,9 +50,6 @@ struct findIndexOfClosure PR_STATIC_CALLBACK(PRBool) FindElementCallback(void* aElement, void* aClosure); - -NS_IMPL_ISUPPORTS2(nsArray, nsIArray, nsIMutableArray) - nsArray::~nsArray() { Clear(); diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index cdea14b2f4e..a4d9a2ae754 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -66,45 +66,6 @@ static PLDHashTable gAtomTable; static PLArenaPool* gStaticAtomArena = 0; -class nsStaticAtomWrapper : public nsIAtom -{ -public: - nsStaticAtomWrapper(const nsStaticAtom* aAtom, PRUint32 aLength) : - mStaticAtom(aAtom), mLength(aLength) - { - MOZ_COUNT_CTOR(nsStaticAtomWrapper); - } - ~nsStaticAtomWrapper() { // no subclasses -> not virtual - // this is arena allocated and won't be called except in debug - // builds. If this function ever does anything non-debug, be sure - // to get rid of the ifdefs in AtomTableClearEntry! - MOZ_COUNT_DTOR(nsStaticAtomWrapper); - } - - NS_IMETHOD QueryInterface(REFNSIID aIID, - void** aInstancePtr); - NS_IMETHOD_(nsrefcnt) AddRef(void); - NS_IMETHOD_(nsrefcnt) Release(void); - - NS_DECL_NSIATOM - - const nsStaticAtom* GetStaticAtom() const { - return mStaticAtom; - } - - PRUint32 getLength() const { - return mLength; - } - -private: - const nsStaticAtom* mStaticAtom; - - // The length of the string in the static atom. The static atom - // (nsStaticAtom) doesn't hold a length, so we keep it here in the - // wrapper instead. - PRUint32 mLength; -}; - // The |key| pointer in the various PLDHashTable callbacks we use is an // AtomTableClearEntry*. These pointers can come from two places: either a // (probably stack-allocated) string key being passed to PL_DHashTableOperate, @@ -444,8 +405,6 @@ AtomImpl::~AtomImpl() } } -NS_IMPL_ISUPPORTS1(AtomImpl, nsIAtom) - PermanentAtomImpl::PermanentAtomImpl() : AtomImpl() { @@ -566,8 +525,6 @@ nsStaticAtomWrapper::Release() return 1; } -NS_IMPL_QUERY_INTERFACE1(nsStaticAtomWrapper, nsIAtom) - NS_IMETHODIMP nsStaticAtomWrapper::GetUTF8String(const char** aResult) { diff --git a/xpcom/ds/nsByteBuffer.cpp b/xpcom/ds/nsByteBuffer.cpp index a51ff9d612a..ae1f5b18006 100644 --- a/xpcom/ds/nsByteBuffer.cpp +++ b/xpcom/ds/nsByteBuffer.cpp @@ -59,8 +59,6 @@ ByteBufferImpl::Init(PRUint32 aBufferSize) return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } -NS_IMPL_ISUPPORTS1(ByteBufferImpl,nsIByteBuffer) - ByteBufferImpl::~ByteBufferImpl() { if (nsnull != mBuffer) { diff --git a/xpcom/ds/nsHashPropertyBag.cpp b/xpcom/ds/nsHashPropertyBag.cpp index 980b07f185b..3ea27ec1c0c 100755 --- a/xpcom/ds/nsHashPropertyBag.cpp +++ b/xpcom/ds/nsHashPropertyBag.cpp @@ -70,13 +70,6 @@ NS_NewHashPropertyBag(nsIWritablePropertyBag* *_retval) NS_IMPL_THREADSAFE_ADDREF(nsHashPropertyBag) NS_IMPL_THREADSAFE_RELEASE(nsHashPropertyBag) -NS_INTERFACE_MAP_BEGIN(nsHashPropertyBag) - NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIPropertyBag, nsIWritablePropertyBag) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWritablePropertyBag) - NS_INTERFACE_MAP_ENTRY(nsIPropertyBag2) - NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag2) -NS_INTERFACE_MAP_END nsresult nsHashPropertyBag::Init() @@ -146,22 +139,6 @@ nsHashPropertyBag::DeleteProperty(const nsAString& name) // nsSimpleProperty class and impl; used for GetEnumerator // -class nsSimpleProperty : public nsIProperty { -public: - nsSimpleProperty(const nsAString& aName, nsIVariant* aValue) - : mName(aName), mValue(aValue) - { - } - - NS_DECL_ISUPPORTS - NS_DECL_NSIPROPERTY -protected: - nsString mName; - nsCOMPtr mValue; -}; - -NS_IMPL_ISUPPORTS1(nsSimpleProperty, nsIProperty) - NS_IMETHODIMP nsSimpleProperty::GetName(nsAString& aName) { diff --git a/xpcom/ds/nsHashPropertyBag.h b/xpcom/ds/nsHashPropertyBag.h index 12d4f5c3da4..93b03a33d7d 100755 --- a/xpcom/ds/nsHashPropertyBag.h +++ b/xpcom/ds/nsHashPropertyBag.h @@ -48,6 +48,7 @@ #include "nsIWritablePropertyBag.h" #include "nsIWritablePropertyBag2.h" #include "nsInterfaceHashtable.h" +#include "nsIProperty.h" // Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration // controls member method visibility. @@ -86,4 +87,18 @@ protected: extern "C" NS_COM nsresult NS_NewHashPropertyBag(nsIWritablePropertyBag* *_retval); +class nsSimpleProperty : public nsIProperty { +public: + nsSimpleProperty(const nsAString& aName, nsIVariant* aValue) + : mName(aName), mValue(aValue) + { + } + + NS_DECL_ISUPPORTS + NS_DECL_NSIPROPERTY +protected: + nsString mName; + nsCOMPtr mValue; +}; + #endif /* nsHashPropertyBag_h___ */ diff --git a/xpcom/ds/nsIByteBuffer.h b/xpcom/ds/nsIByteBuffer.h index 35a73811ddb..abcaf1cd986 100644 --- a/xpcom/ds/nsIByteBuffer.h +++ b/xpcom/ds/nsIByteBuffer.h @@ -43,9 +43,6 @@ class nsIInputStream; -#define NS_IBYTE_BUFFER_IID \ -{ 0xe4a6e4b0, 0x93b4, 0x11d1, \ - {0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} } #define NS_IBYTEBUFFER_IID \ { 0xe4a6e4b0, 0x93b4, 0x11d1, \ {0x89, 0x5b, 0x00, 0x60, 0x08, 0x91, 0x1b, 0x81} } diff --git a/xpcom/ds/nsINIParserImpl.cpp b/xpcom/ds/nsINIParserImpl.cpp index 612b936718f..1ed0ef6be8c 100644 --- a/xpcom/ds/nsINIParserImpl.cpp +++ b/xpcom/ds/nsINIParserImpl.cpp @@ -43,25 +43,6 @@ #include "nsStringEnumerator.h" #include "nsVoidArray.h" -class nsINIParserImpl : - public nsIINIParser -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIINIPARSER - - nsresult Init(nsILocalFile* aINIFile) { - return mParser.Init(aINIFile); - } - -private: - nsINIParser mParser; -}; - -NS_IMPL_ISUPPORTS2(nsINIParserFactory, - nsIINIParserFactory, - nsIFactory) - NS_IMETHODIMP nsINIParserFactory::CreateINIParser(nsILocalFile* aINIFile, nsIINIParser* *aResult) @@ -97,9 +78,6 @@ nsINIParserFactory::LockFactory(PRBool aLock) return NS_OK; } -NS_IMPL_ISUPPORTS1(nsINIParserImpl, - nsIINIParser) - static PRBool SectionCB(const char* aSection, void *aClosure) { diff --git a/xpcom/ds/nsINIParserImpl.h b/xpcom/ds/nsINIParserImpl.h index ef16c3b5994..14ed43d82ba 100644 --- a/xpcom/ds/nsINIParserImpl.h +++ b/xpcom/ds/nsINIParserImpl.h @@ -39,6 +39,7 @@ #define nsINIParserImpl_h__ #include "nsIINIParser.h" +#include "nsINIParser.h" #include "nsIFactory.h" #define NS_INIPARSERFACTORY_CID \ @@ -58,4 +59,19 @@ public: NS_DECL_NSIFACTORY }; +class nsINIParserImpl : + public nsIINIParser +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIINIPARSER + + nsresult Init(nsILocalFile* aINIFile) { + return mParser.Init(aINIFile); + } + +private: + nsINIParser mParser; +}; + #endif // nsINIParserImpl_h__ diff --git a/xpcom/ds/nsIUnicharBuffer.h b/xpcom/ds/nsIUnicharBuffer.h index 28b737e11b0..6faa8b0247c 100644 --- a/xpcom/ds/nsIUnicharBuffer.h +++ b/xpcom/ds/nsIUnicharBuffer.h @@ -39,6 +39,7 @@ #include "nscore.h" #include "nsISupports.h" +#include "prlog.h" #define NS_IUNICHARBUFFER_IID \ { 0x14cf6970, 0x93b5, 0x11d1, \ diff --git a/xpcom/ds/nsObserverList.cpp b/xpcom/ds/nsObserverList.cpp index 697ab89556b..bafacdaf294 100644 --- a/xpcom/ds/nsObserverList.cpp +++ b/xpcom/ds/nsObserverList.cpp @@ -129,8 +129,6 @@ nsObserverList::NotifyObservers(nsISupports *aSubject, } } -NS_IMPL_ISUPPORTS1(nsObserverEnumerator, nsISimpleEnumerator) - nsObserverEnumerator::nsObserverEnumerator(nsObserverList* aObserverList) : mIndex(0) { diff --git a/xpcom/ds/nsPersistentProperties.cpp b/xpcom/ds/nsPersistentProperties.cpp index b0e209fdc27..15892905a14 100644 --- a/xpcom/ds/nsPersistentProperties.cpp +++ b/xpcom/ds/nsPersistentProperties.cpp @@ -141,8 +141,6 @@ nsPersistentProperties::Create(nsISupports *aOuter, REFNSIID aIID, void **aResul return rv; } -NS_IMPL_THREADSAFE_ISUPPORTS2(nsPersistentProperties, nsIPersistentProperties, nsIProperties) - NS_IMETHODIMP nsPersistentProperties::Load(nsIInputStream *aIn) { @@ -478,8 +476,6 @@ nsPropertyElement::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) return rv; } -NS_IMPL_ISUPPORTS1(nsPropertyElement, nsIPropertyElement) - NS_IMETHODIMP nsPropertyElement::GetKey(nsACString& aReturnKey) { diff --git a/xpcom/ds/nsStaticAtom.h b/xpcom/ds/nsStaticAtom.h index 6c76d0161e7..2a744e8e841 100644 --- a/xpcom/ds/nsStaticAtom.h +++ b/xpcom/ds/nsStaticAtom.h @@ -56,6 +56,44 @@ struct nsStaticAtom { nsIAtom ** mAtom; }; +class nsStaticAtomWrapper : public nsIAtom +{ +public: + nsStaticAtomWrapper(const nsStaticAtom* aAtom, PRUint32 aLength) : + mStaticAtom(aAtom), mLength(aLength) + { + MOZ_COUNT_CTOR(nsStaticAtomWrapper); + } + ~nsStaticAtomWrapper() { // no subclasses -> not virtual + // this is arena allocated and won't be called except in debug + // builds. If this function ever does anything non-debug, be sure + // to get rid of the ifdefs in AtomTableClearEntry! + MOZ_COUNT_DTOR(nsStaticAtomWrapper); + } + + NS_IMETHOD QueryInterface(REFNSIID aIID, + void** aInstancePtr); + NS_IMETHOD_(nsrefcnt) AddRef(void); + NS_IMETHOD_(nsrefcnt) Release(void); + + NS_DECL_NSIATOM + + const nsStaticAtom* GetStaticAtom() const { + return mStaticAtom; + } + + PRUint32 getLength() const { + return mLength; + } + +private: + const nsStaticAtom* mStaticAtom; + + // The length of the string in the static atom. The static atom + // (nsStaticAtom) doesn't hold a length, so we keep it here in the + // wrapper instead. + PRUint32 mLength; +}; // register your lookup function with the atom table. Your function // will be called when at atom is not found in the main atom table. diff --git a/xpcom/ds/nsStringEnumerator.cpp b/xpcom/ds/nsStringEnumerator.cpp index 76960c8fac3..0753433f2e9 100644 --- a/xpcom/ds/nsStringEnumerator.cpp +++ b/xpcom/ds/nsStringEnumerator.cpp @@ -49,73 +49,6 @@ // nsStringEnumerator // -class nsStringEnumerator : public nsIStringEnumerator, - public nsIUTF8StringEnumerator, - public nsISimpleEnumerator -{ -public: - nsStringEnumerator(const nsStringArray* aArray, PRBool aOwnsArray) : - mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE) - {} - - nsStringEnumerator(const nsCStringArray* aArray, PRBool aOwnsArray) : - mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE) - {} - - nsStringEnumerator(const nsStringArray* aArray, nsISupports* aOwner) : - mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE) - {} - - nsStringEnumerator(const nsCStringArray* aArray, nsISupports* aOwner) : - mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE) - {} - - NS_DECL_ISUPPORTS - NS_DECL_NSIUTF8STRINGENUMERATOR - - // have to declare nsIStringEnumerator manually, because of - // overlapping method names - NS_IMETHOD GetNext(nsAString& aResult); - NS_DECL_NSISIMPLEENUMERATOR - -private: - ~nsStringEnumerator() { - if (mOwnsArray) { - // const-casting is safe here, because the NS_New* - // constructors make sure mOwnsArray is consistent with - // the constness of the objects - if (mIsUnicode) - delete const_cast(mArray); - else - delete const_cast(mCArray); - } - } - - union { - const nsStringArray* mArray; - const nsCStringArray* mCArray; - }; - - inline PRUint32 Count() { - return mIsUnicode ? mArray->Count() : mCArray->Count(); - } - - PRUint32 mIndex; - - // the owner allows us to hold a strong reference to the object - // that owns the array. Having a non-null value in mOwner implies - // that mOwnsArray is PR_FALSE, because we rely on the real owner - // to release the array - nsCOMPtr mOwner; - PRPackedBool mOwnsArray; - PRPackedBool mIsUnicode; -}; - -NS_IMPL_ISUPPORTS3(nsStringEnumerator, - nsIStringEnumerator, - nsIUTF8StringEnumerator, - nsISimpleEnumerator) - NS_IMETHODIMP nsStringEnumerator::HasMore(PRBool* aResult) { diff --git a/xpcom/ds/nsStringEnumerator.h b/xpcom/ds/nsStringEnumerator.h index 5ee83405590..1b376ba57c4 100644 --- a/xpcom/ds/nsStringEnumerator.h +++ b/xpcom/ds/nsStringEnumerator.h @@ -38,6 +38,8 @@ #include "nsIStringEnumerator.h" #include "nsVoidArray.h" +#include "nsISimpleEnumerator.h" +#include "nsCOMPtr.h" // nsIStringEnumerator/nsIUTF8StringEnumerator implementations // @@ -120,3 +122,65 @@ NS_COM nsresult NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult, const nsCStringArray* aArray, nsISupports* aOwner); + +class nsStringEnumerator : public nsIStringEnumerator, + public nsIUTF8StringEnumerator, + public nsISimpleEnumerator +{ +public: + nsStringEnumerator(const nsStringArray* aArray, PRBool aOwnsArray) : + mArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_TRUE) + {} + + nsStringEnumerator(const nsCStringArray* aArray, PRBool aOwnsArray) : + mCArray(aArray), mIndex(0), mOwnsArray(aOwnsArray), mIsUnicode(PR_FALSE) + {} + + nsStringEnumerator(const nsStringArray* aArray, nsISupports* aOwner) : + mArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_TRUE) + {} + + nsStringEnumerator(const nsCStringArray* aArray, nsISupports* aOwner) : + mCArray(aArray), mIndex(0), mOwner(aOwner), mOwnsArray(PR_FALSE), mIsUnicode(PR_FALSE) + {} + + NS_DECL_ISUPPORTS + NS_DECL_NSIUTF8STRINGENUMERATOR + + // have to declare nsIStringEnumerator manually, because of + // overlapping method names + NS_IMETHOD GetNext(nsAString& aResult); + NS_DECL_NSISIMPLEENUMERATOR + +private: + ~nsStringEnumerator() { + if (mOwnsArray) { + // const-casting is safe here, because the NS_New* + // constructors make sure mOwnsArray is consistent with + // the constness of the objects + if (mIsUnicode) + delete const_cast(mArray); + else + delete const_cast(mCArray); + } + } + + union { + const nsStringArray* mArray; + const nsCStringArray* mCArray; + }; + + inline PRUint32 Count() { + return mIsUnicode ? mArray->Count() : mCArray->Count(); + } + + PRUint32 mIndex; + + // the owner allows us to hold a strong reference to the object + // that owns the array. Having a non-null value in mOwner implies + // that mOwnsArray is PR_FALSE, because we rely on the real owner + // to release the array + nsCOMPtr mOwner; + PRPackedBool mOwnsArray; + PRPackedBool mIsUnicode; +}; diff --git a/xpcom/ds/nsSupportsArray.cpp b/xpcom/ds/nsSupportsArray.cpp index f1b092537de..bea210e575e 100644 --- a/xpcom/ds/nsSupportsArray.cpp +++ b/xpcom/ds/nsSupportsArray.cpp @@ -216,8 +216,6 @@ nsSupportsArray::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) return it->QueryInterface(aIID, aResult); } -NS_IMPL_THREADSAFE_ISUPPORTS3(nsSupportsArray, nsISupportsArray, nsICollection, nsISerializable) - NS_IMETHODIMP nsSupportsArray::Read(nsIObjectInputStream *aStream) { @@ -682,27 +680,6 @@ NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult) return rv; } -class nsArrayEnumerator : public nsISimpleEnumerator -{ -public: - // nsISupports interface - NS_DECL_ISUPPORTS - - // nsISimpleEnumerator interface - NS_IMETHOD HasMoreElements(PRBool* aResult); - NS_IMETHOD GetNext(nsISupports** aResult); - - // nsArrayEnumerator methods - nsArrayEnumerator(nsISupportsArray* aValueArray); - -private: - ~nsArrayEnumerator(void); - -protected: - nsISupportsArray* mValueArray; - PRInt32 mIndex; -}; - nsArrayEnumerator::nsArrayEnumerator(nsISupportsArray* aValueArray) : mValueArray(aValueArray), mIndex(0) @@ -715,8 +692,6 @@ nsArrayEnumerator::~nsArrayEnumerator(void) NS_IF_RELEASE(mValueArray); } -NS_IMPL_ISUPPORTS1(nsArrayEnumerator, nsISimpleEnumerator) - NS_IMETHODIMP nsArrayEnumerator::HasMoreElements(PRBool* aResult) { diff --git a/xpcom/ds/nsSupportsArray.h b/xpcom/ds/nsSupportsArray.h index 07f3abd8c96..d49eac84620 100644 --- a/xpcom/ds/nsSupportsArray.h +++ b/xpcom/ds/nsSupportsArray.h @@ -168,4 +168,25 @@ private: nsSupportsArray(const nsISupportsArray& other); }; +class nsArrayEnumerator : public nsISimpleEnumerator +{ +public: + // nsISupports interface + NS_DECL_ISUPPORTS + + // nsISimpleEnumerator interface + NS_IMETHOD HasMoreElements(PRBool* aResult); + NS_IMETHOD GetNext(nsISupports** aResult); + + // nsArrayEnumerator methods + nsArrayEnumerator(nsISupportsArray* aValueArray); + +private: + ~nsArrayEnumerator(void); + +protected: + nsISupportsArray* mValueArray; + PRInt32 mIndex; +}; + #endif // nsSupportsArray_h__ diff --git a/xpcom/ds/nsSupportsArrayEnumerator.cpp b/xpcom/ds/nsSupportsArrayEnumerator.cpp index 38d7d728d56..5016c8c3181 100644 --- a/xpcom/ds/nsSupportsArrayEnumerator.cpp +++ b/xpcom/ds/nsSupportsArrayEnumerator.cpp @@ -50,8 +50,6 @@ nsSupportsArrayEnumerator::~nsSupportsArrayEnumerator() NS_RELEASE(mArray); } -NS_IMPL_ISUPPORTS2(nsSupportsArrayEnumerator, nsIBidirectionalEnumerator, nsIEnumerator) - NS_IMETHODIMP nsSupportsArrayEnumerator::First() { diff --git a/xpcom/ds/nsSupportsPrimitives.cpp b/xpcom/ds/nsSupportsPrimitives.cpp index 7fe5502a384..cceacc19e0e 100644 --- a/xpcom/ds/nsSupportsPrimitives.cpp +++ b/xpcom/ds/nsSupportsPrimitives.cpp @@ -47,8 +47,6 @@ /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive) - nsSupportsIDImpl::nsSupportsIDImpl() : mData(nsnull) { @@ -107,9 +105,6 @@ NS_IMETHODIMP nsSupportsIDImpl::ToString(char **_retval) * nsSupportsCStringImpl *****************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsCStringImpl, nsISupportsCString, - nsISupportsPrimitive) - NS_IMETHODIMP nsSupportsCStringImpl::GetType(PRUint16 *aType) { NS_ASSERTION(aType, "Bad pointer"); @@ -144,9 +139,6 @@ NS_IMETHODIMP nsSupportsCStringImpl::SetData(const nsACString& aData) * nsSupportsStringImpl *****************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString, - nsISupportsPrimitive) - NS_IMETHODIMP nsSupportsStringImpl::GetType(PRUint16 *aType) { NS_ASSERTION(aType, "Bad pointer"); @@ -179,9 +171,6 @@ NS_IMETHODIMP nsSupportsStringImpl::SetData(const nsAString& aData) /***************************************************************************/ -NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool, - nsISupportsPrimitive) - nsSupportsPRBoolImpl::nsSupportsPRBoolImpl() : mData(PR_FALSE) { @@ -220,9 +209,6 @@ NS_IMETHODIMP nsSupportsPRBoolImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRUint8Impl, nsISupportsPRUint8, - nsISupportsPrimitive) - nsSupportsPRUint8Impl::nsSupportsPRUint8Impl() : mData(0) { @@ -265,9 +251,6 @@ NS_IMETHODIMP nsSupportsPRUint8Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRUint16Impl, nsISupportsPRUint16, - nsISupportsPrimitive) - nsSupportsPRUint16Impl::nsSupportsPRUint16Impl() : mData(0) { @@ -310,9 +293,6 @@ NS_IMETHODIMP nsSupportsPRUint16Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRUint32Impl, nsISupportsPRUint32, - nsISupportsPrimitive) - nsSupportsPRUint32Impl::nsSupportsPRUint32Impl() : mData(0) { @@ -355,9 +335,6 @@ NS_IMETHODIMP nsSupportsPRUint32Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRUint64Impl, nsISupportsPRUint64, - nsISupportsPrimitive) - nsSupportsPRUint64Impl::nsSupportsPRUint64Impl() : mData(LL_ZERO) { @@ -400,9 +377,6 @@ NS_IMETHODIMP nsSupportsPRUint64Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRTimeImpl, nsISupportsPRTime, - nsISupportsPrimitive) - nsSupportsPRTimeImpl::nsSupportsPRTimeImpl() : mData(LL_ZERO) { @@ -445,9 +419,6 @@ NS_IMETHODIMP nsSupportsPRTimeImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsCharImpl, nsISupportsChar, - nsISupportsPrimitive) - nsSupportsCharImpl::nsSupportsCharImpl() : mData(0) { @@ -490,9 +461,6 @@ NS_IMETHODIMP nsSupportsCharImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRInt16Impl, nsISupportsPRInt16, - nsISupportsPrimitive) - nsSupportsPRInt16Impl::nsSupportsPRInt16Impl() : mData(0) { @@ -535,9 +503,6 @@ NS_IMETHODIMP nsSupportsPRInt16Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRInt32Impl, nsISupportsPRInt32, - nsISupportsPrimitive) - nsSupportsPRInt32Impl::nsSupportsPRInt32Impl() : mData(0) { @@ -580,9 +545,6 @@ NS_IMETHODIMP nsSupportsPRInt32Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsPRInt64Impl, nsISupportsPRInt64, - nsISupportsPrimitive) - nsSupportsPRInt64Impl::nsSupportsPRInt64Impl() : mData(LL_ZERO) { @@ -625,9 +587,6 @@ NS_IMETHODIMP nsSupportsPRInt64Impl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsFloatImpl, nsISupportsFloat, - nsISupportsPrimitive) - nsSupportsFloatImpl::nsSupportsFloatImpl() : mData(float(0.0)) { @@ -670,9 +629,6 @@ NS_IMETHODIMP nsSupportsFloatImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsDoubleImpl, nsISupportsDouble, - nsISupportsPrimitive) - nsSupportsDoubleImpl::nsSupportsDoubleImpl() : mData(double(0.0)) { @@ -716,9 +672,6 @@ NS_IMETHODIMP nsSupportsDoubleImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid, - nsISupportsPrimitive) - nsSupportsVoidImpl::nsSupportsVoidImpl() : mData(nsnull) { @@ -758,10 +711,6 @@ NS_IMETHODIMP nsSupportsVoidImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsInterfacePointerImpl, - nsISupportsInterfacePointer, - nsISupportsPrimitive) - nsSupportsInterfacePointerImpl::nsSupportsInterfacePointerImpl() : mIID(nsnull) { @@ -839,8 +788,6 @@ NS_IMETHODIMP nsSupportsInterfacePointerImpl::ToString(char **_retval) /***************************************************************************/ -NS_IMPL_ISUPPORTS2(nsSupportsDependentCString,nsISupportsCString,nsISupportsPrimitive) - nsSupportsDependentCString::nsSupportsDependentCString(const char* aStr) : mData(aStr) { } diff --git a/xpcom/ds/nsUnicharBuffer.cpp b/xpcom/ds/nsUnicharBuffer.cpp index 12033da04b7..de898b15657 100644 --- a/xpcom/ds/nsUnicharBuffer.cpp +++ b/xpcom/ds/nsUnicharBuffer.cpp @@ -74,8 +74,6 @@ UnicharBufferImpl::Init(PRUint32 aBufferSize) return mBuffer ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } -NS_IMPL_ISUPPORTS1(UnicharBufferImpl, nsIUnicharBuffer) - UnicharBufferImpl::~UnicharBufferImpl() { if (nsnull != mBuffer) { diff --git a/xpcom/ds/nsVariant.cpp b/xpcom/ds/nsVariant.cpp index c33621b977b..f78ac96e85b 100644 --- a/xpcom/ds/nsVariant.cpp +++ b/xpcom/ds/nsVariant.cpp @@ -1689,8 +1689,6 @@ nsVariant::Traverse(const nsDiscriminatedUnion& data, /***************************************************************************/ // members... -NS_IMPL_ISUPPORTS2(nsVariant, nsIVariant, nsIWritableVariant) - nsVariant::nsVariant() : mWritable(PR_TRUE) { diff --git a/xpcom/ds/xpcomds.gqi b/xpcom/ds/xpcomds.gqi new file mode 100644 index 00000000000..a41d0e9d786 --- /dev/null +++ b/xpcom/ds/xpcomds.gqi @@ -0,0 +1,135 @@ +%import-idl "nsIMutableArray.idl" +%import-idl "nsIProperty.idl" +%import-idl "nsIINIParser.idl" +%import-idl "nsIFactory.idl" +%import-idl "nsIVariant.idl" +%import-idl "nsIPersistentProperties2.idl" +%import-idl "nsISimpleEnumerator.idl" +%import-idl "nsIStringEnumerator.idl" +%import-idl "nsISupportsArray.idl" +%import-idl "nsISerializable.idl" +%import-idl "nsIAtom.idl" +%import-idl "nsISupportsPrimitives.idl" +%import-idl "nsIWritablePropertyBag.idl" +%import-idl "nsIWritablePropertyBag2.idl" + +%{C++ +#include "nsArray.h" +#include "nsIByteBuffer.h" +#include "nsHashPropertyBag.h" +#include "nsINIParserImpl.h" +#include "nsVariant.h" +#include "nsByteBuffer.h" +#include "nsPersistentProperties.h" +#include "nsUnicharBuffer.h" +#include "nsObserverList.h" +#include "nsStringEnumerator.h" +#include "nsSupportsArray.h" +#include "nsAtomTable.h" +#include "nsStaticAtom.h" +#include "nsSupportsArrayEnumerator.h" +#include "nsSupportsPrimitives.h" +%} + +%pseudo-iid nsIByteBuffer e4a6e4b0-93b4-11d1-895b-006008911b81 +%pseudo-iid nsIUnicharBuffer 14cf6970-93b5-11d1-895b-006008911b81 + +NS_IMPL_ISUPPORTS2(nsArray, nsIArray, nsIMutableArray) + +NS_IMPL_ISUPPORTS1(nsSimpleProperty, nsIProperty) + +NS_IMPL_ISUPPORTS2(nsINIParserFactory, + nsIINIParserFactory, + nsIFactory) + +NS_IMPL_ISUPPORTS1(nsINIParserImpl, + nsIINIParser) + +NS_IMPL_ISUPPORTS2(nsVariant, nsIVariant, nsIWritableVariant) + +NS_IMPL_ISUPPORTS1(ByteBufferImpl,nsIByteBuffer) + +NS_IMPL_THREADSAFE_ISUPPORTS2(nsPersistentProperties, nsIPersistentProperties, nsIProperties) + +NS_INTERFACE_MAP_BEGIN(nsHashPropertyBag) + NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIPropertyBag, nsIWritablePropertyBag) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWritablePropertyBag) + NS_INTERFACE_MAP_ENTRY(nsIPropertyBag2) + NS_INTERFACE_MAP_ENTRY(nsIWritablePropertyBag2) +NS_INTERFACE_MAP_END + +NS_IMPL_ISUPPORTS1(nsPropertyElement, nsIPropertyElement) + +NS_IMPL_ISUPPORTS1(UnicharBufferImpl, nsIUnicharBuffer) + +NS_IMPL_ISUPPORTS1(nsObserverEnumerator, nsISimpleEnumerator) + +NS_IMPL_ISUPPORTS3(nsStringEnumerator, + nsIStringEnumerator, + nsIUTF8StringEnumerator, + nsISimpleEnumerator) + +NS_IMPL_THREADSAFE_ISUPPORTS3(nsSupportsArray, nsISupportsArray, nsICollection, nsISerializable) + +NS_IMPL_ISUPPORTS1(nsArrayEnumerator, nsISimpleEnumerator) + +NS_IMPL_ISUPPORTS1(AtomImpl, nsIAtom) + +NS_IMPL_QUERY_INTERFACE1(nsStaticAtomWrapper, nsIAtom) + +NS_IMPL_ISUPPORTS2(nsSupportsArrayEnumerator, nsIBidirectionalEnumerator, nsIEnumerator) + +NS_IMPL_ISUPPORTS2(nsSupportsIDImpl, nsISupportsID, nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsCStringImpl, nsISupportsCString, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsStringImpl, nsISupportsString, + nsISupportsPrimitive) + +NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsPRBoolImpl, nsISupportsPRBool, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRUint8Impl, nsISupportsPRUint8, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRUint16Impl, nsISupportsPRUint16, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRUint32Impl, nsISupportsPRUint32, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRUint64Impl, nsISupportsPRUint64, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRTimeImpl, nsISupportsPRTime, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsCharImpl, nsISupportsChar, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRInt16Impl, nsISupportsPRInt16, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRInt32Impl, nsISupportsPRInt32, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsPRInt64Impl, nsISupportsPRInt64, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsFloatImpl, nsISupportsFloat, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsDoubleImpl, nsISupportsDouble, + nsISupportsPrimitive) + +NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsVoidImpl, nsISupportsVoid, + nsISupportsPrimitive) + +NS_IMPL_THREADSAFE_ISUPPORTS2(nsSupportsInterfacePointerImpl, + nsISupportsInterfacePointer, + nsISupportsPrimitive) + +NS_IMPL_ISUPPORTS2(nsSupportsDependentCString,nsISupportsCString,nsISupportsPrimitive) +