From 9a92abfadcb581232f54049457143b15f07f1ec4 Mon Sep 17 00:00:00 2001 From: "peterv%netscape.com" Date: Tue, 15 May 2001 20:35:23 +0000 Subject: [PATCH] Add DOM ClassInfo for Transformiix classes. r=Pike, sr=jst. --- dom/public/nsIDOMClassInfo.h | 5 + dom/src/base/nsDOMClassInfo.cpp | 8 ++ .../build/XSLTProcessorModule.cpp | 10 +- .../public/nsIXPathNodeSelector.idl | 8 +- .../source/xpath/XPathProcessor.cpp | 110 +++++++----------- .../source/xpath/XPathProcessor.h | 10 +- .../transformiix/source/xpath/nsNodeSet.cpp | 23 +++- .../source/xslt/XSLTProcessor.cpp | 23 +++- 8 files changed, 102 insertions(+), 95 deletions(-) diff --git a/dom/public/nsIDOMClassInfo.h b/dom/public/nsIDOMClassInfo.h index 286a5a50f03..6a3acbea8bd 100644 --- a/dom/public/nsIDOMClassInfo.h +++ b/dom/public/nsIDOMClassInfo.h @@ -173,6 +173,11 @@ enum nsDOMClassInfoID { eDOMClassInfo_DOMSerializer_id, eDOMClassInfo_DOMParser_id, + // Transformiix classes + eDOMClassInfo_XSLTProcessor_id, + eDOMClassInfo_XPathProcessor_id, + eDOMClassInfo_NodeSet_id, + // This one better be the last one in this list eDOMClassInfoIDCount }; diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index dd0e5c8551f..fcc9918db4b 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -476,6 +476,14 @@ nsDOMClassInfoData sClassInfoData[] = { DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(DOMParser, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) + + // Transformiix classes + NS_DEFINE_CLASSINFO_DATA(XSLTProcessor, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(XPathProcessor, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(NodeSet, nsArraySH, + ARRAY_SCRIPTABLE_FLAGS) }; nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull; diff --git a/extensions/transformiix/build/XSLTProcessorModule.cpp b/extensions/transformiix/build/XSLTProcessorModule.cpp index 5fc1f8dac98..00583b3de62 100755 --- a/extensions/transformiix/build/XSLTProcessorModule.cpp +++ b/extensions/transformiix/build/XSLTProcessorModule.cpp @@ -26,13 +26,11 @@ #include "nsIGenericFactory.h" #include "nsICategoryManager.h" #include "nsIScriptNameSpaceManager.h" -#include "prprf.h" +#include "nsXPIDLString.h" #include "XSLTProcessor.h" #include "XPathProcessor.h" #include "nsSyncLoader.h" -#include "nsIScriptNameSpaceManager.h" -#include "nsXPIDLString.h" // Factory Constructor NS_GENERIC_FACTORY_CONSTRUCTOR(XSLTProcessor) @@ -41,9 +39,9 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSyncLoader) static NS_METHOD RegisterTransformiix(nsIComponentManager *aCompMgr, - nsIFile *aPath, - const char *registryLocation, - const char *componentType, + nsIFile *aPath, + const char *registryLocation, + const char *componentType, const nsModuleComponentInfo *info) { nsresult rv = NS_OK; diff --git a/extensions/transformiix/public/nsIXPathNodeSelector.idl b/extensions/transformiix/public/nsIXPathNodeSelector.idl index 3b41c1a4aa1..223fe7de998 100644 --- a/extensions/transformiix/public/nsIXPathNodeSelector.idl +++ b/extensions/transformiix/public/nsIXPathNodeSelector.idl @@ -14,8 +14,10 @@ #include "nsISupports.idl" -interface nsIDOMNode; -interface nsIDOMNodeList; +#include "domstubs.idl" +%{C++ +#include "nsString.h" +%} /** * The nsIXPathNodeSelector can be used to query a DOM tree using XPath. @@ -35,7 +37,7 @@ interface nsIXPathNodeSelector : nsISupports * @returns The result of the XPath query. */ nsIDOMNodeList selectNodes(in nsIDOMNode aContextNode, - in string aPattern); + in DOMString aPattern); }; diff --git a/extensions/transformiix/source/xpath/XPathProcessor.cpp b/extensions/transformiix/source/xpath/XPathProcessor.cpp index 19605f7fa3e..c0059dc293b 100644 --- a/extensions/transformiix/source/xpath/XPathProcessor.cpp +++ b/extensions/transformiix/source/xpath/XPathProcessor.cpp @@ -28,28 +28,48 @@ #include "ProcessorState.h" #include "Expr.h" #include "nsNodeSet.h" +#include "nsIDOMClassInfo.h" -NS_IMPL_ISUPPORTS2(XPathProcessor, - nsIXPathNodeSelector, - nsISecurityCheckedComponent) -/** +// XPConnect interface list for XPathProcessor +NS_CLASSINFO_MAP_BEGIN(XPathProcessor) + NS_CLASSINFO_MAP_ENTRY(nsIXPathNodeSelector) +NS_CLASSINFO_MAP_END + + +// QueryInterface implementation for XPathProcessor +NS_INTERFACE_MAP_BEGIN(XPathProcessor) + NS_INTERFACE_MAP_ENTRY(nsIXPathNodeSelector) + NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XPathProcessor) +NS_INTERFACE_MAP_END + + +NS_IMPL_ADDREF(XPathProcessor) +NS_IMPL_RELEASE(XPathProcessor) + + +/* * Creates a new XPathProcessor -**/ -XPathProcessor::XPathProcessor() { - - NS_INIT_ISUPPORTS(); -} //-- XPathProcessor - -/** - * Default destructor -**/ -XPathProcessor::~XPathProcessor() { -} //-- ~XPathProcessor - -/* nsIDOMNodeList selectNodes (in nsIDOMNode aContextNode, in string aPattern); */ -NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char *aPattern, nsIDOMNodeList **_retval) + */ +XPathProcessor::XPathProcessor() { + NS_INIT_ISUPPORTS(); +} + +/* + * Default destructor + */ +XPathProcessor::~XPathProcessor() +{ +} + +/* nsIDOMNodeList selectNodes (in nsIDOMNode aContextNode, in DOMString aPattern); */ +NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, + const nsAReadableString & aPattern, + nsIDOMNodeList **_retval) +{ + String pattern(PromiseFlatString(aPattern).get()); + nsCOMPtr aOwnerDOMDocument; aContextNode->GetOwnerDocument(getter_AddRefs(aOwnerDOMDocument)); nsCOMPtr aOwnerDocument = do_QueryInterface(aOwnerDOMDocument); @@ -59,10 +79,10 @@ NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char * ProcessorState* aProcessorState = new ProcessorState(); ExprParser aParser; - Expr* aExpression = aParser.createExpr(aPattern); + Expr* aExpression = aParser.createExpr(pattern); ExprResult* exprResult = aExpression->evaluate(aNode, aProcessorState); nsNodeSet* resultSet; - if ( exprResult->getResultType() == ExprResult::NODESET ) { + if (exprResult->getResultType() == ExprResult::NODESET) { resultSet = new nsNodeSet((NodeSet*)exprResult); } else { @@ -79,53 +99,3 @@ NS_IMETHODIMP XPathProcessor::SelectNodes(nsIDOMNode *aContextNode, const char * return NS_OK; } - -/* - * nsISecurityCheckedComponent - */ - -static const char* kAllAccess = "AllAccess"; - -/* string canCreateWrapper (in nsIIDPtr iid); */ -NS_IMETHODIMP -XPathProcessor::CanCreateWrapper(const nsIID * iid, char **_retval) -{ - if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) { - *_retval = nsCRT::strdup(kAllAccess); - } - - return NS_OK; -} - -/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */ -NS_IMETHODIMP -XPathProcessor::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval) -{ - if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) { - *_retval = nsCRT::strdup(kAllAccess); - } - - return NS_OK; -} - -/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -XPathProcessor::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval) -{ - if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) { - *_retval = nsCRT::strdup(kAllAccess); - } - - return NS_OK; -} - -/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */ -NS_IMETHODIMP -XPathProcessor::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval) -{ - if (iid->Equals(NS_GET_IID(nsIXPathNodeSelector))) { - *_retval = nsCRT::strdup(kAllAccess); - } - - return NS_OK; -} diff --git a/extensions/transformiix/source/xpath/XPathProcessor.h b/extensions/transformiix/source/xpath/XPathProcessor.h index 3f41204738c..9d3197f240a 100644 --- a/extensions/transformiix/source/xpath/XPathProcessor.h +++ b/extensions/transformiix/source/xpath/XPathProcessor.h @@ -27,7 +27,6 @@ #define XPathProcessor_h__ #include "nsIXPathNodeSelector.h" -#include "nsISecurityCheckedComponent.h" /* e4172588-1dd1-11b2-bf09-ec309437245a */ #define TRANSFORMIIX_XPATH_PROCESSOR_CID \ @@ -39,8 +38,7 @@ /** * A class for processing an XPath query **/ -class XPathProcessor : public nsIXPathNodeSelector, - public nsISecurityCheckedComponent +class XPathProcessor : public nsIXPathNodeSelector { public: /** @@ -58,10 +56,6 @@ public: // nsIXPathNodeSelector interface NS_DECL_NSIXPATHNODESELECTOR - - // nsISecurityCheckedComponent - NS_DECL_NSISECURITYCHECKEDCOMPONENT - -}; //-- XPathProcessor +}; #endif diff --git a/extensions/transformiix/source/xpath/nsNodeSet.cpp b/extensions/transformiix/source/xpath/nsNodeSet.cpp index c2c907d543b..4264d1ebd24 100644 --- a/extensions/transformiix/source/xpath/nsNodeSet.cpp +++ b/extensions/transformiix/source/xpath/nsNodeSet.cpp @@ -24,14 +24,27 @@ */ #include "nsNodeSet.h" -#include "nsDOMCID.h" -#include "nsIDOMScriptObjectFactory.h" -#include "nsIScriptGlobalObject.h" -#include "nsIServiceManager.h" +#include "nsIDOMClassInfo.h" static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); -NS_IMPL_ISUPPORTS1(nsNodeSet, nsIDOMNodeList) + +// XPConnect interface list for NodeSet +NS_CLASSINFO_MAP_BEGIN(NodeSet) + NS_CLASSINFO_MAP_ENTRY(nsIDOMNodeList) +NS_CLASSINFO_MAP_END + + +// QueryInterface implementation for nsNodeSet +NS_INTERFACE_MAP_BEGIN(nsNodeSet) + NS_INTERFACE_MAP_ENTRY(nsIDOMNodeList) + NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(NodeSet) +NS_INTERFACE_MAP_END + + +NS_IMPL_ADDREF(nsNodeSet) +NS_IMPL_RELEASE(nsNodeSet) + nsNodeSet::nsNodeSet(NodeSet* aNodeSet) { NS_INIT_ISUPPORTS(); diff --git a/extensions/transformiix/source/xslt/XSLTProcessor.cpp b/extensions/transformiix/source/xslt/XSLTProcessor.cpp index 40d5adb7703..e02cda516bd 100644 --- a/extensions/transformiix/source/xslt/XSLTProcessor.cpp +++ b/extensions/transformiix/source/xslt/XSLTProcessor.cpp @@ -38,7 +38,7 @@ * Olivier Gerardin * -- Changed behavior of passing parameters to templates * - * $Id: XSLTProcessor.cpp,v 1.46 2001-05-15 06:13:02 axel%pike.org Exp $ + * $Id: XSLTProcessor.cpp,v 1.47 2001-05-15 20:34:58 peterv%netscape.com Exp $ */ #include "XSLTProcessor.h" @@ -59,6 +59,7 @@ #include "nsILoadGroup.h" #include "nsIChannel.h" #include "nsNetCID.h" +#include "nsIDOMClassInfo.h" //#include "nslog.h" #else #include "printers.h" @@ -72,7 +73,7 @@ /** * XSLTProcessor is a class for Processing XSL stylesheets * @author Keith Visco - * @version $Revision: 1.46 $ $Date: 2001-05-15 06:13:02 $ + * @version $Revision: 1.47 $ $Date: 2001-05-15 20:34:58 $ **/ /** @@ -138,7 +139,23 @@ XSLTProcessor::~XSLTProcessor() { } //-- ~XSLTProcessor #ifdef MOZ_XSL -NS_IMPL_ISUPPORTS1(XSLTProcessor, nsIDocumentTransformer) + +// XPConnect interface list for XSLTProcessor +NS_CLASSINFO_MAP_BEGIN(XSLTProcessor) + NS_CLASSINFO_MAP_ENTRY(nsIDocumentTransformer) +NS_CLASSINFO_MAP_END + + +// QueryInterface implementation for XSLTProcessor +NS_INTERFACE_MAP_BEGIN(XSLTProcessor) + NS_INTERFACE_MAP_ENTRY(nsIDocumentTransformer) + NS_INTERFACE_MAP_ENTRY_DOM_CLASSINFO(XSLTProcessor) +NS_INTERFACE_MAP_END + + +NS_IMPL_ADDREF(XSLTProcessor) +NS_IMPL_RELEASE(XSLTProcessor) + #endif /**