diff options
author | Pale Moon <git-repo@palemoon.org> | 2016-09-01 13:39:08 +0200 |
---|---|---|
committer | Pale Moon <git-repo@palemoon.org> | 2016-09-01 13:39:08 +0200 |
commit | 3d8ce1a11a7347cc94a937719c4bc8df46fb8d14 (patch) | |
tree | 8c26ca375a6312751c00a27e1653fb6f189f0463 /rdf | |
parent | e449bdb1ec3a82f204bffdd9c3c54069d086eee3 (diff) | |
download | palemoon-gre-3d8ce1a11a7347cc94a937719c4bc8df46fb8d14.tar.gz |
Base import of Tycho code (warning: huge commit)
Diffstat (limited to 'rdf')
-rw-r--r-- | rdf/base/idl/moz.build | 33 | ||||
-rw-r--r-- | rdf/base/idl/xulstubs.idl | 31 | ||||
-rw-r--r-- | rdf/base/moz.build | 52 | ||||
-rw-r--r-- | rdf/base/nsCompositeDataSource.cpp (renamed from rdf/base/src/nsCompositeDataSource.cpp) | 10 | ||||
-rw-r--r-- | rdf/base/nsContainerEnumerator.cpp (renamed from rdf/base/src/nsContainerEnumerator.cpp) | 15 | ||||
-rw-r--r-- | rdf/base/nsDefaultResourceFactory.cpp (renamed from rdf/base/src/nsDefaultResourceFactory.cpp) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFCompositeDataSource.idl (renamed from rdf/base/idl/nsIRDFCompositeDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFContainer.idl (renamed from rdf/base/idl/nsIRDFContainer.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFContainerUtils.idl (renamed from rdf/base/idl/nsIRDFContainerUtils.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFContentSink.h (renamed from rdf/base/public/nsIRDFContentSink.h) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFDataSource.idl (renamed from rdf/base/idl/nsIRDFDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFDelegateFactory.idl (renamed from rdf/base/idl/nsIRDFDelegateFactory.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFInMemoryDataSource.idl (renamed from rdf/base/idl/nsIRDFInMemoryDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFInferDataSource.idl (renamed from rdf/base/idl/nsIRDFInferDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFLiteral.idl (renamed from rdf/base/idl/nsIRDFLiteral.idl) | 2 | ||||
-rw-r--r-- | rdf/base/nsIRDFNode.idl (renamed from rdf/base/idl/nsIRDFNode.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFObserver.idl (renamed from rdf/base/idl/nsIRDFObserver.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFPropagatableDataSource.idl (renamed from rdf/base/idl/nsIRDFPropagatableDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFPurgeableDataSource.idl (renamed from rdf/base/idl/nsIRDFPurgeableDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFRemoteDataSource.idl (renamed from rdf/base/idl/nsIRDFRemoteDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFResource.idl (renamed from rdf/base/idl/nsIRDFResource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFService.idl (renamed from rdf/base/idl/nsIRDFService.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFXMLParser.idl (renamed from rdf/base/idl/nsIRDFXMLParser.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFXMLSerializer.idl (renamed from rdf/base/idl/nsIRDFXMLSerializer.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFXMLSink.idl (renamed from rdf/base/idl/nsIRDFXMLSink.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsIRDFXMLSource.idl (renamed from rdf/base/idl/nsIRDFXMLSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/nsInMemoryDataSource.cpp (renamed from rdf/base/src/nsInMemoryDataSource.cpp) | 259 | ||||
-rw-r--r-- | rdf/base/nsNameSpaceMap.cpp (renamed from rdf/base/src/nsNameSpaceMap.cpp) | 0 | ||||
-rw-r--r-- | rdf/base/nsNameSpaceMap.h (renamed from rdf/base/src/nsNameSpaceMap.h) | 2 | ||||
-rw-r--r-- | rdf/base/nsRDFBaseDataSources.h (renamed from rdf/base/src/nsRDFBaseDataSources.h) | 0 | ||||
-rw-r--r-- | rdf/base/nsRDFContainer.cpp (renamed from rdf/base/src/nsRDFContainer.cpp) | 17 | ||||
-rw-r--r-- | rdf/base/nsRDFContainerUtils.cpp (renamed from rdf/base/src/nsRDFContainerUtils.cpp) | 11 | ||||
-rw-r--r-- | rdf/base/nsRDFContentSink.cpp (renamed from rdf/base/src/nsRDFContentSink.cpp) | 173 | ||||
-rw-r--r-- | rdf/base/nsRDFContentSinkAtomList.h (renamed from rdf/base/src/nsRDFContentSinkAtomList.h) | 0 | ||||
-rw-r--r-- | rdf/base/nsRDFService.cpp (renamed from rdf/base/src/nsRDFService.cpp) | 255 | ||||
-rw-r--r-- | rdf/base/nsRDFService.h (renamed from rdf/base/src/nsRDFService.h) | 4 | ||||
-rw-r--r-- | rdf/base/nsRDFXMLDataSource.cpp (renamed from rdf/base/src/nsRDFXMLDataSource.cpp) | 100 | ||||
-rw-r--r-- | rdf/base/nsRDFXMLParser.cpp (renamed from rdf/base/src/nsRDFXMLParser.cpp) | 14 | ||||
-rw-r--r-- | rdf/base/nsRDFXMLParser.h (renamed from rdf/base/src/nsRDFXMLParser.h) | 0 | ||||
-rw-r--r-- | rdf/base/nsRDFXMLSerializer.cpp (renamed from rdf/base/src/nsRDFXMLSerializer.cpp) | 24 | ||||
-rw-r--r-- | rdf/base/nsRDFXMLSerializer.h (renamed from rdf/base/src/nsRDFXMLSerializer.h) | 0 | ||||
-rw-r--r-- | rdf/base/public/moz.build | 13 | ||||
-rw-r--r-- | rdf/base/rdf.h (renamed from rdf/base/public/rdf.h) | 0 | ||||
-rw-r--r-- | rdf/base/rdfIDataSource.idl (renamed from rdf/base/idl/rdfIDataSource.idl) | 0 | ||||
-rw-r--r-- | rdf/base/rdfISerializer.idl (renamed from rdf/base/idl/rdfISerializer.idl) | 0 | ||||
-rw-r--r-- | rdf/base/rdfITripleVisitor.idl (renamed from rdf/base/idl/rdfITripleVisitor.idl) | 0 | ||||
-rw-r--r-- | rdf/base/rdfTriplesSerializer.cpp (renamed from rdf/base/src/rdfTriplesSerializer.cpp) | 15 | ||||
-rw-r--r-- | rdf/base/rdfutil.cpp (renamed from rdf/base/src/rdfutil.cpp) | 6 | ||||
-rw-r--r-- | rdf/base/rdfutil.h (renamed from rdf/base/src/rdfutil.h) | 1 | ||||
-rw-r--r-- | rdf/base/src/Makefile.in | 19 | ||||
-rw-r--r-- | rdf/base/src/moz.build | 27 | ||||
-rw-r--r-- | rdf/build/Makefile.in | 32 | ||||
-rw-r--r-- | rdf/build/moz.build | 12 | ||||
-rw-r--r-- | rdf/build/nsRDFModule.cpp | 58 | ||||
-rw-r--r-- | rdf/datasource/moz.build | 20 | ||||
-rw-r--r-- | rdf/datasource/nsFileSystemDataSource.cpp (renamed from rdf/datasource/src/nsFileSystemDataSource.cpp) | 35 | ||||
-rw-r--r-- | rdf/datasource/nsFileSystemDataSource.h (renamed from rdf/datasource/src/nsFileSystemDataSource.h) | 4 | ||||
-rw-r--r-- | rdf/datasource/nsILocalStore.h (renamed from rdf/datasource/public/nsILocalStore.h) | 0 | ||||
-rw-r--r-- | rdf/datasource/nsIRDFFTP.h (renamed from rdf/datasource/public/nsIRDFFTP.h) | 0 | ||||
-rw-r--r-- | rdf/datasource/nsLocalStore.cpp (renamed from rdf/datasource/src/nsLocalStore.cpp) | 65 | ||||
-rw-r--r-- | rdf/datasource/nsRDFBuiltInDataSources.h (renamed from rdf/datasource/src/nsRDFBuiltInDataSources.h) | 0 | ||||
-rw-r--r-- | rdf/datasource/src/Makefile.in | 23 | ||||
-rw-r--r-- | rdf/datasource/src/moz.build | 15 | ||||
-rw-r--r-- | rdf/moz.build | 4 | ||||
-rw-r--r-- | rdf/tests/dsds/DataSourceViewer.css | 34 | ||||
-rw-r--r-- | rdf/tests/dsds/DataSourceViewer.xul | 38 | ||||
-rw-r--r-- | rdf/tests/dsds/Makefile.in | 41 | ||||
-rw-r--r-- | rdf/tests/dsds/moz.build | 15 | ||||
-rw-r--r-- | rdf/tests/dsds/nsRDFDOMDataSource.cpp | 86 | ||||
-rw-r--r-- | rdf/tests/dsds/nsRDFDataSourceDS.cpp | 456 | ||||
-rw-r--r-- | rdf/tests/dsds/nsRDFDataSourceDS.h | 19 | ||||
-rw-r--r-- | rdf/tests/dsds/nsRDFDataSourceFactory.cpp | 70 | ||||
-rw-r--r-- | rdf/tests/moz.build | 4 | ||||
-rw-r--r-- | rdf/tests/rdfcat/Makefile.in | 26 | ||||
-rw-r--r-- | rdf/tests/rdfcat/moz.build | 8 | ||||
-rw-r--r-- | rdf/tests/rdfcat/rdfcat.cpp | 18 | ||||
-rw-r--r-- | rdf/tests/rdfpoll/Makefile.in | 23 | ||||
-rw-r--r-- | rdf/tests/rdfpoll/moz.build | 6 | ||||
-rw-r--r-- | rdf/tests/rdfpoll/rdfpoll.cpp | 7 | ||||
-rw-r--r-- | rdf/tests/triplescat/Makefile.in | 26 | ||||
-rw-r--r-- | rdf/tests/triplescat/moz.build | 8 | ||||
-rw-r--r-- | rdf/tests/triplescat/triplescat.cpp | 18 | ||||
-rw-r--r-- | rdf/tests/unit/xpcshell.ini | 6 | ||||
-rw-r--r-- | rdf/util/Makefile.in (renamed from rdf/util/src/Makefile.in) | 17 | ||||
-rw-r--r-- | rdf/util/internal/moz.build (renamed from rdf/util/src/internal/moz.build) | 9 | ||||
-rw-r--r-- | rdf/util/moz.build | 16 | ||||
-rw-r--r-- | rdf/util/nsRDFResource.cpp (renamed from rdf/util/src/nsRDFResource.cpp) | 4 | ||||
-rw-r--r-- | rdf/util/nsRDFResource.h (renamed from rdf/util/public/nsRDFResource.h) | 20 | ||||
-rw-r--r-- | rdf/util/objs.mozbuild (renamed from rdf/datasource/public/moz.build) | 9 | ||||
-rw-r--r-- | rdf/util/public/moz.build | 12 | ||||
-rw-r--r-- | rdf/util/src/internal/Makefile.in | 31 | ||||
-rw-r--r-- | rdf/util/src/moz.build | 16 | ||||
-rw-r--r-- | rdf/util/src/objs.mk | 9 |
93 files changed, 648 insertions, 1755 deletions
diff --git a/rdf/base/idl/moz.build b/rdf/base/idl/moz.build deleted file mode 100644 index 5951cc018..000000000 --- a/rdf/base/idl/moz.build +++ /dev/null @@ -1,33 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -XPIDL_SOURCES += [ - 'nsIRDFCompositeDataSource.idl', - 'nsIRDFContainer.idl', - 'nsIRDFContainerUtils.idl', - 'nsIRDFDataSource.idl', - 'nsIRDFDelegateFactory.idl', - 'nsIRDFInMemoryDataSource.idl', - 'nsIRDFInferDataSource.idl', - 'nsIRDFLiteral.idl', - 'nsIRDFNode.idl', - 'nsIRDFObserver.idl', - 'nsIRDFPropagatableDataSource.idl', - 'nsIRDFPurgeableDataSource.idl', - 'nsIRDFRemoteDataSource.idl', - 'nsIRDFResource.idl', - 'nsIRDFService.idl', - 'nsIRDFXMLParser.idl', - 'nsIRDFXMLSerializer.idl', - 'nsIRDFXMLSink.idl', - 'nsIRDFXMLSource.idl', - 'rdfIDataSource.idl', - 'rdfISerializer.idl', - 'rdfITripleVisitor.idl', -] - -MODULE = 'rdf' - diff --git a/rdf/base/idl/xulstubs.idl b/rdf/base/idl/xulstubs.idl deleted file mode 100644 index 4d828cdca..000000000 --- a/rdf/base/idl/xulstubs.idl +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* DOM stubs so that we can pass DOM objects across XPConnect */ - -%{C++ -/* C++ should ignore this file because there are real DOM interfaces - elsewhere, so if 0 it out -*/ -#if 0 -%} - -#include "domstubs.idl" - -[scriptable, uuid(7FB67F1D-F1FF-450A-9A63-261344E13AC4)] -interface nsIDOMXULElement : nsIDOMElement {}; - -[scriptable, uuid(E3F0D263-10A2-4703-BD5F-E68F32F4DC31)] -interface nsIDOMXULTreeElement : nsIDOMXULElement {}; - -[scriptable, uuid(f3c50361-14fe-11d3-bf87-00105a1b0627)] -interface nsIDOMXULCommandDispatcher : nsISupports {}; - -[scriptable, uuid(17ddd8c0-c5f8-11d2-a6ae-00104bde6048)] -interface nsIDOMXULDocument : nsISupports {}; - -%{C++ -#endif -%} diff --git a/rdf/base/moz.build b/rdf/base/moz.build index ccafce8f3..7fa8a52c0 100644 --- a/rdf/base/moz.build +++ b/rdf/base/moz.build @@ -4,4 +4,54 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += ['idl', 'public', 'src'] +XPIDL_SOURCES += [ + 'nsIRDFCompositeDataSource.idl', + 'nsIRDFContainer.idl', + 'nsIRDFContainerUtils.idl', + 'nsIRDFDataSource.idl', + 'nsIRDFDelegateFactory.idl', + 'nsIRDFInferDataSource.idl', + 'nsIRDFInMemoryDataSource.idl', + 'nsIRDFLiteral.idl', + 'nsIRDFNode.idl', + 'nsIRDFObserver.idl', + 'nsIRDFPropagatableDataSource.idl', + 'nsIRDFPurgeableDataSource.idl', + 'nsIRDFRemoteDataSource.idl', + 'nsIRDFResource.idl', + 'nsIRDFService.idl', + 'nsIRDFXMLParser.idl', + 'nsIRDFXMLSerializer.idl', + 'nsIRDFXMLSink.idl', + 'nsIRDFXMLSource.idl', + 'rdfIDataSource.idl', + 'rdfISerializer.idl', + 'rdfITripleVisitor.idl', +] + +XPIDL_MODULE = 'rdf' + +EXPORTS += [ + 'nsIRDFContentSink.h', + 'rdf.h', +] + +UNIFIED_SOURCES += [ + 'nsCompositeDataSource.cpp', + 'nsContainerEnumerator.cpp', + 'nsDefaultResourceFactory.cpp', + 'nsInMemoryDataSource.cpp', + 'nsNameSpaceMap.cpp', + 'nsRDFContainer.cpp', + 'nsRDFContainerUtils.cpp', + 'nsRDFContentSink.cpp', + 'nsRDFService.cpp', + 'nsRDFXMLDataSource.cpp', + 'nsRDFXMLParser.cpp', + 'nsRDFXMLSerializer.cpp', + 'rdfTriplesSerializer.cpp', + 'rdfutil.cpp', +] + +FAIL_ON_WARNINGS = True +FINAL_LIBRARY = 'xul' diff --git a/rdf/base/src/nsCompositeDataSource.cpp b/rdf/base/nsCompositeDataSource.cpp index e2b848927..7760dc5c6 100644 --- a/rdf/base/src/nsCompositeDataSource.cpp +++ b/rdf/base/nsCompositeDataSource.cpp @@ -42,15 +42,13 @@ #include "nsEnumeratorUtils.h" -#ifdef DEBUG +#ifdef PR_LOGGING #include "prlog.h" #include "prprf.h" #include <stdio.h> PRLogModuleInfo* nsRDFLog = nullptr; #endif -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); - //---------------------------------------------------------------------- // // CompositeDataSourceImpl @@ -65,7 +63,7 @@ class CompositeDataSourceImpl : public nsIRDFCompositeDataSource, { public: CompositeDataSourceImpl(void); - CompositeDataSourceImpl(char** dataSources); + explicit CompositeDataSourceImpl(char** dataSources); // nsISupports interface NS_DECL_CYCLE_COLLECTING_ISUPPORTS @@ -162,7 +160,7 @@ CompositeEnumeratorImpl::~CompositeEnumeratorImpl(void) NS_IMPL_ADDREF(CompositeEnumeratorImpl) NS_IMPL_RELEASE(CompositeEnumeratorImpl) -NS_IMPL_QUERY_INTERFACE1(CompositeEnumeratorImpl, nsISimpleEnumerator) +NS_IMPL_QUERY_INTERFACE(CompositeEnumeratorImpl, nsISimpleEnumerator) NS_IMETHODIMP CompositeEnumeratorImpl::HasMoreElements(bool* aResult) @@ -505,6 +503,8 @@ CompositeDataSourceImpl::CompositeDataSourceImpl(void) // nsISupports interface // +NS_IMPL_CYCLE_COLLECTION_CLASS(CompositeDataSourceImpl) + NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CompositeDataSourceImpl) uint32_t i, count = tmp->mDataSources.Count(); for (i = count; i > 0; --i) { diff --git a/rdf/base/src/nsContainerEnumerator.cpp b/rdf/base/nsContainerEnumerator.cpp index d91963806..b26988b47 100644 --- a/rdf/base/src/nsContainerEnumerator.cpp +++ b/rdf/base/nsContainerEnumerator.cpp @@ -36,11 +36,6 @@ //////////////////////////////////////////////////////////////////////// -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); - -//////////////////////////////////////////////////////////////////////// - class ContainerEnumeratorImpl : public nsISimpleEnumerator { private: // pseudo-constants @@ -56,9 +51,10 @@ private: nsCOMPtr<nsIRDFNode> mResult; int32_t mNextIndex; + virtual ~ContainerEnumeratorImpl(); + public: ContainerEnumeratorImpl(nsIRDFDataSource* ds, nsIRDFResource* container); - virtual ~ContainerEnumeratorImpl(); nsresult Init(); @@ -84,6 +80,8 @@ ContainerEnumeratorImpl::Init() { if (gRefCnt++ == 0) { nsresult rv; + + NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); nsCOMPtr<nsIRDFService> rdf = do_GetService(kRDFServiceCID); NS_ASSERTION(rdf != nullptr, "unable to acquire resource manager"); if (! rdf) @@ -93,6 +91,7 @@ ContainerEnumeratorImpl::Init() NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get resource"); if (NS_FAILED(rv)) return rv; + NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); rv = CallGetService(kRDFContainerUtilsCID, &gRDFC); if (NS_FAILED(rv)) return rv; } @@ -109,7 +108,7 @@ ContainerEnumeratorImpl::~ContainerEnumeratorImpl() } } -NS_IMPL_ISUPPORTS1(ContainerEnumeratorImpl, nsISimpleEnumerator) +NS_IMPL_ISUPPORTS(ContainerEnumeratorImpl, nsISimpleEnumerator) NS_IMETHODIMP @@ -156,7 +155,7 @@ ContainerEnumeratorImpl::HasMoreElements(bool* aResult) if (! nextValLiteral) continue; - const PRUnichar *nextValStr; + const char16_t *nextValStr; nextValLiteral->GetValueConst(&nextValStr); nsresult err; diff --git a/rdf/base/src/nsDefaultResourceFactory.cpp b/rdf/base/nsDefaultResourceFactory.cpp index 448822a9d..448822a9d 100644 --- a/rdf/base/src/nsDefaultResourceFactory.cpp +++ b/rdf/base/nsDefaultResourceFactory.cpp diff --git a/rdf/base/idl/nsIRDFCompositeDataSource.idl b/rdf/base/nsIRDFCompositeDataSource.idl index 071b8f3ac..071b8f3ac 100644 --- a/rdf/base/idl/nsIRDFCompositeDataSource.idl +++ b/rdf/base/nsIRDFCompositeDataSource.idl diff --git a/rdf/base/idl/nsIRDFContainer.idl b/rdf/base/nsIRDFContainer.idl index 78352b2b3..78352b2b3 100644 --- a/rdf/base/idl/nsIRDFContainer.idl +++ b/rdf/base/nsIRDFContainer.idl diff --git a/rdf/base/idl/nsIRDFContainerUtils.idl b/rdf/base/nsIRDFContainerUtils.idl index 21cb0b625..21cb0b625 100644 --- a/rdf/base/idl/nsIRDFContainerUtils.idl +++ b/rdf/base/nsIRDFContainerUtils.idl diff --git a/rdf/base/public/nsIRDFContentSink.h b/rdf/base/nsIRDFContentSink.h index 293e8baad..293e8baad 100644 --- a/rdf/base/public/nsIRDFContentSink.h +++ b/rdf/base/nsIRDFContentSink.h diff --git a/rdf/base/idl/nsIRDFDataSource.idl b/rdf/base/nsIRDFDataSource.idl index df383330a..df383330a 100644 --- a/rdf/base/idl/nsIRDFDataSource.idl +++ b/rdf/base/nsIRDFDataSource.idl diff --git a/rdf/base/idl/nsIRDFDelegateFactory.idl b/rdf/base/nsIRDFDelegateFactory.idl index 6fbc42fd5..6fbc42fd5 100644 --- a/rdf/base/idl/nsIRDFDelegateFactory.idl +++ b/rdf/base/nsIRDFDelegateFactory.idl diff --git a/rdf/base/idl/nsIRDFInMemoryDataSource.idl b/rdf/base/nsIRDFInMemoryDataSource.idl index 35734efe6..35734efe6 100644 --- a/rdf/base/idl/nsIRDFInMemoryDataSource.idl +++ b/rdf/base/nsIRDFInMemoryDataSource.idl diff --git a/rdf/base/idl/nsIRDFInferDataSource.idl b/rdf/base/nsIRDFInferDataSource.idl index 07bafcfff..07bafcfff 100644 --- a/rdf/base/idl/nsIRDFInferDataSource.idl +++ b/rdf/base/nsIRDFInferDataSource.idl diff --git a/rdf/base/idl/nsIRDFLiteral.idl b/rdf/base/nsIRDFLiteral.idl index 33f618afb..3d289c4fe 100644 --- a/rdf/base/idl/nsIRDFLiteral.idl +++ b/rdf/base/nsIRDFLiteral.idl @@ -6,7 +6,7 @@ #include "nsIRDFNode.idl" %{C++ -#include "nscore.h" // for PRUnichar +#include "nscore.h" // for char16_t %} [ptr] native const_octet_ptr(const uint8_t); diff --git a/rdf/base/idl/nsIRDFNode.idl b/rdf/base/nsIRDFNode.idl index 2bd7d4967..2bd7d4967 100644 --- a/rdf/base/idl/nsIRDFNode.idl +++ b/rdf/base/nsIRDFNode.idl diff --git a/rdf/base/idl/nsIRDFObserver.idl b/rdf/base/nsIRDFObserver.idl index 1923c5b38..1923c5b38 100644 --- a/rdf/base/idl/nsIRDFObserver.idl +++ b/rdf/base/nsIRDFObserver.idl diff --git a/rdf/base/idl/nsIRDFPropagatableDataSource.idl b/rdf/base/nsIRDFPropagatableDataSource.idl index dfe510e9c..dfe510e9c 100644 --- a/rdf/base/idl/nsIRDFPropagatableDataSource.idl +++ b/rdf/base/nsIRDFPropagatableDataSource.idl diff --git a/rdf/base/idl/nsIRDFPurgeableDataSource.idl b/rdf/base/nsIRDFPurgeableDataSource.idl index 05973df0e..05973df0e 100644 --- a/rdf/base/idl/nsIRDFPurgeableDataSource.idl +++ b/rdf/base/nsIRDFPurgeableDataSource.idl diff --git a/rdf/base/idl/nsIRDFRemoteDataSource.idl b/rdf/base/nsIRDFRemoteDataSource.idl index fd2cd1b0b..fd2cd1b0b 100644 --- a/rdf/base/idl/nsIRDFRemoteDataSource.idl +++ b/rdf/base/nsIRDFRemoteDataSource.idl diff --git a/rdf/base/idl/nsIRDFResource.idl b/rdf/base/nsIRDFResource.idl index df4d4b8ff..df4d4b8ff 100644 --- a/rdf/base/idl/nsIRDFResource.idl +++ b/rdf/base/nsIRDFResource.idl diff --git a/rdf/base/idl/nsIRDFService.idl b/rdf/base/nsIRDFService.idl index 08023feab..08023feab 100644 --- a/rdf/base/idl/nsIRDFService.idl +++ b/rdf/base/nsIRDFService.idl diff --git a/rdf/base/idl/nsIRDFXMLParser.idl b/rdf/base/nsIRDFXMLParser.idl index 1e7dde51f..1e7dde51f 100644 --- a/rdf/base/idl/nsIRDFXMLParser.idl +++ b/rdf/base/nsIRDFXMLParser.idl diff --git a/rdf/base/idl/nsIRDFXMLSerializer.idl b/rdf/base/nsIRDFXMLSerializer.idl index e16ef2a2a..e16ef2a2a 100644 --- a/rdf/base/idl/nsIRDFXMLSerializer.idl +++ b/rdf/base/nsIRDFXMLSerializer.idl diff --git a/rdf/base/idl/nsIRDFXMLSink.idl b/rdf/base/nsIRDFXMLSink.idl index 8c9d9461c..8c9d9461c 100644 --- a/rdf/base/idl/nsIRDFXMLSink.idl +++ b/rdf/base/nsIRDFXMLSink.idl diff --git a/rdf/base/idl/nsIRDFXMLSource.idl b/rdf/base/nsIRDFXMLSource.idl index 794d8b662..794d8b662 100644 --- a/rdf/base/idl/nsIRDFXMLSource.idl +++ b/rdf/base/nsIRDFXMLSource.idl diff --git a/rdf/base/src/nsInMemoryDataSource.cpp b/rdf/base/nsInMemoryDataSource.cpp index 529fc9fd1..d09163583 100644 --- a/rdf/base/src/nsInMemoryDataSource.cpp +++ b/rdf/base/nsInMemoryDataSource.cpp @@ -69,11 +69,6 @@ #include "rdfIDataSource.h" #include "rdfITripleVisitor.h" -#ifdef PR_LOGGING -static PRLogModuleInfo* gLog = nullptr; -#endif - - // This struct is used as the slot value in the forward and reverse // arcs hash tables. // @@ -92,10 +87,12 @@ public: nsIRDFResource* aProperty, nsIRDFNode* aTarget, bool aTruthValue); - Assertion(nsIRDFResource* aSource); // PLDHashTable assertion variant + explicit Assertion(nsIRDFResource* aSource); // PLDHashTable assertion variant +private: ~Assertion(); +public: void AddRef() { if (mRefCnt == UINT16_MAX) { NS_WARNING("refcount overflow, leaking Assertion"); @@ -149,8 +146,7 @@ public: }; -struct Entry { - PLDHashEntryHdr mHdr; +struct Entry : PLDHashEntryHdr { nsIRDFNode* mNode; Assertion* mAssertions; }; @@ -162,12 +158,12 @@ Assertion::Assertion(nsIRDFResource* aSource) mRefCnt(0), mHashEntry(true) { - MOZ_COUNT_CTOR(RDF_Assertion); + MOZ_COUNT_CTOR(Assertion); NS_ADDREF(mSource); - u.hash.mPropertyHash = PL_NewDHashTable(PL_DHashGetStubOps(), - nullptr, sizeof(Entry), PL_DHASH_MIN_SIZE); + u.hash.mPropertyHash = + PL_NewDHashTable(PL_DHashGetStubOps(), sizeof(Entry)); } Assertion::Assertion(nsIRDFResource* aSource, @@ -179,7 +175,7 @@ Assertion::Assertion(nsIRDFResource* aSource, mRefCnt(0), mHashEntry(false) { - MOZ_COUNT_CTOR(RDF_Assertion); + MOZ_COUNT_CTOR(Assertion); u.as.mProperty = aProperty; u.as.mTarget = aTarget; @@ -197,12 +193,12 @@ Assertion::~Assertion() { if (mHashEntry && u.hash.mPropertyHash) { PL_DHashTableEnumerate(u.hash.mPropertyHash, DeletePropertyHashEntry, - NULL); + nullptr); PL_DHashTableDestroy(u.hash.mPropertyHash); u.hash.mPropertyHash = nullptr; } - MOZ_COUNT_DTOR(RDF_Assertion); + MOZ_COUNT_DTOR(Assertion); #ifdef DEBUG_REFS --gInstanceCount; fprintf(stdout, "%d - RDF: Assertion\n", gInstanceCount); @@ -220,7 +216,7 @@ PLDHashOperator Assertion::DeletePropertyHashEntry(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); Assertion* as = entry->mAssertions; while (as) { @@ -288,7 +284,7 @@ protected: nsIRDFResource* property, nsIRDFNode* target); - InMemoryDataSource(nsISupports* aOuter); + explicit InMemoryDataSource(nsISupports* aOuter); virtual ~InMemoryDataSource(); nsresult Init(); @@ -323,37 +319,45 @@ public: // Implementation methods Assertion* GetForwardArcs(nsIRDFResource* u) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mForwardArcs, u, PL_DHASH_LOOKUP); - return PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; } + PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mForwardArcs, u); + return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; + } Assertion* GetReverseArcs(nsIRDFNode* v) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mReverseArcs, v, PL_DHASH_LOOKUP); - return PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; } + PLDHashEntryHdr* hdr = PL_DHashTableSearch(&mReverseArcs, v); + return hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; + } void SetForwardArcs(nsIRDFResource* u, Assertion* as) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mForwardArcs, u, - as ? PL_DHASH_ADD : PL_DHASH_REMOVE); - if (as && hdr) { - Entry* entry = reinterpret_cast<Entry*>(hdr); - entry->mNode = u; - entry->mAssertions = as; - } } + if (as) { + Entry* entry = static_cast<Entry*> + (PL_DHashTableAdd(&mForwardArcs, u, mozilla::fallible)); + if (entry) { + entry->mNode = u; + entry->mAssertions = as; + } + } + else { + PL_DHashTableRemove(&mForwardArcs, u); + } + } void SetReverseArcs(nsIRDFNode* v, Assertion* as) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(&mReverseArcs, v, - as ? PL_DHASH_ADD : PL_DHASH_REMOVE); - if (as && hdr) { - Entry* entry = reinterpret_cast<Entry*>(hdr); - entry->mNode = v; - entry->mAssertions = as; - } } + if (as) { + Entry* entry = static_cast<Entry*> + (PL_DHashTableAdd(&mReverseArcs, v, mozilla::fallible)); + if (entry) { + entry->mNode = v; + entry->mAssertions = as; + } + } + else { + PL_DHashTableRemove(&mReverseArcs, v); + } + } #ifdef PR_LOGGING void @@ -365,8 +369,17 @@ public: #endif bool mPropagateChanges; + +private: +#ifdef PR_LOGGING + static PRLogModuleInfo* gLog; +#endif }; +#ifdef PR_LOGGING +PRLogModuleInfo* InMemoryDataSource::gLog; +#endif + //---------------------------------------------------------------------- // // InMemoryAssertionEnumeratorImpl @@ -387,6 +400,8 @@ private: Assertion* mNextAssertion; nsCOMPtr<nsISupportsArray> mHashArcs; + virtual ~InMemoryAssertionEnumeratorImpl(); + public: InMemoryAssertionEnumeratorImpl(InMemoryDataSource* aDataSource, nsIRDFResource* aSource, @@ -394,8 +409,6 @@ public: nsIRDFNode* aTarget, bool aTruthValue); - virtual ~InMemoryAssertionEnumeratorImpl(); - // nsISupports interface NS_DECL_ISUPPORTS @@ -430,11 +443,11 @@ InMemoryAssertionEnumeratorImpl::InMemoryAssertionEnumeratorImpl( if (mNextAssertion && mNextAssertion->mHashEntry) { // its our magical HASH_ENTRY forward hash for assertions - PLDHashEntryHdr* hdr = PL_DHashTableOperate(mNextAssertion->u.hash.mPropertyHash, - aProperty, PL_DHASH_LOOKUP); - mNextAssertion = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(mNextAssertion->u.hash.mPropertyHash, + aProperty); + mNextAssertion = + hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; } } else { @@ -465,7 +478,7 @@ InMemoryAssertionEnumeratorImpl::~InMemoryAssertionEnumeratorImpl() NS_IMPL_ADDREF(InMemoryAssertionEnumeratorImpl) NS_IMPL_RELEASE(InMemoryAssertionEnumeratorImpl) -NS_IMPL_QUERY_INTERFACE1(InMemoryAssertionEnumeratorImpl, nsISimpleEnumerator) +NS_IMPL_QUERY_INTERFACE(InMemoryAssertionEnumeratorImpl, nsISimpleEnumerator) NS_IMETHODIMP InMemoryAssertionEnumeratorImpl::HasMoreElements(bool* aResult) @@ -559,13 +572,13 @@ private: ArcEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg); + virtual ~InMemoryArcsEnumeratorImpl(); + public: InMemoryArcsEnumeratorImpl(InMemoryDataSource* aDataSource, nsIRDFResource* aSource, nsIRDFNode* aTarget); - virtual ~InMemoryArcsEnumeratorImpl(); - // nsISupports interface NS_DECL_ISUPPORTS @@ -579,7 +592,7 @@ InMemoryArcsEnumeratorImpl::ArcEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); nsISupportsArray* resources = static_cast<nsISupportsArray*>(aArg); resources->AppendElement(entry->mNode); @@ -633,7 +646,7 @@ InMemoryArcsEnumeratorImpl::~InMemoryArcsEnumeratorImpl() NS_IMPL_ADDREF(InMemoryArcsEnumeratorImpl) NS_IMPL_RELEASE(InMemoryArcsEnumeratorImpl) -NS_IMPL_QUERY_INTERFACE1(InMemoryArcsEnumeratorImpl, nsISimpleEnumerator) +NS_IMPL_QUERY_INTERFACE(InMemoryArcsEnumeratorImpl, nsISimpleEnumerator) NS_IMETHODIMP InMemoryArcsEnumeratorImpl::HasMoreElements(bool* aResult) @@ -766,31 +779,16 @@ InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter) { NS_INIT_AGGREGATED(aOuter); - mForwardArcs.ops = nullptr; - mReverseArcs.ops = nullptr; mPropagateChanges = true; + MOZ_COUNT_CTOR(InMemoryDataSource); } nsresult InMemoryDataSource::Init() { - if (!PL_DHashTableInit(&mForwardArcs, - PL_DHashGetStubOps(), - nullptr, - sizeof(Entry), - PL_DHASH_MIN_SIZE)) { - mForwardArcs.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } - if (!PL_DHashTableInit(&mReverseArcs, - PL_DHashGetStubOps(), - nullptr, - sizeof(Entry), - PL_DHASH_MIN_SIZE)) { - mReverseArcs.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } + PL_DHashTableInit(&mForwardArcs, PL_DHashGetStubOps(), sizeof(Entry)); + PL_DHashTableInit(&mReverseArcs, PL_DHashGetStubOps(), sizeof(Entry)); #ifdef PR_LOGGING if (! gLog) @@ -808,27 +806,28 @@ InMemoryDataSource::~InMemoryDataSource() fprintf(stdout, "%d - RDF: InMemoryDataSource\n", gInstanceCount); #endif - if (mForwardArcs.ops) { + if (mForwardArcs.IsInitialized()) { // This'll release all of the Assertion objects that are // associated with this data source. We only need to do this // for the forward arcs, because the reverse arcs table // indexes the exact same set of resources. - PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, NULL); + PL_DHashTableEnumerate(&mForwardArcs, DeleteForwardArcsEntry, nullptr); PL_DHashTableFinish(&mForwardArcs); } - if (mReverseArcs.ops) + if (mReverseArcs.IsInitialized()) PL_DHashTableFinish(&mReverseArcs); PR_LOG(gLog, PR_LOG_NOTICE, ("InMemoryDataSource(%p): destroyed.", this)); + MOZ_COUNT_DTOR(InMemoryDataSource); } PLDHashOperator InMemoryDataSource::DeleteForwardArcsEntry(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); Assertion* as = entry->mAssertions; while (as) { @@ -845,6 +844,8 @@ InMemoryDataSource::DeleteForwardArcsEntry(PLDHashTable* aTable, PLDHashEntryHdr //////////////////////////////////////////////////////////////////////// +NS_IMPL_CYCLE_COLLECTION_CLASS(InMemoryDataSource) + NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(InMemoryDataSource) NS_IMPL_CYCLE_COLLECTION_UNLINK(mObservers) NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -977,10 +978,9 @@ InMemoryDataSource::GetTarget(nsIRDFResource* source, Assertion *as = GetForwardArcs(source); if (as && as->mHashEntry) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(as->u.hash.mPropertyHash, property, PL_DHASH_LOOKUP); - Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(as->u.hash.mPropertyHash, property); + Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; while (val) { if (tv == val->u.as.mTruthValue) { *target = val->u.as.mTarget; @@ -1023,10 +1023,9 @@ InMemoryDataSource::HasAssertion(nsIRDFResource* source, Assertion *as = GetForwardArcs(source); if (as && as->mHashEntry) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(as->u.hash.mPropertyHash, property, PL_DHASH_LOOKUP); - Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(as->u.hash.mPropertyHash, property); + Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; while (val) { if ((val->u.as.mTarget == target) && (tv == (val->u.as.mTruthValue))) { *hasAssertion = true; @@ -1136,10 +1135,9 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource, bool haveHash = (next) ? next->mHashEntry : false; if (haveHash) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash, aProperty, PL_DHASH_LOOKUP); - Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty); + Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; while (val) { if (val->u.as.mTarget == aTarget) { // Wow, we already had the assertion. Make sure that the @@ -1177,11 +1175,10 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource, if (haveHash) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash, - aProperty, PL_DHASH_LOOKUP); - Assertion *asRef = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty); + Assertion *asRef = + hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; if (asRef) { as->mNext = asRef->mNext; @@ -1189,11 +1186,11 @@ InMemoryDataSource::LockedAssert(nsIRDFResource* aSource, } else { - hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash, - aProperty, PL_DHASH_ADD); + hdr = PL_DHashTableAdd(next->u.hash.mPropertyHash, aProperty, + mozilla::fallible); if (hdr) { - Entry* entry = reinterpret_cast<Entry*>(hdr); + Entry* entry = static_cast<Entry*>(hdr); entry->mNode = aProperty; entry->mAssertions = as; } @@ -1276,14 +1273,12 @@ InMemoryDataSource::LockedUnassert(nsIRDFResource* aSource, Assertion* prev = next; Assertion* root = next; Assertion* as = nullptr; - + bool haveHash = (next) ? next->mHashEntry : false; if (haveHash) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(next->u.hash.mPropertyHash, - aProperty, PL_DHASH_LOOKUP); - prev = next = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(next->u.hash.mPropertyHash, aProperty); + prev = next = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; bool first = true; while (next) { if (aTarget == next->u.as.mTarget) { @@ -1303,18 +1298,19 @@ InMemoryDataSource::LockedUnassert(nsIRDFResource* aSource, PL_DHashTableRawRemove(root->u.hash.mPropertyHash, hdr); if (next && next->mNext) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(root->u.hash.mPropertyHash, - aProperty, PL_DHASH_ADD); + PLDHashEntryHdr* hdr = + PL_DHashTableAdd(root->u.hash.mPropertyHash, aProperty, + mozilla::fallible); if (hdr) { - Entry* entry = reinterpret_cast<Entry*>(hdr); + Entry* entry = static_cast<Entry*>(hdr); entry->mNode = aProperty; entry->mAssertions = next->mNext; } } else { // If this second-level hash empties out, clean it up. - if (!root->u.hash.mPropertyHash->entryCount) { - delete root; + if (!root->u.hash.mPropertyHash->EntryCount()) { + root->Release(); SetForwardArcs(aSource, nullptr); } } @@ -1577,16 +1573,14 @@ InMemoryDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *resu return NS_OK; } -NS_IMETHODIMP +NS_IMETHODIMP InMemoryDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *result) { Assertion* ass = GetForwardArcs(aSource); if (ass && ass->mHashEntry) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(ass->u.hash.mPropertyHash, - aArc, PL_DHASH_LOOKUP); - Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(ass->u.hash.mPropertyHash, aArc); + Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; if (val) { *result = true; return NS_OK; @@ -1648,7 +1642,7 @@ InMemoryDataSource::ResourceEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); static_cast<nsCOMArray<nsIRDFNode>*>(aArg)->AppendObject(entry->mNode); return PL_DHASH_NEXT; } @@ -1658,7 +1652,7 @@ NS_IMETHODIMP InMemoryDataSource::GetAllResources(nsISimpleEnumerator** aResult) { nsCOMArray<nsIRDFNode> nodes; - nodes.SetCapacity(mForwardArcs.entryCount); + nodes.SetCapacity(mForwardArcs.EntryCount()); // Enumerate all of our entries into an nsCOMArray PL_DHashTableEnumerate(&mForwardArcs, ResourceEnumerator, &nodes); @@ -1733,7 +1727,7 @@ InMemoryDataSource::EnsureFastContainment(nsIRDFResource* aSource) // Add the datasource's owning reference. hashAssertion->AddRef(); - register Assertion *first = GetForwardArcs(aSource); + Assertion *first = GetForwardArcs(aSource); SetForwardArcs(aSource, hashAssertion); // mutate references of existing forward assertions into this hash @@ -1743,20 +1737,17 @@ InMemoryDataSource::EnsureFastContainment(nsIRDFResource* aSource) nextRef = first->mNext; nsIRDFResource *prop = first->u.as.mProperty; - PLDHashEntryHdr* hdr = PL_DHashTableOperate(table, - prop, PL_DHASH_LOOKUP); - Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = PL_DHashTableSearch(table, prop); + Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; if (val) { first->mNext = val->mNext; val->mNext = first; } else { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(table, - prop, PL_DHASH_ADD); + PLDHashEntryHdr* hdr = PL_DHashTableAdd(table, prop, + mozilla::fallible); if (hdr) { - Entry* entry = reinterpret_cast<Entry*>(hdr); + Entry* entry = static_cast<Entry*>(hdr); entry->mNode = prop; entry->mAssertions = first; first->mNext = nullptr; @@ -1809,11 +1800,9 @@ InMemoryDataSource::Mark(nsIRDFResource* aSource, Assertion *as = GetForwardArcs(aSource); if (as && as->mHashEntry) { - PLDHashEntryHdr* hdr = PL_DHashTableOperate(as->u.hash.mPropertyHash, - aProperty, PL_DHASH_LOOKUP); - Assertion* val = PL_DHASH_ENTRY_IS_BUSY(hdr) - ? reinterpret_cast<Entry*>(hdr)->mAssertions - : nullptr; + PLDHashEntryHdr* hdr = + PL_DHashTableSearch(as->u.hash.mPropertyHash, aProperty); + Assertion* val = hdr ? static_cast<Entry*>(hdr)->mAssertions : nullptr; while (val) { if ((val->u.as.mTarget == aTarget) && (aTruthValue == (val->u.as.mTruthValue))) { @@ -1906,7 +1895,7 @@ InMemoryDataSource::SweepForwardArcsEntries(PLDHashTable* aTable, uint32_t aNumber, void* aArg) { PLDHashOperator result = PL_DHASH_NEXT; - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); SweepInfo* info = static_cast<SweepInfo*>(aArg); Assertion* as = entry->mAssertions; @@ -1917,8 +1906,8 @@ InMemoryDataSource::SweepForwardArcsEntries(PLDHashTable* aTable, SweepForwardArcsEntries, info); // If the sub-hash is now empty, clean it up. - if (!as->u.hash.mPropertyHash->entryCount) { - delete as; + if (!as->u.hash.mPropertyHash->EntryCount()) { + as->Release(); result = PL_DHASH_REMOVE; } @@ -1945,10 +1934,10 @@ InMemoryDataSource::SweepForwardArcsEntries(PLDHashTable* aTable, // remove from the reverse arcs PLDHashEntryHdr* hdr = - PL_DHashTableOperate(info->mReverseArcs, as->u.as.mTarget, PL_DHASH_LOOKUP); - NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(hdr), "no assertion in reverse arcs"); + PL_DHashTableSearch(info->mReverseArcs, as->u.as.mTarget); + NS_ASSERTION(hdr, "no assertion in reverse arcs"); - Entry* rentry = reinterpret_cast<Entry*>(hdr); + Entry* rentry = static_cast<Entry*>(hdr); Assertion* ras = rentry->mAssertions; Assertion* rprev = nullptr; while (ras) { @@ -1995,7 +1984,7 @@ InMemoryDataSource::SweepForwardArcsEntries(PLDHashTable* aTable, class VisitorClosure { public: - VisitorClosure(rdfITripleVisitor* aVisitor) : + explicit VisitorClosure(rdfITripleVisitor* aVisitor) : mVisitor(aVisitor), mRv(NS_OK) {} @@ -2006,7 +1995,7 @@ public: PLDHashOperator SubjectEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); VisitorClosure* closure = static_cast<VisitorClosure*>(aArg); nsresult rv; @@ -2048,7 +2037,7 @@ public: PLDHashOperator TriplesInnerEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); Assertion* assertion = entry->mAssertions; TriplesInnerClosure* closure = static_cast<TriplesInnerClosure*>(aArg); @@ -2069,7 +2058,7 @@ TriplesInnerEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, PLDHashOperator TriplesEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr, uint32_t aNumber, void* aArg) { - Entry* entry = reinterpret_cast<Entry*>(aHdr); + Entry* entry = static_cast<Entry*>(aHdr); VisitorClosure* closure = static_cast<VisitorClosure*>(aArg); nsresult rv; diff --git a/rdf/base/src/nsNameSpaceMap.cpp b/rdf/base/nsNameSpaceMap.cpp index b486a233d..b486a233d 100644 --- a/rdf/base/src/nsNameSpaceMap.cpp +++ b/rdf/base/nsNameSpaceMap.cpp diff --git a/rdf/base/src/nsNameSpaceMap.h b/rdf/base/nsNameSpaceMap.h index a67898098..bc7c02029 100644 --- a/rdf/base/src/nsNameSpaceMap.h +++ b/rdf/base/nsNameSpaceMap.h @@ -41,7 +41,7 @@ public: protected: friend class nsNameSpaceMap; - const_iterator(const Entry* aCurrent) + explicit const_iterator(const Entry* aCurrent) : mCurrent(aCurrent) {} const Entry* mCurrent; diff --git a/rdf/base/src/nsRDFBaseDataSources.h b/rdf/base/nsRDFBaseDataSources.h index 0243e1359..0243e1359 100644 --- a/rdf/base/src/nsRDFBaseDataSources.h +++ b/rdf/base/nsRDFBaseDataSources.h diff --git a/rdf/base/src/nsRDFContainer.cpp b/rdf/base/nsRDFContainer.cpp index 751dbbedd..6000c70d5 100644 --- a/rdf/base/src/nsRDFContainer.cpp +++ b/rdf/base/nsRDFContainer.cpp @@ -45,10 +45,6 @@ #include "nsXPIDLString.h" #include "rdf.h" -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); -static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; - #define RDF_SEQ_LIST_LIMIT 8 class RDFContainerImpl : public nsIRDFContainer @@ -92,7 +88,7 @@ nsIRDFResource* RDFContainerImpl::kRDF_nextVal; //////////////////////////////////////////////////////////////////////// // nsISupports interface -NS_IMPL_ISUPPORTS1(RDFContainerImpl, nsIRDFContainer) +NS_IMPL_ISUPPORTS(RDFContainerImpl, nsIRDFContainer) @@ -177,7 +173,7 @@ RDFContainerImpl::GetCount(int32_t *aCount) rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral)); if (NS_FAILED(rv)) return rv; - const PRUnichar *s; + const char16_t *s; rv = nextValLiteral->GetValueConst( &s ); if (NS_FAILED(rv)) return rv; @@ -381,6 +377,7 @@ RDFContainerImpl::Init() if (gRefCnt++ == 0) { nsresult rv; + NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); rv = CallGetService(kRDFServiceCID, &gRDFService); if (NS_FAILED(rv)) { NS_ERROR("unable to get RDF service"); @@ -391,6 +388,7 @@ RDFContainerImpl::Init() &kRDF_nextVal); if (NS_FAILED(rv)) return rv; + NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils); if (NS_FAILED(rv)) { NS_ERROR("unable to get RDF container utils service"); @@ -672,13 +670,13 @@ RDFContainerImpl::GetNextValue(nsIRDFResource** aResult) rv = nextValNode->QueryInterface(NS_GET_IID(nsIRDFLiteral), getter_AddRefs(nextValLiteral)); if (NS_FAILED(rv)) return rv; - const PRUnichar* s; + const char16_t* s; rv = nextValLiteral->GetValueConst(&s); if (NS_FAILED(rv)) return rv; int32_t nextVal = 0; { - for (const PRUnichar* p = s; *p != 0; ++p) { + for (const char16_t* p = s; *p != 0; ++p) { NS_ASSERTION(*p >= '0' && *p <= '9', "not a digit"); if (*p < '0' || *p > '9') break; @@ -688,10 +686,11 @@ RDFContainerImpl::GetNextValue(nsIRDFResource** aResult) } } + static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; char buf[sizeof(kRDFNameSpaceURI) + 16]; nsFixedCString nextValStr(buf, sizeof(buf), 0); nextValStr = kRDFNameSpaceURI; - nextValStr.Append("_"); + nextValStr.Append('_'); nextValStr.AppendInt(nextVal, 10); rv = gRDFService->GetResource(nextValStr, aResult); diff --git a/rdf/base/src/nsRDFContainerUtils.cpp b/rdf/base/nsRDFContainerUtils.cpp index 31f4fff04..360d75fb6 100644 --- a/rdf/base/src/nsRDFContainerUtils.cpp +++ b/rdf/base/nsRDFContainerUtils.cpp @@ -23,9 +23,6 @@ #include "rdf.h" #include "rdfutil.h" -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; - class RDFContainerUtilsImpl : public nsIRDFContainerUtils { public: @@ -57,9 +54,9 @@ private: static nsIRDFResource* kRDF_Seq; static nsIRDFResource* kRDF_Alt; static nsIRDFLiteral* kOne; + static const char kRDFNameSpaceURI[]; }; - int32_t RDFContainerUtilsImpl::gRefCnt = 0; nsIRDFService* RDFContainerUtilsImpl::gRDFService; nsIRDFResource* RDFContainerUtilsImpl::kRDF_instanceOf; @@ -68,11 +65,12 @@ nsIRDFResource* RDFContainerUtilsImpl::kRDF_Bag; nsIRDFResource* RDFContainerUtilsImpl::kRDF_Seq; nsIRDFResource* RDFContainerUtilsImpl::kRDF_Alt; nsIRDFLiteral* RDFContainerUtilsImpl::kOne; +const char RDFContainerUtilsImpl::kRDFNameSpaceURI[] = RDF_NAMESPACE_URI; //////////////////////////////////////////////////////////////////////// // nsISupports interface -NS_IMPL_THREADSAFE_ISUPPORTS1(RDFContainerUtilsImpl, nsIRDFContainerUtils) +NS_IMPL_ISUPPORTS(RDFContainerUtilsImpl, nsIRDFContainerUtils) //////////////////////////////////////////////////////////////////////// // nsIRDFContainerUtils interface @@ -325,6 +323,7 @@ RDFContainerUtilsImpl::RDFContainerUtilsImpl() if (gRefCnt++ == 0) { nsresult rv; + NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); rv = CallGetService(kRDFServiceCID, &gRDFService); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); @@ -339,7 +338,7 @@ RDFContainerUtilsImpl::RDFContainerUtilsImpl() &kRDF_Seq); gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Alt"), &kRDF_Alt); - gRDFService->GetLiteral(NS_LITERAL_STRING("1").get(), &kOne); + gRDFService->GetLiteral(MOZ_UTF16("1"), &kOne); } } } diff --git a/rdf/base/src/nsRDFContentSink.cpp b/rdf/base/nsRDFContentSink.cpp index a984c998a..8c8eccb30 100644 --- a/rdf/base/src/nsRDFContentSink.cpp +++ b/rdf/base/nsRDFContentSink.cpp @@ -38,8 +38,6 @@ */ -#include "mozilla/Util.h" - #include "nsCOMPtr.h" #include "nsInterfaceHashtable.h" #include "nsIContentSink.h" @@ -68,25 +66,6 @@ using namespace mozilla; -//////////////////////////////////////////////////////////////////////// -// XPCOM IIDs - -static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID); // XXX grr... -static NS_DEFINE_IID(kIExpatSinkIID, NS_IEXPATSINK_IID); -static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID); -static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); -static NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID); -static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID); - -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); -static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); - -//////////////////////////////////////////////////////////////////////// - -#ifdef PR_LOGGING -static PRLogModuleInfo* gLog; -#endif - /////////////////////////////////////////////////////////////////////// enum RDFContentSinkState { @@ -123,27 +102,26 @@ class RDFContentSinkImpl : public nsIRDFContentSink, { public: RDFContentSinkImpl(); - virtual ~RDFContentSinkImpl(); // nsISupports NS_DECL_ISUPPORTS NS_DECL_NSIEXPATSINK // nsIContentSink - NS_IMETHOD WillParse(void); - NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode); - NS_IMETHOD DidBuildModel(bool aTerminated); - NS_IMETHOD WillInterrupt(void); - NS_IMETHOD WillResume(void); - NS_IMETHOD SetParser(nsParserBase* aParser); - virtual void FlushPendingNotifications(mozFlushType aType) { } - NS_IMETHOD SetDocumentCharset(nsACString& aCharset) { return NS_OK; } - virtual nsISupports *GetTarget() { return nullptr; } + NS_IMETHOD WillParse(void) override; + NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override; + NS_IMETHOD DidBuildModel(bool aTerminated) override; + NS_IMETHOD WillInterrupt(void) override; + NS_IMETHOD WillResume(void) override; + NS_IMETHOD SetParser(nsParserBase* aParser) override; + virtual void FlushPendingNotifications(mozFlushType aType) override { } + NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override { return NS_OK; } + virtual nsISupports *GetTarget() override { return nullptr; } // nsIRDFContentSink - NS_IMETHOD Init(nsIURI* aURL); - NS_IMETHOD SetDataSource(nsIRDFDataSource* aDataSource); - NS_IMETHOD GetDataSource(nsIRDFDataSource*& aDataSource); + NS_IMETHOD Init(nsIURI* aURL) override; + NS_IMETHOD SetDataSource(nsIRDFDataSource* aDataSource) override; + NS_IMETHOD GetDataSource(nsIRDFDataSource*& aDataSource) override; // pseudo constants static int32_t gRefCnt; @@ -167,25 +145,27 @@ public: } ContainerInfo; protected: + virtual ~RDFContentSinkImpl(); + // Text management void ParseText(nsIRDFNode **aResult); nsresult FlushText(); - nsresult AddText(const PRUnichar* aText, int32_t aLength); + nsresult AddText(const char16_t* aText, int32_t aLength); // RDF-specific parsing - nsresult OpenRDF(const PRUnichar* aName); - nsresult OpenObject(const PRUnichar* aName ,const PRUnichar** aAttributes); - nsresult OpenProperty(const PRUnichar* aName, const PRUnichar** aAttributes); - nsresult OpenMember(const PRUnichar* aName, const PRUnichar** aAttributes); - nsresult OpenValue(const PRUnichar* aName, const PRUnichar** aAttributes); + nsresult OpenRDF(const char16_t* aName); + nsresult OpenObject(const char16_t* aName ,const char16_t** aAttributes); + nsresult OpenProperty(const char16_t* aName, const char16_t** aAttributes); + nsresult OpenMember(const char16_t* aName, const char16_t** aAttributes); + nsresult OpenValue(const char16_t* aName, const char16_t** aAttributes); - nsresult GetIdAboutAttribute(const PRUnichar** aAttributes, nsIRDFResource** aResource, bool* aIsAnonymous = nullptr); - nsresult GetResourceAttribute(const PRUnichar** aAttributes, nsIRDFResource** aResource); - nsresult AddProperties(const PRUnichar** aAttributes, nsIRDFResource* aSubject, int32_t* aCount = nullptr); - void SetParseMode(const PRUnichar **aAttributes); + nsresult GetIdAboutAttribute(const char16_t** aAttributes, nsIRDFResource** aResource, bool* aIsAnonymous = nullptr); + nsresult GetResourceAttribute(const char16_t** aAttributes, nsIRDFResource** aResource); + nsresult AddProperties(const char16_t** aAttributes, nsIRDFResource* aSubject, int32_t* aCount = nullptr); + void SetParseMode(const char16_t **aAttributes); - PRUnichar* mText; + char16_t* mText; int32_t mTextLength; int32_t mTextSize; @@ -196,7 +176,7 @@ protected: * Hopefully, this will keep namespace definitions intact in a * parse - serialize cycle. */ - void RegisterNamespaces(const PRUnichar **aAttributes); + void RegisterNamespaces(const char16_t **aAttributes); /** * Extracts the localname from aExpatName, the name that the Expat parser @@ -204,7 +184,7 @@ protected: * aLocalName will contain the localname in aExpatName. * The return value is a dependent string containing just the namespace. */ - const nsDependentSubstring SplitExpatName(const PRUnichar *aExpatName, + const nsDependentSubstring SplitExpatName(const char16_t *aExpatName, nsIAtom **aLocalName); enum eContainerType { eBag, eSeq, eAlt }; @@ -244,6 +224,11 @@ protected: nsAutoTArray<RDFContextStackElement, 8>* mContextStack; nsIURI* mDocumentURL; + +private: +#ifdef PR_LOGGING + static PRLogModuleInfo* gLog; +#endif }; int32_t RDFContentSinkImpl::gRefCnt = 0; @@ -256,6 +241,10 @@ nsIRDFResource* RDFContentSinkImpl::kRDF_Bag; nsIRDFResource* RDFContentSinkImpl::kRDF_Seq; nsIRDFResource* RDFContentSinkImpl::kRDF_nextVal; +#ifdef PR_LOGGING +PRLogModuleInfo* RDFContentSinkImpl::gLog; +#endif + //////////////////////////////////////////////////////////////////////// #define RDF_ATOM(name_, value_) nsIAtom* RDFContentSinkImpl::name_; @@ -282,6 +271,7 @@ RDFContentSinkImpl::RDFContentSinkImpl() mDocumentURL(nullptr) { if (gRefCnt++ == 0) { + NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); nsresult rv = CallGetService(kRDFServiceCID, &gRDFService); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); @@ -300,14 +290,12 @@ RDFContentSinkImpl::RDFContentSinkImpl() &kRDF_nextVal); } - + NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID); rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils); NS_RegisterStaticAtoms(rdf_atoms); } - mNodeIDMap.Init(); - #ifdef PR_LOGGING if (! gLog) gLog = PR_NewLogModule("nsRDFContentSink"); @@ -383,6 +371,12 @@ RDFContentSinkImpl::QueryInterface(REFNSIID iid, void** result) if (! result) return NS_ERROR_NULL_POINTER; + NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID); + NS_DEFINE_IID(kIExpatSinkIID, NS_IEXPATSINK_IID); + NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + NS_DEFINE_IID(kIXMLContentSinkIID, NS_IXMLCONTENT_SINK_IID); + NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID); + *result = nullptr; if (iid.Equals(kIRDFContentSinkIID) || iid.Equals(kIXMLContentSinkIID) || @@ -401,10 +395,9 @@ RDFContentSinkImpl::QueryInterface(REFNSIID iid, void** result) } NS_IMETHODIMP -RDFContentSinkImpl::HandleStartElement(const PRUnichar *aName, - const PRUnichar **aAtts, +RDFContentSinkImpl::HandleStartElement(const char16_t *aName, + const char16_t **aAtts, uint32_t aAttsCount, - int32_t aIndex, uint32_t aLineNumber) { FlushText(); @@ -446,7 +439,7 @@ RDFContentSinkImpl::HandleStartElement(const PRUnichar *aName, } NS_IMETHODIMP -RDFContentSinkImpl::HandleEndElement(const PRUnichar *aName) +RDFContentSinkImpl::HandleEndElement(const char16_t *aName) { FlushText(); @@ -497,13 +490,13 @@ RDFContentSinkImpl::HandleEndElement(const PRUnichar *aName) } NS_IMETHODIMP -RDFContentSinkImpl::HandleComment(const PRUnichar *aName) +RDFContentSinkImpl::HandleComment(const char16_t *aName) { return NS_OK; } NS_IMETHODIMP -RDFContentSinkImpl::HandleCDataSection(const PRUnichar *aData, +RDFContentSinkImpl::HandleCDataSection(const char16_t *aData, uint32_t aLength) { return aData ? AddText(aData, aLength) : NS_OK; @@ -520,30 +513,30 @@ RDFContentSinkImpl::HandleDoctypeDecl(const nsAString & aSubset, } NS_IMETHODIMP -RDFContentSinkImpl::HandleCharacterData(const PRUnichar *aData, +RDFContentSinkImpl::HandleCharacterData(const char16_t *aData, uint32_t aLength) { return aData ? AddText(aData, aLength) : NS_OK; } NS_IMETHODIMP -RDFContentSinkImpl::HandleProcessingInstruction(const PRUnichar *aTarget, - const PRUnichar *aData) +RDFContentSinkImpl::HandleProcessingInstruction(const char16_t *aTarget, + const char16_t *aData) { return NS_OK; } NS_IMETHODIMP -RDFContentSinkImpl::HandleXMLDeclaration(const PRUnichar *aVersion, - const PRUnichar *aEncoding, +RDFContentSinkImpl::HandleXMLDeclaration(const char16_t *aVersion, + const char16_t *aEncoding, int32_t aStandalone) { return NS_OK; } NS_IMETHODIMP -RDFContentSinkImpl::ReportError(const PRUnichar* aErrorText, - const PRUnichar* aSourceText, +RDFContentSinkImpl::ReportError(const char16_t* aErrorText, + const char16_t* aSourceText, nsIScriptError *aError, bool *_retval) { @@ -653,7 +646,7 @@ RDFContentSinkImpl::GetDataSource(nsIRDFDataSource*& aDataSource) // Text buffering static bool -rdf_IsDataInBuffer(PRUnichar* buffer, int32_t length) +rdf_IsDataInBuffer(char16_t* buffer, int32_t length) { for (int32_t i = 0; i < length; ++i) { if (buffer[i] == ' ' || @@ -758,11 +751,11 @@ RDFContentSinkImpl::FlushText() nsresult -RDFContentSinkImpl::AddText(const PRUnichar* aText, int32_t aLength) +RDFContentSinkImpl::AddText(const char16_t* aText, int32_t aLength) { // Create buffer when we first need it if (0 == mTextSize) { - mText = (PRUnichar *) moz_malloc(sizeof(PRUnichar) * 4096); + mText = (char16_t *) moz_malloc(sizeof(char16_t) * 4096); if (!mText) { return NS_ERROR_OUT_OF_MEMORY; } @@ -779,14 +772,14 @@ RDFContentSinkImpl::AddText(const PRUnichar* aText, int32_t aLength) // don't clobber mText or mTextSize until the new mem is allocated. int32_t newSize = (2 * mTextSize > (mTextSize + aLength)) ? (2 * mTextSize) : (mTextSize + aLength); - PRUnichar* newText = - (PRUnichar *) moz_realloc(mText, sizeof(PRUnichar) * newSize); + char16_t* newText = + (char16_t *) moz_realloc(mText, sizeof(char16_t) * newSize); if (!newText) return NS_ERROR_OUT_OF_MEMORY; mTextSize = newSize; mText = newText; } - memcpy(&mText[mTextLength], aText, sizeof(PRUnichar) * aLength); + memcpy(&mText[mTextLength], aText, sizeof(char16_t) * aLength); mTextLength += aLength; return NS_OK; @@ -801,7 +794,7 @@ rdf_RequiresAbsoluteURI(const nsString& uri) } nsresult -RDFContentSinkImpl::GetIdAboutAttribute(const PRUnichar** aAttributes, +RDFContentSinkImpl::GetIdAboutAttribute(const char16_t** aAttributes, nsIRDFResource** aResource, bool* aIsAnonymous) { @@ -895,7 +888,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const PRUnichar** aAttributes, } nsresult -RDFContentSinkImpl::GetResourceAttribute(const PRUnichar** aAttributes, +RDFContentSinkImpl::GetResourceAttribute(const char16_t** aAttributes, nsIRDFResource** aResource) { nsCOMPtr<nsIAtom> localName; @@ -959,7 +952,7 @@ RDFContentSinkImpl::GetResourceAttribute(const PRUnichar** aAttributes, } nsresult -RDFContentSinkImpl::AddProperties(const PRUnichar** aAttributes, +RDFContentSinkImpl::AddProperties(const char16_t** aAttributes, nsIRDFResource* aSubject, int32_t* aCount) { @@ -1013,7 +1006,7 @@ RDFContentSinkImpl::AddProperties(const PRUnichar** aAttributes, } void -RDFContentSinkImpl::SetParseMode(const PRUnichar **aAttributes) +RDFContentSinkImpl::SetParseMode(const char16_t **aAttributes) { nsCOMPtr<nsIAtom> localName; for (; *aAttributes; aAttributes += 2) { @@ -1046,7 +1039,7 @@ RDFContentSinkImpl::SetParseMode(const PRUnichar **aAttributes) // RDF-specific routines used to build the model nsresult -RDFContentSinkImpl::OpenRDF(const PRUnichar* aName) +RDFContentSinkImpl::OpenRDF(const char16_t* aName) { // ensure that we're actually reading RDF by making sure that the // opening tag is <rdf:RDF>, where "rdf:" corresponds to whatever @@ -1069,8 +1062,8 @@ RDFContentSinkImpl::OpenRDF(const PRUnichar* aName) } nsresult -RDFContentSinkImpl::OpenObject(const PRUnichar* aName, - const PRUnichar** aAttributes) +RDFContentSinkImpl::OpenObject(const char16_t* aName, + const char16_t** aAttributes) { // an "object" non-terminal is either a "description", a "typed // node", or a "container", so this change the content sink's @@ -1143,7 +1136,7 @@ RDFContentSinkImpl::OpenObject(const PRUnichar* aName, } nsresult -RDFContentSinkImpl::OpenProperty(const PRUnichar* aName, const PRUnichar** aAttributes) +RDFContentSinkImpl::OpenProperty(const char16_t* aName, const char16_t** aAttributes) { nsresult rv; @@ -1216,8 +1209,8 @@ RDFContentSinkImpl::OpenProperty(const PRUnichar* aName, const PRUnichar** aAttr } nsresult -RDFContentSinkImpl::OpenMember(const PRUnichar* aName, - const PRUnichar** aAttributes) +RDFContentSinkImpl::OpenMember(const char16_t* aName, + const char16_t** aAttributes) { // ensure that we're actually reading a member element by making // sure that the opening tag is <rdf:li>, where "rdf:" corresponds @@ -1272,7 +1265,7 @@ RDFContentSinkImpl::OpenMember(const PRUnichar* aName, nsresult -RDFContentSinkImpl::OpenValue(const PRUnichar* aName, const PRUnichar** aAttributes) +RDFContentSinkImpl::OpenValue(const char16_t* aName, const char16_t** aAttributes) { // a "value" can either be an object or a string: we'll only get // *here* if it's an object, as raw text is added as a leaf. @@ -1282,7 +1275,7 @@ RDFContentSinkImpl::OpenValue(const PRUnichar* aName, const PRUnichar** aAttribu //////////////////////////////////////////////////////////////////////// // namespace resolution void -RDFContentSinkImpl::RegisterNamespaces(const PRUnichar **aAttributes) +RDFContentSinkImpl::RegisterNamespaces(const char16_t **aAttributes) { nsCOMPtr<nsIRDFXMLSink> sink = do_QueryInterface(mDataSource); if (!sink) { @@ -1291,8 +1284,8 @@ RDFContentSinkImpl::RegisterNamespaces(const PRUnichar **aAttributes) NS_NAMED_LITERAL_STRING(xmlns, "http://www.w3.org/2000/xmlns/"); for (; *aAttributes; aAttributes += 2) { // check the namespace - const PRUnichar* attr = aAttributes[0]; - const PRUnichar* xmlnsP = xmlns.BeginReading(); + const char16_t* attr = aAttributes[0]; + const char16_t* xmlnsP = xmlns.BeginReading(); while (*attr == *xmlnsP) { ++attr; ++xmlnsP; @@ -1302,7 +1295,7 @@ RDFContentSinkImpl::RegisterNamespaces(const PRUnichar **aAttributes) continue; } // get the localname (or "xmlns" for the default namespace) - const PRUnichar* endLocal = ++attr; + const char16_t* endLocal = ++attr; while (*endLocal && *endLocal != 0xFFFF) { ++endLocal; } @@ -1319,7 +1312,7 @@ RDFContentSinkImpl::RegisterNamespaces(const PRUnichar **aAttributes) // Qualified name resolution const nsDependentSubstring -RDFContentSinkImpl::SplitExpatName(const PRUnichar *aExpatName, +RDFContentSinkImpl::SplitExpatName(const char16_t *aExpatName, nsIAtom **aLocalName) { /** @@ -1332,9 +1325,9 @@ RDFContentSinkImpl::SplitExpatName(const PRUnichar *aExpatName, * */ - const PRUnichar *uriEnd = aExpatName; - const PRUnichar *nameStart = aExpatName; - const PRUnichar *pos; + const char16_t *uriEnd = aExpatName; + const char16_t *nameStart = aExpatName; + const char16_t *pos; for (pos = aExpatName; *pos; ++pos) { if (*pos == 0xFFFF) { if (uriEnd != aExpatName) { @@ -1347,7 +1340,7 @@ RDFContentSinkImpl::SplitExpatName(const PRUnichar *aExpatName, } const nsDependentSubstring& nameSpaceURI = Substring(aExpatName, uriEnd); - *aLocalName = NS_NewAtom(Substring(nameStart, pos)).get(); + *aLocalName = NS_NewAtom(Substring(nameStart, pos)).take(); return nameSpaceURI; } @@ -1398,7 +1391,7 @@ RDFContentSinkImpl::ReinitContainer(nsIRDFResource* aContainerType, nsIRDFResour nsresult rv; nsCOMPtr<nsIRDFLiteral> one; - rv = gRDFService->GetLiteral(NS_LITERAL_STRING("1").get(), getter_AddRefs(one)); + rv = gRDFService->GetLiteral(MOZ_UTF16("1"), getter_AddRefs(one)); if (NS_FAILED(rv)) return rv; // Re-initialize the 'nextval' property diff --git a/rdf/base/src/nsRDFContentSinkAtomList.h b/rdf/base/nsRDFContentSinkAtomList.h index 5ef4f7b4e..5ef4f7b4e 100644 --- a/rdf/base/src/nsRDFContentSinkAtomList.h +++ b/rdf/base/nsRDFContentSinkAtomList.h diff --git a/rdf/base/src/nsRDFService.cpp b/rdf/base/nsRDFService.cpp index 8c0d8131d..15b43c403 100644 --- a/rdf/base/src/nsRDFService.cpp +++ b/rdf/base/nsRDFService.cpp @@ -55,7 +55,6 @@ #include "rdf.h" #include "nsCRT.h" #include "nsCRTGlue.h" -#include "prbit.h" #include "mozilla/HashFunctions.h" using namespace mozilla; @@ -140,14 +139,11 @@ struct ResourceHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gResourceTableOps = { - PL_DHashAllocTable, - PL_DHashFreeTable, +static const PLDHashTableOps gResourceTableOps = { ResourceHashEntry::HashKey, ResourceHashEntry::MatchEntry, PL_DHashMoveEntryStub, PL_DHashClearEntryStub, - PL_DHashFinalizeStub, nullptr }; @@ -158,12 +154,12 @@ static PLDHashTableOps gResourceTableOps = { struct LiteralHashEntry : public PLDHashEntryHdr { nsIRDFLiteral *mLiteral; - const PRUnichar *mKey; + const char16_t *mKey; static PLDHashNumber HashKey(PLDHashTable *table, const void *key) { - return HashString(static_cast<const PRUnichar *>(key)); + return HashString(static_cast<const char16_t *>(key)); } static bool @@ -173,19 +169,16 @@ struct LiteralHashEntry : public PLDHashEntryHdr { const LiteralHashEntry *entry = static_cast<const LiteralHashEntry *>(hdr); - return 0 == nsCRT::strcmp(static_cast<const PRUnichar *>(key), + return 0 == nsCRT::strcmp(static_cast<const char16_t *>(key), entry->mKey); } }; -static PLDHashTableOps gLiteralTableOps = { - PL_DHashAllocTable, - PL_DHashFreeTable, +static const PLDHashTableOps gLiteralTableOps = { LiteralHashEntry::HashKey, LiteralHashEntry::MatchEntry, PL_DHashMoveEntryStub, PL_DHashClearEntryStub, - PL_DHashFinalizeStub, nullptr }; @@ -215,14 +208,11 @@ struct IntHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gIntTableOps = { - PL_DHashAllocTable, - PL_DHashFreeTable, +static const PLDHashTableOps gIntTableOps = { IntHashEntry::HashKey, IntHashEntry::MatchEntry, PL_DHashMoveEntryStub, PL_DHashClearEntryStub, - PL_DHashFinalizeStub, nullptr }; @@ -256,14 +246,11 @@ struct DateHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gDateTableOps = { - PL_DHashAllocTable, - PL_DHashFreeTable, +static const PLDHashTableOps gDateTableOps = { DateHashEntry::HashKey, DateHashEntry::MatchEntry, PL_DHashMoveEntryStub, PL_DHashClearEntryStub, - PL_DHashFinalizeStub, nullptr }; @@ -284,6 +271,7 @@ public: RDFServiceImpl::gRDFService->RegisterBlob(this); } +protected: virtual ~BlobImpl() { RDFServiceImpl::gRDFService->UnregisterBlob(this); @@ -295,6 +283,7 @@ public: delete[] mData.mBytes; } +public: NS_DECL_ISUPPORTS NS_DECL_NSIRDFNODE NS_DECL_NSIRDFBLOB @@ -302,7 +291,7 @@ public: Data mData; }; -NS_IMPL_ISUPPORTS2(BlobImpl, nsIRDFNode, nsIRDFBlob) +NS_IMPL_ISUPPORTS(BlobImpl, nsIRDFNode, nsIRDFBlob) NS_IMETHODIMP BlobImpl::EqualsNode(nsIRDFNode *aNode, bool *aEquals) @@ -374,14 +363,11 @@ struct BlobHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gBlobTableOps = { - PL_DHashAllocTable, - PL_DHashFreeTable, +static const PLDHashTableOps gBlobTableOps = { BlobHashEntry::HashKey, BlobHashEntry::MatchEntry, PL_DHashMoveEntryStub, PL_DHashClearEntryStub, - PL_DHashFinalizeStub, nullptr }; @@ -395,10 +381,10 @@ static PLDHashTableOps gBlobTableOps = { class LiteralImpl : public nsIRDFLiteral { public: static nsresult - Create(const PRUnichar* aValue, nsIRDFLiteral** aResult); + Create(const char16_t* aValue, nsIRDFLiteral** aResult); // nsISupports - NS_DECL_ISUPPORTS + NS_DECL_THREADSAFE_ISUPPORTS // nsIRDFNode NS_DECL_NSIRDFNODE @@ -407,37 +393,37 @@ public: NS_DECL_NSIRDFLITERAL protected: - LiteralImpl(const PRUnichar* s); + explicit LiteralImpl(const char16_t* s); virtual ~LiteralImpl(); - const PRUnichar* GetValue() const { - size_t objectSize = ((sizeof(LiteralImpl) + sizeof(PRUnichar) - 1) / sizeof(PRUnichar)) * sizeof(PRUnichar); - return reinterpret_cast<const PRUnichar*>(reinterpret_cast<const unsigned char*>(this) + objectSize); + const char16_t* GetValue() const { + size_t objectSize = ((sizeof(LiteralImpl) + sizeof(char16_t) - 1) / sizeof(char16_t)) * sizeof(char16_t); + return reinterpret_cast<const char16_t*>(reinterpret_cast<const unsigned char*>(this) + objectSize); } }; nsresult -LiteralImpl::Create(const PRUnichar* aValue, nsIRDFLiteral** aResult) +LiteralImpl::Create(const char16_t* aValue, nsIRDFLiteral** aResult) { // Goofy math to get alignment right. Copied from nsSharedString.h. - size_t objectSize = ((sizeof(LiteralImpl) + sizeof(PRUnichar) - 1) / sizeof(PRUnichar)) * sizeof(PRUnichar); - size_t stringLen = nsCharTraits<PRUnichar>::length(aValue); - size_t stringSize = (stringLen + 1) * sizeof(PRUnichar); + size_t objectSize = ((sizeof(LiteralImpl) + sizeof(char16_t) - 1) / sizeof(char16_t)) * sizeof(char16_t); + size_t stringLen = nsCharTraits<char16_t>::length(aValue); + size_t stringSize = (stringLen + 1) * sizeof(char16_t); void* objectPtr = operator new(objectSize + stringSize); if (! objectPtr) return NS_ERROR_NULL_POINTER; - PRUnichar* buf = reinterpret_cast<PRUnichar*>(static_cast<unsigned char*>(objectPtr) + objectSize); - nsCharTraits<PRUnichar>::copy(buf, aValue, stringLen + 1); + char16_t* buf = reinterpret_cast<char16_t*>(static_cast<unsigned char*>(objectPtr) + objectSize); + nsCharTraits<char16_t>::copy(buf, aValue, stringLen + 1); NS_ADDREF(*aResult = new (objectPtr) LiteralImpl(buf)); return NS_OK; } -LiteralImpl::LiteralImpl(const PRUnichar* s) +LiteralImpl::LiteralImpl(const char16_t* s) { RDFServiceImpl::gRDFService->RegisterLiteral(this); NS_ADDREF(RDFServiceImpl::gRDFService); @@ -454,8 +440,8 @@ LiteralImpl::~LiteralImpl() NS_RELEASE2(RDFServiceImpl::gRDFService, refcnt); } -NS_IMPL_THREADSAFE_ADDREF(LiteralImpl) -NS_IMPL_THREADSAFE_RELEASE(LiteralImpl) +NS_IMPL_ADDREF(LiteralImpl) +NS_IMPL_RELEASE(LiteralImpl) nsresult LiteralImpl::QueryInterface(REFNSIID iid, void** result) @@ -495,20 +481,20 @@ LiteralImpl::EqualsNode(nsIRDFNode* aNode, bool* aResult) } NS_IMETHODIMP -LiteralImpl::GetValue(PRUnichar* *value) +LiteralImpl::GetValue(char16_t* *value) { NS_ASSERTION(value, "null ptr"); if (! value) return NS_ERROR_NULL_POINTER; - const PRUnichar *temp = GetValue(); + const char16_t *temp = GetValue(); *value = temp? NS_strdup(temp) : 0; return NS_OK; } NS_IMETHODIMP -LiteralImpl::GetValueConst(const PRUnichar** aValue) +LiteralImpl::GetValueConst(const char16_t** aValue) { *aValue = GetValue(); return NS_OK; @@ -520,8 +506,7 @@ LiteralImpl::GetValueConst(const PRUnichar** aValue) class DateImpl : public nsIRDFDate { public: - DateImpl(const PRTime s); - virtual ~DateImpl(); + explicit DateImpl(const PRTime s); // nsISupports NS_DECL_ISUPPORTS @@ -530,9 +515,11 @@ public: NS_DECL_NSIRDFNODE // nsIRDFDate - NS_IMETHOD GetValue(PRTime *value); + NS_IMETHOD GetValue(PRTime *value) override; private: + virtual ~DateImpl(); + nsresult EqualsDate(nsIRDFDate* date, bool* result); PRTime mValue; }; @@ -616,7 +603,7 @@ DateImpl::EqualsDate(nsIRDFDate* date, bool* result) if (NS_FAILED(rv = date->GetValue(&p))) return rv; - *result = LL_EQ(p, mValue); + *result = p == mValue; return NS_OK; } @@ -626,8 +613,7 @@ DateImpl::EqualsDate(nsIRDFDate* date, bool* result) class IntImpl : public nsIRDFInt { public: - IntImpl(int32_t s); - virtual ~IntImpl(); + explicit IntImpl(int32_t s); // nsISupports NS_DECL_ISUPPORTS @@ -636,9 +622,11 @@ public: NS_DECL_NSIRDFNODE // nsIRDFInt - NS_IMETHOD GetValue(int32_t *value); + NS_IMETHOD GetValue(int32_t *value) override; private: + virtual ~IntImpl(); + nsresult EqualsInt(nsIRDFInt* value, bool* result); int32_t mValue; }; @@ -735,11 +723,6 @@ RDFServiceImpl::gRDFService; RDFServiceImpl::RDFServiceImpl() : mNamedDataSources(nullptr) { - mResources.ops = nullptr; - mLiterals.ops = nullptr; - mInts.ops = nullptr; - mDates.ops = nullptr; - mBlobs.ops = nullptr; gRDFService = this; } @@ -757,31 +740,17 @@ RDFServiceImpl::Init() if (! mNamedDataSources) return NS_ERROR_OUT_OF_MEMORY; - if (!PL_DHashTableInit(&mResources, &gResourceTableOps, nullptr, - sizeof(ResourceHashEntry), PL_DHASH_MIN_SIZE)) { - mResources.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } - if (!PL_DHashTableInit(&mLiterals, &gLiteralTableOps, nullptr, - sizeof(LiteralHashEntry), PL_DHASH_MIN_SIZE)) { - mLiterals.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } - if (!PL_DHashTableInit(&mInts, &gIntTableOps, nullptr, - sizeof(IntHashEntry), PL_DHASH_MIN_SIZE)) { - mInts.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } - if (!PL_DHashTableInit(&mDates, &gDateTableOps, nullptr, - sizeof(DateHashEntry), PL_DHASH_MIN_SIZE)) { - mDates.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } - if (!PL_DHashTableInit(&mBlobs, &gBlobTableOps, nullptr, - sizeof(BlobHashEntry), PL_DHASH_MIN_SIZE)) { - mBlobs.ops = nullptr; - return NS_ERROR_OUT_OF_MEMORY; - } + PL_DHashTableInit(&mResources, &gResourceTableOps, + sizeof(ResourceHashEntry)); + + PL_DHashTableInit(&mLiterals, &gLiteralTableOps, sizeof(LiteralHashEntry)); + + PL_DHashTableInit(&mInts, &gIntTableOps, sizeof(IntHashEntry)); + + PL_DHashTableInit(&mDates, &gDateTableOps, sizeof(DateHashEntry)); + + PL_DHashTableInit(&mBlobs, &gBlobTableOps, sizeof(BlobHashEntry)); + mDefaultResourceFactory = do_GetClassObject(kRDFDefaultResourceCID, &rv); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get default resource factory"); if (NS_FAILED(rv)) return rv; @@ -801,15 +770,15 @@ RDFServiceImpl::~RDFServiceImpl() PL_HashTableDestroy(mNamedDataSources); mNamedDataSources = nullptr; } - if (mResources.ops) + if (mResources.IsInitialized()) PL_DHashTableFinish(&mResources); - if (mLiterals.ops) + if (mLiterals.IsInitialized()) PL_DHashTableFinish(&mLiterals); - if (mInts.ops) + if (mInts.IsInitialized()) PL_DHashTableFinish(&mInts); - if (mDates.ops) + if (mDates.IsInitialized()) PL_DHashTableFinish(&mDates); - if (mBlobs.ops) + if (mBlobs.IsInitialized()) PL_DHashTableFinish(&mBlobs); gRDFService = nullptr; } @@ -838,7 +807,7 @@ RDFServiceImpl::CreateSingleton(nsISupports* aOuter, return serv->QueryInterface(aIID, aResult); } -NS_IMPL_THREADSAFE_ISUPPORTS2(RDFServiceImpl, nsIRDFService, nsISupportsWeakReference) +NS_IMPL_ISUPPORTS(RDFServiceImpl, nsIRDFService, nsISupportsWeakReference) // Per RFC2396. static const uint8_t @@ -892,10 +861,8 @@ RDFServiceImpl::GetResource(const nsACString& aURI, nsIRDFResource** aResource) // First, check the cache to see if we've already created and // registered this thing. - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mResources, flatURI.get(), PL_DHASH_LOOKUP); - - if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { + PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mResources, flatURI.get()); + if (hdr) { ResourceHashEntry *entry = static_cast<ResourceHashEntry *>(hdr); NS_ADDREF(*aResource = entry->mResource); return NS_OK; @@ -1020,7 +987,7 @@ static int32_t kShift = 6; // service. Now that it's a member we can be more cleverer. s.Truncate(); - s.Append("rdf:#$"); + s.AppendLiteral("rdf:#$"); uint32_t id = ++gCounter; while (id) { @@ -1051,7 +1018,7 @@ static int32_t kShift = 6; NS_IMETHODIMP -RDFServiceImpl::GetLiteral(const PRUnichar* aValue, nsIRDFLiteral** aLiteral) +RDFServiceImpl::GetLiteral(const char16_t* aValue, nsIRDFLiteral** aLiteral) { NS_PRECONDITION(aValue != nullptr, "null ptr"); if (! aValue) @@ -1062,10 +1029,8 @@ RDFServiceImpl::GetLiteral(const PRUnichar* aValue, nsIRDFLiteral** aLiteral) return NS_ERROR_NULL_POINTER; // See if we have one already cached - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mLiterals, aValue, PL_DHASH_LOOKUP); - - if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { + PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mLiterals, aValue); + if (hdr) { LiteralHashEntry *entry = static_cast<LiteralHashEntry *>(hdr); NS_ADDREF(*aLiteral = entry->mLiteral); return NS_OK; @@ -1079,10 +1044,8 @@ NS_IMETHODIMP RDFServiceImpl::GetDateLiteral(PRTime aTime, nsIRDFDate** aResult) { // See if we have one already cached - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mDates, &aTime, PL_DHASH_LOOKUP); - - if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { + PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mDates, &aTime); + if (hdr) { DateHashEntry *entry = static_cast<DateHashEntry *>(hdr); NS_ADDREF(*aResult = entry->mDate); return NS_OK; @@ -1100,10 +1063,8 @@ NS_IMETHODIMP RDFServiceImpl::GetIntLiteral(int32_t aInt, nsIRDFInt** aResult) { // See if we have one already cached - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mInts, &aInt, PL_DHASH_LOOKUP); - - if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { + PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mInts, &aInt); + if (hdr) { IntHashEntry *entry = static_cast<IntHashEntry *>(hdr); NS_ADDREF(*aResult = entry->mInt); return NS_OK; @@ -1123,10 +1084,8 @@ RDFServiceImpl::GetBlobLiteral(const uint8_t *aBytes, int32_t aLength, { BlobImpl::Data key = { aLength, const_cast<uint8_t *>(aBytes) }; - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mBlobs, &key, PL_DHASH_LOOKUP); - - if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { + PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mBlobs, &key); + if (hdr) { BlobHashEntry *entry = static_cast<BlobHashEntry *>(hdr); NS_ADDREF(*aResult = entry->mBlob); return NS_OK; @@ -1186,10 +1145,8 @@ RDFServiceImpl::RegisterResource(nsIRDFResource* aResource, bool aReplace) if (! uri) return NS_ERROR_NULL_POINTER; - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mResources, uri, PL_DHASH_LOOKUP); - - if (PL_DHASH_ENTRY_IS_BUSY(hdr)) { + PLDHashEntryHdr *hdr = PL_DHashTableSearch(&mResources, uri); + if (hdr) { if (!aReplace) { NS_WARNING("resource already registered, and replace not specified"); return NS_ERROR_FAILURE; // already registered @@ -1205,7 +1162,7 @@ RDFServiceImpl::RegisterResource(nsIRDFResource* aResource, bool aReplace) aResource, (const char*) uri)); } else { - hdr = PL_DHashTableOperate(&mResources, uri, PL_DHASH_ADD); + hdr = PL_DHashTableAdd(&mResources, uri, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1247,11 +1204,11 @@ RDFServiceImpl::UnregisterResource(nsIRDFResource* aResource) aResource, (const char*) uri)); #ifdef DEBUG - if (PL_DHASH_ENTRY_IS_FREE(PL_DHashTableOperate(&mResources, uri, PL_DHASH_LOOKUP))) + if (!PL_DHashTableSearch(&mResources, uri)) NS_WARNING("resource was never registered"); #endif - PL_DHashTableOperate(&mResources, uri, PL_DHASH_REMOVE); + PL_DHashTableRemove(&mResources, uri); return NS_OK; } @@ -1397,7 +1354,7 @@ RDFServiceImpl::GetDataSource(const char* aURI, bool aBlock, nsIRDFDataSource** Substring(spec, 4, spec.Length() - 4)); // Strip params to get ``base'' contractID for data source. - int32_t p = contractID.FindChar(PRUnichar('&')); + int32_t p = contractID.FindChar(char16_t('&')); if (p >= 0) contractID.Truncate(p); @@ -1436,17 +1393,13 @@ RDFServiceImpl::GetDataSource(const char* aURI, bool aBlock, nsIRDFDataSource** nsresult RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral) { - const PRUnichar* value; + const char16_t* value; aLiteral->GetValueConst(&value); - NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableOperate(&mLiterals, - value, - PL_DHASH_LOOKUP)), + NS_ASSERTION(!PL_DHashTableSearch(&mLiterals, value), "literal already registered"); - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mLiterals, value, PL_DHASH_ADD); - + PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mLiterals, value, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1461,7 +1414,7 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral) PR_LOG(gLog, PR_LOG_DEBUG, ("rdfserv register-literal [%p] %s", - aLiteral, (const PRUnichar*) value)); + aLiteral, (const char16_t*) value)); return NS_OK; } @@ -1470,21 +1423,19 @@ RDFServiceImpl::RegisterLiteral(nsIRDFLiteral* aLiteral) nsresult RDFServiceImpl::UnregisterLiteral(nsIRDFLiteral* aLiteral) { - const PRUnichar* value; + const char16_t* value; aLiteral->GetValueConst(&value); - NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableOperate(&mLiterals, - value, - PL_DHASH_LOOKUP)), + NS_ASSERTION(PL_DHashTableSearch(&mLiterals, value), "literal was never registered"); - PL_DHashTableOperate(&mLiterals, value, PL_DHASH_REMOVE); + PL_DHashTableRemove(&mLiterals, value); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. PR_LOG(gLog, PR_LOG_DEBUG, ("rdfserv unregister-literal [%p] %s", - aLiteral, (const PRUnichar*) value)); + aLiteral, (const char16_t*) value)); return NS_OK; } @@ -1497,14 +1448,10 @@ RDFServiceImpl::RegisterInt(nsIRDFInt* aInt) int32_t value; aInt->GetValue(&value); - NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableOperate(&mInts, - &value, - PL_DHASH_LOOKUP)), + NS_ASSERTION(!PL_DHashTableSearch(&mInts, &value), "int already registered"); - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mInts, &value, PL_DHASH_ADD); - + PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mInts, &value, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1531,12 +1478,10 @@ RDFServiceImpl::UnregisterInt(nsIRDFInt* aInt) int32_t value; aInt->GetValue(&value); - NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableOperate(&mInts, - &value, - PL_DHASH_LOOKUP)), + NS_ASSERTION(PL_DHashTableSearch(&mInts, &value), "int was never registered"); - PL_DHashTableOperate(&mInts, &value, PL_DHASH_REMOVE); + PL_DHashTableRemove(&mInts, &value); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. @@ -1555,14 +1500,10 @@ RDFServiceImpl::RegisterDate(nsIRDFDate* aDate) PRTime value; aDate->GetValue(&value); - NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableOperate(&mDates, - &value, - PL_DHASH_LOOKUP)), + NS_ASSERTION(!PL_DHashTableSearch(&mDates, &value), "date already registered"); - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mDates, &value, PL_DHASH_ADD); - + PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mDates, &value, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1589,12 +1530,10 @@ RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate) PRTime value; aDate->GetValue(&value); - NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableOperate(&mDates, - &value, - PL_DHASH_LOOKUP)), + NS_ASSERTION(PL_DHashTableSearch(&mDates, &value), "date was never registered"); - PL_DHashTableOperate(&mDates, &value, PL_DHASH_REMOVE); + PL_DHashTableRemove(&mDates, &value); // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. @@ -1608,14 +1547,10 @@ RDFServiceImpl::UnregisterDate(nsIRDFDate* aDate) nsresult RDFServiceImpl::RegisterBlob(BlobImpl *aBlob) { - NS_ASSERTION(PL_DHASH_ENTRY_IS_FREE(PL_DHashTableOperate(&mBlobs, - &aBlob->mData, - PL_DHASH_LOOKUP)), + NS_ASSERTION(!PL_DHashTableSearch(&mBlobs, &aBlob->mData), "blob already registered"); - PLDHashEntryHdr *hdr = - PL_DHashTableOperate(&mBlobs, &aBlob->mData, PL_DHASH_ADD); - + PLDHashEntryHdr *hdr = PL_DHashTableAdd(&mBlobs, &aBlob->mData, fallible); if (! hdr) return NS_ERROR_OUT_OF_MEMORY; @@ -1637,13 +1572,11 @@ RDFServiceImpl::RegisterBlob(BlobImpl *aBlob) nsresult RDFServiceImpl::UnregisterBlob(BlobImpl *aBlob) { - NS_ASSERTION(PL_DHASH_ENTRY_IS_BUSY(PL_DHashTableOperate(&mBlobs, - &aBlob->mData, - PL_DHASH_LOOKUP)), + NS_ASSERTION(PL_DHashTableSearch(&mBlobs, &aBlob->mData), "blob was never registered"); - PL_DHashTableOperate(&mBlobs, &aBlob->mData, PL_DHASH_REMOVE); - + PL_DHashTableRemove(&mBlobs, &aBlob->mData); + // N.B. that we _don't_ release the literal: we only held a weak // reference to it in the hashtable. PR_LOG(gLog, PR_LOG_DEBUG, diff --git a/rdf/base/src/nsRDFService.h b/rdf/base/nsRDFService.h index ce9070572..27905f9b9 100644 --- a/rdf/base/src/nsRDFService.h +++ b/rdf/base/nsRDFService.h @@ -33,8 +33,8 @@ class nsIRDFInt; class nsIRDFDate; class BlobImpl; -class RDFServiceImpl : public nsIRDFService, - public nsSupportsWeakReference +class RDFServiceImpl final : public nsIRDFService, + public nsSupportsWeakReference { protected: PLHashTable* mNamedDataSources; diff --git a/rdf/base/src/nsRDFXMLDataSource.cpp b/rdf/base/nsRDFXMLDataSource.cpp index 4b78b680c..c4c6a0965 100644 --- a/rdf/base/src/nsRDFXMLDataSource.cpp +++ b/rdf/base/nsRDFXMLDataSource.cpp @@ -94,19 +94,12 @@ #include "nsIChannelEventSink.h" #include "nsIAsyncVerifyRedirectCallback.h" #include "nsNetUtil.h" +#include "nsIContentPolicy.h" +#include "nsContentUtils.h" #include "rdfIDataSource.h" //---------------------------------------------------------------------- - -static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID); -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); - -#ifdef PR_LOGGING -static PRLogModuleInfo* gLog; -#endif - -//---------------------------------------------------------------------- // // RDFXMLDataSourceImpl // @@ -141,6 +134,10 @@ protected: static int32_t gRefCnt; static nsIRDFService* gRDFService; +#ifdef PR_LOGGING + static PRLogModuleInfo* gLog; +#endif + nsresult Init(); RDFXMLDataSourceImpl(void); virtual ~RDFXMLDataSourceImpl(void); @@ -161,118 +158,118 @@ public: nsIRDFDataSource) // nsIRDFDataSource - NS_IMETHOD GetURI(char* *uri); + NS_IMETHOD GetURI(char* *uri) override; NS_IMETHOD GetSource(nsIRDFResource* property, nsIRDFNode* target, bool tv, - nsIRDFResource** source) { + nsIRDFResource** source) override { return mInner->GetSource(property, target, tv, source); } NS_IMETHOD GetSources(nsIRDFResource* property, nsIRDFNode* target, bool tv, - nsISimpleEnumerator** sources) { + nsISimpleEnumerator** sources) override { return mInner->GetSources(property, target, tv, sources); } NS_IMETHOD GetTarget(nsIRDFResource* source, nsIRDFResource* property, bool tv, - nsIRDFNode** target) { + nsIRDFNode** target) override { return mInner->GetTarget(source, property, tv, target); } NS_IMETHOD GetTargets(nsIRDFResource* source, nsIRDFResource* property, bool tv, - nsISimpleEnumerator** targets) { + nsISimpleEnumerator** targets) override { return mInner->GetTargets(source, property, tv, targets); } NS_IMETHOD Assert(nsIRDFResource* aSource, nsIRDFResource* aProperty, nsIRDFNode* aTarget, - bool tv); + bool tv) override; NS_IMETHOD Unassert(nsIRDFResource* source, nsIRDFResource* property, - nsIRDFNode* target); + nsIRDFNode* target) override; NS_IMETHOD Change(nsIRDFResource* aSource, nsIRDFResource* aProperty, nsIRDFNode* aOldTarget, - nsIRDFNode* aNewTarget); + nsIRDFNode* aNewTarget) override; NS_IMETHOD Move(nsIRDFResource* aOldSource, nsIRDFResource* aNewSource, nsIRDFResource* aProperty, - nsIRDFNode* aTarget); + nsIRDFNode* aTarget) override; NS_IMETHOD HasAssertion(nsIRDFResource* source, nsIRDFResource* property, nsIRDFNode* target, bool tv, - bool* hasAssertion) { + bool* hasAssertion) override { return mInner->HasAssertion(source, property, target, tv, hasAssertion); } - NS_IMETHOD AddObserver(nsIRDFObserver* aObserver) { + NS_IMETHOD AddObserver(nsIRDFObserver* aObserver) override { return mInner->AddObserver(aObserver); } - NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver) { + NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver) override { return mInner->RemoveObserver(aObserver); } - NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval) { + NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval) override { return mInner->HasArcIn(aNode, aArc, _retval); } - NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval) { + NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval) override { return mInner->HasArcOut(aSource, aArc, _retval); } NS_IMETHOD ArcLabelsIn(nsIRDFNode* node, - nsISimpleEnumerator** labels) { + nsISimpleEnumerator** labels) override { return mInner->ArcLabelsIn(node, labels); } NS_IMETHOD ArcLabelsOut(nsIRDFResource* source, - nsISimpleEnumerator** labels) { + nsISimpleEnumerator** labels) override { return mInner->ArcLabelsOut(source, labels); } - NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) { + NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) override { return mInner->GetAllResources(aResult); } NS_IMETHOD GetAllCmds(nsIRDFResource* source, - nsISimpleEnumerator/*<nsIRDFResource>*/** commands) { + nsISimpleEnumerator/*<nsIRDFResource>*/** commands) override { return mInner->GetAllCmds(source, commands); } NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources, nsIRDFResource* aCommand, nsISupportsArray/*<nsIRDFResource>*/* aArguments, - bool* aResult) { + bool* aResult) override { return mInner->IsCommandEnabled(aSources, aCommand, aArguments, aResult); } NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources, nsIRDFResource* aCommand, - nsISupportsArray/*<nsIRDFResource>*/* aArguments) { + nsISupportsArray/*<nsIRDFResource>*/* aArguments) override { // XXX Uh oh, this could cause problems wrt. the "dirty" flag // if it changes the in-memory store's internal state. return mInner->DoCommand(aSources, aCommand, aArguments); } - NS_IMETHOD BeginUpdateBatch() { + NS_IMETHOD BeginUpdateBatch() override { return mInner->BeginUpdateBatch(); } - NS_IMETHOD EndUpdateBatch() { + NS_IMETHOD EndUpdateBatch() override { return mInner->EndUpdateBatch(); } @@ -298,14 +295,14 @@ public: NS_DECL_NSICHANNELEVENTSINK // rdfIDataSource - NS_IMETHOD VisitAllSubjects(rdfITripleVisitor *aVisitor) { + NS_IMETHOD VisitAllSubjects(rdfITripleVisitor *aVisitor) override { nsresult rv; nsCOMPtr<rdfIDataSource> rdfds = do_QueryInterface(mInner, &rv); if (NS_FAILED(rv)) return rv; return rdfds->VisitAllSubjects(aVisitor); } - NS_IMETHOD VisitAllTriples(rdfITripleVisitor *aVisitor) { + NS_IMETHOD VisitAllTriples(rdfITripleVisitor *aVisitor) override { nsresult rv; nsCOMPtr<rdfIDataSource> rdfds = do_QueryInterface(mInner, &rv); if (NS_FAILED(rv)) return rv; @@ -363,6 +360,10 @@ protected: int32_t RDFXMLDataSourceImpl::gRefCnt = 0; nsIRDFService* RDFXMLDataSourceImpl::gRDFService; +#ifdef PR_LOGGING +PRLogModuleInfo* RDFXMLDataSourceImpl::gLog; +#endif + static const char kFileURIPrefix[] = "file:"; static const char kResourceURIPrefix[] = "resource:"; @@ -410,10 +411,12 @@ nsresult RDFXMLDataSourceImpl::Init() { nsresult rv; + NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID); mInner = do_CreateInstance(kRDFInMemoryDataSourceCID, &rv); if (NS_FAILED(rv)) return rv; if (gRefCnt++ == 0) { + NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); rv = CallGetService(kRDFServiceCID, &gRDFService); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get RDF service"); @@ -426,13 +429,11 @@ RDFXMLDataSourceImpl::Init() RDFXMLDataSourceImpl::~RDFXMLDataSourceImpl(void) { - nsresult rv; - // Unregister first so that nobody else tries to get us. - rv = gRDFService->UnregisterDataSource(this); + (void) gRDFService->UnregisterDataSource(this); // Now flush contents - rv = Flush(); + (void) Flush(); // Release RDF/XML sink observers mObservers.Clear(); @@ -441,6 +442,8 @@ RDFXMLDataSourceImpl::~RDFXMLDataSourceImpl(void) NS_IF_RELEASE(gRDFService); } +NS_IMPL_CYCLE_COLLECTION_CLASS(RDFXMLDataSourceImpl) + NS_IMPL_CYCLE_COLLECTION_UNLINK_0(RDFXMLDataSourceImpl) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(RDFXMLDataSourceImpl) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInner) @@ -482,7 +485,12 @@ RDFXMLDataSourceImpl::BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer) nsCOMPtr<nsIRequest> request; // Null LoadGroup ? - rv = NS_NewChannel(getter_AddRefs(channel), aURL, nullptr); + rv = NS_NewChannel(getter_AddRefs(channel), + aURL, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); + if (NS_FAILED(rv)) return rv; nsCOMPtr<nsIInputStream> in; rv = channel->Open(getter_AddRefs(in)); @@ -740,6 +748,7 @@ RDFXMLDataSourceImpl::rdfXMLFlush(nsIURI *aURI) // we are, we're screwed: it's too late to serialize because // many of the services that we'll need to acquire to properly // write the file will be unaquirable. + NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); nsCOMPtr<nsIRDFService> dummy = do_GetService(kRDFServiceCID, &rv); if (NS_FAILED(rv)) { NS_WARNING("unable to Flush() dirty datasource during XPCOM shutdown"); @@ -880,7 +889,7 @@ RDFXMLDataSourceImpl::AsyncOnChannelRedirect(nsIChannel *aOldChannel, NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIPrincipal> oldPrincipal; - secMan->GetChannelPrincipal(aOldChannel, getter_AddRefs(oldPrincipal)); + secMan->GetChannelResultPrincipal(aOldChannel, getter_AddRefs(oldPrincipal)); nsCOMPtr<nsIURI> newURI; aNewChannel->GetURI(getter_AddRefs(newURI)); @@ -946,8 +955,17 @@ RDFXMLDataSourceImpl::Refresh(bool aBlocking) } else { // Null LoadGroup ? - rv = NS_OpenURI(this, nullptr, mURL, nullptr, nullptr, this); - if (NS_FAILED(rv)) return rv; + nsCOMPtr<nsIChannel> channel; + rv = NS_NewChannel(getter_AddRefs(channel), + mURL, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER, + nullptr, // aLoadGroup + this); // aCallbacks + NS_ENSURE_SUCCESS(rv, rv); + rv = channel->AsyncOpen(this, nullptr); + NS_ENSURE_SUCCESS(rv, rv); // So we don't try to issue two asynchronous loads at once. mLoadState = eLoadState_Pending; diff --git a/rdf/base/src/nsRDFXMLParser.cpp b/rdf/base/nsRDFXMLParser.cpp index aefb384bc..fc466f3a9 100644 --- a/rdf/base/src/nsRDFXMLParser.cpp +++ b/rdf/base/nsRDFXMLParser.cpp @@ -13,10 +13,11 @@ #include "nsParserCIID.h" #include "nsStringStream.h" #include "nsNetUtil.h" +#include "nsNullPrincipal.h" static NS_DEFINE_CID(kParserCID, NS_PARSER_CID); -NS_IMPL_ISUPPORTS1(nsRDFXMLParser, nsIRDFXMLParser) +NS_IMPL_ISUPPORTS(nsRDFXMLParser, nsIRDFXMLParser) nsresult nsRDFXMLParser::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult) @@ -114,8 +115,17 @@ nsRDFXMLParser::ParseString(nsIRDFDataSource* aSink, nsIURI* aBaseURI, const nsA rv = NS_NewCStringInputStream(getter_AddRefs(stream), aString); if (NS_FAILED(rv)) return rv; + nsCOMPtr<nsIPrincipal> nullPrincipal = + do_CreateInstance("@mozilla.org/nullprincipal;1", &rv); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr<nsIChannel> channel; - rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aBaseURI, stream, + rv = NS_NewInputStreamChannel(getter_AddRefs(channel), + aBaseURI, + stream, + nullPrincipal, + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER, NS_LITERAL_CSTRING("text/xml")); if (NS_FAILED(rv)) return rv; diff --git a/rdf/base/src/nsRDFXMLParser.h b/rdf/base/nsRDFXMLParser.h index d35c873fb..d35c873fb 100644 --- a/rdf/base/src/nsRDFXMLParser.h +++ b/rdf/base/nsRDFXMLParser.h diff --git a/rdf/base/src/nsRDFXMLSerializer.cpp b/rdf/base/nsRDFXMLSerializer.cpp index 24b7cb4e0..27dea21d7 100644 --- a/rdf/base/src/nsRDFXMLSerializer.cpp +++ b/rdf/base/nsRDFXMLSerializer.cpp @@ -113,7 +113,7 @@ nsRDFXMLSerializer::~nsRDFXMLSerializer() } } -NS_IMPL_ISUPPORTS2(nsRDFXMLSerializer, nsIRDFXMLSerializer, nsIRDFXMLSource) +NS_IMPL_ISUPPORTS(nsRDFXMLSerializer, nsIRDFXMLSerializer, nsIRDFXMLSource) NS_IMETHODIMP nsRDFXMLSerializer::Init(nsIRDFDataSource* aDataSource) @@ -133,7 +133,6 @@ nsRDFXMLSerializer::Init(nsIRDFDataSource* aDataSource) prefix = do_GetAtom("NC"); AddNameSpace(prefix, NS_LITERAL_STRING("http://home.netscape.com/NC-rdf#")); - mQNames.Init(); mPrefixID = 0; return NS_OK; @@ -372,7 +371,7 @@ nsRDFXMLSerializer::SerializeInlineAssertion(nsIOutputStream* aStream, NS_LITERAL_CSTRING("\n ")); if (NS_FAILED(rv)) return rv; - const PRUnichar* value; + const char16_t* value; aValue->GetValueConst(&value); NS_ConvertUTF16toUTF8 s(value); @@ -425,7 +424,7 @@ nsRDFXMLSerializer::SerializeChildAssertion(nsIOutputStream* aStream, goto no_close_tag; } else if ((literal = do_QueryInterface(aValue)) != nullptr) { - const PRUnichar *value; + const char16_t *value; literal->GetValueConst(&value); NS_ConvertUTF16toUTF8 s(value); @@ -516,12 +515,12 @@ nsRDFXMLSerializer::SerializeProperty(nsIOutputStream* aStream, if (!needsChild) { assertions->HasMoreElements(&needsChild); if (!needsChild) { - const PRUnichar* literalVal = nullptr; + const char16_t* literalVal = nullptr; literal->GetValueConst(&literalVal); if (literalVal) { for (; *literalVal; literalVal++) { - if (*literalVal == PRUnichar('\n') || - *literalVal == PRUnichar('\r')) { + if (*literalVal == char16_t('\n') || + *literalVal == char16_t('\r')) { needsChild = true; break; } @@ -593,7 +592,7 @@ nsRDFXMLSerializer::SerializeDescription(nsIOutputStream* aStream, sizeof(kRDFDescriptionOpen) - 1); if (NS_FAILED(rv)) return rv; } - if (uri[0] == PRUnichar('#')) { + if (uri[0] == char16_t('#')) { uri.Cut(0, 1); rv = rdf_BlockingWrite(aStream, kIDAttr, sizeof(kIDAttr) - 1); } @@ -759,7 +758,7 @@ static const char kRDFLIOpen[] = " <RDF:li"; goto no_close_tag; } else if ((literal = do_QueryInterface(aMember)) != nullptr) { - const PRUnichar *value; + const char16_t *value; literal->GetValueConst(&value); static const char kRDFLIOpenGT[] = ">"; // close the '<RDF:LI' before adding the literal @@ -1007,17 +1006,18 @@ nsRDFXMLSerializer::SerializeEpilogue(nsIOutputStream* aStream) return rdf_BlockingWrite(aStream, NS_LITERAL_CSTRING("</RDF:RDF>\n")); } -class QNameCollector MOZ_FINAL : public rdfITripleVisitor { +class QNameCollector final : public rdfITripleVisitor { public: NS_DECL_ISUPPORTS NS_DECL_RDFITRIPLEVISITOR - QNameCollector(nsRDFXMLSerializer* aParent) + explicit QNameCollector(nsRDFXMLSerializer* aParent) : mParent(aParent){} private: + ~QNameCollector() {} nsRDFXMLSerializer* mParent; }; -NS_IMPL_ISUPPORTS1(QNameCollector, rdfITripleVisitor) +NS_IMPL_ISUPPORTS(QNameCollector, rdfITripleVisitor) nsresult QNameCollector::Visit(nsIRDFNode* aSubject, nsIRDFResource* aPredicate, nsIRDFNode* aObject, bool aTruthValue) diff --git a/rdf/base/src/nsRDFXMLSerializer.h b/rdf/base/nsRDFXMLSerializer.h index f6ad9a455..f6ad9a455 100644 --- a/rdf/base/src/nsRDFXMLSerializer.h +++ b/rdf/base/nsRDFXMLSerializer.h diff --git a/rdf/base/public/moz.build b/rdf/base/public/moz.build deleted file mode 100644 index f7bc4129e..000000000 --- a/rdf/base/public/moz.build +++ /dev/null @@ -1,13 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -MODULE = 'rdf' - -EXPORTS += [ - 'nsIRDFContentSink.h', - 'rdf.h', -] - diff --git a/rdf/base/public/rdf.h b/rdf/base/rdf.h index a863884a0..a863884a0 100644 --- a/rdf/base/public/rdf.h +++ b/rdf/base/rdf.h diff --git a/rdf/base/idl/rdfIDataSource.idl b/rdf/base/rdfIDataSource.idl index 848cbca11..848cbca11 100644 --- a/rdf/base/idl/rdfIDataSource.idl +++ b/rdf/base/rdfIDataSource.idl diff --git a/rdf/base/idl/rdfISerializer.idl b/rdf/base/rdfISerializer.idl index 9ec6b69ea..9ec6b69ea 100644 --- a/rdf/base/idl/rdfISerializer.idl +++ b/rdf/base/rdfISerializer.idl diff --git a/rdf/base/idl/rdfITripleVisitor.idl b/rdf/base/rdfITripleVisitor.idl index ecac14871..ecac14871 100644 --- a/rdf/base/idl/rdfITripleVisitor.idl +++ b/rdf/base/rdfITripleVisitor.idl diff --git a/rdf/base/src/rdfTriplesSerializer.cpp b/rdf/base/rdfTriplesSerializer.cpp index ea8d304b8..f419c7612 100644 --- a/rdf/base/src/rdfTriplesSerializer.cpp +++ b/rdf/base/rdfTriplesSerializer.cpp @@ -21,18 +21,19 @@ #include "nsIRDFLiteral.h" #include "mozilla/Attributes.h" -class TriplesVisitor MOZ_FINAL : public rdfITripleVisitor +class TriplesVisitor final : public rdfITripleVisitor { public: - TriplesVisitor(nsIOutputStream* aOut) : mOut(aOut) {} + explicit TriplesVisitor(nsIOutputStream* aOut) : mOut(aOut) {} NS_DECL_RDFITRIPLEVISITOR NS_DECL_ISUPPORTS protected: + ~TriplesVisitor() {} nsresult writeResource(nsIRDFResource* aResource); nsIOutputStream* mOut; }; -NS_IMPL_ISUPPORTS1(TriplesVisitor, rdfITripleVisitor) +NS_IMPL_ISUPPORTS(TriplesVisitor, rdfITripleVisitor) nsresult TriplesVisitor::writeResource(nsIRDFResource *aResource) @@ -74,10 +75,10 @@ TriplesVisitor::Visit(nsIRDFNode *aSubject, nsIRDFResource *aPredicate, if (res) { rv = writeResource(res); } else if ((lit = do_QueryInterface(aObject)) != nullptr) { - const PRUnichar *value; + const char16_t *value; lit->GetValueConst(&value); nsAutoCString object; - object.AppendLiteral("\""); + object.Append('"'); AppendUTF16toUTF8(value, object); object.AppendLiteral("\" "); uint32_t writeCount = object.Length(); @@ -97,7 +98,7 @@ TriplesVisitor::Visit(nsIRDFNode *aSubject, nsIRDFResource *aPredicate, return mOut->Write(".\n", 2, &wroteCount); } -class rdfTriplesSerializer MOZ_FINAL : public rdfISerializer +class rdfTriplesSerializer final : public rdfISerializer { public: NS_DECL_ISUPPORTS @@ -124,7 +125,7 @@ NS_NewTriplesSerializer(rdfISerializer** aResult) return NS_OK; } -NS_IMPL_ISUPPORTS1(rdfTriplesSerializer, rdfISerializer) +NS_IMPL_ISUPPORTS(rdfTriplesSerializer, rdfISerializer) rdfTriplesSerializer::rdfTriplesSerializer() { diff --git a/rdf/base/src/rdfutil.cpp b/rdf/base/rdfutil.cpp index 982174ccc..9a3f794b0 100644 --- a/rdf/base/src/rdfutil.cpp +++ b/rdf/base/rdfutil.cpp @@ -67,7 +67,7 @@ rdf_FormatDate(PRTime aTime, nsACString &aResult) aResult.Append(buf); // usecs - aResult.Append(" +"); + aResult.AppendLiteral(" +"); int32_t usec = t.tm_usec; for (int32_t digit = 100000; digit > 1; digit /= 10) { aResult.Append(char('0' + (usec / digit))); @@ -104,9 +104,7 @@ rdf_ParseDate(const nsACString &aTime) usec += *digit - '0'; } - PRTime temp; - LL_I2L(temp, usec); - t += temp; + t += usec; } return t; diff --git a/rdf/base/src/rdfutil.h b/rdf/base/rdfutil.h index 80657e8eb..284f8e57a 100644 --- a/rdf/base/src/rdfutil.h +++ b/rdf/base/rdfutil.h @@ -22,7 +22,6 @@ #ifndef rdfutil_h__ #define rdfutil_h__ -#include "prtypes.h" class nsACString; class nsCString; diff --git a/rdf/base/src/Makefile.in b/rdf/base/src/Makefile.in deleted file mode 100644 index 541ee89b7..000000000 --- a/rdf/base/src/Makefile.in +++ /dev/null @@ -1,19 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBXUL_LIBRARY = 1 - -# we don't want the shared lib, but we want to force the creation of a static lib. -FORCE_STATIC_LIB = 1 - -include $(topsrcdir)/config/rules.mk - diff --git a/rdf/base/src/moz.build b/rdf/base/src/moz.build deleted file mode 100644 index 70844226d..000000000 --- a/rdf/base/src/moz.build +++ /dev/null @@ -1,27 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -MODULE = 'rdf' - -CPP_SOURCES += [ - 'nsCompositeDataSource.cpp', - 'nsContainerEnumerator.cpp', - 'nsDefaultResourceFactory.cpp', - 'nsInMemoryDataSource.cpp', - 'nsNameSpaceMap.cpp', - 'nsRDFContainer.cpp', - 'nsRDFContainerUtils.cpp', - 'nsRDFContentSink.cpp', - 'nsRDFService.cpp', - 'nsRDFXMLDataSource.cpp', - 'nsRDFXMLParser.cpp', - 'nsRDFXMLSerializer.cpp', - 'rdfTriplesSerializer.cpp', - 'rdfutil.cpp', -] - -LIBRARY_NAME = 'rdfbase_s' - diff --git a/rdf/build/Makefile.in b/rdf/build/Makefile.in deleted file mode 100644 index 65d077bac..000000000 --- a/rdf/build/Makefile.in +++ /dev/null @@ -1,32 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -EXPORT_LIBRARY = 1 -IS_COMPONENT = 1 -MODULE_NAME = nsRDFModule -LIBXUL_LIBRARY = 1 - -# XXX Note dependencies on implementation headers for factory functions - -SHARED_LIBRARY_LIBS = \ - ../base/src/$(LIB_PREFIX)rdfbase_s.$(LIB_SUFFIX) \ - ../datasource/src/$(LIB_PREFIX)rdfdatasource_s.$(LIB_SUFFIX) \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -LOCAL_INCLUDES = \ - -I$(srcdir)/../base/src \ - -I$(srcdir)/../content/src \ - -I$(srcdir)/../datasource/src \ - $(NULL) - diff --git a/rdf/build/moz.build b/rdf/build/moz.build index 6894fb38c..cf99137ea 100644 --- a/rdf/build/moz.build +++ b/rdf/build/moz.build @@ -4,15 +4,19 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -MODULE = 'rdf' - EXPORTS += [ 'nsRDFCID.h', ] -CPP_SOURCES += [ +SOURCES += [ 'nsRDFModule.cpp', ] -LIBRARY_NAME = 'rdf' +FINAL_LIBRARY = 'xul' + +LOCAL_INCLUDES += [ + '/rdf/base', + '/rdf/datasource', +] +FAIL_ON_WARNINGS = True diff --git a/rdf/build/nsRDFModule.cpp b/rdf/build/nsRDFModule.cpp index 18b2c54e0..d1af94bc0 100644 --- a/rdf/build/nsRDFModule.cpp +++ b/rdf/build/nsRDFModule.cpp @@ -113,20 +113,20 @@ NS_DEFINE_NAMED_CID(NS_LOCALSTORE_CID); static const mozilla::Module::CIDEntry kRDFCIDs[] = { - { &kNS_RDFCOMPOSITEDATASOURCE_CID, false, NULL, CreateNewRDFCompositeDataSource }, - { &kNS_RDFFILESYSTEMDATASOURCE_CID, false, NULL, FileSystemDataSource::Create }, - { &kNS_RDFINMEMORYDATASOURCE_CID, false, NULL, NS_NewRDFInMemoryDataSource }, - { &kNS_RDFXMLDATASOURCE_CID, false, NULL, CreateNewRDFXMLDataSource }, - { &kNS_RDFDEFAULTRESOURCE_CID, false, NULL, CreateNewRDFDefaultResource }, - { &kNS_RDFCONTENTSINK_CID, false, NULL, CreateNewRDFContentSink }, - { &kNS_RDFCONTAINER_CID, false, NULL, CreateNewRDFContainer }, - { &kNS_RDFCONTAINERUTILS_CID, false, NULL, CreateNewRDFContainerUtils }, - { &kNS_RDFSERVICE_CID, false, NULL, RDFServiceImpl::CreateSingleton }, - { &kNS_RDFXMLPARSER_CID, false, NULL, nsRDFXMLParser::Create }, - { &kNS_RDFXMLSERIALIZER_CID, false, NULL, nsRDFXMLSerializer::Create }, - { &kNS_RDFNTRIPLES_SERIALIZER_CID, false, NULL, CreateNewTriplesSerializer }, - { &kNS_LOCALSTORE_CID, false, NULL, NS_NewLocalStore }, - { NULL } + { &kNS_RDFCOMPOSITEDATASOURCE_CID, false, nullptr, CreateNewRDFCompositeDataSource }, + { &kNS_RDFFILESYSTEMDATASOURCE_CID, false, nullptr, FileSystemDataSource::Create }, + { &kNS_RDFINMEMORYDATASOURCE_CID, false, nullptr, NS_NewRDFInMemoryDataSource }, + { &kNS_RDFXMLDATASOURCE_CID, false, nullptr, CreateNewRDFXMLDataSource }, + { &kNS_RDFDEFAULTRESOURCE_CID, false, nullptr, CreateNewRDFDefaultResource }, + { &kNS_RDFCONTENTSINK_CID, false, nullptr, CreateNewRDFContentSink }, + { &kNS_RDFCONTAINER_CID, false, nullptr, CreateNewRDFContainer }, + { &kNS_RDFCONTAINERUTILS_CID, false, nullptr, CreateNewRDFContainerUtils }, + { &kNS_RDFSERVICE_CID, false, nullptr, RDFServiceImpl::CreateSingleton }, + { &kNS_RDFXMLPARSER_CID, false, nullptr, nsRDFXMLParser::Create }, + { &kNS_RDFXMLSERIALIZER_CID, false, nullptr, nsRDFXMLSerializer::Create }, + { &kNS_RDFNTRIPLES_SERIALIZER_CID, false, nullptr, CreateNewTriplesSerializer }, + { &kNS_LOCALSTORE_CID, false, nullptr, NS_NewLocalStore }, + { nullptr } }; static const mozilla::Module::ContractIDEntry kRDFContracts[] = { @@ -143,37 +143,17 @@ static const mozilla::Module::ContractIDEntry kRDFContracts[] = { { NS_RDF_CONTRACTID "/xml-serializer;1", &kNS_RDFXMLSERIALIZER_CID }, { NS_RDF_SERIALIZER "ntriples", &kNS_RDFNTRIPLES_SERIALIZER_CID }, { NS_LOCALSTORE_CONTRACTID, &kNS_LOCALSTORE_CID }, - { NULL } + { nullptr } }; -static nsresult -StartupRDFModule() -{ - if (RDFServiceImpl::gRDFService) { - NS_ERROR("Leaked the RDF service from a previous startup."); - RDFServiceImpl::gRDFService = nullptr; - } - - return NS_OK; -} - -static void -ShutdownRDFModule() -{ - if (RDFServiceImpl::gRDFService) { - // XXX make this an assertion! - NS_WARNING("Leaking the RDF Service."); - } -} - static const mozilla::Module kRDFModule = { mozilla::Module::kVersion, kRDFCIDs, kRDFContracts, - NULL, - NULL, - StartupRDFModule, - ShutdownRDFModule + nullptr, + nullptr, + nullptr, + nullptr }; NSMODULE_DEFN(nsRDFModule) = &kRDFModule; diff --git a/rdf/datasource/moz.build b/rdf/datasource/moz.build index 8ff468534..d4cfa552d 100644 --- a/rdf/datasource/moz.build +++ b/rdf/datasource/moz.build @@ -4,4 +4,22 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += ['public', 'src'] +EXPORTS += [ + 'nsILocalStore.h', +] + +UNIFIED_SOURCES += [ + 'nsFileSystemDataSource.cpp', + 'nsLocalStore.cpp', +] + +FINAL_LIBRARY = 'xul' + +# "This is a dependency on rdfutil.h: it'll go away once that becomes +# a first-class XPCOM interface." +LOCAL_INCLUDES += [ + '/rdf/base', +] + +if CONFIG['GNU_CXX']: + FAIL_ON_WARNINGS = True diff --git a/rdf/datasource/src/nsFileSystemDataSource.cpp b/rdf/datasource/nsFileSystemDataSource.cpp index d48cd24f9..4ccca1d60 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/rdf/datasource/nsFileSystemDataSource.cpp @@ -148,8 +148,8 @@ FileSystemDataSource::Init() tmp = mRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "type"), getter_AddRefs(mRDF_type)); - static const PRUnichar kTrue[] = {'t','r','u','e','\0'}; - static const PRUnichar kFalse[] = {'f','a','l','s','e','\0'}; + static const char16_t kTrue[] = {'t','r','u','e','\0'}; + static const char16_t kFalse[] = {'f','a','l','s','e','\0'}; tmp = mRDFService->GetLiteral(kTrue, getter_AddRefs(mLiteralTrue)); if (NS_FAILED(tmp)) { @@ -208,7 +208,7 @@ FileSystemDataSource::Create(nsISupports* aOuter, const nsIID& aIID, void **aRes return self->QueryInterface(aIID, aResult); } -NS_IMPL_ISUPPORTS1(FileSystemDataSource, nsIRDFDataSource) +NS_IMPL_ISUPPORTS(FileSystemDataSource, nsIRDFDataSource) NS_IMETHODIMP FileSystemDataSource::GetURI(char **uri) @@ -292,7 +292,7 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source, if (property == mNC_pulse) { nsIRDFLiteral *pulseLiteral; - mRDFService->GetLiteral(NS_LITERAL_STRING("12").get(), &pulseLiteral); + mRDFService->GetLiteral(MOZ_UTF16("12"), &pulseLiteral); *target = pulseLiteral; return NS_OK; } @@ -327,7 +327,7 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source, if (isFavorite || !url) rv = NS_RDF_NO_VALUE; if (rv == NS_RDF_NO_VALUE) return(rv); - const PRUnichar *uni = nullptr; + const char16_t *uni = nullptr; url->GetValueConst(&uni); if (!uni) return(NS_RDF_NO_VALUE); nsAutoString urlStr; @@ -404,7 +404,7 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source, else if (property == mNC_pulse) { nsCOMPtr<nsIRDFLiteral> pulseLiteral; - mRDFService->GetLiteral(NS_LITERAL_STRING("12").get(), getter_AddRefs(pulseLiteral)); + mRDFService->GetLiteral(MOZ_UTF16("12"), getter_AddRefs(pulseLiteral)); rv = pulseLiteral->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target); return(rv); } @@ -480,7 +480,7 @@ FileSystemDataSource::GetTargets(nsIRDFResource *source, else if (property == mNC_pulse) { nsCOMPtr<nsIRDFLiteral> pulseLiteral; - mRDFService->GetLiteral(NS_LITERAL_STRING("12").get(), + mRDFService->GetLiteral(MOZ_UTF16("12"), getter_AddRefs(pulseLiteral)); return NS_NewSingletonEnumerator(targets, pulseLiteral); } @@ -524,7 +524,7 @@ FileSystemDataSource::GetTargets(nsIRDFResource *source, else if (property == mNC_pulse) { nsCOMPtr<nsIRDFLiteral> pulseLiteral; - rv = mRDFService->GetLiteral(NS_LITERAL_STRING("12").get(), + rv = mRDFService->GetLiteral(MOZ_UTF16("12"), getter_AddRefs(pulseLiteral)); if (NS_FAILED(rv)) return rv; @@ -838,30 +838,29 @@ FileSystemDataSource::EndUpdateBatch() nsresult FileSystemDataSource::GetVolumeList(nsISimpleEnumerator** aResult) { - nsresult rv; nsCOMArray<nsIRDFResource> volumes; nsCOMPtr<nsIRDFResource> vol; #ifdef XP_WIN int32_t driveType; - PRUnichar drive[32]; + wchar_t drive[32]; int32_t volNum; for (volNum = 0; volNum < 26; volNum++) { - swprintf( drive, L"%c:\\", volNum + (PRUnichar)'A'); + swprintf( drive, L"%c:\\", volNum + (char16_t)'A'); driveType = GetDriveTypeW(drive); if (driveType != DRIVE_UNKNOWN && driveType != DRIVE_NO_ROOT_DIR) { nsAutoCString url; url.AppendPrintf("file:///%c|/", volNum + 'A'); - rv = mRDFService->GetResource(url, getter_AddRefs(vol)); + nsresult rv = mRDFService->GetResource(url, getter_AddRefs(vol)); if (NS_FAILED(rv)) return rv; - volumes.AppendObject(vol); + volumes.AppendObject(vol); } } #endif @@ -912,7 +911,7 @@ FileSystemDataSource::isValidFolder(nsIRDFResource *source) if (NS_FAILED(rv = GetName(res, getter_AddRefs(nameLiteral)))) break; - const PRUnichar *uniName; + const char16_t *uniName; if (NS_FAILED(rv = nameLiteral->GetValueConst(&uniName))) break; nsAutoString name(uniName); @@ -1081,11 +1080,7 @@ FileSystemDataSource::GetLastMod(nsIRDFResource *source, nsIRDFDate **aResult) return(rv); // convert from milliseconds to seconds - PRTime temp64, thousand; - LL_I2L(thousand, PR_MSEC_PER_SEC); - temp64 = lastModDate * thousand; - - mRDFService->GetDateLiteral(temp64, aResult); + mRDFService->GetDateLiteral(lastModDate * PR_MSEC_PER_SEC, aResult); return(NS_OK); } @@ -1210,7 +1205,7 @@ FileSystemDataSource::GetExtension(nsIRDFResource *source, nsIRDFLiteral **aResu if (NS_FAILED(rv)) return rv; - const PRUnichar* unicodeLeafName; + const char16_t* unicodeLeafName; rv = name->GetValueConst(&unicodeLeafName); if (NS_FAILED(rv)) return rv; diff --git a/rdf/datasource/src/nsFileSystemDataSource.h b/rdf/datasource/nsFileSystemDataSource.h index 6b0cd20b8..09fa17400 100644 --- a/rdf/datasource/src/nsFileSystemDataSource.h +++ b/rdf/datasource/nsFileSystemDataSource.h @@ -18,7 +18,7 @@ #define USE_NC_EXTENSION #endif -class FileSystemDataSource MOZ_FINAL : public nsIRDFDataSource +class FileSystemDataSource final : public nsIRDFDataSource { public: NS_DECL_ISUPPORTS @@ -27,11 +27,11 @@ public: static nsresult Create(nsISupports* aOuter, const nsIID& aIID, void **aResult); - ~FileSystemDataSource() { } nsresult Init(); private: FileSystemDataSource() { } + ~FileSystemDataSource() { } // helper methods bool isFileURI(nsIRDFResource* aResource); diff --git a/rdf/datasource/public/nsILocalStore.h b/rdf/datasource/nsILocalStore.h index b41226593..b41226593 100644 --- a/rdf/datasource/public/nsILocalStore.h +++ b/rdf/datasource/nsILocalStore.h diff --git a/rdf/datasource/public/nsIRDFFTP.h b/rdf/datasource/nsIRDFFTP.h index 8965b4a38..8965b4a38 100644 --- a/rdf/datasource/public/nsIRDFFTP.h +++ b/rdf/datasource/nsIRDFFTP.h diff --git a/rdf/datasource/src/nsLocalStore.cpp b/rdf/datasource/nsLocalStore.cpp index d6cddc4c6..9adb2494b 100644 --- a/rdf/datasource/src/nsLocalStore.cpp +++ b/rdf/datasource/nsLocalStore.cpp @@ -66,60 +66,60 @@ public: // nsIRDFDataSource interface. Most of these are just delegated to // the inner, in-memory datasource. - NS_IMETHOD GetURI(char* *aURI); + NS_IMETHOD GetURI(char* *aURI) override; NS_IMETHOD GetSource(nsIRDFResource* aProperty, nsIRDFNode* aTarget, bool aTruthValue, - nsIRDFResource** aSource) { + nsIRDFResource** aSource) override { return mInner->GetSource(aProperty, aTarget, aTruthValue, aSource); } NS_IMETHOD GetSources(nsIRDFResource* aProperty, nsIRDFNode* aTarget, bool aTruthValue, - nsISimpleEnumerator** aSources) { + nsISimpleEnumerator** aSources) override { return mInner->GetSources(aProperty, aTarget, aTruthValue, aSources); } NS_IMETHOD GetTarget(nsIRDFResource* aSource, nsIRDFResource* aProperty, bool aTruthValue, - nsIRDFNode** aTarget) { + nsIRDFNode** aTarget) override { return mInner->GetTarget(aSource, aProperty, aTruthValue, aTarget); } NS_IMETHOD GetTargets(nsIRDFResource* aSource, nsIRDFResource* aProperty, bool aTruthValue, - nsISimpleEnumerator** aTargets) { + nsISimpleEnumerator** aTargets) override { return mInner->GetTargets(aSource, aProperty, aTruthValue, aTargets); } NS_IMETHOD Assert(nsIRDFResource* aSource, nsIRDFResource* aProperty, nsIRDFNode* aTarget, - bool aTruthValue) { + bool aTruthValue) override { return mInner->Assert(aSource, aProperty, aTarget, aTruthValue); } NS_IMETHOD Unassert(nsIRDFResource* aSource, nsIRDFResource* aProperty, - nsIRDFNode* aTarget) { + nsIRDFNode* aTarget) override { return mInner->Unassert(aSource, aProperty, aTarget); } NS_IMETHOD Change(nsIRDFResource* aSource, nsIRDFResource* aProperty, nsIRDFNode* aOldTarget, - nsIRDFNode* aNewTarget) { + nsIRDFNode* aNewTarget) override { return mInner->Change(aSource, aProperty, aOldTarget, aNewTarget); } NS_IMETHOD Move(nsIRDFResource* aOldSource, nsIRDFResource* aNewSource, nsIRDFResource* aProperty, - nsIRDFNode* aTarget) { + nsIRDFNode* aTarget) override { return mInner->Move(aOldSource, aNewSource, aProperty, aTarget); } @@ -127,65 +127,65 @@ public: nsIRDFResource* aProperty, nsIRDFNode* aTarget, bool aTruthValue, - bool* hasAssertion) { + bool* hasAssertion) override { return mInner->HasAssertion(aSource, aProperty, aTarget, aTruthValue, hasAssertion); } - NS_IMETHOD AddObserver(nsIRDFObserver* aObserver) { + NS_IMETHOD AddObserver(nsIRDFObserver* aObserver) override { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver) { + NS_IMETHOD RemoveObserver(nsIRDFObserver* aObserver) override { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval) { + NS_IMETHOD HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, bool *_retval) override { return mInner->HasArcIn(aNode, aArc, _retval); } - NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval) { + NS_IMETHOD HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, bool *_retval) override { return mInner->HasArcOut(aSource, aArc, _retval); } NS_IMETHOD ArcLabelsIn(nsIRDFNode* aNode, - nsISimpleEnumerator** aLabels) { + nsISimpleEnumerator** aLabels) override { return mInner->ArcLabelsIn(aNode, aLabels); } NS_IMETHOD ArcLabelsOut(nsIRDFResource* aSource, - nsISimpleEnumerator** aLabels) { + nsISimpleEnumerator** aLabels) override { return mInner->ArcLabelsOut(aSource, aLabels); } - NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) { + NS_IMETHOD GetAllResources(nsISimpleEnumerator** aResult) override { return mInner->GetAllResources(aResult); } NS_IMETHOD GetAllCmds(nsIRDFResource* aSource, - nsISimpleEnumerator/*<nsIRDFResource>*/** aCommands); + nsISimpleEnumerator/*<nsIRDFResource>*/** aCommands) override; NS_IMETHOD IsCommandEnabled(nsISupportsArray/*<nsIRDFResource>*/* aSources, nsIRDFResource* aCommand, nsISupportsArray/*<nsIRDFResource>*/* aArguments, - bool* aResult); + bool* aResult) override; NS_IMETHOD DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources, nsIRDFResource* aCommand, - nsISupportsArray/*<nsIRDFResource>*/* aArguments); + nsISupportsArray/*<nsIRDFResource>*/* aArguments) override; - NS_IMETHOD BeginUpdateBatch() { + NS_IMETHOD BeginUpdateBatch() override { return mInner->BeginUpdateBatch(); } - NS_IMETHOD EndUpdateBatch() { + NS_IMETHOD EndUpdateBatch() override { return mInner->EndUpdateBatch(); } - NS_IMETHOD GetLoaded(bool* _result); - NS_IMETHOD Init(const char *uri); - NS_IMETHOD Flush(); - NS_IMETHOD FlushTo(const char *aURI); - NS_IMETHOD Refresh(bool sync); + NS_IMETHOD GetLoaded(bool* _result) override; + NS_IMETHOD Init(const char *uri) override; + NS_IMETHOD Flush() override; + NS_IMETHOD FlushTo(const char *aURI) override; + NS_IMETHOD Refresh(bool sync) override; // nsIObserver NS_DECL_NSIOBSERVER @@ -233,7 +233,7 @@ NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult) return rv; } -NS_IMPL_CYCLE_COLLECTION_1(LocalStoreImpl, mInner) +NS_IMPL_CYCLE_COLLECTION(LocalStoreImpl, mInner) NS_IMPL_CYCLE_COLLECTING_ADDREF(LocalStoreImpl) NS_IMPL_CYCLE_COLLECTING_RELEASE(LocalStoreImpl) @@ -459,7 +459,7 @@ LocalStoreImpl::DoCommand(nsISupportsArray* aSources, } NS_IMETHODIMP -LocalStoreImpl::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *someData) +LocalStoreImpl::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData) { nsresult rv = NS_OK; @@ -474,13 +474,6 @@ LocalStoreImpl::Observe(nsISupports *aSubject, const char *aTopic, const PRUnich // Create an in-memory datasource for use while we're // profile-less. mInner = do_CreateInstance(NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource"); - - if (!nsCRT::strcmp(NS_ConvertUTF16toUTF8(someData).get(), "shutdown-cleanse")) { - nsCOMPtr<nsIFile> aFile; - rv = NS_GetSpecialDirectory(NS_APP_LOCALSTORE_50_FILE, getter_AddRefs(aFile)); - if (NS_SUCCEEDED(rv)) - rv = aFile->Remove(false); - } } else if (!nsCRT::strcmp(aTopic, "profile-do-change")) { rv = LoadData(); diff --git a/rdf/datasource/src/nsRDFBuiltInDataSources.h b/rdf/datasource/nsRDFBuiltInDataSources.h index 297fe7164..297fe7164 100644 --- a/rdf/datasource/src/nsRDFBuiltInDataSources.h +++ b/rdf/datasource/nsRDFBuiltInDataSources.h diff --git a/rdf/datasource/src/Makefile.in b/rdf/datasource/src/Makefile.in deleted file mode 100644 index c7cfa70ae..000000000 --- a/rdf/datasource/src/Makefile.in +++ /dev/null @@ -1,23 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBXUL_LIBRARY = 1 - -# we don't want the shared lib, but we want to force the creation of a static lib. -FORCE_STATIC_LIB = 1 - -include $(topsrcdir)/config/rules.mk - -# XXX This is a dependency on rdfutil.h: it'll go away once that becomes -# a first-class XPCOM interface. -INCLUDES += -I$(srcdir)/../../base/src - diff --git a/rdf/datasource/src/moz.build b/rdf/datasource/src/moz.build deleted file mode 100644 index c9d03ae25..000000000 --- a/rdf/datasource/src/moz.build +++ /dev/null @@ -1,15 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -MODULE = 'rdf' - -CPP_SOURCES += [ - 'nsFileSystemDataSource.cpp', - 'nsLocalStore.cpp', -] - -LIBRARY_NAME = 'rdfdatasource_s' - diff --git a/rdf/moz.build b/rdf/moz.build index d22ee0299..ee0387e22 100644 --- a/rdf/moz.build +++ b/rdf/moz.build @@ -5,7 +5,5 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += ['base', 'util', 'datasource', 'build'] -TEST_TOOL_DIRS += ['tests'] - -MODULE = 'rdf' +TEST_DIRS += ['tests'] diff --git a/rdf/tests/dsds/DataSourceViewer.css b/rdf/tests/dsds/DataSourceViewer.css deleted file mode 100644 index c544b874d..000000000 --- a/rdf/tests/dsds/DataSourceViewer.css +++ /dev/null @@ -1,34 +0,0 @@ -tree { - display: table; - background-color: white; - border: none; - border-spacing: 0px; - /*border-collapse: collapse;*/ - width: 100%; - table-layout: fixed; -} - -treeitem { - display: table-row; -} - -treehead { - display: table-header-group; -} - -treebody { - display: table-row-group; -} - -treecell { - display: table-cell; - color: black; - font-family: Verdana; - font-size: 10pt; - white-space: nowrap; -} - -treecell[selectedcell] { - background-color: #666699; - color: white; -} diff --git a/rdf/tests/dsds/DataSourceViewer.xul b/rdf/tests/dsds/DataSourceViewer.xul deleted file mode 100644 index 54ed2709c..000000000 --- a/rdf/tests/dsds/DataSourceViewer.xul +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0"?> -<?xml-stylesheet href="DataSourceViewer.css" type="text/css"?> - -<window - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - style="width: 100%; height: 100%"> - - -<tree datasources="rdf:datasource" - id="dataSourceTree" - containment="http://home.netscape.com/NC-rdf#child"> - <treecolgroup> - <treecol id="NameColumn" resource="http://home.netscape.com/NC-rdf#Name" flex="1"/> - <treecol id="ValueColumn" resource="http://home.netscape.com/NC-rdf#Value" flex="1"/> - </treecolgroup> - <treehead> - <treeitem> - <treecell>Name</treecell> - <treecell>Value</treecell> - </treeitem> - </treehead> - - - <treebody id="rdf:mailnewsfolders" name="dataSourceTreeBody"> - <treeitem id="msgaccounts:/" open="true"> - <treecell> - <treeindentation/> - <html:img hspace="2" style="vertical-align: bottom" src="chrome://messenger/skin/localMailHost.gif"/>Accounts - </treecell> - <treecell/> - <treecell/> - </treeitem> - </treebody> - <treechildren flex="1"/> -</tree> -</window> diff --git a/rdf/tests/dsds/Makefile.in b/rdf/tests/dsds/Makefile.in deleted file mode 100644 index c3bdbdd8f..000000000 --- a/rdf/tests/dsds/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -MOZILLA_INTERNAL_API = 1 - - - -IS_COMPONENT = 1 - -SAMPLES_DIR = $(DIST)/bin/res/samples/rdf - -RESOURCE_SAMPLES = \ - DataSourceViewer.xul \ - DataSourceViewer.css \ - $(NULL) - -EXTRA_DSO_LDOPTS = \ - -L$(DIST)/bin \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) - -include $(topsrcdir)/config/rules.mk - -GARBAGE += $(addprefix $(SAMPLES_DIR)/, $(RESOURCE_SAMPLES)) - -libs:: - $(INSTALL) $(addprefix $(srcdir)/,$(RESOURCE_SAMPLES)) $(SAMPLES_DIR) - -install:: $(RESOURCE_SAMPLES) - $(SYSINSTALL) $(IFLAGS1) $^ $(DESTDIR)$(mozappdir)/res/samples/rdf - diff --git a/rdf/tests/dsds/moz.build b/rdf/tests/dsds/moz.build deleted file mode 100644 index d40038347..000000000 --- a/rdf/tests/dsds/moz.build +++ /dev/null @@ -1,15 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -MODULE = 'rdf' - -CPP_SOURCES += [ - 'nsRDFDataSourceDS.cpp', - 'nsRDFDataSourceFactory.cpp', -] - -LIBRARY_NAME = 'rdfdsds' - diff --git a/rdf/tests/dsds/nsRDFDOMDataSource.cpp b/rdf/tests/dsds/nsRDFDOMDataSource.cpp deleted file mode 100644 index d8c22da12..000000000 --- a/rdf/tests/dsds/nsRDFDOMDataSource.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __gen_nsRDFDOMDataSource_h__ -#define __gen_nsRDFDOMDataSource_h__ - -#include "nsRDFDOMDataSource.h" - -/* starting interface: nsRDFDOMDataSource */ - -/* {0F78DA58-8321-11d2-8EAC-00805F29F370} */ -#define NS_IRDFDATASOURCE_IID_STR "0F78DA58-8321-11d2-8EAC-00805F29F370" -#define NS_IRDFDATASOURCE_IID \ - {0x0F78DA58, 0x8321, 0x11d2, \ - { 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }} - -class nsRDFDOMDataSource : public nsISupports { - public: - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IRDFDATASOURCE_IID) - - /* void Init (in string uri); */ - NS_IMETHOD Init(const char *uri) = 0; - - /* readonly attribute string URI; */ - NS_IMETHOD GetURI(char * *aURI) = 0; - - /* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ - NS_IMETHOD GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, nsIRDFResource **_retval) = 0; - - /* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ - NS_IMETHOD GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, nsISimpleEnumerator **_retval) = 0; - - /* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */ - NS_IMETHOD GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool aTruthValue, nsIRDFNode **_retval) = 0; - - /* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */ - NS_IMETHOD GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, bool aTruthValue, nsISimpleEnumerator **_retval) = 0; - - /* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ - NS_IMETHOD Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue) = 0; - - /* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */ - NS_IMETHOD Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget) = 0; - - /* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ - NS_IMETHOD HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, bool *_retval) = 0; - - /* void AddObserver (in nsIRDFObserver aObserver); */ - NS_IMETHOD AddObserver(nsIRDFObserver *aObserver) = 0; - - /* void RemoveObserver (in nsIRDFObserver aObserver); */ - NS_IMETHOD RemoveObserver(nsIRDFObserver *aObserver) = 0; - - /* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */ - NS_IMETHOD ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval) = 0; - - /* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */ - NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource, nsISimpleEnumerator **_retval) = 0; - - /* nsISimpleEnumerator GetAllResources (); */ - NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval) = 0; - - /* void Flush (); */ - NS_IMETHOD Flush() = 0; - - /* nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource); */ - NS_IMETHOD GetAllCmds(nsIRDFResource *aSource, nsISimpleEnumerator **_retval) = 0; - - /* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */ - NS_IMETHOD IsCommandEnabled(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments, bool *_retval) = 0; - - /* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */ - NS_IMETHOD DoCommand(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments) = 0; - - /* void beginUpdateBatch (); */ - NS_IMETHOD BeginUpdateBatch() = 0; - - /* void endUpdateBatch (); */ - NS_IMETHOD EndUpdateBatch() = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsRDFDOMDataSource, NS_IRDFDATASOURCE_IID) - -#endif /* __gen_nsRDFDOMDataSource_h__ */ diff --git a/rdf/tests/dsds/nsRDFDataSourceDS.cpp b/rdf/tests/dsds/nsRDFDataSourceDS.cpp deleted file mode 100644 index 781463ac6..000000000 --- a/rdf/tests/dsds/nsRDFDataSourceDS.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - - -#include "nsCRT.h" -#include "nsCOMPtr.h" - -#include "nsIRDFService.h" -#include "nsRDFCID.h" -#include "nsIRDFDataSource.h" -#include "nsIRDFRemoteDataSource.h" -#include "rdf.h" - -#include "nsIServiceManager.h" - -#include "nsEnumeratorUtils.h" - -#include "nsXPIDLString.h" - -#ifdef DEBUG -#include <stdio.h> -#endif - -/** - * RDF vocabulary describing assertions in inner datasource - * - * For a particular resource, we want to provide all arcs out and - * in that the inner datasource has. - * This is done by introducing helper resources for each triple of - * the form - * x-moz-dsds:<subject-resource-pointer><predicate-resource-pointer>\ - * <object-node-pointer> - * For each triple, that has the resource in question as subject, a - * "arcsout" assertion goes from that resource to a x-moz-dsds resource. - * For each triple, that has the resource in question as object, a - * "arcsin" assertion goes from that resource to a x-moz-dsds resource. - * For each x-moz-dsds resource, there is a "subject" arc to the subject, - * a "predicate" arc to the predicate and a "object" arc to the object. - * - * The namespace of this vocabulary is - * "http://www.mozilla.org/rdf/vocab/dsds". - * - * XXX we might want to add a "qname" resource from each resource to a - * somewhat canonical "prefix:localname" literal. - */ - -#define NS_RDF_DSDS_NAMESPACE_URI "http://www.mozilla.org/rdf/vocab/dsds#" -#define NS_RDF_ARCSOUT NS_RDF_DSDS_NAMESPACE_URI "arcsout" -#define NS_RDF_ARCSIN NS_RDF_DSDS_NAMESPACE_URI "arcsin" -#define NS_RDF_SUBJECT NS_RDF_DSDS_NAMESPACE_URI "subject" -#define NS_RDF_PREDICATE NS_RDF_DSDS_NAMESPACE_URI "predicate" -#define NS_RDF_OBJECT NS_RDF_DSDS_NAMESPACE_URI "object" - -#define NC_RDF_Name NC_NAMESPACE_URI "Name" -#define NC_RDF_Value NC_NAMESPACE_URI "Value" -#define NC_RDF_Child NC_NAMESPACE_URI "child" - -static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); - -class nsRDFDataSourceDataSource : - public nsIRDFDataSource, - public nsIRDFRemoteDataSource { -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIRDFDATASOURCE - NS_DECL_NSIRDFREMOTEDATASOURCE - - nsRDFDataSourceDataSource(); - virtual ~nsRDFDataSourceDataSource(); - -private: - nsCString mURI; - nsCOMPtr<nsIRDFDataSource> mDataSource; - - static nsIRDFResource* kNC_Name; - static nsIRDFResource* kNC_Value; - static nsIRDFResource* kNC_Child; - -}; - -nsIRDFResource* nsRDFDataSourceDataSource::kNC_Name=nullptr; -nsIRDFResource* nsRDFDataSourceDataSource::kNC_Value=nullptr; -nsIRDFResource* nsRDFDataSourceDataSource::kNC_Child=nullptr; - - -nsRDFDataSourceDataSource::nsRDFDataSourceDataSource() -{ -} - -nsRDFDataSourceDataSource::~nsRDFDataSourceDataSource() -{ -} - - -NS_IMPL_ISUPPORTS2(nsRDFDataSourceDataSource, - nsIRDFDataSource, - nsIRDFRemoteDataSource) - -/** - * Implement nsIRDFRemoteDataSource - */ - -/* readonly attribute boolean loaded; */ -NS_IMETHODIMP nsRDFDataSourceDataSource::GetLoaded(bool *aLoaded) -{ - nsCOMPtr<nsIRDFRemoteDataSource> remote = - do_QueryInterface(mDataSource); - if (remote) { - return remote->GetLoaded(aLoaded); - } - *aLoaded = true; - return NS_OK; -} - -/* void Init (in string uri); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::Init(const char *uri) -{ - nsresult rv; - - mURI = uri; - - // cut off "rdf:datasource?" - NS_NAMED_LITERAL_CSTRING(prefix, "rdf:datasource"); - nsAutoCString mInnerURI; - mInnerURI = Substring(mURI, prefix.Length() + 1); - // bail if datasorce is empty or we're trying to inspect ourself - if (mInnerURI.IsEmpty() || mInnerURI == prefix) { - mURI.Truncate(); - return NS_ERROR_INVALID_ARG; - } - nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv)); - rv = rdf->GetDataSource(mInnerURI.get(), getter_AddRefs(mDataSource)); - if (NS_FAILED(rv)) { - mURI.Truncate(); - NS_WARNING("Could not get inner datasource"); - return rv; - } - - // get RDF resources - - if (!kNC_Name) { - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_Name), &kNC_Name); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_Child), &kNC_Child); - rdf->GetResource(NS_LITERAL_CSTRING(NC_RDF_Value), &kNC_Value); - } - -#ifdef DEBUG_alecf - printf("nsRDFDataSourceDataSource::Init(%s)\n", uri); -#endif - - return NS_OK; -} - -/* void Refresh (in boolean aBlocking); */ -NS_IMETHODIMP nsRDFDataSourceDataSource::Refresh(bool aBlocking) -{ - nsCOMPtr<nsIRDFRemoteDataSource> remote = - do_QueryInterface(mDataSource); - if (remote) { - return remote->Refresh(aBlocking); - } - return NS_OK; -} - -/* void Flush (); */ -NS_IMETHODIMP nsRDFDataSourceDataSource::Flush() -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/* void FlushTo (in string aURI); */ -NS_IMETHODIMP nsRDFDataSourceDataSource::FlushTo(const char *aURI) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - -/** - * Implement nsIRDFDataSource - */ - -/* readonly attribute string URI; */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::GetURI(char * *aURI) -{ -#ifdef DEBUG_alecf - printf("nsRDFDataSourceDataSource::GetURI()\n"); -#endif - *aURI = ToNewCString(mURI); - - return NS_OK; -} - -/* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::GetSource(nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, - nsIRDFResource **_retval) -{ - return NS_RDF_NO_VALUE; -} - -/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::GetSources(nsIRDFResource *aProperty, - nsIRDFNode *aTarget, - bool aTruthValue, - nsISimpleEnumerator **_retval) -{ - return NS_RDF_NO_VALUE; -} - -/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::GetTarget(nsIRDFResource *aSource, - nsIRDFResource *aProperty, - bool aTruthValue, - nsIRDFNode **_retval) -{ -#ifdef DEBUG_alecf - nsXPIDLCString sourceval; - nsXPIDLCString propval; - aSource->GetValue(getter_Copies(sourceval)); - aProperty->GetValue(getter_Copies(propval)); - printf("GetTarget(%s, %s,..)\n", (const char*)sourceval, - (const char*)propval); -#endif - - return NS_OK; -} - -/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::GetTargets(nsIRDFResource *aSource, - nsIRDFResource *aProperty, - bool aTruthValue, - nsISimpleEnumerator **_retval) -{ - nsXPIDLCString sourceval; - aSource->GetValue(getter_Copies(sourceval)); - nsXPIDLCString propval; - aProperty->GetValue(getter_Copies(propval)); -#ifdef DEBUG_alecf - printf("GetTargets(%s, %s,..)\n", (const char*)sourceval, - (const char*)propval); -#endif - - nsresult rv; - bool isProp; - nsCOMPtr<nsISupportsArray> arcs; - nsISimpleEnumerator *enumerator; - - if (NS_SUCCEEDED(aProperty->EqualsNode(kNC_Child, &isProp)) && - isProp) { - - // here we need to determine if we need to extract out the source - // or use aSource? - if (StringBeginsWith(sourceval, NS_LITERAL_CSTRING("dsresource:"))) { - // somehow get the source - // XXX ? rv = mDataSource->ArcLabelsOut(realsource, &enumerator); - rv = mDataSource->ArcLabelsOut(aSource, &enumerator); - } else { - rv = mDataSource->ArcLabelsOut(aSource, &enumerator); - } - // enumerate all the children and create the composite resources - bool hasMoreArcs=false; - - rv = enumerator->HasMoreElements(&hasMoreArcs); - while (NS_SUCCEEDED(rv) && hasMoreArcs) { - - // get the next arc - nsCOMPtr<nsISupports> arcSupports; - rv = enumerator->GetNext(getter_AddRefs(arcSupports)); - nsCOMPtr<nsIRDFResource> arc = do_QueryInterface(arcSupports, &rv); - - // get all the resources on the ends of the arc arcs - nsCOMPtr<nsISimpleEnumerator> targetEnumerator; - rv = mDataSource->GetTargets(aSource, arc, true, - getter_AddRefs(targetEnumerator)); - - bool hasMoreTargets; - rv = targetEnumerator->HasMoreElements(&hasMoreTargets); - while (NS_SUCCEEDED(rv) && hasMoreTargets) { - // get the next target - nsCOMPtr<nsISupports> targetSupports; - rv = enumerator->GetNext(getter_AddRefs(targetSupports)); - nsCOMPtr<nsIRDFResource> target=do_QueryInterface(targetSupports, &rv); - - // now we have an (arc, target) tuple that will be our node - // arc will become #Name - // target will become #Value -#ifdef DEBUG_alecf - nsXPIDLString arcValue; - nsXPIDLString targetValue; - - arc->GetValue(getter_Copies(arcValue)); - target->GetValue(getter_Copies(targetValue)); - printf("#child of %s:\n\t%s = %s\n", - (const char*)sourceval -#endif - - } - - rv = enumerator->HasMoreElements(&hasMoreArcs); - } - - } else if (NS_SUCCEEDED(aProperty->EqualsNode(kNC_Name, &isProp)) && - isProp) { - if (StringBeginsWith(sourceval, NS_LITERAL_CSTRING("dsresource:"))) { - // extract out the name - - } - - } else if (NS_SUCCEEDED(aProperty->EqualsNode(kNC_Value, &isProp)) && - isProp) { - - - } else { - rv = NS_NewISupportsArray(getter_AddRefs(arcs)); - if (NS_FAILED(rv)) return rv; - - nsArrayEnumerator* cursor = - new nsArrayEnumerator(arcs); - - if (!cursor) return NS_ERROR_OUT_OF_MEMORY; - - *_retval = cursor; - NS_ADDREF(*_retval); - } - - return NS_OK; -} - -/* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue) -{ - return NS_RDF_NO_VALUE; -} - -/* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget) -{ - return NS_RDF_NO_VALUE; -} - -/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, bool aTruthValue, bool *_retval) -{ - return NS_RDF_NO_VALUE; -} - -/* void AddObserver (in nsIRDFObserver aObserver); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::AddObserver(nsIRDFObserver *aObserver) -{ - return NS_RDF_NO_VALUE; -} - -/* void RemoveObserver (in nsIRDFObserver aObserver); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::RemoveObserver(nsIRDFObserver *aObserver) -{ - return NS_RDF_NO_VALUE; -} - -/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::ArcLabelsIn(nsIRDFNode *aNode, nsISimpleEnumerator **_retval) -{ - return NS_RDF_NO_VALUE; -} - -/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::ArcLabelsOut(nsIRDFResource *aSource, - nsISimpleEnumerator **_retval) -{ - nsresult rv=NS_OK; - - nsCOMPtr<nsISupportsArray> arcs; - rv = NS_NewISupportsArray(getter_AddRefs(arcs)); - - if (NS_FAILED(rv)) return rv; - nsXPIDLCString sourceval; - aSource->GetValue(getter_Copies(sourceval)); - -#ifdef DEBUG_alecf - printf("ArcLabelsOut(%s)\n", (const char*)sourceval); -#endif - - arcs->AppendElement(kNC_Name); - arcs->AppendElement(kNC_Value); - arcs->AppendElement(kNC_Child); - - nsArrayEnumerator* cursor = - new nsArrayEnumerator(arcs); - - if (!cursor) return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(cursor); - *_retval = cursor; - - return NS_OK; -} - -/* nsISimpleEnumerator GetAllResources (); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::GetAllResources(nsISimpleEnumerator **_retval) -{ - return NS_RDF_NO_VALUE; -} - -/* boolean IsCommandEnabled (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::IsCommandEnabled(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments, bool *_retval) -{ - return NS_RDF_NO_VALUE; -} - -/* void DoCommand (in nsISupportsArray aSources, in nsIRDFResource aCommand, in nsISupportsArray aArguments); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::DoCommand(nsISupportsArray * aSources, nsIRDFResource *aCommand, nsISupportsArray * aArguments) -{ - return NS_RDF_NO_VALUE; -} - -/* void beginUpdateBatch (); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::BeginUpdateBatch() -{ - return NS_OK; -} - -/* void endUpdateBatch (); */ -NS_IMETHODIMP -nsRDFDataSourceDataSource::EndUpdateBatch() -{ - return NS_OK; -} - -nsresult -NS_NewRDFDataSourceDataSource(nsISupports *, const nsIID& iid, - void ** result) - -{ - nsRDFDataSourceDataSource * dsds = new nsRDFDataSourceDataSource(); - if (!dsds) return NS_ERROR_NOT_INITIALIZED; - return dsds->QueryInterface(iid, result); - -} diff --git a/rdf/tests/dsds/nsRDFDataSourceDS.h b/rdf/tests/dsds/nsRDFDataSourceDS.h deleted file mode 100644 index 8e3380ed7..000000000 --- a/rdf/tests/dsds/nsRDFDataSourceDS.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef __nsRDFDataSourceDS_h -#define __nsRDFDataSourceDS_h - - -/* {aa1b3f18-1aad-11d3-84bf-006008948010} */ -#define NS_RDFDATASOURCEDATASOURCE_CID \ - {0xaa1b3f18, 0x1aad, 0x11d3, \ - {0x84, 0xbf, 0x00, 0x60, 0x08, 0x94, 0x80, 0x10}} - -nsresult -NS_NewRDFDataSourceDataSource(nsISupports* aOuter, - const nsIID& iid, void **result); - -#endif diff --git a/rdf/tests/dsds/nsRDFDataSourceFactory.cpp b/rdf/tests/dsds/nsRDFDataSourceFactory.cpp deleted file mode 100644 index af0706aa0..000000000 --- a/rdf/tests/dsds/nsRDFDataSourceFactory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsIGenericFactory.h" -#include "nsRDFDataSourceDS.h" -#include "nsIComponentManager.h" -#include "nsIServiceManager.h" -#include "rdf.h" - -#ifdef DEBUG -#include <stdio.h> -#endif - -static NS_DEFINE_CID(kRDFDataSourceCID, NS_RDFDATASOURCEDATASOURCE_CID); -static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID); - -nsresult -NSGetFactory(nsISupports* aServMgr, - const nsCID &aClass, - const char* aClassName, - const char* aContractID, - nsIFactory **aFactory) -{ - nsresult rv=NS_OK; - nsIGenericFactory* fact; - if (aClass.Equals(kRDFDataSourceCID)) - rv = NS_NewGenericFactory(&fact, NS_NewRDFDataSourceDataSource); - else - rv = NS_ERROR_FAILURE; - - if (NS_SUCCEEDED(rv)) - *aFactory = fact; - -#ifdef DEBUG_alecf - printf("nsRDFDataSource's NSGetFactory!\n"); -#endif - return rv; -} - -nsresult -NSRegisterSelf(nsISupports* aServMgr, const char* aPath) -{ - nsresult rv; - nsCOMPtr<nsIComponentManager> compMgr = - do_GetService(kComponentManagerCID, aServMgr, &rv); - if (NS_FAILED(rv)) return rv; - - rv = compMgr->RegisterComponent(kRDFDataSourceCID, - "Generic DataSource DataSource", - NS_RDF_DATASOURCE_CONTRACTID_PREFIX "datasource", - aPath, true, true); - - return rv; - -} - -nsresult -NSUnregisterSelf(nsISupports* aServMgr, const char* aPath) -{ - nsresult rv; - nsCOMPtr<nsIComponentManager> compMgr = - do_GetService(kComponentManagerCID, aServMgr, &rv); - if (NS_FAILED(rv)) return rv; - - rv = compMgr->UnregisterComponent(kRDFDataSourceCID, aPath); - - return rv; -} diff --git a/rdf/tests/moz.build b/rdf/tests/moz.build index bb8b9b0fa..7fd8fb3d0 100644 --- a/rdf/tests/moz.build +++ b/rdf/tests/moz.build @@ -4,8 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += ['rdfcat', 'rdfpoll', 'triplescat'] - -MODULE = 'test_rdf' +TEST_DIRS += ['rdfcat', 'rdfpoll', 'triplescat'] XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini'] diff --git a/rdf/tests/rdfcat/Makefile.in b/rdf/tests/rdfcat/Makefile.in deleted file mode 100644 index 70d914bda..000000000 --- a/rdf/tests/rdfcat/Makefile.in +++ /dev/null @@ -1,26 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBS = \ - $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ - $(LIBS_DIR) \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) - -ifeq ($(OS_ARCH),WINNT) -MAPFILE=rdfcat.map -endif - -include $(topsrcdir)/config/rules.mk - -CXXFLAGS += $(TK_CFLAGS) diff --git a/rdf/tests/rdfcat/moz.build b/rdf/tests/rdfcat/moz.build index 4fd5db4de..836b2987f 100644 --- a/rdf/tests/rdfcat/moz.build +++ b/rdf/tests/rdfcat/moz.build @@ -4,8 +4,12 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'rdfcat' +GoannaProgram('rdfcat', linkage='dependent') -CPP_SOURCES += [ +SOURCES += [ 'rdfcat.cpp', ] + +CXXFLAGS += CONFIG['TK_CFLAGS'] + +FAIL_ON_WARNINGS = True diff --git a/rdf/tests/rdfcat/rdfcat.cpp b/rdf/tests/rdfcat/rdfcat.cpp index e5e16c4bd..52f5aae29 100644 --- a/rdf/tests/rdfcat/rdfcat.cpp +++ b/rdf/tests/rdfcat/rdfcat.cpp @@ -56,49 +56,51 @@ static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID); class ConsoleOutputStreamImpl : public nsIOutputStream { +protected: + virtual ~ConsoleOutputStreamImpl(void) {} + public: ConsoleOutputStreamImpl(void) {} - virtual ~ConsoleOutputStreamImpl(void) {} // nsISupports interface NS_DECL_ISUPPORTS // nsIOutputStream interface - NS_IMETHOD Close(void) { + NS_IMETHOD Close(void) override { return NS_OK; } - NS_IMETHOD Write(const char* aBuf, uint32_t aCount, uint32_t *aWriteCount) { + NS_IMETHOD Write(const char* aBuf, uint32_t aCount, uint32_t *aWriteCount) override { PR_Write(PR_GetSpecialFD(PR_StandardOutput), aBuf, aCount); *aWriteCount = aCount; return NS_OK; } NS_IMETHOD - WriteFrom(nsIInputStream *inStr, uint32_t count, uint32_t *_retval) { + WriteFrom(nsIInputStream *inStr, uint32_t count, uint32_t *_retval) override { NS_NOTREACHED("WriteFrom"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD - WriteSegments(nsReadSegmentFun reader, void * closure, uint32_t count, uint32_t *_retval) { + WriteSegments(nsReadSegmentFun reader, void * closure, uint32_t count, uint32_t *_retval) override { NS_NOTREACHED("WriteSegments"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD - IsNonBlocking(bool *aNonBlocking) { + IsNonBlocking(bool *aNonBlocking) override { NS_NOTREACHED("IsNonBlocking"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD Flush(void) { + NS_IMETHOD Flush(void) override { PR_Sync(PR_GetSpecialFD(PR_StandardOutput)); return NS_OK; } }; -NS_IMPL_ISUPPORTS1(ConsoleOutputStreamImpl, nsIOutputStream) +NS_IMPL_ISUPPORTS(ConsoleOutputStreamImpl, nsIOutputStream) //////////////////////////////////////////////////////////////////////// diff --git a/rdf/tests/rdfpoll/Makefile.in b/rdf/tests/rdfpoll/Makefile.in deleted file mode 100644 index 02a8f2e2f..000000000 --- a/rdf/tests/rdfpoll/Makefile.in +++ /dev/null @@ -1,23 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBS = \ - $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ - $(LIBS_DIR) \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) - -include $(topsrcdir)/config/config.mk - -include $(topsrcdir)/config/rules.mk - diff --git a/rdf/tests/rdfpoll/moz.build b/rdf/tests/rdfpoll/moz.build index 66dd46829..e71ca638f 100644 --- a/rdf/tests/rdfpoll/moz.build +++ b/rdf/tests/rdfpoll/moz.build @@ -4,8 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'rdfpoll' +GoannaProgram('rdfpoll', linkage='dependent') -CPP_SOURCES += [ +SOURCES += [ 'rdfpoll.cpp', ] + +FAIL_ON_WARNINGS = True diff --git a/rdf/tests/rdfpoll/rdfpoll.cpp b/rdf/tests/rdfpoll/rdfpoll.cpp index 90bb4df87..0d173e3a0 100644 --- a/rdf/tests/rdfpoll/rdfpoll.cpp +++ b/rdf/tests/rdfpoll/rdfpoll.cpp @@ -37,6 +37,7 @@ #include "plstr.h" #include "nsEmbedString.h" #include "nsNetCID.h" +#include "prtime.h" //////////////////////////////////////////////////////////////////////// // CIDs @@ -54,9 +55,11 @@ static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID); class Observer : public nsIRDFObserver { +protected: + virtual ~Observer() {} + public: Observer(); - virtual ~Observer() {} // nsISupports interface NS_DECL_ISUPPORTS @@ -69,7 +72,7 @@ Observer::Observer() { } -NS_IMPL_ISUPPORTS1(Observer, nsIRDFObserver) +NS_IMPL_ISUPPORTS(Observer, nsIRDFObserver) static nsresult rdf_WriteOp(const char* aOp, diff --git a/rdf/tests/triplescat/Makefile.in b/rdf/tests/triplescat/Makefile.in deleted file mode 100644 index 7d002f182..000000000 --- a/rdf/tests/triplescat/Makefile.in +++ /dev/null @@ -1,26 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -LIBS = \ - $(DIST)/lib/$(LIB_PREFIX)xpcomglue_s.$(LIB_SUFFIX) \ - $(LIBS_DIR) \ - $(XPCOM_LIBS) \ - $(NSPR_LIBS) \ - $(NULL) - -ifeq ($(OS_ARCH),WINNT) -MAPFILE=triplescat.map -endif - -include $(topsrcdir)/config/rules.mk - -CXXFLAGS += $(TK_CFLAGS) diff --git a/rdf/tests/triplescat/moz.build b/rdf/tests/triplescat/moz.build index e7cacf53c..78a58a7af 100644 --- a/rdf/tests/triplescat/moz.build +++ b/rdf/tests/triplescat/moz.build @@ -4,8 +4,12 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -PROGRAM = 'triplescat' +GoannaProgram('triplescat', linkage='dependent') -CPP_SOURCES += [ +SOURCES += [ 'triplescat.cpp', ] + +CXXFLAGS += CONFIG['TK_CFLAGS'] + +FAIL_ON_WARNINGS = True diff --git a/rdf/tests/triplescat/triplescat.cpp b/rdf/tests/triplescat/triplescat.cpp index ce5fe7cf3..abe4427b9 100644 --- a/rdf/tests/triplescat/triplescat.cpp +++ b/rdf/tests/triplescat/triplescat.cpp @@ -54,49 +54,51 @@ class ConsoleOutputStreamImpl : public nsIOutputStream { +protected: + virtual ~ConsoleOutputStreamImpl(void) {} + public: ConsoleOutputStreamImpl(void) {} - virtual ~ConsoleOutputStreamImpl(void) {} // nsISupports interface NS_DECL_ISUPPORTS // nsIOutputStream interface - NS_IMETHOD Close(void) { + NS_IMETHOD Close(void) override { return NS_OK; } - NS_IMETHOD Write(const char* aBuf, uint32_t aCount, uint32_t *aWriteCount) { + NS_IMETHOD Write(const char* aBuf, uint32_t aCount, uint32_t *aWriteCount) override { PR_Write(PR_GetSpecialFD(PR_StandardOutput), aBuf, aCount); *aWriteCount = aCount; return NS_OK; } NS_IMETHOD - WriteFrom(nsIInputStream *inStr, uint32_t count, uint32_t *_retval) { + WriteFrom(nsIInputStream *inStr, uint32_t count, uint32_t *_retval) override { NS_NOTREACHED("WriteFrom"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD - WriteSegments(nsReadSegmentFun reader, void * closure, uint32_t count, uint32_t *_retval) { + WriteSegments(nsReadSegmentFun reader, void * closure, uint32_t count, uint32_t *_retval) override { NS_NOTREACHED("WriteSegments"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHOD - IsNonBlocking(bool *aNonBlocking) { + IsNonBlocking(bool *aNonBlocking) override { NS_NOTREACHED("IsNonBlocking"); return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD Flush(void) { + NS_IMETHOD Flush(void) override { PR_Sync(PR_GetSpecialFD(PR_StandardOutput)); return NS_OK; } }; -NS_IMPL_ISUPPORTS1(ConsoleOutputStreamImpl, nsIOutputStream) +NS_IMPL_ISUPPORTS(ConsoleOutputStreamImpl, nsIOutputStream) //////////////////////////////////////////////////////////////////////// diff --git a/rdf/tests/unit/xpcshell.ini b/rdf/tests/unit/xpcshell.ini index fdb3e9f43..9709b800c 100644 --- a/rdf/tests/unit/xpcshell.ini +++ b/rdf/tests/unit/xpcshell.ini @@ -1,5 +1,7 @@ [DEFAULT] -head = -tail = +head = +tail = +skip-if = toolkit == 'gonk' +support-files = sample.rdf [test_rdfredirect.js] diff --git a/rdf/util/src/Makefile.in b/rdf/util/Makefile.in index 6ae2f6117..3e8913631 100644 --- a/rdf/util/src/Makefile.in +++ b/rdf/util/Makefile.in @@ -3,25 +3,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - # This makefile builds the rdfutil_external_s library which should be # used by frozen (dependent) linkage components. The internal-linkage code should use # rdfutil_s which is built in the internal/ subdirectory. -include $(srcdir)/objs.mk - -EXTRA_DEPS += $(srcdir)/objs.mk - DIST_INSTALL = 1 - -# we don't want the shared lib, but we want to force the creation of a static lib. -FORCE_STATIC_LIB = 1 - -include $(topsrcdir)/config/rules.mk - diff --git a/rdf/util/src/internal/moz.build b/rdf/util/internal/moz.build index e8ab12062..a7d2fc06a 100644 --- a/rdf/util/src/internal/moz.build +++ b/rdf/util/internal/moz.build @@ -4,11 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -MODULE = 'rdfutil' +include('../objs.mozbuild') -CPP_SOURCES += [ - '$(RDF_UTIL_SRC_LCPPSRCS)', -] +SOURCES += rdf_util_src_cppsrcs -LIBRARY_NAME = 'rdfutil_s' +FINAL_LIBRARY = 'xul' +FAIL_ON_WARNINGS = True diff --git a/rdf/util/moz.build b/rdf/util/moz.build index 934f58a95..b924f8245 100644 --- a/rdf/util/moz.build +++ b/rdf/util/moz.build @@ -4,7 +4,19 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -DIRS += ['public', 'src'] +DIRS += ['internal'] -MODULE = 'rdfutil' +EXPORTS += [ + 'nsRDFResource.h', +] +include('objs.mozbuild') + +SOURCES += rdf_util_src_cppsrcs + +Library('rdfutil_external_s') + +# we don't want the shared lib, but we want to force the creation of a static lib. +FORCE_STATIC_LIB = True + +FAIL_ON_WARNINGS = True diff --git a/rdf/util/src/nsRDFResource.cpp b/rdf/util/nsRDFResource.cpp index 13c173284..f7920667b 100644 --- a/rdf/util/src/nsRDFResource.cpp +++ b/rdf/util/nsRDFResource.cpp @@ -42,7 +42,7 @@ nsRDFResource::~nsRDFResource(void) NS_RELEASE(gRDFService); } -NS_IMPL_THREADSAFE_ISUPPORTS2(nsRDFResource, nsIRDFResource, nsIRDFNode) +NS_IMPL_ISUPPORTS(nsRDFResource, nsIRDFResource, nsIRDFNode) //////////////////////////////////////////////////////////////////////////////// // nsIRDFNode methods: @@ -155,7 +155,7 @@ nsRDFResource::GetDelegate(const char* aKey, REFNSIID aIID, void** aResult) // Construct a ContractID of the form "@mozilla.org/rdf/delegate/[key]/[scheme];1 nsAutoCString contractID(NS_RDF_DELEGATEFACTORY_CONTRACTID_PREFIX); contractID.Append(aKey); - contractID.Append("&scheme="); + contractID.AppendLiteral("&scheme="); int32_t i = mURI.FindChar(':'); contractID += StringHead(mURI, i); diff --git a/rdf/util/public/nsRDFResource.h b/rdf/util/nsRDFResource.h index 878c109aa..7556b323c 100644 --- a/rdf/util/public/nsRDFResource.h +++ b/rdf/util/nsRDFResource.h @@ -22,25 +22,25 @@ class nsIRDFService; class nsRDFResource : public nsIRDFResource { public: - NS_DECL_ISUPPORTS + NS_DECL_THREADSAFE_ISUPPORTS // nsIRDFNode methods: - NS_IMETHOD EqualsNode(nsIRDFNode* aNode, bool* aResult); + NS_IMETHOD EqualsNode(nsIRDFNode* aNode, bool* aResult) override; // nsIRDFResource methods: - NS_IMETHOD Init(const char* aURI); - NS_IMETHOD GetValue(char* *aURI); - NS_IMETHOD GetValueUTF8(nsACString& aResult); - NS_IMETHOD GetValueConst(const char** aURI); - NS_IMETHOD EqualsString(const char* aURI, bool* aResult); - NS_IMETHOD GetDelegate(const char* aKey, REFNSIID aIID, void** aResult); - NS_IMETHOD ReleaseDelegate(const char* aKey); + NS_IMETHOD Init(const char* aURI) override; + NS_IMETHOD GetValue(char* *aURI) override; + NS_IMETHOD GetValueUTF8(nsACString& aResult) override; + NS_IMETHOD GetValueConst(const char** aURI) override; + NS_IMETHOD EqualsString(const char* aURI, bool* aResult) override; + NS_IMETHOD GetDelegate(const char* aKey, REFNSIID aIID, void** aResult) override; + NS_IMETHOD ReleaseDelegate(const char* aKey) override; // nsRDFResource methods: nsRDFResource(void); - virtual ~nsRDFResource(void); protected: + virtual ~nsRDFResource(void); static nsIRDFService* gRDFService; static nsrefcnt gRDFServiceRefCnt; diff --git a/rdf/datasource/public/moz.build b/rdf/util/objs.mozbuild index a9f8aeb40..b69000024 100644 --- a/rdf/datasource/public/moz.build +++ b/rdf/util/objs.mozbuild @@ -4,9 +4,10 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -MODULE = 'rdf' - -EXPORTS += [ - 'nsILocalStore.h', +rdf_util_src_lcppsrcs = [ + 'nsRDFResource.cpp', ] +rdf_util_src_cppsrcs = [ + '%s/rdf/util/%s' % (TOPSRCDIR, s) for s in rdf_util_src_lcppsrcs +] diff --git a/rdf/util/public/moz.build b/rdf/util/public/moz.build deleted file mode 100644 index c5a23226c..000000000 --- a/rdf/util/public/moz.build +++ /dev/null @@ -1,12 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -MODULE = 'rdfutil' - -EXPORTS += [ - 'nsRDFResource.h', -] - diff --git a/rdf/util/src/internal/Makefile.in b/rdf/util/src/internal/Makefile.in deleted file mode 100644 index a2aef58f1..000000000 --- a/rdf/util/src/internal/Makefile.in +++ /dev/null @@ -1,31 +0,0 @@ -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DEPTH = @DEPTH@ -topsrcdir = @top_srcdir@ -srcdir = @srcdir@ -VPATH = @srcdir@ - -include $(DEPTH)/config/autoconf.mk - -# This makefile builds the version of unicharutils_s static library which uses -# internal linkage. Components that use frozen (external) linkage should use -# rdfutil_external_s. - -include $(srcdir)/../objs.mk - -EXTRA_DEPS += $(srcdir)/../objs.mk - -MOZILLA_INTERNAL_API = 1 - -# we don't want the shared lib, but we want to force the creation of a static lib. -FORCE_STATIC_LIB = 1 - -include $(topsrcdir)/config/rules.mk - -$(RDF_UTIL_SRC_LCPPSRCS): %: $(srcdir)/../% - $(INSTALL) $^ . - -GARBAGE += $(RDF_UTIL_SRC_LCPPSRCS) diff --git a/rdf/util/src/moz.build b/rdf/util/src/moz.build deleted file mode 100644 index a8762180f..000000000 --- a/rdf/util/src/moz.build +++ /dev/null @@ -1,16 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DIRS += ['internal'] - -MODULE = 'rdfutil' - -CPP_SOURCES += [ - '$(RDF_UTIL_SRC_LCPPSRCS)', -] - -LIBRARY_NAME = 'rdfutil_external_s' - diff --git a/rdf/util/src/objs.mk b/rdf/util/src/objs.mk deleted file mode 100644 index 4887259e7..000000000 --- a/rdf/util/src/objs.mk +++ /dev/null @@ -1,9 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -RDF_UTIL_SRC_LCPPSRCS = \ - nsRDFResource.cpp \ - $(NULL) - -RDF_UTIL_SRC_CPPSRCS = $(addprefix $(topsrcdir)/rdf/util/src/, $(RDF_UTIL_SRC_LCPPSRCS)) |