Bug 116328. Add nsIRDFBlob sorting to rdfliner. r=varga@utcru.sk, sr=hyatt.

This commit is contained in:
waterson%netscape.com 2002-01-24 23:03:01 +00:00
Родитель d8ec3bd21a
Коммит 97ae9866cc
5 изменённых файлов: 56 добавлений и 16 удалений

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

@ -1826,10 +1826,10 @@ nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aR
if (mCollation) {
mCollation->CompareRawSortKey(NS_REINTERPRET_CAST(const PRUint8*, lstr),
nsCRT::strlen(lstr) * sizeof(PRUnichar),
NS_REINTERPRET_CAST(const PRUint8*, rstr),
nsCRT::strlen(rstr) * sizeof(PRUnichar),
&result);
nsCRT::strlen(lstr) * sizeof(PRUnichar),
NS_REINTERPRET_CAST(const PRUint8*, rstr),
nsCRT::strlen(rstr) * sizeof(PRUnichar),
&result);
}
else
result = ::Compare(nsDependentString(lstr),
@ -1883,6 +1883,26 @@ nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aR
}
}
if (mCollation) {
// Blobs? (We can only compare these reasonably if we have a
// collation object.)
nsCOMPtr<nsIRDFBlob> l = do_QueryInterface(leftNode);
if (l) {
nsCOMPtr<nsIRDFBlob> r = do_QueryInterface(rightNode);
if (r) {
const PRUint8 *lval, *rval;
PRInt32 llen, rlen;
l->GetValue(&lval);
l->GetLength(&llen);
r->GetValue(&rval);
r->GetLength(&rlen);
mCollation->CompareRawSortKey(lval, llen, rval, rlen, &result);
return result;
}
}
}
// Ack! Apples & oranges...
return 0;
}

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

@ -1826,10 +1826,10 @@ nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aR
if (mCollation) {
mCollation->CompareRawSortKey(NS_REINTERPRET_CAST(const PRUint8*, lstr),
nsCRT::strlen(lstr) * sizeof(PRUnichar),
NS_REINTERPRET_CAST(const PRUint8*, rstr),
nsCRT::strlen(rstr) * sizeof(PRUnichar),
&result);
nsCRT::strlen(lstr) * sizeof(PRUnichar),
NS_REINTERPRET_CAST(const PRUint8*, rstr),
nsCRT::strlen(rstr) * sizeof(PRUnichar),
&result);
}
else
result = ::Compare(nsDependentString(lstr),
@ -1883,6 +1883,26 @@ nsXULOutlinerBuilder::CompareMatches(nsTemplateMatch* aLeft, nsTemplateMatch* aR
}
}
if (mCollation) {
// Blobs? (We can only compare these reasonably if we have a
// collation object.)
nsCOMPtr<nsIRDFBlob> l = do_QueryInterface(leftNode);
if (l) {
nsCOMPtr<nsIRDFBlob> r = do_QueryInterface(rightNode);
if (r) {
const PRUint8 *lval, *rval;
PRInt32 llen, rlen;
l->GetValue(&lval);
l->GetLength(&llen);
r->GetValue(&rval);
r->GetLength(&rlen);
mCollation->CompareRawSortKey(lval, llen, rval, rlen, &result);
return result;
}
}
}
// Ack! Apples & oranges...
return 0;
}

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

@ -41,7 +41,7 @@
#include "nscore.h" // for PRUnichar
%}
[ptr] native octet_ptr(PRUint8);
[ptr] native const_octet_ptr(const PRUint8);
/**
* A literal node in the graph, whose value is a string.
@ -91,7 +91,7 @@ interface nsIRDFBlob : nsIRDFNode {
/**
* The binary data.
*/
[noscript] readonly attribute octet_ptr value;
[noscript] readonly attribute const_octet_ptr value;
/**
* The data's length.

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

@ -69,7 +69,7 @@ interface nsIRDFService : nsISupports {
nsIRDFInt GetIntLiteral(in long aValue);
// Construct an RDF literal from a data blob
[noscript] nsIRDFBlob getBlobLiteral(in octet_ptr aValue, in long aLength);
[noscript] nsIRDFBlob getBlobLiteral(in const_octet_ptr aValue, in long aLength);
boolean IsAnonymousResource(in nsIRDFResource aResource);

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

@ -389,7 +389,7 @@ public:
PRUint8 *mBytes;
};
BlobImpl(PRUint8 *aBytes, PRInt32 aLength)
BlobImpl(const PRUint8 *aBytes, PRInt32 aLength)
{
NS_INIT_REFCNT();
mData.mLength = aLength;
@ -424,7 +424,7 @@ BlobImpl::EqualsNode(nsIRDFNode *aNode, PRBool *aEquals)
blob->GetLength(&length);
if (length == mData.mLength) {
PRUint8 *bytes;
const PRUint8 *bytes;
blob->GetValue(&bytes);
if (0 == nsCRT::memcmp(bytes, mData.mBytes, length)) {
@ -439,7 +439,7 @@ BlobImpl::EqualsNode(nsIRDFNode *aNode, PRBool *aEquals)
}
NS_IMETHODIMP
BlobImpl::GetValue(PRUint8 **aResult)
BlobImpl::GetValue(const PRUint8 **aResult)
{
*aResult = mData.mBytes;
return NS_OK;
@ -1253,10 +1253,10 @@ RDFServiceImpl::GetIntLiteral(PRInt32 aInt, nsIRDFInt** aResult)
}
NS_IMETHODIMP
RDFServiceImpl::GetBlobLiteral(PRUint8 *aBytes, PRInt32 aLength,
RDFServiceImpl::GetBlobLiteral(const PRUint8 *aBytes, PRInt32 aLength,
nsIRDFBlob **aResult)
{
BlobImpl::Data key = { aLength, aBytes };
BlobImpl::Data key = { aLength, NS_CONST_CAST(PRUint8 *, aBytes) };
PLDHashEntryHdr *hdr =
PL_DHashTableOperate(&mBlobs, &key, PL_DHASH_LOOKUP);