2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2010-06-10 11:11:40 -07:00
|
|
|
#include "mozilla/ModuleUtils.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#include "nsIFactory.h"
|
|
|
|
#include "nsRDFService.h"
|
|
|
|
#include "nsIRDFContainer.h"
|
|
|
|
#include "nsIRDFContainerUtils.h"
|
|
|
|
#include "nsIRDFCompositeDataSource.h"
|
|
|
|
#include "nsIRDFContentSink.h"
|
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsRDFBaseDataSources.h"
|
|
|
|
#include "nsRDFBuiltInDataSources.h"
|
|
|
|
#include "nsFileSystemDataSource.h"
|
|
|
|
#include "nsRDFCID.h"
|
|
|
|
#include "nsIComponentManager.h"
|
|
|
|
#include "rdf.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsILocalStore.h"
|
|
|
|
#include "nsRDFXMLParser.h"
|
|
|
|
#include "nsRDFXMLSerializer.h"
|
|
|
|
|
|
|
|
#include "rdfISerializer.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Functions used to create new instances of a given object by the
|
|
|
|
// generic factory.
|
|
|
|
|
|
|
|
#define MAKE_CTOR(_func,_new,_ifname) \
|
2010-06-10 11:11:40 -07:00
|
|
|
static nsresult \
|
2007-03-22 10:30:00 -07:00
|
|
|
CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
|
|
|
|
{ \
|
|
|
|
if (!aResult) { \
|
|
|
|
return NS_ERROR_INVALID_POINTER; \
|
|
|
|
} \
|
|
|
|
if (aOuter) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_NO_AGGREGATION; \
|
|
|
|
} \
|
|
|
|
nsI##_ifname* inst; \
|
|
|
|
nsresult rv = NS_New##_new(&inst); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
} \
|
|
|
|
NS_RELEASE(inst); /* get rid of extra refcnt */ \
|
|
|
|
return rv; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern nsresult
|
|
|
|
NS_NewDefaultResource(nsIRDFResource** aResult);
|
|
|
|
|
|
|
|
MAKE_CTOR(RDFXMLDataSource,RDFXMLDataSource,RDFDataSource)
|
|
|
|
MAKE_CTOR(RDFCompositeDataSource,RDFCompositeDataSource,RDFCompositeDataSource)
|
|
|
|
MAKE_CTOR(RDFContainer,RDFContainer,RDFContainer)
|
|
|
|
|
|
|
|
MAKE_CTOR(RDFContainerUtils,RDFContainerUtils,RDFContainerUtils)
|
|
|
|
|
|
|
|
MAKE_CTOR(RDFContentSink,RDFContentSink,RDFContentSink)
|
|
|
|
MAKE_CTOR(RDFDefaultResource,DefaultResource,RDFResource)
|
|
|
|
|
|
|
|
#define MAKE_RDF_CTOR(_func,_new,_ifname) \
|
2010-06-10 11:11:40 -07:00
|
|
|
static nsresult \
|
2007-03-22 10:30:00 -07:00
|
|
|
CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
|
|
|
|
{ \
|
|
|
|
if (!aResult) { \
|
|
|
|
return NS_ERROR_INVALID_POINTER; \
|
|
|
|
} \
|
|
|
|
if (aOuter) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_NO_AGGREGATION; \
|
|
|
|
} \
|
|
|
|
rdfI##_ifname* inst; \
|
|
|
|
nsresult rv = NS_New##_new(&inst); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
return rv; \
|
|
|
|
} \
|
|
|
|
rv = inst->QueryInterface(aIID, aResult); \
|
|
|
|
if (NS_FAILED(rv)) { \
|
2012-07-30 07:20:58 -07:00
|
|
|
*aResult = nullptr; \
|
2007-03-22 10:30:00 -07:00
|
|
|
} \
|
|
|
|
NS_RELEASE(inst); /* get rid of extra refcnt */ \
|
|
|
|
return rv; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern nsresult
|
|
|
|
NS_NewTriplesSerializer(rdfISerializer** aResult);
|
|
|
|
|
|
|
|
MAKE_RDF_CTOR(TriplesSerializer, TriplesSerializer, Serializer)
|
|
|
|
|
2010-06-10 11:11:40 -07:00
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFCOMPOSITEDATASOURCE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFFILESYSTEMDATASOURCE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFINMEMORYDATASOURCE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFXMLDATASOURCE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFDEFAULTRESOURCE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFCONTENTSINK_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFCONTAINER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFCONTAINERUTILS_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFSERVICE_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFXMLPARSER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFXMLSERIALIZER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_RDFNTRIPLES_SERIALIZER_CID);
|
|
|
|
NS_DEFINE_NAMED_CID(NS_LOCALSTORE_CID);
|
|
|
|
|
|
|
|
|
|
|
|
static const mozilla::Module::CIDEntry kRDFCIDs[] = {
|
2013-07-31 08:44:03 -07:00
|
|
|
{ &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 }
|
2010-06-10 11:11:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const mozilla::Module::ContractIDEntry kRDFContracts[] = {
|
|
|
|
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "composite-datasource", &kNS_RDFCOMPOSITEDATASOURCE_CID },
|
|
|
|
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "files", &kNS_RDFFILESYSTEMDATASOURCE_CID },
|
|
|
|
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "in-memory-datasource", &kNS_RDFINMEMORYDATASOURCE_CID },
|
|
|
|
{ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "xml-datasource", &kNS_RDFXMLDATASOURCE_CID },
|
|
|
|
{ NS_RDF_RESOURCE_FACTORY_CONTRACTID, &kNS_RDFDEFAULTRESOURCE_CID },
|
|
|
|
{ NS_RDF_CONTRACTID "/content-sink;1", &kNS_RDFCONTENTSINK_CID },
|
|
|
|
{ NS_RDF_CONTRACTID "/container;1", &kNS_RDFCONTAINER_CID },
|
|
|
|
{ NS_RDF_CONTRACTID "/container-utils;1", &kNS_RDFCONTAINERUTILS_CID },
|
|
|
|
{ NS_RDF_CONTRACTID "/rdf-service;1", &kNS_RDFSERVICE_CID },
|
|
|
|
{ NS_RDF_CONTRACTID "/xml-parser;1", &kNS_RDFXMLPARSER_CID },
|
|
|
|
{ NS_RDF_CONTRACTID "/xml-serializer;1", &kNS_RDFXMLSERIALIZER_CID },
|
|
|
|
{ NS_RDF_SERIALIZER "ntriples", &kNS_RDFNTRIPLES_SERIALIZER_CID },
|
|
|
|
{ NS_LOCALSTORE_CONTRACTID, &kNS_LOCALSTORE_CID },
|
2013-07-31 08:44:03 -07:00
|
|
|
{ nullptr }
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2010-06-10 11:11:40 -07:00
|
|
|
static const mozilla::Module kRDFModule = {
|
|
|
|
mozilla::Module::kVersion,
|
|
|
|
kRDFCIDs,
|
|
|
|
kRDFContracts,
|
2013-07-31 08:44:03 -07:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2014-08-04 16:51:20 -07:00
|
|
|
nullptr,
|
|
|
|
nullptr
|
2010-06-10 11:11:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
NSMODULE_DEFN(nsRDFModule) = &kRDFModule;
|