Changed RDF-specific errors to be success rather than error codes.

This commit is contained in:
waterson%netscape.com 1999-03-30 02:30:16 +00:00
Родитель 669067e608
Коммит 95fe5b64f9
26 изменённых файлов: 429 добавлений и 275 удалений

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

@ -457,7 +457,14 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
nsVoidArray *tempArray;
if ((tempArray = new nsVoidArray()) == nsnull) return (NS_ERROR_OUT_OF_MEMORY);
while (NS_SUCCEEDED(rv = properties->Advance())) {
while (1) {
rv = properties->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = properties->GetLabel(getter_AddRefs(property))))
@ -478,7 +485,14 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
return rv;
}
while (NS_SUCCEEDED(rv = assertions->Advance())) {
while (1) {
rv = assertions->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> value;
if (NS_FAILED(rv = assertions->GetValue(getter_AddRefs(value)))) {
NS_ERROR("unable to get cursor value");
@ -539,11 +553,7 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
}
delete tempArray;
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
// This is a normal return code from nsIRDFCursor::Advance()
rv = NS_OK;
return rv;
return NS_OK;
}
@ -1114,7 +1124,7 @@ RDFGenericBuilderImpl::FindChildByTag(nsIContent* aElement,
return NS_OK;
}
return NS_ERROR_RDF_NO_VALUE; // not found
return NS_RDF_NO_VALUE; // not found
}
@ -1169,7 +1179,7 @@ RDFGenericBuilderImpl::FindChildByTagAndResource(nsIContent* aElement,
return NS_OK;
}
return NS_ERROR_RDF_NO_VALUE; // not found
return NS_RDF_NO_VALUE; // not found
}
@ -1181,23 +1191,23 @@ RDFGenericBuilderImpl::EnsureElementHasGenericChild(nsIContent* parent,
{
nsresult rv;
if (NS_SUCCEEDED(rv = FindChildByTag(parent, nameSpaceID, tag, result)))
return NS_OK;
if (rv != NS_ERROR_RDF_NO_VALUE)
return rv; // something really bad happened
// if we get here, we need to construct a new child element.
nsCOMPtr<nsIContent> element;
if (NS_FAILED(rv = NS_NewRDFElement(nameSpaceID, tag, getter_AddRefs(element))))
rv = FindChildByTag(parent, nameSpaceID, tag, result);
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
return rv;
if (rv == NS_RDF_NO_VALUE) {
// we need to construct a new child element.
nsCOMPtr<nsIContent> element;
*result = element;
NS_ADDREF(*result);
if (NS_FAILED(rv = NS_NewRDFElement(nameSpaceID, tag, getter_AddRefs(element))))
return rv;
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
return rv;
*result = element;
NS_ADDREF(*result);
}
return NS_OK;
}
@ -1382,7 +1392,15 @@ RDFGenericBuilderImpl::IsContainer(nsIContent* aElement, nsIRDFResource* aResour
return result;
}
while (NS_SUCCEEDED(arcs->Advance())) {
while (1) {
nsresult rv = arcs->Advance();
NS_ASSERTION(NS_SUCCEEDED(rv), "severe error advancing cursor");
if (NS_FAILED(rv))
return PR_FALSE;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(arcs->GetLabel(getter_AddRefs(property)))) {
NS_ERROR("unable to get cursor value");
@ -1575,7 +1593,7 @@ RDFGenericBuilderImpl::CloseWidgetItem(nsIContent* aElement)
}
else rv = FindChildByTag(aElement, kNameSpaceID_XUL, parentAtom, getter_AddRefs(parentNode));
if (rv == NS_ERROR_RDF_NO_VALUE) {
if (rv == NS_RDF_NO_VALUE) {
// No tag; must've already been closed
return NS_OK;
}

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

@ -1404,8 +1404,10 @@ NS_IMETHODIMP nsMsgDBEnumerator::Next(void)
NS_IF_RELEASE(mResultHdr);
mResultHdr = nsnull;
rv = mRowCursor->NextRow(mDB->GetEnv(), &hdrRow, &rowPos);
if (!hdrRow)
rv = NS_ERROR_RDF_CURSOR_EMPTY;
if (!hdrRow) {
mDone = PR_TRUE;
return NS_RDF_CURSOR_EMPTY;
}
if (NS_FAILED(rv)) {
mDone = PR_TRUE;
return rv;

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

@ -281,11 +281,11 @@ NS_IMETHODIMP nsMSGFolderDataSource::GetTarget(nsIRDFResource* source,
PRBool tv,
nsIRDFNode** target)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
// we only have positive assertions in the mail data source.
if (! tv)
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
//XXX these need to start being their own functions
nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(source, &rv));

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

@ -66,8 +66,8 @@ static const char* kTag##prefix##_##name = #name
/* Returned from nsIRDFCursor::Advance() if the cursor has no more
elements to enuemrate */
#define NS_ERROR_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 1)
#define NS_ERROR_RDF_NO_VALUE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 2)
#define NS_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 1)
#define NS_RDF_NO_VALUE NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_RDF, 2)

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

@ -296,7 +296,7 @@ DBArcsInOutCursor::Advance(void)
while (mInCursor || mOutCursor) {
nsresult result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
while (NS_SUCCEEDED(result)) {
while (NS_SUCCEEDED(result) && (result != NS_RDF_CURSOR_EMPTY)) {
nsIRDFNode* obj ;
result = GetValue(&obj);
NS_ASSERTION(NS_SUCCEEDED(result), "Advance is broken");
@ -307,7 +307,7 @@ DBArcsInOutCursor::Advance(void)
result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
}
if (result != NS_ERROR_RDF_CURSOR_EMPTY)
if (NS_FAILED(result))
return result;
NS_IF_RELEASE(mInCursor);
@ -325,7 +325,7 @@ DBArcsInOutCursor::Advance(void)
ds->ArcLabelsOut(mSource, &mOutCursor);
}
}
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
////////////////////////////////////////////////////////////////////////
@ -509,7 +509,9 @@ DBGetSTCursor::Advance(void)
nsIRDFDataSource* ds;
while (mCurrentCursor) {
nsresult result = mCurrentCursor->Advance();
while (NS_ERROR_RDF_CURSOR_EMPTY != result) {
if (NS_FAILED(result)) return result;
while (NS_RDF_CURSOR_EMPTY != result) {
nsIRDFResource* src;
nsIRDFNode* trg;
mCurrentCursor->GetSource(&src);
@ -534,7 +536,7 @@ DBGetSTCursor::Advance(void)
else
ds->GetSources(mLabel, mTarget, mTruthValue, &mCurrentCursor);
}
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
@ -634,7 +636,11 @@ CompositeDataSourceImpl::GetSource(nsIRDFResource* property,
for (PRInt32 i = 0; i < count; ++i) {
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
if (NS_FAILED(ds->GetSource(property, target, tv, source)))
nsresult rv;
rv = ds->GetSource(property, target, tv, source);
if (NS_FAILED(rv)) return rv;
if (rv == NS_RDF_NO_VALUE)
continue;
// okay, found it. make sure we don't have the opposite
@ -643,9 +649,9 @@ CompositeDataSourceImpl::GetSource(nsIRDFResource* property,
return NS_OK;
NS_RELEASE(*source);
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
@ -675,7 +681,12 @@ CompositeDataSourceImpl::GetTarget(nsIRDFResource* source,
for (PRInt32 i = 0; i < count; ++i) {
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
if (NS_FAILED(ds->GetTarget(source, property, tv, target)))
nsresult rv;
rv = ds->GetTarget(source, property, tv, target);
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_NO_VALUE)
continue;
// okay, found it. make sure we don't have the opposite
@ -684,10 +695,10 @@ CompositeDataSourceImpl::GetTarget(nsIRDFResource* source,
return NS_OK;
NS_RELEASE(*target);
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
PRBool

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

@ -197,7 +197,7 @@ ContainerCursorImpl::Advance(void)
// initialize rv to the case where mNextIndex has advanced past the
// last element
rv = NS_ERROR_RDF_CURSOR_EMPTY;
rv = NS_RDF_CURSOR_EMPTY;
while (mNextIndex < last) {
NS_IF_RELEASE(mOrdinalProperty);
@ -205,10 +205,11 @@ ContainerCursorImpl::Advance(void)
break;
rv = mDataSource->GetTarget(mContainer, mOrdinalProperty, PR_TRUE, &mCurrent);
if (NS_FAILED(rv)) return rv;
++mNextIndex;
if (NS_SUCCEEDED(rv)) {
if (rv == NS_OK) {
// Don't bother releasing mCurrent; we'll let the AddRef
// serve as the implicit addref that GetNext() should
// perform.

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

@ -68,7 +68,7 @@ public:
// nsIRDFCursor
NS_IMETHOD Advance(void) {
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
// nsIRDFAssertionCursor
@ -139,7 +139,7 @@ public:
// nsIRDFCursor
NS_IMETHOD Advance(void) {
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
// nsIRDFArcsOutCursor
@ -206,7 +206,7 @@ public:
// nsIRDFCursor
NS_IMETHOD Advance(void) {
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
// nsIRDFArcsInCursor

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

@ -363,7 +363,7 @@ InMemoryAssertionCursor::Advance(void)
}
// If we get here, the cursor is empty.
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
NS_IMETHODIMP
@ -611,7 +611,7 @@ InMemoryArcsCursor::Advance(void)
NS_IF_RELEASE(mCurrent);
if (mNextIndex >= mElements.Count())
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
// Cast is ok because this is a closed system. This code
// effectively "transfers" the reference from the array to
@ -764,7 +764,7 @@ NS_IMETHODIMP
InMemoryResourceCursor::Advance(void)
{
if (mNext >= mResources.Count())
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
if (mNext >= 0) {
nsIRDFResource* resource = NS_STATIC_CAST(nsIRDFResource*, mResources[mNext]);
@ -774,7 +774,7 @@ InMemoryResourceCursor::Advance(void)
++mNext;
if (mNext >= mResources.Count())
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
return NS_OK;
}
@ -1009,7 +1009,7 @@ InMemoryDataSource::GetSource(nsIRDFResource* property,
return NS_OK;
}
*source = nsnull;
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP
@ -1052,7 +1052,7 @@ InMemoryDataSource::GetTarget(nsIRDFResource* source,
// If we get here, then there was no target with for the specified
// property & truth value.
*target = nsnull;
return NS_ERROR_RDF_NO_VALUE;
return NS_RDF_NO_VALUE;
}
NS_IMETHODIMP

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

@ -1777,7 +1777,8 @@ nsIRDFCompositeDataSource::InitJSClass(JSContext *cx)
JSObject *globj = JS_GetGlobalObject(cx);
if (!globj)
return 0;
JSObject *proto = JS_InitClass(cx, globj, 0, &nsIRDFCompositeDataSource_class, nsIRDFCompositeDataSource_ctor, 0,
JSObject *parentProto = nsIRDFDataSource::InitJSClass(cx);
JSObject *proto = JS_InitClass(cx, globj, parentProto, &nsIRDFCompositeDataSource_class, nsIRDFCompositeDataSource_ctor, 0,
0, nsIRDFCompositeDataSource_funcs, 0, 0);
return proto;
}

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

@ -1099,11 +1099,18 @@ RDFXMLDataSourceImpl::SerializeProperty(nsIOutputStream* aStream,
{
nsresult rv;
nsIRDFAssertionCursor* assertions = nsnull;
if (NS_FAILED(rv = mInner->GetTargets(aResource, aProperty, PR_TRUE, &assertions)))
nsCOMPtr<nsIRDFAssertionCursor> assertions;
if (NS_FAILED(rv = mInner->GetTargets(aResource, aProperty, PR_TRUE, getter_AddRefs(assertions))))
return rv;
while (NS_SUCCEEDED(rv = assertions->Advance())) {
while (1) {
rv = assertions->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsIRDFNode* value;
if (NS_FAILED(rv = assertions->GetValue(&value)))
break;
@ -1115,11 +1122,7 @@ RDFXMLDataSourceImpl::SerializeProperty(nsIOutputStream* aStream,
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
NS_RELEASE(assertions);
return rv;
return NS_OK;
}
@ -1153,11 +1156,18 @@ static const char kRDFDescription3[] = " </RDF:Description>\n";
rdf_BlockingWrite(aStream, uri);
rdf_BlockingWrite(aStream, kRDFDescription2, sizeof(kRDFDescription2) - 1);
nsIRDFArcsOutCursor* arcs = nsnull;
if (NS_FAILED(rv = mInner->ArcLabelsOut(aResource, &arcs)))
nsCOMPtr<nsIRDFArcsOutCursor> arcs;
if (NS_FAILED(rv = mInner->ArcLabelsOut(aResource, getter_AddRefs(arcs))))
return rv;
while (NS_SUCCEEDED(rv = arcs->Advance())) {
while (1) {
rv = arcs->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsIRDFResource* property;
if (NS_FAILED(rv = arcs->GetLabel(&property)))
break;
@ -1169,13 +1179,8 @@ static const char kRDFDescription3[] = " </RDF:Description>\n";
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
NS_IF_RELEASE(arcs);
rdf_BlockingWrite(aStream, kRDFDescription3, sizeof(kRDFDescription3) - 1);
return rv;
return NS_OK;
}
nsresult
@ -1189,14 +1194,21 @@ RDFXMLDataSourceImpl::SerializeMember(nsIOutputStream* aStream,
// there may for some random reason be two or more elements with
// the same ordinal value. Okay, I'm paranoid.
nsIRDFAssertionCursor* cursor;
if (NS_FAILED(rv = mInner->GetTargets(aContainer, aProperty, PR_TRUE, &cursor)))
nsCOMPtr<nsIRDFAssertionCursor> cursor;
if (NS_FAILED(rv = mInner->GetTargets(aContainer, aProperty, PR_TRUE, getter_AddRefs(cursor))))
return rv;
nsXPIDLCString docURI;
mInner->GetURI(getter_Copies(docURI));
while (NS_SUCCEEDED(rv = cursor->Advance())) {
while (1) {
rv = cursor->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsIRDFNode* node;
if (NS_FAILED(rv = cursor->GetTarget(&node)))
@ -1246,11 +1258,7 @@ static const char kRDFLILiteral2[] = "</RDF:li>\n";
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
NS_RELEASE(cursor);
return rv;
return NS_OK;
}
@ -1310,11 +1318,18 @@ static const char kRDFAlt[] = "RDF:Alt";
// We iterate through all of the arcs, in case someone has applied
// properties to the bag itself.
nsIRDFArcsOutCursor* arcs;
if (NS_FAILED(rv = mInner->ArcLabelsOut(aContainer, &arcs)))
nsCOMPtr<nsIRDFArcsOutCursor> arcs;
if (NS_FAILED(rv = mInner->ArcLabelsOut(aContainer, getter_AddRefs(arcs))))
return rv;
while (NS_SUCCEEDED(rv = arcs->Advance())) {
while (1) {
rv = arcs->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsIRDFResource* property;
if (NS_FAILED(rv = arcs->GetLabel(&property)))
@ -1352,18 +1367,12 @@ static const char kRDFAlt[] = "RDF:Alt";
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
NS_RELEASE(arcs);
// close the container tag
rdf_BlockingWrite(aStream, " </", 4);
rdf_BlockingWrite(aStream, tag);
rdf_BlockingWrite(aStream, ">\n", 2);
return rv;
return NS_OK;
}
@ -1431,15 +1440,24 @@ NS_IMETHODIMP
RDFXMLDataSourceImpl::Serialize(nsIOutputStream* aStream)
{
nsresult rv;
nsIRDFResourceCursor* resources = nsnull;
nsCOMPtr<nsIRDFResourceCursor> resources;
if (NS_FAILED(rv = mInner->GetAllResources(&resources)))
goto done;
rv = mInner->GetAllResources(getter_AddRefs(resources));
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = SerializePrologue(aStream)))
goto done;
rv = SerializePrologue(aStream);
if (NS_FAILED(rv))
return rv;
while (1) {
rv = resources->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
while (NS_SUCCEEDED(rv = resources->Advance())) {
nsIRDFResource* resource;
if (NS_FAILED(rv = resources->GetResource(&resource)))
break;
@ -1456,16 +1474,7 @@ RDFXMLDataSourceImpl::Serialize(nsIOutputStream* aStream)
break;
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
if (NS_FAILED(rv))
goto done;
rv = SerializeEpilogue(aStream);
done:
NS_IF_RELEASE(resources);
return rv;
}

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

@ -827,7 +827,14 @@ rdf_ContainerRemoveElement(nsIRDFDataSource* aDataSource,
return rv;
}
while (NS_SUCCEEDED(rv = elements->Advance())) {
while (1) {
rv = elements->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> element;
if (NS_FAILED(rv = elements->GetTarget(getter_AddRefs(element)))) {
NS_ERROR("unable to read cursor");
@ -866,7 +873,14 @@ rdf_ContainerRemoveElement(nsIRDFDataSource* aDataSource,
// Now slide the rest of the collection backwards to fill in
// the gap.
while (NS_SUCCEEDED(rv = elements->Advance())) {
while (1) {
rv = elements->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
if (NS_FAILED(rv = elements->GetTarget(getter_AddRefs(element)))) {
NS_ERROR("unable to get element from cursor");
return rv;
@ -895,8 +909,6 @@ rdf_ContainerRemoveElement(nsIRDFDataSource* aDataSource,
++index;
}
NS_ASSERTION(rv == NS_ERROR_RDF_CURSOR_EMPTY, "severe error advancing cursor");
// Update the container's nextVal to reflect this mumbo jumbo
if (NS_FAILED(rv = rdf_ContainerSetNextValue(aDataSource, aContainer, index))) {
NS_ERROR("unable to update container's nextVal");
@ -906,8 +918,6 @@ rdf_ContainerRemoveElement(nsIRDFDataSource* aDataSource,
return NS_OK;
}
NS_ASSERTION(rv == NS_ERROR_RDF_CURSOR_EMPTY, "severe error advancing cursor");
NS_WARNING("attempt to remove non-existant element from container");
return NS_OK;
}
@ -951,7 +961,14 @@ rdf_ContainerInsertElementAt(nsIRDFDataSource* aDataSource,
PRInt32 index = 1;
// Advance the cursor to the aIndex'th element.
while (NS_SUCCEEDED(rv = elements->Advance())) {
while (1) {
rv = elements->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
if (NS_FAILED(rv = elements->GetLabel(getter_AddRefs(ordinal)))) {
NS_ERROR("unable to get element's ordinal index");
return rv;
@ -967,16 +984,9 @@ rdf_ContainerInsertElementAt(nsIRDFDataSource* aDataSource,
break;
}
// Make sure Advance() didn't bomb...
NS_ASSERTION(NS_SUCCEEDED(rv) || rv == NS_ERROR_RDF_CURSOR_EMPTY,
"severe error advancing cursor");
if (NS_FAILED(rv) && rv != NS_ERROR_RDF_CURSOR_EMPTY)
return rv;
// Remember if we've exhausted the cursor: if so, this degenerates
// into a simple "append" operation.
PRBool cursorExhausted = (rv == NS_ERROR_RDF_CURSOR_EMPTY);
PRBool cursorExhausted = (rv == NS_RDF_CURSOR_EMPTY);
// XXX Be paranoid: there may have been a "hole"
if (index > aIndex)
@ -1036,9 +1046,15 @@ rdf_ContainerInsertElementAt(nsIRDFDataSource* aDataSource,
NS_ERROR("unable to add element to container");
return rv;
}
} while (NS_SUCCEEDED(rv = elements->Advance()));
NS_ASSERTION(rv == NS_ERROR_RDF_CURSOR_EMPTY, "severe error advancing cursor");
rv = elements->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
}
while (1);
}
// Now update the container's nextVal
@ -1085,7 +1101,14 @@ rdf_ContainerIndexOf(nsIRDFDataSource* aDataSource,
// Advance the cursor until we find the element we want
while (NS_SUCCEEDED(rv = elements->Advance())) {
while (1) {
rv = elements->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> element;
if (NS_FAILED(rv = elements->GetTarget(getter_AddRefs(element)))) {
NS_ERROR("unable to get element from cursor");
@ -1112,8 +1135,6 @@ rdf_ContainerIndexOf(nsIRDFDataSource* aDataSource,
return NS_OK;
}
NS_ASSERTION(rv == NS_ERROR_RDF_CURSOR_EMPTY, "severe error advancing cursor");
NS_WARNING("element not found");
*aIndex = -1;
return NS_OK;

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

@ -1,9 +1,7 @@
<RDF xmlns:r="http://www.w3.org/TR/RDF/"
<r:RDF xmlns:r="http://www.w3.org/TR/WD-rdf-syntax#"
xmlns:d="http://purl.org/dc/elements/1.0/"
xmlns="http://directory.mozilla.org/rdf">
<Topic r:about="Arts/Books">
<catid>1</catid>
<narrow r:resource="http://www.amazon.com"/>
@ -1710,4 +1708,4 @@
</RDF>
</r:RDF>

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

@ -377,7 +377,16 @@ nsBrowsingProfile::CountPageVisit(const char* initialURL)
nsIRDFAssertionCursor* cursor;
rv = gCategoryDB->GetSources(kOPENDIR_link, urlRes, PR_TRUE, &cursor);
if (NS_SUCCEEDED(rv)) {
while (NS_SUCCEEDED(cursor->Advance())) {
while (1) {
rv = cursor->Advance();
if (NS_FAILED(rv)) {
done = PR_TRUE;
break;
}
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsIRDFResource* category;
rv = cursor->GetSource(&category);
if (NS_SUCCEEDED(rv)) {

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

@ -457,7 +457,14 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
nsVoidArray *tempArray;
if ((tempArray = new nsVoidArray()) == nsnull) return (NS_ERROR_OUT_OF_MEMORY);
while (NS_SUCCEEDED(rv = properties->Advance())) {
while (1) {
rv = properties->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = properties->GetLabel(getter_AddRefs(property))))
@ -478,7 +485,14 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
return rv;
}
while (NS_SUCCEEDED(rv = assertions->Advance())) {
while (1) {
rv = assertions->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> value;
if (NS_FAILED(rv = assertions->GetValue(getter_AddRefs(value)))) {
NS_ERROR("unable to get cursor value");
@ -539,11 +553,7 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
}
delete tempArray;
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
// This is a normal return code from nsIRDFCursor::Advance()
rv = NS_OK;
return rv;
return NS_OK;
}
@ -1114,7 +1124,7 @@ RDFGenericBuilderImpl::FindChildByTag(nsIContent* aElement,
return NS_OK;
}
return NS_ERROR_RDF_NO_VALUE; // not found
return NS_RDF_NO_VALUE; // not found
}
@ -1169,7 +1179,7 @@ RDFGenericBuilderImpl::FindChildByTagAndResource(nsIContent* aElement,
return NS_OK;
}
return NS_ERROR_RDF_NO_VALUE; // not found
return NS_RDF_NO_VALUE; // not found
}
@ -1181,23 +1191,23 @@ RDFGenericBuilderImpl::EnsureElementHasGenericChild(nsIContent* parent,
{
nsresult rv;
if (NS_SUCCEEDED(rv = FindChildByTag(parent, nameSpaceID, tag, result)))
return NS_OK;
if (rv != NS_ERROR_RDF_NO_VALUE)
return rv; // something really bad happened
// if we get here, we need to construct a new child element.
nsCOMPtr<nsIContent> element;
if (NS_FAILED(rv = NS_NewRDFElement(nameSpaceID, tag, getter_AddRefs(element))))
rv = FindChildByTag(parent, nameSpaceID, tag, result);
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
return rv;
if (rv == NS_RDF_NO_VALUE) {
// we need to construct a new child element.
nsCOMPtr<nsIContent> element;
*result = element;
NS_ADDREF(*result);
if (NS_FAILED(rv = NS_NewRDFElement(nameSpaceID, tag, getter_AddRefs(element))))
return rv;
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
return rv;
*result = element;
NS_ADDREF(*result);
}
return NS_OK;
}
@ -1382,7 +1392,15 @@ RDFGenericBuilderImpl::IsContainer(nsIContent* aElement, nsIRDFResource* aResour
return result;
}
while (NS_SUCCEEDED(arcs->Advance())) {
while (1) {
nsresult rv = arcs->Advance();
NS_ASSERTION(NS_SUCCEEDED(rv), "severe error advancing cursor");
if (NS_FAILED(rv))
return PR_FALSE;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(arcs->GetLabel(getter_AddRefs(property)))) {
NS_ERROR("unable to get cursor value");
@ -1575,7 +1593,7 @@ RDFGenericBuilderImpl::CloseWidgetItem(nsIContent* aElement)
}
else rv = FindChildByTag(aElement, kNameSpaceID_XUL, parentAtom, getter_AddRefs(parentNode));
if (rv == NS_ERROR_RDF_NO_VALUE) {
if (rv == NS_RDF_NO_VALUE) {
// No tag; must've already been closed
return NS_OK;
}

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

@ -246,7 +246,14 @@ RDFMenuBuilderImpl::AddWidgetItem(nsIContent* aElement,
return rv;
}
while (NS_SUCCEEDED(rv = arcs->Advance())) {
while (1) {
rv = arcs->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = arcs->GetLabel(getter_AddRefs(property)))) {
NS_ERROR("unable to get cursor value");
@ -304,11 +311,6 @@ RDFMenuBuilderImpl::AddWidgetItem(nsIContent* aElement,
// XXX: This is a hack until the menu folks get their act together.
menuItem->SetAttribute(kNameSpaceID_None, kOpenAtom, "true", PR_FALSE);
if (NS_FAILED(rv) && (rv != NS_ERROR_RDF_CURSOR_EMPTY)) {
NS_ERROR("error advancing cursor");
return rv;
}
// Finally, mark this as a "container" so that we know to
// recursively generate kids if they're asked for.

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

@ -228,7 +228,14 @@ RDFToolbarBuilderImpl::AddWidgetItem(nsIContent* aElement,
return rv;
}
while (NS_SUCCEEDED(rv = arcs->Advance())) {
while (1) {
rv = arcs->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = arcs->GetLabel(getter_AddRefs(property)))) {
NS_ERROR("unable to get cursor value");
@ -290,11 +297,6 @@ RDFToolbarBuilderImpl::AddWidgetItem(nsIContent* aElement,
toolbarItem->SetAttribute(kNameSpaceID_None, imagesrc, "resource:/res/toolbar/TB_Location.gif", PR_FALSE);
}
if (NS_FAILED(rv) && (rv != NS_ERROR_RDF_CURSOR_EMPTY)) {
NS_ERROR("error advancing cursor");
return rv;
}
// Finally, mark this as a "container" so that we know to
// recursively generate kids if they're asked for.
if (markAsContainer == PR_TRUE)

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

@ -559,7 +559,14 @@ RDFTreeBuilderImpl::AddWidgetItem(nsIContent* aElement,
return rv;
}
while (NS_SUCCEEDED(rv = arcs->Advance())) {
while (1) {
rv = arcs->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = arcs->GetLabel(getter_AddRefs(property)))) {
NS_ERROR("unable to get cursor value");
@ -620,11 +627,6 @@ RDFTreeBuilderImpl::AddWidgetItem(nsIContent* aElement,
}
}
if (NS_FAILED(rv) && (rv != NS_ERROR_RDF_CURSOR_EMPTY)) {
NS_ERROR("error advancing cursor");
return rv;
}
if (markAsContainer)
{
// Finally, mark this as a "container" so that we know to
@ -955,11 +957,21 @@ RDFTreeBuilderImpl::CreateTreeItemCells(nsIContent* aTreeItemElement)
// ...then query the RDF back-end
nsCOMPtr<nsIRDFNode> value;
if (NS_SUCCEEDED(rv = mDB->GetTarget(treeItemResource,
property,
PR_TRUE,
getter_AddRefs(value)))) {
rv = mDB->GetTarget(treeItemResource,
property,
PR_TRUE,
getter_AddRefs(value));
if (rv == NS_RDF_NO_VALUE) {
// There was no value for this. It'll have to get set
// later, when an OnAssert() comes in (if it even has
// a value at all...)
}
else if (NS_FAILED(rv)) {
NS_ERROR("error getting cell's value");
return rv; // XXX something serious happened
}
else {
// Attach a plain old text node: nothing fancy. Here's
// where we'd do wacky stuff like pull in an icon or
// whatever.
@ -968,15 +980,6 @@ RDFTreeBuilderImpl::CreateTreeItemCells(nsIContent* aTreeItemElement)
return rv;
}
}
else if (rv == NS_ERROR_RDF_NO_VALUE) {
// otherwise, there was no value for this. It'll have to
// get set later, when an OnAssert() comes in (if it even
// has a value at all...)
}
else {
NS_ERROR("error getting cell's value");
return rv; // XXX something serious happened
}
}
++cellIndex;

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

@ -559,7 +559,14 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement)
return rv;
}
while (NS_SUCCEEDED(rv = children->Advance())) {
while (1) {
rv = children->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> child;
if (NS_FAILED(rv = children->GetTarget(getter_AddRefs(child)))) {
NS_ERROR("error reading cursor");
@ -572,9 +579,6 @@ RDFXULBuilderImpl::CreateContents(nsIContent* aElement)
}
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
// Now that we've built the children, check to see if the includesrc attribute
// exists on the node.
nsString includeSrc;
@ -1538,7 +1542,14 @@ RDFXULBuilderImpl::CreateHTMLElement(nsIRDFResource* aResource,
}
// Advance that cursor 'til it runs outta steam
while (NS_SUCCEEDED(rv = properties->Advance())) {
while (1) {
rv = properties->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = properties->GetLabel(getter_AddRefs(property)))) {
@ -1569,15 +1580,6 @@ RDFXULBuilderImpl::CreateHTMLElement(nsIRDFResource* aResource,
}
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY) {
rv = NS_OK;
}
else if (NS_FAILED(rv)) {
// uh oh...
NS_ERROR("problem iterating properties");
return rv;
}
// Create the children NOW, because we can't do it lazily.
if (NS_FAILED(rv = CreateHTMLContents(element, aResource))) {
NS_ERROR("error creating child contents");
@ -1674,7 +1676,14 @@ RDFXULBuilderImpl::CreateHTMLContents(nsIContent* aElement,
return rv;
}
while (NS_SUCCEEDED(rv = children->Advance())) {
while (1) {
rv = children->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> child;
if (NS_FAILED(rv = children->GetTarget(getter_AddRefs(child)))) {
NS_ERROR("error reading cursor");
@ -1687,10 +1696,7 @@ RDFXULBuilderImpl::CreateHTMLContents(nsIContent* aElement,
}
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
rv = NS_OK;
return rv;
return NS_OK;
}
@ -1723,7 +1729,14 @@ RDFXULBuilderImpl::CreateXULElement(nsIRDFResource* aResource,
}
// Advance that cursor 'til it runs outta steam
while (NS_SUCCEEDED(rv = properties->Advance())) {
while (1) {
rv = properties->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = properties->GetLabel(getter_AddRefs(property)))) {
@ -1753,15 +1766,6 @@ RDFXULBuilderImpl::CreateXULElement(nsIRDFResource* aResource,
}
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY) {
rv = NS_OK;
}
else if (NS_FAILED(rv)) {
// uh oh...
NS_ERROR("problem iterating properties");
return rv;
}
// Make it a container so that its contents get recursively
// generated on-demand.
if (NS_FAILED(rv = element->SetAttribute(kNameSpaceID_RDF, kContainerAtom, "true", PR_FALSE))) {

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

@ -457,7 +457,14 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
nsVoidArray *tempArray;
if ((tempArray = new nsVoidArray()) == nsnull) return (NS_ERROR_OUT_OF_MEMORY);
while (NS_SUCCEEDED(rv = properties->Advance())) {
while (1) {
rv = properties->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(rv = properties->GetLabel(getter_AddRefs(property))))
@ -478,7 +485,14 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
return rv;
}
while (NS_SUCCEEDED(rv = assertions->Advance())) {
while (1) {
rv = assertions->Advance();
if (NS_FAILED(rv))
return rv;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFNode> value;
if (NS_FAILED(rv = assertions->GetValue(getter_AddRefs(value)))) {
NS_ERROR("unable to get cursor value");
@ -539,11 +553,7 @@ RDFGenericBuilderImpl::CreateContents(nsIContent* aElement)
}
delete tempArray;
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
// This is a normal return code from nsIRDFCursor::Advance()
rv = NS_OK;
return rv;
return NS_OK;
}
@ -1114,7 +1124,7 @@ RDFGenericBuilderImpl::FindChildByTag(nsIContent* aElement,
return NS_OK;
}
return NS_ERROR_RDF_NO_VALUE; // not found
return NS_RDF_NO_VALUE; // not found
}
@ -1169,7 +1179,7 @@ RDFGenericBuilderImpl::FindChildByTagAndResource(nsIContent* aElement,
return NS_OK;
}
return NS_ERROR_RDF_NO_VALUE; // not found
return NS_RDF_NO_VALUE; // not found
}
@ -1181,23 +1191,23 @@ RDFGenericBuilderImpl::EnsureElementHasGenericChild(nsIContent* parent,
{
nsresult rv;
if (NS_SUCCEEDED(rv = FindChildByTag(parent, nameSpaceID, tag, result)))
return NS_OK;
if (rv != NS_ERROR_RDF_NO_VALUE)
return rv; // something really bad happened
// if we get here, we need to construct a new child element.
nsCOMPtr<nsIContent> element;
if (NS_FAILED(rv = NS_NewRDFElement(nameSpaceID, tag, getter_AddRefs(element))))
rv = FindChildByTag(parent, nameSpaceID, tag, result);
if (NS_FAILED(rv))
return rv;
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
return rv;
if (rv == NS_RDF_NO_VALUE) {
// we need to construct a new child element.
nsCOMPtr<nsIContent> element;
*result = element;
NS_ADDREF(*result);
if (NS_FAILED(rv = NS_NewRDFElement(nameSpaceID, tag, getter_AddRefs(element))))
return rv;
if (NS_FAILED(rv = parent->AppendChildTo(element, PR_FALSE)))
return rv;
*result = element;
NS_ADDREF(*result);
}
return NS_OK;
}
@ -1382,7 +1392,15 @@ RDFGenericBuilderImpl::IsContainer(nsIContent* aElement, nsIRDFResource* aResour
return result;
}
while (NS_SUCCEEDED(arcs->Advance())) {
while (1) {
nsresult rv = arcs->Advance();
NS_ASSERTION(NS_SUCCEEDED(rv), "severe error advancing cursor");
if (NS_FAILED(rv))
return PR_FALSE;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsCOMPtr<nsIRDFResource> property;
if (NS_FAILED(arcs->GetLabel(getter_AddRefs(property)))) {
NS_ERROR("unable to get cursor value");
@ -1575,7 +1593,7 @@ RDFGenericBuilderImpl::CloseWidgetItem(nsIContent* aElement)
}
else rv = FindChildByTag(aElement, kNameSpaceID_XUL, parentAtom, getter_AddRefs(parentNode));
if (rv == NS_ERROR_RDF_NO_VALUE) {
if (rv == NS_RDF_NO_VALUE) {
// No tag; must've already been closed
return NS_OK;
}

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

@ -41,6 +41,7 @@ LINCS= -I$(PUBLIC)\rdf \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\js \
-I$(PUBLIC)\dom \
-I$(PUBLIC)\brprof \
-I$(DEPTH)\rdf\base\src \
$(NULL)

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

@ -286,7 +286,7 @@ FTPDataSource::GetTarget(nsIRDFResource *source,
PRBool tv,
nsIRDFNode **target /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
// we only have positive assertions in the FTP data source.
if (! tv)
@ -328,7 +328,7 @@ FTPDataSource::GetTarget(nsIRDFResource *source,
}
else
{
rv = NS_ERROR_RDF_NO_VALUE;
rv = NS_RDF_NO_VALUE;
}
}
return(rv);
@ -702,7 +702,7 @@ NS_IMETHODIMP
FTPDataSource::ArcLabelsOut(nsIRDFResource *source,
nsIRDFArcsOutCursor **labels /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
*labels = nsnull;
@ -853,7 +853,7 @@ FTPCursor::Advance(void)
if (!mArray)
return NS_ERROR_NULL_POINTER;
if (mArray->Count() <= mCount)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
NS_IF_RELEASE(mValue);
mTarget = mValue = (nsIRDFNode *)mArray->ElementAt(mCount++);
NS_ADDREF(mValue);

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

@ -229,8 +229,7 @@ FileSystemDataSource::GetSource(nsIRDFResource* property,
PRBool tv,
nsIRDFResource** source /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
return rv;
return NS_RDF_NO_VALUE;
}
@ -261,7 +260,7 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source,
PRBool tv,
nsIRDFNode **target /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
// we only have positive assertions in the file system data source.
if (! tv)
@ -302,7 +301,7 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source,
}
else
{
rv = NS_ERROR_RDF_NO_VALUE;
rv = NS_RDF_NO_VALUE;
}
}
return(rv);
@ -440,7 +439,7 @@ NS_IMETHODIMP
FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
nsIRDFArcsOutCursor **labels /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
*labels = nsnull;
@ -686,7 +685,7 @@ FileSystemCursor::Advance(void)
if (!mArray)
return NS_ERROR_NULL_POINTER;
if (mArray->Count() <= mCount)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
NS_IF_RELEASE(mValue);
mTarget = mValue = (nsIRDFNode *)mArray->ElementAt(mCount++);
NS_ADDREF(mValue);

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

@ -213,8 +213,7 @@ FindDataSource::GetSource(nsIRDFResource* property,
PRBool tv,
nsIRDFResource** source /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
return rv;
return NS_RDF_NO_VALUE;
}
@ -237,7 +236,7 @@ FindDataSource::GetTarget(nsIRDFResource *source,
PRBool tv,
nsIRDFNode **target /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
// we only have positive assertions in the find data source.
if (! tv)
@ -284,7 +283,7 @@ FindDataSource::GetTarget(nsIRDFResource *source,
}
else
{
rv = NS_ERROR_RDF_NO_VALUE;
rv = NS_RDF_NO_VALUE;
}
}
return(rv);
@ -408,8 +407,15 @@ FindDataSource::parseFindURL(nsIRDFResource *u, nsVoidArray *array)
nsIRDFResourceCursor *cursor = nsnull;
if (NS_SUCCEEDED(rv = datasource->GetAllResources(&cursor)))
{
while (NS_SUCCEEDED(rv = cursor->Advance()))
while (1)
{
rv = cursor->Advance();
if (NS_FAILED(rv))
break;
if (rv == NS_RDF_CURSOR_EMPTY)
break;
nsIRDFNode *node = nsnull;
if (NS_SUCCEEDED(rv = cursor->GetValue(&node)))
{
@ -444,7 +450,7 @@ FindDataSource::parseFindURL(nsIRDFResource *u, nsVoidArray *array)
}
}
}
if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
if (rv == NS_RDF_CURSOR_EMPTY)
{
rv = NS_OK;
}
@ -612,7 +618,7 @@ NS_IMETHODIMP
FindDataSource::ArcLabelsOut(nsIRDFResource *source,
nsIRDFArcsOutCursor **labels /* out */)
{
nsresult rv = NS_ERROR_RDF_NO_VALUE;
nsresult rv = NS_RDF_NO_VALUE;
*labels = nsnull;
@ -770,7 +776,7 @@ FindCursor::Advance(void)
if (!mArray)
return NS_ERROR_NULL_POINTER;
if (mArray->Count() <= mCount)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
NS_IF_RELEASE(mValue);
mTarget = mValue = (nsIRDFNode *)mArray->ElementAt(mCount++);
NS_ADDREF(mValue);

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

@ -48,6 +48,10 @@
#include "prlong.h"
#include "rdf.h"
#if defined(MOZ_BRPROF)
#include "nsIBrowsingProfile.h"
#endif
#include "nsFileSpec.h"
#include "nsFileStream.h"
#include "nsSpecialSystemDirectory.h"
@ -71,6 +75,9 @@ static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
#if defined(MOZ_BRPROF)
static NS_DEFINE_CID(kBrowsingProfileCID, NS_BROWSINGPROFILE_CID);
#endif
////////////////////////////////////////////////////////////////////////
// RDF property & resource declarations
@ -140,6 +147,10 @@ protected:
PLHashTable* mLastVisitDateHash;
PRExplodedTime mSessionTime;
#if defined(MOZ_BRPROF)
nsIBrowsingProfile* mBrowsingProfile;
#endif
static PRInt32 gRefCnt;
static nsIRDFResource* mResourcePage;
static nsIRDFResource* mResourceDate;
@ -197,7 +208,7 @@ public:
}
nsAutoString url(uri);
if (url.Find("NC:") == 0)
return(NS_ERROR_FAILURE);
return(NS_RDF_NO_VALUE);
nsIRDFLiteral *literal;
if (NS_FAILED(rv = gRDFService->GetLiteral(url, &literal)))
{
@ -329,6 +340,9 @@ nsIRDFResource *nsHistoryDataSource::mResourceHistoryByDate;
nsHistoryDataSource::nsHistoryDataSource(void)
: mInner(nsnull),
mLastVisitDateHash(nsnull)
#if defined(MOZ_BRPROF)
, mBrowsingProfile(nsnull)
#endif
{
NS_INIT_REFCNT();
if (gRefCnt++ == 0)
@ -371,6 +385,11 @@ nsHistoryDataSource::~nsHistoryDataSource(void)
NS_IF_RELEASE(mResourceHistoryByDate);
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
#if defined(MOZ_BRPROF)
nsServiceManager::ReleaseService(kBrowsingProfileCID, mBrowsingProfile);
#endif
gRDFService = nsnull;
}
if (mLastVisitDateHash)
@ -410,8 +429,6 @@ nsHistoryDataSource::QueryInterface(REFNSIID aIID, void** aResult)
}
}
NS_IMETHODIMP
nsHistoryDataSource::Init(const char* uri)
{
@ -427,6 +444,23 @@ nsHistoryDataSource::Init(const char* uri)
if (NS_FAILED(rv = gRDFService->RegisterDataSource(this, PR_FALSE)))
return rv;
#if defined(MOZ_BRPROF)
{
// Force the browsing profile to be loaded and initialized
// here. Mostly we do this so that it's not on the netlib
// thread, which seems to be broken right now.
rv = nsServiceManager::GetService(kBrowsingProfileCID,
nsIBrowsingProfile::GetIID(),
(nsISupports**) &mBrowsingProfile);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to get browsing profile");
if (NS_SUCCEEDED(rv)) {
rv = mBrowsingProfile->Init(nsnull);
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to intialize browsing profile");
}
}
#endif
mLastVisitDateHash = PL_NewHashTable(400, rdf_HashPointer,
PL_CompareValues,
PL_CompareValues,

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

@ -222,9 +222,6 @@ main(int argc, char** argv)
goto done;
}
extern void foobar();
foobar();
done:
NS_IF_RELEASE(out);
NS_IF_RELEASE(ds);

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

@ -42,13 +42,13 @@ NS_IMETHODIMP nsRDFArrayCursor::Advance(void)
if (!mStarted) {
mStarted = PR_TRUE;
nsresult rv = First();
if (NS_FAILED(rv)) return NS_ERROR_RDF_CURSOR_EMPTY;
if (NS_FAILED(rv)) return NS_RDF_CURSOR_EMPTY;
}
else {
nsresult rv = Next();
if (NS_FAILED(rv)) return NS_ERROR_RDF_CURSOR_EMPTY;
if (NS_FAILED(rv)) return NS_RDF_CURSOR_EMPTY;
}
return IsDone() == NS_OK ? NS_ERROR_RDF_CURSOR_EMPTY : NS_OK;
return IsDone() == NS_OK ? NS_RDF_CURSOR_EMPTY : NS_OK;
}
NS_IMETHODIMP nsRDFArrayCursor::GetDataSource(nsIRDFDataSource** aDataSource)
@ -160,7 +160,7 @@ NS_IMETHODIMP nsRDFSingletonAssertionCursor::Advance(void)
{
if (!mConsumed) {
mConsumed = PR_TRUE;
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
}
return NS_OK;
}
@ -175,7 +175,7 @@ NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetDataSource(nsIRDFDataSource** aD
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetValue(nsIRDFNode** aValue)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
if (mValue == nsnull) {
if (mInverse)
return mDataSource->GetSource(mPredicate, mNode, mTruthValue,
@ -191,7 +191,7 @@ NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetValue(nsIRDFNode** aValue)
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetSource(nsIRDFResource* *aSubject)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
if (mInverse) {
return GetValue((nsIRDFNode**)aSubject);
}
@ -205,7 +205,7 @@ NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetSource(nsIRDFResource* *aSubject
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetLabel(nsIRDFResource* *aPredicate)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
*aPredicate = mPredicate;
NS_ADDREF(mPredicate);
return NS_OK;
@ -214,7 +214,7 @@ NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetLabel(nsIRDFResource* *aPredicat
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetTarget(nsIRDFNode* *aObject)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
if (mInverse) {
*aObject = mNode;
NS_ADDREF(mNode);
@ -228,7 +228,7 @@ NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetTarget(nsIRDFNode* *aObject)
NS_IMETHODIMP nsRDFSingletonAssertionCursor::GetTruthValue(PRBool *aTruthValue)
{
if (mConsumed)
return NS_ERROR_RDF_CURSOR_EMPTY;
return NS_RDF_CURSOR_EMPTY;
*aTruthValue = mTruthValue;
return NS_OK;
}
@ -300,13 +300,13 @@ NS_IMETHODIMP nsRDFEnumeratorCursor::Advance(void)
if (!mStarted) {
mStarted = PR_TRUE;
nsresult rv = mEnum->First();
if (NS_FAILED(rv)) return NS_ERROR_RDF_CURSOR_EMPTY;
if (NS_FAILED(rv)) return NS_RDF_CURSOR_EMPTY;
}
else {
nsresult rv = mEnum->Next();
if (NS_FAILED(rv)) return NS_ERROR_RDF_CURSOR_EMPTY;
if (NS_FAILED(rv)) return NS_RDF_CURSOR_EMPTY;
}
return mEnum->IsDone() == NS_OK ? NS_ERROR_RDF_CURSOR_EMPTY : NS_OK;
return mEnum->IsDone() == NS_OK ? NS_RDF_CURSOR_EMPTY : NS_OK;
}
NS_IMETHODIMP nsRDFEnumeratorCursor::GetDataSource(nsIRDFDataSource** aDataSource)