bug 157142, link transformiix standalone to xpcom, r=sicking, sr=peterv
git-svn-id: svn://10.0.0.236/trunk@135459 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -171,7 +171,6 @@ RegisterTransformiix(nsIComponentManager *aCompMgr,
|
||||
return rv;
|
||||
}
|
||||
|
||||
TX_LG_IMPL;
|
||||
static PRBool gInitialized = PR_FALSE;
|
||||
static nsIExceptionProvider *gXPathExceptionProvider = 0;
|
||||
nsINameSpaceManager *gTxNameSpaceManager = 0;
|
||||
|
||||
@@ -26,11 +26,12 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES += unicharutil \
|
||||
dom \
|
||||
content \
|
||||
widget \
|
||||
|
||||
@@ -40,38 +40,6 @@
|
||||
#ifndef TxLog_h__
|
||||
#define TxLog_h__
|
||||
|
||||
#ifdef TX_EXE
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
#include <stdio.h>
|
||||
|
||||
#define PRLogModuleInfo void
|
||||
#define PR_NewLogModule(_name)
|
||||
#define PR_FREE_IF(_name)
|
||||
|
||||
typedef enum PRLogModuleLevel {
|
||||
PR_LOG_NONE = 0, /* nothing */
|
||||
PR_LOG_ALWAYS = 1, /* always printed */
|
||||
PR_LOG_ERROR = 2, /* error messages */
|
||||
PR_LOG_WARNING = 3, /* warning messages */
|
||||
PR_LOG_DEBUG = 4, /* debug messages */
|
||||
|
||||
PR_LOG_NOTICE = PR_LOG_DEBUG, /* notice messages */
|
||||
PR_LOG_WARN = PR_LOG_WARNING, /* warning messages */
|
||||
PR_LOG_MIN = PR_LOG_DEBUG, /* minimal debugging messages */
|
||||
PR_LOG_MAX = PR_LOG_DEBUG /* maximal debugging messages */
|
||||
} PRLogModuleLevel;
|
||||
|
||||
|
||||
#define PR_LOG(_name, _level, _message) printf##_message
|
||||
|
||||
#else
|
||||
|
||||
#define PR_LOG(_name, _level, _message)
|
||||
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "prlog.h"
|
||||
#include "prmem.h"
|
||||
#endif
|
||||
@@ -103,5 +71,3 @@ public:
|
||||
#define TX_LG_DELETE
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,434 +30,80 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
String::String() : mBuffer(0),
|
||||
mBufferLength(0),
|
||||
mLength(0)
|
||||
String::String(const UNICODE_CHAR* aSource, PRUint32 aLength)
|
||||
{
|
||||
}
|
||||
|
||||
String::String(const String& aSource) : mBuffer(aSource.toUnicode()),
|
||||
mBufferLength(aSource.mLength),
|
||||
mLength(aSource.mLength)
|
||||
{
|
||||
}
|
||||
|
||||
String::String(const UNICODE_CHAR* aSource,
|
||||
PRUint32 aLength) : mBuffer(0),
|
||||
mBufferLength(0),
|
||||
mLength(0)
|
||||
{
|
||||
if (!aSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aLength == 0) {
|
||||
aLength = unicodeLength(aSource);
|
||||
}
|
||||
if (!ensureCapacity(aLength)) {
|
||||
return;
|
||||
}
|
||||
memcpy(mBuffer, aSource, aLength * sizeof(UNICODE_CHAR));
|
||||
mLength = aLength;
|
||||
}
|
||||
|
||||
String::~String()
|
||||
{
|
||||
delete [] mBuffer;
|
||||
}
|
||||
|
||||
void String::append(UNICODE_CHAR aSource)
|
||||
{
|
||||
if (!ensureCapacity(1)) {
|
||||
return;
|
||||
}
|
||||
mBuffer[mLength] = aSource;
|
||||
++mLength;
|
||||
}
|
||||
|
||||
void String::append(const String& aSource)
|
||||
{
|
||||
if (!ensureCapacity(aSource.mLength)) {
|
||||
return;
|
||||
}
|
||||
memcpy(&mBuffer[mLength], aSource.mBuffer,
|
||||
aSource.mLength * sizeof(UNICODE_CHAR));
|
||||
mLength += aSource.mLength;
|
||||
}
|
||||
|
||||
void String::append(const UNICODE_CHAR* aSource, PRUint32 aLength)
|
||||
{
|
||||
if (!ensureCapacity(aLength)) {
|
||||
return;
|
||||
}
|
||||
memcpy(&mBuffer[mLength], aSource,
|
||||
aLength * sizeof(UNICODE_CHAR));
|
||||
mLength += aLength;
|
||||
}
|
||||
|
||||
void String::insert(PRUint32 aOffset, UNICODE_CHAR aSource)
|
||||
{
|
||||
if (!ensureCapacity(1)) {
|
||||
return;
|
||||
}
|
||||
if (aOffset < mLength) {
|
||||
memmove(&mBuffer[aOffset + 1], &mBuffer[aOffset],
|
||||
(mLength - aOffset) * sizeof(UNICODE_CHAR));
|
||||
}
|
||||
mBuffer[aOffset] = aSource;
|
||||
mLength += 1;
|
||||
}
|
||||
|
||||
void String::insert(PRUint32 aOffset, const String& aSource)
|
||||
{
|
||||
if (!ensureCapacity(aSource.mLength)) {
|
||||
return;
|
||||
}
|
||||
if (aOffset < mLength) {
|
||||
memmove(&mBuffer[aOffset + aSource.mLength], &mBuffer[aOffset],
|
||||
(mLength - aOffset) * sizeof(UNICODE_CHAR));
|
||||
}
|
||||
memcpy(&mBuffer[aOffset], aSource.mBuffer,
|
||||
aSource.mLength * sizeof(UNICODE_CHAR));
|
||||
mLength += aSource.mLength;
|
||||
}
|
||||
|
||||
void String::replace(PRUint32 aOffset, UNICODE_CHAR aSource)
|
||||
{
|
||||
if (aOffset < mLength) {
|
||||
mBuffer[aOffset] = aSource;
|
||||
if (aLength) {
|
||||
mString = Substring(aSource, aSource + aLength);
|
||||
}
|
||||
else {
|
||||
append(aSource);
|
||||
mString = nsDependentString(aSource);
|
||||
}
|
||||
}
|
||||
|
||||
void String::replace(PRUint32 aOffset, const String& aSource)
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(const char_type* lhs,
|
||||
const char_type* rhs,
|
||||
PRUint32 aLength ) const
|
||||
{
|
||||
if (aOffset < mLength) {
|
||||
PRUint32 finalLength = aOffset + aSource.mLength;
|
||||
|
||||
if (finalLength > mLength) {
|
||||
if (!ensureCapacity(finalLength - mBufferLength)) {
|
||||
return;
|
||||
}
|
||||
mLength = finalLength;
|
||||
}
|
||||
memcpy(&mBuffer[aOffset], aSource.mBuffer,
|
||||
aSource.mLength * sizeof(UNICODE_CHAR));
|
||||
}
|
||||
else {
|
||||
append(aSource);
|
||||
}
|
||||
}
|
||||
|
||||
void String::deleteChars(PRUint32 aOffset, PRUint32 aCount)
|
||||
{
|
||||
PRUint32 cutEnd = aOffset + aCount;
|
||||
|
||||
if (cutEnd < mLength) {
|
||||
memmove(&mBuffer[aOffset], &mBuffer[cutEnd],
|
||||
(mLength - cutEnd) * sizeof(UNICODE_CHAR));
|
||||
mLength -= aCount;
|
||||
}
|
||||
else {
|
||||
mLength = aOffset;
|
||||
}
|
||||
}
|
||||
|
||||
void String::clear()
|
||||
{
|
||||
mLength = 0;
|
||||
}
|
||||
|
||||
PRInt32 String::indexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
NS_ASSERTION(aOffset >= 0, "Passed negative offset to indexOf.");
|
||||
if (aOffset < 0) {
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 searchIndex = aOffset;
|
||||
|
||||
while (searchIndex < (PRInt32)mLength) {
|
||||
if (mBuffer[searchIndex] == aData) {
|
||||
return searchIndex;
|
||||
}
|
||||
++searchIndex;
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 String::indexOf(const String& aData, PRInt32 aOffset) const
|
||||
{
|
||||
NS_ASSERTION(aOffset >= 0, "Passed negative offset to indexOf.");
|
||||
if (aOffset < 0) {
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 searchIndex = aOffset;
|
||||
PRInt32 searchLimit = mLength - aData.mLength;
|
||||
|
||||
while (searchIndex <= searchLimit) {
|
||||
if (memcmp(&mBuffer[searchIndex], aData.mBuffer,
|
||||
aData.mLength * sizeof(UNICODE_CHAR)) == 0) {
|
||||
return searchIndex;
|
||||
}
|
||||
++searchIndex;
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
PRInt32 String::lastIndexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset) const
|
||||
{
|
||||
NS_ASSERTION(aOffset >= 0, "Passed negative offset to lastIndexOf.");
|
||||
if (aOffset < 0) {
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
PRUint32 searchIndex = mLength - aOffset;
|
||||
while (--searchIndex >= 0) {
|
||||
if (mBuffer[searchIndex] == aData) {
|
||||
return searchIndex;
|
||||
}
|
||||
}
|
||||
return kNotFound;
|
||||
}
|
||||
|
||||
MBool String::isEqual(const String& aData) const
|
||||
{
|
||||
if (mLength != aData.mLength) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
return (memcmp(mBuffer, aData.mBuffer, mLength * sizeof(UNICODE_CHAR)) == 0);
|
||||
}
|
||||
|
||||
MBool String::isEqualIgnoreCase(const String& aData) const
|
||||
{
|
||||
if (mLength != aData.mLength) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
UNICODE_CHAR thisChar, otherChar;
|
||||
PRUint32 compLoop = 0;
|
||||
while (compLoop < mLength) {
|
||||
thisChar = mBuffer[compLoop];
|
||||
while (compLoop < aLength) {
|
||||
thisChar = lhs[compLoop];
|
||||
if ((thisChar >= 'A') && (thisChar <= 'Z')) {
|
||||
thisChar += 32;
|
||||
}
|
||||
otherChar = aData.mBuffer[compLoop];
|
||||
otherChar = rhs[compLoop];
|
||||
if ((otherChar >= 'A') && (otherChar <= 'Z')) {
|
||||
otherChar += 32;
|
||||
}
|
||||
if (thisChar != otherChar) {
|
||||
return MB_FALSE;
|
||||
return thisChar - otherChar;
|
||||
}
|
||||
++compLoop;
|
||||
}
|
||||
return MB_TRUE;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void String::truncate(PRUint32 aLength)
|
||||
int
|
||||
txCaseInsensitiveStringComparator::operator()(char_type lhs,
|
||||
char_type rhs) const
|
||||
{
|
||||
NS_ASSERTION(aLength <= mBufferLength, "truncate can't increase buffer");
|
||||
mLength = (aLength > mBufferLength) ? mBufferLength : aLength;
|
||||
}
|
||||
|
||||
String& String::subString(PRUint32 aStart, String& aDest) const
|
||||
{
|
||||
return subString(aStart, mLength, aDest);
|
||||
}
|
||||
|
||||
String& String::subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
String& aDest) const
|
||||
{
|
||||
PRUint32 end = (aEnd > mLength) ? mLength : aEnd;
|
||||
|
||||
aDest.clear();
|
||||
if (aStart >= end) {
|
||||
return aDest;
|
||||
if (lhs >= 'A' && lhs <= 'Z') {
|
||||
lhs += 32;
|
||||
}
|
||||
PRUint32 substrLength = end - aStart;
|
||||
|
||||
if (!aDest.ensureCapacity(substrLength)) {
|
||||
return aDest;
|
||||
if (rhs >= 'A' && rhs <= 'Z') {
|
||||
rhs += 32;
|
||||
}
|
||||
memcpy(aDest.mBuffer, &mBuffer[aStart],
|
||||
substrLength * sizeof(UNICODE_CHAR));
|
||||
aDest.mLength = substrLength;
|
||||
|
||||
return aDest;
|
||||
}
|
||||
return lhs - rhs;
|
||||
}
|
||||
|
||||
void String::toLowerCase()
|
||||
{
|
||||
PRUint32 conversionLoop;
|
||||
|
||||
for (conversionLoop = 0; conversionLoop < mLength; ++conversionLoop) {
|
||||
if ((mBuffer[conversionLoop] >= 'A') &&
|
||||
(mBuffer[conversionLoop] <= 'Z'))
|
||||
mBuffer[conversionLoop] += 32;
|
||||
nsAFlatString::char_iterator c, e;
|
||||
mString.BeginWriting(c);
|
||||
mString.EndWriting(e);
|
||||
while (c != e) {
|
||||
if (*c >= 'A' && *c <= 'Z')
|
||||
*c += 32;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
void String::toUpperCase()
|
||||
{
|
||||
PRUint32 conversionLoop;
|
||||
|
||||
for (conversionLoop = 0; conversionLoop < mLength; ++conversionLoop) {
|
||||
if ((mBuffer[conversionLoop] >= 'a') &&
|
||||
(mBuffer[conversionLoop] <= 'z'))
|
||||
mBuffer[conversionLoop] -= 32;
|
||||
nsAFlatString::char_iterator c, e;
|
||||
mString.BeginWriting(c);
|
||||
mString.EndWriting(e);
|
||||
while (c != e) {
|
||||
if (*c >= 'a' && *c <= 'z')
|
||||
*c -= 32;
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
||||
String& String::operator = (const String& aSource)
|
||||
{
|
||||
delete [] mBuffer;
|
||||
mBuffer = aSource.toUnicode();
|
||||
mBufferLength = aSource.mLength;
|
||||
mLength = aSource.mLength;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MBool String::ensureCapacity(PRUint32 aCapacity)
|
||||
{
|
||||
PRUint32 needed = aCapacity + mLength;
|
||||
if (needed >= 0x8000) {
|
||||
NS_ASSERTION(0, "Asked for too large a buffer.");
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
if (needed < mBufferLength) {
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
UNICODE_CHAR* tempBuffer = new UNICODE_CHAR[needed];
|
||||
NS_ASSERTION(tempBuffer, "Couldn't allocate string buffer.");
|
||||
if (!tempBuffer) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
if (mLength > 0) {
|
||||
memcpy(tempBuffer, mBuffer, mLength * sizeof(UNICODE_CHAR));
|
||||
}
|
||||
delete [] mBuffer;
|
||||
mBuffer = tempBuffer;
|
||||
mBufferLength = needed;
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
UNICODE_CHAR* String::toUnicode() const
|
||||
{
|
||||
if (mLength == 0) {
|
||||
return 0;
|
||||
}
|
||||
UNICODE_CHAR* tmpBuffer = new UNICODE_CHAR[mLength];
|
||||
NS_ASSERTION(tmpBuffer, "out of memory");
|
||||
if (tmpBuffer) {
|
||||
memcpy(tmpBuffer, mBuffer, mLength * sizeof(UNICODE_CHAR));
|
||||
}
|
||||
return tmpBuffer;
|
||||
}
|
||||
|
||||
PRUint32 String::unicodeLength(const UNICODE_CHAR* aData)
|
||||
{
|
||||
PRUint32 index = 0;
|
||||
|
||||
// Count UNICODE_CHARs Until a Unicode "NULL" is found.
|
||||
while (aData[index] != 0x0000) {
|
||||
++index;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
ostream& operator<<(ostream& aOutput, const String& aSource)
|
||||
{
|
||||
PRUint32 outputLoop;
|
||||
|
||||
for (outputLoop = 0; outputLoop < aSource.mLength; ++outputLoop) {
|
||||
aOutput << (char)aSource.charAt(outputLoop);
|
||||
}
|
||||
aOutput << NS_LossyConvertUCS2toASCII(aSource.mString).get();
|
||||
return aOutput;
|
||||
}
|
||||
|
||||
// XXX DEPRECATED
|
||||
String::String(PRUint32 aSize) : mBuffer(0),
|
||||
mBufferLength(0),
|
||||
mLength(0)
|
||||
{
|
||||
ensureCapacity(aSize);
|
||||
}
|
||||
|
||||
String::String(const char* aSource) : mBuffer(0),
|
||||
mBufferLength(0),
|
||||
mLength(0)
|
||||
{
|
||||
if (!aSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
PRUint32 length = strlen(aSource);
|
||||
if (!ensureCapacity(length)) {
|
||||
return;
|
||||
}
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < length; ++counter) {
|
||||
mBuffer[counter] = (UNICODE_CHAR)aSource[counter];
|
||||
}
|
||||
mLength = length;
|
||||
}
|
||||
|
||||
void String::append(const char* aSource)
|
||||
{
|
||||
if (!aSource) {
|
||||
return;
|
||||
}
|
||||
|
||||
PRUint32 length = strlen(aSource);
|
||||
if (!ensureCapacity(length)) {
|
||||
return;
|
||||
}
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < length; ++counter) {
|
||||
mBuffer[mLength + counter] = (UNICODE_CHAR)aSource[counter];
|
||||
}
|
||||
mLength += length;
|
||||
}
|
||||
|
||||
MBool String::isEqual(const char* aData) const
|
||||
{
|
||||
if (!aData) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 length = strlen(aData);
|
||||
if (length != mLength) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < length; ++counter) {
|
||||
if (mBuffer[counter] != (UNICODE_CHAR)aData[counter]) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
}
|
||||
return MB_TRUE;
|
||||
}
|
||||
|
||||
NS_ConvertASCIItoUCS2::NS_ConvertASCIItoUCS2(const char* aSource)
|
||||
{
|
||||
NS_ASSERTION(aSource, "can't convert a null to UCS2");
|
||||
|
||||
PRUint32 length = strlen(aSource);
|
||||
if (!ensureCapacity(length)) {
|
||||
return;
|
||||
}
|
||||
PRUint32 counter;
|
||||
for (counter = 0; counter < length; ++counter) {
|
||||
mBuffer[counter] = (UNICODE_CHAR)aSource[counter];
|
||||
}
|
||||
mLength = length;
|
||||
}
|
||||
|
||||
@@ -30,20 +30,23 @@
|
||||
|
||||
#include "baseutils.h"
|
||||
|
||||
#ifdef TX_EXE
|
||||
#include "TxObject.h"
|
||||
#include <iostream.h>
|
||||
typedef unsigned short UNICODE_CHAR;
|
||||
const PRInt32 kNotFound = -1;
|
||||
#else
|
||||
#include "nsString.h"
|
||||
typedef PRUnichar UNICODE_CHAR;
|
||||
|
||||
#ifdef TX_EXE
|
||||
class txCaseInsensitiveStringComparator
|
||||
: public nsStringComparator
|
||||
{
|
||||
public:
|
||||
virtual int operator()(const char_type*, const char_type*, PRUint32 aLength) const;
|
||||
virtual int operator()(char_type, char_type) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
class String
|
||||
#ifdef TX_EXE
|
||||
: public TxObject
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
/*
|
||||
@@ -62,9 +65,8 @@ public:
|
||||
* If aLength is zero it computes the length from the supplied string.
|
||||
*/
|
||||
explicit String(const UNICODE_CHAR* aSource, PRUint32 aLength = 0);
|
||||
#else
|
||||
explicit String(const nsAString& aSource);
|
||||
#endif
|
||||
explicit String(const nsAString& aSource);
|
||||
~String();
|
||||
|
||||
/*
|
||||
@@ -73,9 +75,7 @@ public:
|
||||
void append(UNICODE_CHAR aSource);
|
||||
void append(const String& aSource);
|
||||
void append(const UNICODE_CHAR* aSource, PRUint32 aLength);
|
||||
#ifndef TX_EXE
|
||||
void append(const nsAString& aSource);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Insert aSource at aOffset in this string.
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
* Returns index of last occurrence of aData.
|
||||
*/
|
||||
PRInt32 lastIndexOf(UNICODE_CHAR aData,
|
||||
PRInt32 aOffset = 0) const;
|
||||
PRInt32 aOffset = -1) const;
|
||||
|
||||
/*
|
||||
* Check equality between strings.
|
||||
@@ -166,14 +166,6 @@ public:
|
||||
*/
|
||||
void truncate(PRUint32 aLength);
|
||||
|
||||
#ifdef TX_EXE
|
||||
/*
|
||||
* Assignment operator. Override default assignment operator
|
||||
* only on standalone, the default will do the right thing for
|
||||
* module.
|
||||
*/
|
||||
String& operator = (const String& aSource);
|
||||
#else
|
||||
/*
|
||||
* Return a reference to this string's nsString.
|
||||
*/
|
||||
@@ -183,36 +175,11 @@ public:
|
||||
* Return a const reference to this string's nsString.
|
||||
*/
|
||||
operator const nsAString&() const;
|
||||
#endif
|
||||
|
||||
#ifndef TX_EXE
|
||||
private:
|
||||
nsString mString;
|
||||
#else
|
||||
protected:
|
||||
/*
|
||||
* Make sure the string buffer can hold aCapacity characters.
|
||||
*/
|
||||
MBool ensureCapacity(PRUint32 aCapacity);
|
||||
|
||||
/*
|
||||
* Allocate a new UNICODE_CHAR buffer and copy this string's
|
||||
* buffer into it. Caller needs to free the buffer.
|
||||
*/
|
||||
UNICODE_CHAR* toUnicode() const;
|
||||
|
||||
/*
|
||||
* Compute the unicode length of aData.
|
||||
*/
|
||||
static PRUint32 unicodeLength(const UNICODE_CHAR* aData);
|
||||
|
||||
friend ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
friend class txCharBuffer;
|
||||
|
||||
UNICODE_CHAR* mBuffer;
|
||||
PRUint32 mBufferLength;
|
||||
PRUint32 mLength;
|
||||
#endif
|
||||
|
||||
// XXX DEPRECATED
|
||||
public:
|
||||
@@ -220,91 +187,18 @@ public:
|
||||
explicit String(const char* aSource); // XXX Used for literal strings
|
||||
void append(const char* aSource);
|
||||
MBool isEqual(const char* aData) const;
|
||||
#ifndef TX_EXE
|
||||
nsString& getNSString();
|
||||
const nsString& getConstNSString() const;
|
||||
#endif
|
||||
// XXX DEPRECATED
|
||||
};
|
||||
|
||||
#ifdef TX_EXE
|
||||
|
||||
/*
|
||||
* Class for converting char*s into Strings
|
||||
*/
|
||||
|
||||
class NS_ConvertASCIItoUCS2 : public String
|
||||
{
|
||||
public:
|
||||
explicit NS_ConvertASCIItoUCS2(const char* aSource);
|
||||
};
|
||||
|
||||
/*
|
||||
* A helper class for getting a char* buffer out of a String.
|
||||
* Don't use this directly, use NS_LossyConvertUCS2toASCII which
|
||||
* is typedef'ed to this class on standalone and will fall back
|
||||
* on the Mozilla implementation for the Mozilla module.
|
||||
*/
|
||||
class txCharBuffer
|
||||
{
|
||||
public:
|
||||
txCharBuffer(const String& aString) : mString(aString),
|
||||
mBuffer(0)
|
||||
{
|
||||
};
|
||||
|
||||
~txCharBuffer()
|
||||
{
|
||||
delete [] mBuffer;
|
||||
};
|
||||
|
||||
const char* get()
|
||||
{
|
||||
if (!mBuffer) {
|
||||
mBuffer = new char[mString.mLength + 1];
|
||||
NS_ASSERTION(mBuffer, "out of memory");
|
||||
if (mBuffer) {
|
||||
PRUint32 loop;
|
||||
for (loop = 0; loop < mString.mLength; ++loop) {
|
||||
mBuffer[loop] = (char)mString.mBuffer[loop];
|
||||
}
|
||||
mBuffer[mString.mLength] = 0;
|
||||
}
|
||||
}
|
||||
return mBuffer;
|
||||
}
|
||||
|
||||
private:
|
||||
const String& mString;
|
||||
char* mBuffer;
|
||||
};
|
||||
|
||||
typedef txCharBuffer NS_LossyConvertUCS2toASCII;
|
||||
|
||||
/*
|
||||
* Translate UNICODE_CHARs to Chars and output to the provided stream.
|
||||
*/
|
||||
ostream& operator << (ostream& aOutput, const String& aSource);
|
||||
|
||||
inline UNICODE_CHAR String::charAt(PRUint32 aIndex) const
|
||||
{
|
||||
NS_ASSERTION(aIndex < mLength, "|charAt| out-of-range");
|
||||
return mBuffer[aIndex];
|
||||
}
|
||||
|
||||
inline MBool String::isEmpty() const
|
||||
{
|
||||
return (mLength == 0);
|
||||
}
|
||||
|
||||
inline PRUint32 String::length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
#else
|
||||
// txMozillaString.h contains all inline implementations for the
|
||||
// Mozilla module.
|
||||
#include "txMozillaString.h"
|
||||
#endif
|
||||
|
||||
#endif // txString_h__
|
||||
|
||||
@@ -32,39 +32,13 @@
|
||||
#ifndef TRANSFRMX_BASEUTILS_H
|
||||
#define TRANSFRMX_BASEUTILS_H
|
||||
|
||||
#ifdef TX_EXE
|
||||
// Standalone
|
||||
typedef int PRInt32;
|
||||
typedef unsigned int PRUint32;
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
typedef PRBool MBool;
|
||||
|
||||
typedef PRInt32 MBool;
|
||||
|
||||
#define MB_TRUE (MBool)1
|
||||
#define MB_FALSE (MBool)0
|
||||
|
||||
#ifdef DEBUG
|
||||
#define NS_ASSERTION(_cond, _msg) \
|
||||
if(!(_cond)) { \
|
||||
cerr << "ASSERTION (" << #_cond << ") " << _msg << endl; \
|
||||
cerr << "on line " << __LINE__ << " in " << __FILE__ << endl; \
|
||||
}
|
||||
#else
|
||||
#define NS_ASSERTION(_cond, _msg) {}
|
||||
#endif
|
||||
|
||||
#define NS_PTR_TO_INT32(x) ((char *)(x) - (char *)0)
|
||||
#define NS_INT32_TO_PTR(x) ((void *)((char *)0 + (x)))
|
||||
|
||||
#else
|
||||
// Mozilla module
|
||||
#include "prtypes.h"
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
typedef PRBool MBool;
|
||||
|
||||
#define MB_TRUE PR_TRUE
|
||||
#define MB_FALSE PR_FALSE
|
||||
#endif
|
||||
#define MB_TRUE PR_TRUE
|
||||
#define MB_FALSE PR_FALSE
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
|
||||
@@ -44,43 +44,8 @@
|
||||
* See nsError.h for details.
|
||||
*/
|
||||
|
||||
#ifdef TX_EXE
|
||||
|
||||
#include "baseutils.h"
|
||||
|
||||
typedef PRUint32 nsresult;
|
||||
|
||||
#define NS_FAILED(_nsresult) ((_nsresult) & 0x80000000)
|
||||
#define NS_SUCCEEDED(_nsresult) (!((_nsresult) & 0x80000000))
|
||||
#define NS_OK 0
|
||||
#define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
|
||||
#define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
|
||||
#define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
|
||||
#define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
|
||||
#define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
|
||||
#define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
|
||||
#define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
|
||||
#define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
|
||||
|
||||
#define NS_ENSURE_TRUE(value, result) \
|
||||
do { \
|
||||
if (!(value)) { \
|
||||
return (result); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define NS_ENSURE_FALSE(value, result) \
|
||||
NS_ENSURE_TRUE(!(value), result)
|
||||
|
||||
#define NS_ENSURE_SUCCESS(value, result) \
|
||||
NS_ENSURE_TRUE(NS_SUCCEEDED(value), result)
|
||||
|
||||
#else // TX_EXE
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
#endif // TX_EXE
|
||||
|
||||
#define NS_ERROR_XPATH_EVAL_FAILED NS_ERROR_FAILURE
|
||||
#define NS_ERROR_XPATH_PARSE_FAILED NS_ERROR_FAILURE
|
||||
#define NS_ERROR_XPATH_INVALID_ARG NS_ERROR_INVALID_ARG
|
||||
|
||||
@@ -41,7 +41,10 @@
|
||||
#define txMozillaString_h__
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#ifndef TX_EXE
|
||||
#include "nsUnicharUtils.h"
|
||||
typedef nsCaseInsensitiveStringComparator txCaseInsensitiveStringComparator;
|
||||
#endif
|
||||
|
||||
MOZ_DECL_CTOR_COUNTER(String)
|
||||
|
||||
@@ -152,7 +155,7 @@ inline MBool String::isEqualIgnoreCase(const String& aData) const
|
||||
{
|
||||
if (this == &aData)
|
||||
return MB_TRUE;
|
||||
return mString.Equals(aData.mString, nsCaseInsensitiveStringComparator());
|
||||
return mString.Equals(aData.mString, txCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
inline MBool String::isEmpty() const
|
||||
@@ -198,6 +201,7 @@ inline String& String::subString(PRUint32 aStart, PRUint32 aEnd,
|
||||
return aDest;
|
||||
}
|
||||
|
||||
#ifndef TX_EXE
|
||||
inline void String::toLowerCase()
|
||||
{
|
||||
ToLowerCase(mString);
|
||||
@@ -207,6 +211,7 @@ inline void String::toUpperCase()
|
||||
{
|
||||
ToUpperCase(mString);
|
||||
}
|
||||
#endif
|
||||
|
||||
inline String::operator nsAString&()
|
||||
{
|
||||
|
||||
@@ -35,7 +35,9 @@ SIMPLE_PROGRAMS += txXSLTMarkDriver$(BIN_SUFFIX)
|
||||
endif
|
||||
EXTRA_DEPS = $(LIBRARY)
|
||||
|
||||
REQUIRES = expat \
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
expat \
|
||||
$(NULL)
|
||||
|
||||
OBJS =../base/ArrayList.$(OBJ_SUFFIX) \
|
||||
@@ -131,6 +133,7 @@ CPP_PROG_LINK = 1
|
||||
|
||||
EXTRA_LIBS = \
|
||||
$(LIB_PREFIX)tx.$(LIB_SUFFIX) \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(NULL)
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)expat_s.$(LIB_SUFFIX) \
|
||||
|
||||
@@ -26,11 +26,12 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
dom \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
REQUIRES += dom \
|
||||
content \
|
||||
widget \
|
||||
unicharutil \
|
||||
|
||||
@@ -145,10 +145,12 @@ MBool XMLUtils::isValidQName(const String& aName)
|
||||
**/
|
||||
MBool XMLUtils::isWhitespace(const String& aText)
|
||||
{
|
||||
PRUint32 size = aText.length();
|
||||
PRUint32 i;
|
||||
for (i = 0; i < size; ++i) {
|
||||
if (!isWhitespace(aText.charAt(i))) {
|
||||
const nsAFlatString& text = aText.getConstNSString();
|
||||
nsAFlatString::const_char_iterator start, end;
|
||||
text.BeginReading(start);
|
||||
text.EndReading(end);
|
||||
for ( ; start != end; ++start) {
|
||||
if (!isWhitespace(*start)) {
|
||||
return MB_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = Attr.cpp \
|
||||
CDATASection.cpp \
|
||||
CharacterData.cpp \
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#endif
|
||||
|
||||
#include "List.h"
|
||||
#include "TxString.h"
|
||||
#include "txAtom.h"
|
||||
#include "baseutils.h"
|
||||
|
||||
#ifndef NULL
|
||||
@@ -64,8 +64,6 @@ class ProcessingInstruction;
|
||||
class EntityReference;
|
||||
class DocumentType;
|
||||
|
||||
class txAtom;
|
||||
|
||||
/*
|
||||
* NULL string for use by Element::getAttribute() for when the attribute
|
||||
* specified by "name" does not exist, and therefore shoud be "NULL".
|
||||
|
||||
@@ -40,7 +40,9 @@ REQUIRES = string \
|
||||
unicharutil \
|
||||
$(NULL)
|
||||
else
|
||||
REQUIRES = expat \
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
expat \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
||||
@@ -26,11 +26,13 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
dom \
|
||||
$(NULL)
|
||||
|
||||
ifndef TX_EXE
|
||||
REQUIRES += dom \
|
||||
content \
|
||||
widget \
|
||||
xpconnect \
|
||||
|
||||
@@ -28,11 +28,12 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = functions util
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
dom \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
REQUIRES += dom \
|
||||
content \
|
||||
widget \
|
||||
necko \
|
||||
|
||||
@@ -75,10 +75,13 @@ TX_IMPL_ATOM_STATICS;
|
||||
TX_IMPL_DOM_STATICS;
|
||||
#endif
|
||||
|
||||
TX_LG_IMPL;
|
||||
|
||||
/* static */
|
||||
MBool
|
||||
txXSLTProcessor::txInit()
|
||||
{
|
||||
TX_LG_CREATE;
|
||||
#ifdef TX_EXE
|
||||
if (!txNamespaceManager::init())
|
||||
return MB_FALSE;
|
||||
@@ -108,6 +111,7 @@ txXSLTProcessor::txInit()
|
||||
MBool
|
||||
txXSLTProcessor::txShutdown()
|
||||
{
|
||||
TX_LG_DELETE;
|
||||
#ifdef TX_EXE
|
||||
txNamespaceManager::shutdown();
|
||||
#endif
|
||||
|
||||
@@ -26,11 +26,12 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
dom \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
REQUIRES += dom \
|
||||
content \
|
||||
widget \
|
||||
unicharutil \
|
||||
|
||||
@@ -26,11 +26,12 @@ VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
ifndef TX_EXE
|
||||
MODULE = transformiix
|
||||
REQUIRES = string \
|
||||
xpcom \
|
||||
dom \
|
||||
$(NULL)
|
||||
ifndef TX_EXE
|
||||
REQUIRES += dom \
|
||||
content \
|
||||
widget \
|
||||
locale \
|
||||
|
||||
Reference in New Issue
Block a user