Closed Bug 297916 Opened 20 years ago Closed 8 years ago

Expose RDF nsresults on Components.results

Categories

(Core Graveyard :: RDF, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: axel, Unassigned)

Details

We should expose some of the RDF nsresults from rdf.h to script, 
Components.results is the canonical candidate.

I wonder if we should prune NS_RDF_CURSOR_EMPTY while we're at it, that one
is dead. At least, that's one we're not supposed to expose.

List of stuff to expose:

/* Returned from nsIRDFDataSource::GetSource() and GetTarget() if the source/target
   has no value */
#define NS_RDF_NO_VALUE           NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 2)

/* Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion (or
   unassertion was accepted by the datasource*/
#define NS_RDF_ASSERTION_ACCEPTED NS_OK

/* Returned from nsIRDFDataSource::Assert() and Unassert() if the assertion (or
   unassertion) was rejected by the datasource; i.e., the datasource was not
   willing to record the statement. */
#define NS_RDF_ASSERTION_REJECTED NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 3)

/* Return this from rdfITripleVisitor to stop cycling */
#define NS_RDF_STOP_VISIT         NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 4)
I'm very worried about dependencies and duplication here. Let's do
Components.result right if we can.
Why are you "very worried" about duplication?  There are no dependencies that I
know of, since the categories are in nsError.h anyway.

Doing Components.results "right" is a fine thing, but I don't think that
duplicating a handful of error codes for RDF or Calendar or whatever is bad
enough to defer solving this  problem until someone rearchitects Components.results.
Maybe leverage nsIErrorService somehow?  nsNetError.h has the same issue, and it
is a much larger set of error codes to duplicate.
Workaround for JavaScript code:

const NS_RDF_NO_VALUE           = ((0x45 + 10) << 16) | 2;
const NS_RDF_ASSERTION_REJECTED = ((0x45 + 10) << 16) | 3;

or (to ensure that the ugly bit shift numbers are correct)

var ser = Components.classes["@mozilla.org/rdf/rdf-service;1"]
	.getService(Components.interfaces.nsIRDFService);
var obj = Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"]
        .createInstance(Components.interfaces.nsIRDFInMemoryDataSource);
var obj = obj.QueryInterface(Components.interfaces.nsIRDFDataSource);
var i = obj.GetTarget(ser.GetResource("urn:nothing"),
        ser.GetResource("urn:nothing"), true);
const NS_RDF_NO_VALUE = Components.lastResult;

But I don't think that there is lot of JavaScript code that actually will use it.
Assignee: axel → nobody
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.