Bug 1329827 (part 1) - Remove rdfISerializer. r=pike.

Neither Firefox nor Thunderbird use any of rdfISerializer,
NS_RDFNTRIPLES_SERIALIZER_CID, and
"@mozilla.org/rdf/serializer;1?format=ntriples".

https://dxr.mozilla.org/addons/source/ shows three addons that use them, but
only one does so meaningfully: ArchView. (The others mention them as part of
long lists of XPCOM interfaces.) According to AMO, ArchView hasn't been updated
since August 2008, it has only 153 users, it doesn't work in Firefox 53. Also,
judging from the code, rdfISerializer is only be used as part of debugging the
addon itself. So I think that use can be ignored.

This patch removes them. It also removes rdfTriplesSerializer.cpp.

--HG--
extra : rebase_source : faae5021ea9b58edf9d8f8b39ddd1551425544fc
This commit is contained in:
Nicholas Nethercote 2016-12-23 15:14:46 +11:00
Родитель f2afbdd978
Коммит 219d02a9a5
5 изменённых файлов: 0 добавлений и 220 удалений

Просмотреть файл

@ -25,7 +25,6 @@ XPIDL_SOURCES += [
'nsIRDFXMLSink.idl',
'nsIRDFXMLSource.idl',
'rdfIDataSource.idl',
'rdfISerializer.idl',
'rdfITripleVisitor.idl',
]
@ -49,7 +48,6 @@ UNIFIED_SOURCES += [
'nsRDFXMLDataSource.cpp',
'nsRDFXMLParser.cpp',
'nsRDFXMLSerializer.cpp',
'rdfTriplesSerializer.cpp',
'rdfutil.cpp',
]

Просмотреть файл

@ -49,8 +49,6 @@ static const char kURI##prefix##_##name[] = ns #name
#define NS_RDF_RESOURCE_FACTORY_CONTRACTID_PREFIX NS_RDF_RESOURCE_FACTORY_CONTRACTID "?name="
#define NS_RDF_INFER_DATASOURCE_CONTRACTID_PREFIX NS_RDF_CONTRACTID "/infer-datasource;1?engine="
#define NS_RDF_SERIALIZER NS_RDF_CONTRACTID "/serializer;1?format="
// contract ID is in the form
// @mozilla.org/rdf/delegate-factory;1?key=<key>&scheme=<scheme>
#define NS_RDF_DELEGATEFACTORY_CONTRACTID "@mozilla.org/rdf/delegate-factory;1"

Просмотреть файл

@ -1,30 +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/. */
#include "nsISupports.idl"
interface rdfIDataSource;
interface nsIOutputStream;
/**
* Interface used to serialize RDF.
*
* @status PLASMA
*/
[scriptable, uuid(f0edfcdd-8bca-4d32-9226-7421001396a4)]
interface rdfISerializer : nsISupports
{
/**
* Synchronously serialize the given datasource to the outputstream.
*
* Implementations are not required to implement any buffering or
* other stream-based optimizations.
*
* @param aDataSource The RDF data source to be serialized.
* @param aOut The output stream to use.
*/
void serialize(in rdfIDataSource aDataSource, in nsIOutputStream aOut);
};

Просмотреть файл

@ -1,151 +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 "nsIOutputStream.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsPrintfCString.h"
#include "nsIBufferedStreams.h"
#include "nsNetCID.h"
#include "nsComponentManagerUtils.h"
#include "rdfISerializer.h"
#include "rdfIDataSource.h"
#include "rdfITripleVisitor.h"
#include "nsIRDFResource.h"
#include "nsIRDFLiteral.h"
#include "mozilla/Attributes.h"
class TriplesVisitor final : public rdfITripleVisitor
{
public:
explicit TriplesVisitor(nsIOutputStream* aOut) : mOut(aOut) {}
NS_DECL_RDFITRIPLEVISITOR
NS_DECL_ISUPPORTS
protected:
~TriplesVisitor() {}
nsresult writeResource(nsIRDFResource* aResource);
nsIOutputStream* mOut;
};
NS_IMPL_ISUPPORTS(TriplesVisitor, rdfITripleVisitor)
nsresult
TriplesVisitor::writeResource(nsIRDFResource *aResource)
{
nsCString res;
uint32_t writeCount, wroteCount;
mOut->Write("<", 1, &wroteCount);
NS_ENSURE_TRUE(wroteCount == 1, NS_ERROR_FAILURE);
nsresult rv = aResource->GetValueUTF8(res);
NS_ENSURE_SUCCESS(rv, rv);
writeCount = res.Length();
mOut->Write(res.get(), writeCount, &wroteCount);
NS_ENSURE_TRUE(writeCount == wroteCount, NS_ERROR_FAILURE);
mOut->Write("> ", 2, &wroteCount);
NS_ENSURE_TRUE(wroteCount == 2, NS_ERROR_FAILURE);
return NS_OK;
}
NS_IMETHODIMP
TriplesVisitor::Visit(nsIRDFNode *aSubject, nsIRDFResource *aPredicate,
nsIRDFNode *aObject, bool aTruthValue)
{
nsCOMPtr<nsIRDFResource> subjectRes = do_QueryInterface(aSubject);
nsresult rv = NS_OK;
if (subjectRes) {
rv = writeResource(subjectRes);
}
if (NS_FAILED(rv)) {
return rv;
}
rv = writeResource(aPredicate);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIRDFResource> res = do_QueryInterface(aObject);
nsCOMPtr<nsIRDFLiteral> lit;
nsCOMPtr<nsIRDFInt> intLit;
uint32_t wroteCount;
if (res) {
rv = writeResource(res);
} else if ((lit = do_QueryInterface(aObject)) != nullptr) {
const char16_t *value;
lit->GetValueConst(&value);
nsAutoCString object;
object.Append('"');
AppendUTF16toUTF8(value, object);
object.AppendLiteral("\" ");
uint32_t writeCount = object.Length();
rv = mOut->Write(object.get(), writeCount, &wroteCount);
NS_ENSURE_TRUE(writeCount == wroteCount, NS_ERROR_FAILURE);
} else if ((intLit = do_QueryInterface(aObject)) != nullptr) {
int32_t value;
intLit->GetValue(&value);
nsPrintfCString
object("\"%i\"^^<http://www.w3.org/2001/XMLSchema#integer> ",
value);
uint32_t writeCount = object.Length();
rv = mOut->Write(object.get(), writeCount, &wroteCount);
NS_ENSURE_TRUE(writeCount == wroteCount, NS_ERROR_FAILURE);
}
NS_ENSURE_SUCCESS(rv, rv);
return mOut->Write(".\n", 2, &wroteCount);
}
class rdfTriplesSerializer final : public rdfISerializer
{
public:
NS_DECL_ISUPPORTS
NS_DECL_RDFISERIALIZER
rdfTriplesSerializer();
private:
~rdfTriplesSerializer();
};
nsresult
NS_NewTriplesSerializer(rdfISerializer** aResult)
{
NS_PRECONDITION(aResult != nullptr, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
*aResult = new rdfTriplesSerializer();
if (! *aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}
NS_IMPL_ISUPPORTS(rdfTriplesSerializer, rdfISerializer)
rdfTriplesSerializer::rdfTriplesSerializer()
{
}
rdfTriplesSerializer::~rdfTriplesSerializer()
{
}
NS_IMETHODIMP
rdfTriplesSerializer::Serialize(rdfIDataSource *aDataSource,
nsIOutputStream *aOut)
{
nsresult rv;
nsCOMPtr<nsIBufferedOutputStream> bufout =
do_CreateInstance(NS_BUFFEREDOUTPUTSTREAM_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = bufout->Init(aOut, 1024);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<rdfITripleVisitor> tv = new TriplesVisitor(bufout);
NS_ENSURE_TRUE(tv, NS_ERROR_OUT_OF_MEMORY);
return aDataSource->VisitAllTriples(tv);
}

Просмотреть файл

@ -23,8 +23,6 @@
#include "nsRDFXMLParser.h"
#include "nsRDFXMLSerializer.h"
#include "rdfISerializer.h"
//----------------------------------------------------------------------
// Functions used to create new instances of a given object by the
@ -67,36 +65,6 @@ MAKE_CTOR(RDFContainerUtils,RDFContainerUtils,RDFContainerUtils)
MAKE_CTOR(RDFContentSink,RDFContentSink,RDFContentSink)
MAKE_CTOR(RDFDefaultResource,DefaultResource,RDFResource)
#define MAKE_RDF_CTOR(_func,_new,_ifname) \
static nsresult \
CreateNew##_func(nsISupports* aOuter, REFNSIID aIID, void **aResult) \
{ \
if (!aResult) { \
return NS_ERROR_INVALID_POINTER; \
} \
if (aOuter) { \
*aResult = nullptr; \
return NS_ERROR_NO_AGGREGATION; \
} \
rdfI##_ifname* inst; \
nsresult rv = NS_New##_new(&inst); \
if (NS_FAILED(rv)) { \
*aResult = nullptr; \
return rv; \
} \
rv = inst->QueryInterface(aIID, aResult); \
if (NS_FAILED(rv)) { \
*aResult = nullptr; \
} \
NS_RELEASE(inst); /* get rid of extra refcnt */ \
return rv; \
}
extern nsresult
NS_NewTriplesSerializer(rdfISerializer** aResult);
MAKE_RDF_CTOR(TriplesSerializer, TriplesSerializer, Serializer)
NS_DEFINE_NAMED_CID(NS_RDFCOMPOSITEDATASOURCE_CID);
NS_DEFINE_NAMED_CID(NS_RDFFILESYSTEMDATASOURCE_CID);
NS_DEFINE_NAMED_CID(NS_RDFINMEMORYDATASOURCE_CID);
@ -108,7 +76,6 @@ 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);
@ -124,7 +91,6 @@ static const mozilla::Module::CIDEntry kRDFCIDs[] = {
{ &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 }
};
@ -141,7 +107,6 @@ static const mozilla::Module::ContractIDEntry kRDFContracts[] = {
{ 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 },
{ nullptr }
};