зеркало из https://github.com/mozilla/pjs.git
scc string fixes
This commit is contained in:
Родитель
0b240f10f7
Коммит
47511cf02b
|
@ -34,6 +34,9 @@
|
||||||
4. Subsumable strings
|
4. Subsumable strings
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#ifndef NEW_STRING_APIS
|
||||||
|
//#define NEW_STRING_APIS 1
|
||||||
|
#endif //NEW_STRING_APIS
|
||||||
|
|
||||||
#ifndef _nsCString_
|
#ifndef _nsCString_
|
||||||
#define _nsCString_
|
#define _nsCString_
|
||||||
|
|
|
@ -2286,6 +2286,15 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||||
Append(aString,aLength);
|
Append(aString,aLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsAutoString::nsAutoString( const nsString& aString )
|
||||||
|
: nsString()
|
||||||
|
{
|
||||||
|
Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE);
|
||||||
|
AddNullTerminator(*this);
|
||||||
|
Append(aString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor that uses external buffer
|
* constructor that uses external buffer
|
||||||
* @param aBuffer describes the external buffer
|
* @param aBuffer describes the external buffer
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
4. Subsumable strings
|
4. Subsumable strings
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#ifndef NEW_STRING_APIS
|
||||||
|
//#define NEW_STRING_APIS 1
|
||||||
|
#endif //NEW_STRING_APIS
|
||||||
|
|
||||||
|
|
||||||
#ifndef _nsString_
|
#ifndef _nsString_
|
||||||
#define _nsString_
|
#define _nsString_
|
||||||
|
@ -898,6 +902,7 @@ public:
|
||||||
virtual ~nsAutoString();
|
virtual ~nsAutoString();
|
||||||
nsAutoString();
|
nsAutoString();
|
||||||
nsAutoString(const nsAutoString& aString);
|
nsAutoString(const nsAutoString& aString);
|
||||||
|
nsAutoString(const nsString& aString);
|
||||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||||
nsAutoString(PRUnichar aChar);
|
nsAutoString(PRUnichar aChar);
|
||||||
nsAutoString(const CBufDescriptor& aBuffer);
|
nsAutoString(const CBufDescriptor& aBuffer);
|
||||||
|
|
|
@ -504,7 +504,7 @@ template <class CharT>
|
||||||
PRUint32
|
PRUint32
|
||||||
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
return PRUint32(count(BeginReading(), EndReading(), c));
|
return PRUint32(count(BeginReading(), EndReading(), c));
|
||||||
#else
|
#else
|
||||||
PRUint32 result = 0;
|
PRUint32 result = 0;
|
||||||
|
@ -679,7 +679,7 @@ inline
|
||||||
int
|
int
|
||||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
||||||
{
|
{
|
||||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs)));
|
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
|
@ -687,7 +687,7 @@ inline
|
||||||
int
|
int
|
||||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
||||||
{
|
{
|
||||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -487,6 +487,8 @@ struct nsCharSourceTraits
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
struct nsCharSourceTraits<CharT*>
|
struct nsCharSourceTraits<CharT*>
|
||||||
{
|
{
|
||||||
|
@ -513,6 +515,37 @@ struct nsCharSourceTraits<CharT*>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSourceTraits<const char*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
readable_size( const char* s )
|
||||||
|
{
|
||||||
|
return PRUint32(nsCharTraits<char>::length(s));
|
||||||
|
// return numeric_limits<PRUint32>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
readable_size( const char* first, const char* last )
|
||||||
|
{
|
||||||
|
return PRUint32(last-first);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
const char*
|
||||||
|
read( const char* s )
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add specialization for |PRUnichar| only if it is needed
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template <class OutputIterator>
|
template <class OutputIterator>
|
||||||
|
@ -526,6 +559,8 @@ struct nsCharSinkTraits
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
struct nsCharSinkTraits<CharT*>
|
struct nsCharSinkTraits<CharT*>
|
||||||
{
|
{
|
||||||
|
@ -539,5 +574,34 @@ struct nsCharSinkTraits<CharT*>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSinkTraits<char*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
write( char*& iter, const char* s, PRUint32 n )
|
||||||
|
{
|
||||||
|
nsCharTraits<char>::copy(iter, s, n);
|
||||||
|
iter += n;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSinkTraits<PRUnichar*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
write( PRUnichar*& iter, const PRUnichar* s, PRUint32 n )
|
||||||
|
{
|
||||||
|
nsCharTraits<PRUnichar>::copy(iter, s, n);
|
||||||
|
iter += n;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // !defined(_nsCharTraits_h__)
|
#endif // !defined(_nsCharTraits_h__)
|
||||||
|
|
|
@ -162,6 +162,7 @@ typedef PRUint16 PRUnichar;
|
||||||
/* under Metrowerks (Mac), we don't have autoconf yet */
|
/* under Metrowerks (Mac), we don't have autoconf yet */
|
||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
#define HAVE_CPP_SPECIALIZATION
|
#define HAVE_CPP_SPECIALIZATION
|
||||||
|
#define HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
#define HAVE_CPP_MODERN_SPECIALIZE_TEMPLATE_SYNTAX
|
||||||
|
|
||||||
#define HAVE_ACCESS_CHANGING_CPP_USING
|
#define HAVE_ACCESS_CHANGING_CPP_USING
|
||||||
|
|
|
@ -504,7 +504,7 @@ template <class CharT>
|
||||||
PRUint32
|
PRUint32
|
||||||
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
return PRUint32(count(BeginReading(), EndReading(), c));
|
return PRUint32(count(BeginReading(), EndReading(), c));
|
||||||
#else
|
#else
|
||||||
PRUint32 result = 0;
|
PRUint32 result = 0;
|
||||||
|
@ -679,7 +679,7 @@ inline
|
||||||
int
|
int
|
||||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
||||||
{
|
{
|
||||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs)));
|
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
|
@ -687,7 +687,7 @@ inline
|
||||||
int
|
int
|
||||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
||||||
{
|
{
|
||||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -487,6 +487,8 @@ struct nsCharSourceTraits
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
struct nsCharSourceTraits<CharT*>
|
struct nsCharSourceTraits<CharT*>
|
||||||
{
|
{
|
||||||
|
@ -513,6 +515,37 @@ struct nsCharSourceTraits<CharT*>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSourceTraits<const char*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
readable_size( const char* s )
|
||||||
|
{
|
||||||
|
return PRUint32(nsCharTraits<char>::length(s));
|
||||||
|
// return numeric_limits<PRUint32>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
readable_size( const char* first, const char* last )
|
||||||
|
{
|
||||||
|
return PRUint32(last-first);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
const char*
|
||||||
|
read( const char* s )
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add specialization for |PRUnichar| only if it is needed
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template <class OutputIterator>
|
template <class OutputIterator>
|
||||||
|
@ -526,6 +559,8 @@ struct nsCharSinkTraits
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
struct nsCharSinkTraits<CharT*>
|
struct nsCharSinkTraits<CharT*>
|
||||||
{
|
{
|
||||||
|
@ -539,5 +574,34 @@ struct nsCharSinkTraits<CharT*>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSinkTraits<char*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
write( char*& iter, const char* s, PRUint32 n )
|
||||||
|
{
|
||||||
|
nsCharTraits<char>::copy(iter, s, n);
|
||||||
|
iter += n;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSinkTraits<PRUnichar*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
write( PRUnichar*& iter, const PRUnichar* s, PRUint32 n )
|
||||||
|
{
|
||||||
|
nsCharTraits<PRUnichar>::copy(iter, s, n);
|
||||||
|
iter += n;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // !defined(_nsCharTraits_h__)
|
#endif // !defined(_nsCharTraits_h__)
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
4. Subsumable strings
|
4. Subsumable strings
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#ifndef NEW_STRING_APIS
|
||||||
|
//#define NEW_STRING_APIS 1
|
||||||
|
#endif //NEW_STRING_APIS
|
||||||
|
|
||||||
#ifndef _nsCString_
|
#ifndef _nsCString_
|
||||||
#define _nsCString_
|
#define _nsCString_
|
||||||
|
|
|
@ -2286,6 +2286,15 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||||
Append(aString,aLength);
|
Append(aString,aLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsAutoString::nsAutoString( const nsString& aString )
|
||||||
|
: nsString()
|
||||||
|
{
|
||||||
|
Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE);
|
||||||
|
AddNullTerminator(*this);
|
||||||
|
Append(aString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor that uses external buffer
|
* constructor that uses external buffer
|
||||||
* @param aBuffer describes the external buffer
|
* @param aBuffer describes the external buffer
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
4. Subsumable strings
|
4. Subsumable strings
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#ifndef NEW_STRING_APIS
|
||||||
|
//#define NEW_STRING_APIS 1
|
||||||
|
#endif //NEW_STRING_APIS
|
||||||
|
|
||||||
|
|
||||||
#ifndef _nsString_
|
#ifndef _nsString_
|
||||||
#define _nsString_
|
#define _nsString_
|
||||||
|
@ -898,6 +902,7 @@ public:
|
||||||
virtual ~nsAutoString();
|
virtual ~nsAutoString();
|
||||||
nsAutoString();
|
nsAutoString();
|
||||||
nsAutoString(const nsAutoString& aString);
|
nsAutoString(const nsAutoString& aString);
|
||||||
|
nsAutoString(const nsString& aString);
|
||||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||||
nsAutoString(PRUnichar aChar);
|
nsAutoString(PRUnichar aChar);
|
||||||
nsAutoString(const CBufDescriptor& aBuffer);
|
nsAutoString(const CBufDescriptor& aBuffer);
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
4. Subsumable strings
|
4. Subsumable strings
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#ifndef NEW_STRING_APIS
|
||||||
|
//#define NEW_STRING_APIS 1
|
||||||
|
#endif //NEW_STRING_APIS
|
||||||
|
|
||||||
#ifndef _nsCString_
|
#ifndef _nsCString_
|
||||||
#define _nsCString_
|
#define _nsCString_
|
||||||
|
|
|
@ -2286,6 +2286,15 @@ nsAutoString::nsAutoString(const PRUnichar* aString,PRInt32 aLength) : nsString(
|
||||||
Append(aString,aLength);
|
Append(aString,aLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsAutoString::nsAutoString( const nsString& aString )
|
||||||
|
: nsString()
|
||||||
|
{
|
||||||
|
Initialize(*this, mBuffer, (sizeof(mBuffer)>>eTwoByte)-1, 0, eTwoByte, PR_FALSE);
|
||||||
|
AddNullTerminator(*this);
|
||||||
|
Append(aString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor that uses external buffer
|
* constructor that uses external buffer
|
||||||
* @param aBuffer describes the external buffer
|
* @param aBuffer describes the external buffer
|
||||||
|
|
|
@ -35,6 +35,10 @@
|
||||||
4. Subsumable strings
|
4. Subsumable strings
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
|
#ifndef NEW_STRING_APIS
|
||||||
|
//#define NEW_STRING_APIS 1
|
||||||
|
#endif //NEW_STRING_APIS
|
||||||
|
|
||||||
|
|
||||||
#ifndef _nsString_
|
#ifndef _nsString_
|
||||||
#define _nsString_
|
#define _nsString_
|
||||||
|
@ -898,6 +902,7 @@ public:
|
||||||
virtual ~nsAutoString();
|
virtual ~nsAutoString();
|
||||||
nsAutoString();
|
nsAutoString();
|
||||||
nsAutoString(const nsAutoString& aString);
|
nsAutoString(const nsAutoString& aString);
|
||||||
|
nsAutoString(const nsString& aString);
|
||||||
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
nsAutoString(const PRUnichar* aString,PRInt32 aLength=-1);
|
||||||
nsAutoString(PRUnichar aChar);
|
nsAutoString(PRUnichar aChar);
|
||||||
nsAutoString(const CBufDescriptor& aBuffer);
|
nsAutoString(const CBufDescriptor& aBuffer);
|
||||||
|
|
|
@ -504,7 +504,7 @@ template <class CharT>
|
||||||
PRUint32
|
PRUint32
|
||||||
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
basic_nsAReadableString<CharT>::CountChar( CharT c ) const
|
||||||
{
|
{
|
||||||
#if 1
|
#if 0
|
||||||
return PRUint32(count(BeginReading(), EndReading(), c));
|
return PRUint32(count(BeginReading(), EndReading(), c));
|
||||||
#else
|
#else
|
||||||
PRUint32 result = 0;
|
PRUint32 result = 0;
|
||||||
|
@ -679,7 +679,7 @@ inline
|
||||||
int
|
int
|
||||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
basic_nsAReadableString<CharT>::Compare( const CharT* rhs ) const
|
||||||
{
|
{
|
||||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs)));
|
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
|
@ -687,7 +687,7 @@ inline
|
||||||
int
|
int
|
||||||
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
basic_nsAReadableString<CharT>::Compare( const CharT* rhs, PRUint32 rhs_length ) const
|
||||||
{
|
{
|
||||||
return ::Compare(*this, NS_STATIC_CAST(basic_nsAReadableString<CharT>, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
return ::Compare(*this, NS_STATIC_CAST(const basic_nsAReadableString<CharT>&, basic_nsLiteralString<CharT>(rhs, rhs_length)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -487,6 +487,8 @@ struct nsCharSourceTraits
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
struct nsCharSourceTraits<CharT*>
|
struct nsCharSourceTraits<CharT*>
|
||||||
{
|
{
|
||||||
|
@ -513,6 +515,37 @@ struct nsCharSourceTraits<CharT*>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSourceTraits<const char*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
readable_size( const char* s )
|
||||||
|
{
|
||||||
|
return PRUint32(nsCharTraits<char>::length(s));
|
||||||
|
// return numeric_limits<PRUint32>::max();
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
readable_size( const char* first, const char* last )
|
||||||
|
{
|
||||||
|
return PRUint32(last-first);
|
||||||
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
const char*
|
||||||
|
read( const char* s )
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add specialization for |PRUnichar| only if it is needed
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template <class OutputIterator>
|
template <class OutputIterator>
|
||||||
|
@ -526,6 +559,8 @@ struct nsCharSinkTraits
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef HAVE_CPP_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
template <class CharT>
|
template <class CharT>
|
||||||
struct nsCharSinkTraits<CharT*>
|
struct nsCharSinkTraits<CharT*>
|
||||||
{
|
{
|
||||||
|
@ -539,5 +574,34 @@ struct nsCharSinkTraits<CharT*>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSinkTraits<char*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
write( char*& iter, const char* s, PRUint32 n )
|
||||||
|
{
|
||||||
|
nsCharTraits<char>::copy(iter, s, n);
|
||||||
|
iter += n;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
NS_SPECIALIZE_TEMPLATE
|
||||||
|
struct nsCharSinkTraits<PRUnichar*>
|
||||||
|
{
|
||||||
|
static
|
||||||
|
PRUint32
|
||||||
|
write( PRUnichar*& iter, const PRUnichar* s, PRUint32 n )
|
||||||
|
{
|
||||||
|
nsCharTraits<PRUnichar>::copy(iter, s, n);
|
||||||
|
iter += n;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // !defined(_nsCharTraits_h__)
|
#endif // !defined(_nsCharTraits_h__)
|
||||||
|
|
|
@ -136,8 +136,8 @@ main(int argc, char* argv[])
|
||||||
char name[16];
|
char name[16];
|
||||||
name[0] = 0;
|
name[0] = 0;
|
||||||
sprintf(name, "%d", i);
|
sprintf(name, "%d", i);
|
||||||
nsAutoString v("");
|
nsAutoString v;
|
||||||
ret = props->GetStringProperty(name, v);
|
ret = props->GetStringProperty(NS_ConvertASCIItoUCS2(name), v);
|
||||||
if (NS_FAILED(ret) || (!v.Length())) {
|
if (NS_FAILED(ret) || (!v.Length())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
#!nmake
|
||||||
|
#
|
||||||
|
# The contents of this file are subject to the Netscape Public
|
||||||
|
# License Version 1.1 (the "License"); you may not use this file
|
||||||
|
# except in compliance with the License. You may obtain a copy of
|
||||||
|
# the License at http://www.mozilla.org/NPL/
|
||||||
|
#
|
||||||
|
# Software distributed under the License is distributed on an "AS
|
||||||
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||||
|
# implied. See the License for the specific language governing
|
||||||
|
# rights and limitations under the License.
|
||||||
|
#
|
||||||
|
# The Original Code is mozilla.org code.
|
||||||
|
#
|
||||||
|
# The Initial Developer of the Original Code is Netscape
|
||||||
|
# Communications Corporation. Portions created by Netscape are
|
||||||
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||||
|
# Rights Reserved.
|
||||||
|
#
|
||||||
|
# Contributor(s):
|
||||||
|
|
||||||
|
DEPTH=..\..\..
|
||||||
|
|
||||||
|
MAKE_OBJ_TYPE = EXE
|
||||||
|
PROGRAM = .\$(OBJDIR)\test_main.exe
|
||||||
|
|
||||||
|
OBJS = \
|
||||||
|
.\$(OBJDIR)\test_main.obj \
|
||||||
|
.\$(OBJDIR)\nsString2.obj \
|
||||||
|
.\$(OBJDIR)\nsStr.obj \
|
||||||
|
.\$(OBJDIR)\nsString.obj \
|
||||||
|
.\$(OBJDIR)\nsCRT.obj \
|
||||||
|
.\$(OBJDIR)\nsAllocator.obj \
|
||||||
|
.\$(OBJDIR)\nsDeque.obj \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
CPPSRCS = \
|
||||||
|
test_main.cpp \
|
||||||
|
$(DEPTH)\xpcom\nsString2.cpp \
|
||||||
|
$(DEPTH)\xpcom\ds\nsStr.cpp \
|
||||||
|
$(DEPTH)\xpcom\ds\nsString.cpp \
|
||||||
|
$(DEPTH)\xpcom\ds\nsCRT.cpp \
|
||||||
|
$(DEPTH)\xpcom\ds\nsAllocator.cpp \
|
||||||
|
$(DEPTH)\xpcom\ds\nsDeque.cpp \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
LCFLAGS = \
|
||||||
|
-DNEW_STRING_APIS -DSTANDALONE_STRING_TESTS -DNDEBUG -GX\
|
||||||
|
$(DEFINES) \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
LINCS=-I$(PUBLIC)\xpcom \
|
||||||
|
-I$(MOZ_TOOLS)\include \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
|
include <$(DEPTH)\config\rules.mak>
|
||||||
|
|
||||||
|
export:: $(PROGRAM)
|
||||||
|
$(MAKE_INSTALL) $(PROGRAM) $(DIST)\bin
|
||||||
|
|
||||||
|
clobber::
|
||||||
|
rm -f $(DIST)\bin\test_main.exe
|
||||||
|
|
||||||
|
$(PROGRAM):: $(OBJS) $(MYLIBS)
|
|
@ -1,6 +1,6 @@
|
||||||
#include <iostream.h>
|
#include <iostream.h>
|
||||||
|
|
||||||
#define TEST_STD_STRING
|
//#define TEST_STD_STRING
|
||||||
|
|
||||||
|
|
||||||
#include "nsString.h"
|
#include "nsString.h"
|
||||||
|
|
|
@ -47,7 +47,8 @@ int main(int argc, char** argv)
|
||||||
if (nsnull == s) {
|
if (nsnull == s) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nsAutoString sb(buf);
|
nsAutoString sb;
|
||||||
|
sb.AssignWithConversion(buf);
|
||||||
strings[count++] = sb.ToNewUnicode();
|
strings[count++] = sb.ToNewUnicode();
|
||||||
sb.ToUpperCase();
|
sb.ToUpperCase();
|
||||||
strings[count++] = sb.ToNewUnicode();
|
strings[count++] = sb.ToNewUnicode();
|
||||||
|
|
Двоичные данные
xpcom/tests/TestCRT.cpp
Двоичные данные
xpcom/tests/TestCRT.cpp
Двоичный файл не отображается.
|
@ -51,7 +51,7 @@ extern ostream &operator<<( ostream &s, nsString &str ) {
|
||||||
|
|
||||||
class TestObserver : public nsIObserver, public nsSupportsWeakReference {
|
class TestObserver : public nsIObserver, public nsSupportsWeakReference {
|
||||||
public:
|
public:
|
||||||
TestObserver( const nsString &name = "unknown" )
|
TestObserver( const nsString &name = NS_ConvertASCIItoUCS2("unknown") )
|
||||||
: mName( name ) {
|
: mName( name ) {
|
||||||
NS_INIT_REFCNT();
|
NS_INIT_REFCNT();
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ TestObserver::Observe( nsISupports *aSubject,
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
nsString topicA( "topic-A" );
|
nsString topicA; topicA.AssignWithConversion( "topic-A" );
|
||||||
nsString topicB( "topic-B" );
|
nsString topicB; topicB.AssignWithConversion( "topic-B" );
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsresult res = nsComponentManager::CreateInstance(NS_OBSERVERSERVICE_PROGID,
|
nsresult res = nsComponentManager::CreateInstance(NS_OBSERVERSERVICE_PROGID,
|
||||||
|
@ -94,9 +94,9 @@ int main(int argc, char *argv[])
|
||||||
if (res == NS_OK) {
|
if (res == NS_OK) {
|
||||||
|
|
||||||
nsIObserver *anObserver;
|
nsIObserver *anObserver;
|
||||||
nsIObserver *aObserver = new TestObserver("Observer-A");
|
nsIObserver *aObserver = new TestObserver(NS_ConvertASCIItoUCS2("Observer-A"));
|
||||||
aObserver->AddRef();
|
aObserver->AddRef();
|
||||||
nsIObserver *bObserver = new TestObserver("Observer-B");
|
nsIObserver *bObserver = new TestObserver(NS_ConvertASCIItoUCS2("Observer-B"));
|
||||||
bObserver->AddRef();
|
bObserver->AddRef();
|
||||||
|
|
||||||
cout << "Adding Observer-A as observer of topic-A..." << endl;
|
cout << "Adding Observer-A as observer of topic-A..." << endl;
|
||||||
|
@ -114,13 +114,13 @@ int main(int argc, char *argv[])
|
||||||
cout << "Testing Notify(observer-A, topic-A)..." << endl;
|
cout << "Testing Notify(observer-A, topic-A)..." << endl;
|
||||||
rv = anObserverService->Notify( aObserver,
|
rv = anObserverService->Notify( aObserver,
|
||||||
topicA.GetUnicode(),
|
topicA.GetUnicode(),
|
||||||
nsString("Testing Notify(observer-A, topic-A)").GetUnicode() );
|
NS_ConvertASCIItoUCS2("Testing Notify(observer-A, topic-A)").GetUnicode() );
|
||||||
testResult(rv);
|
testResult(rv);
|
||||||
|
|
||||||
cout << "Testing Notify(observer-B, topic-B)..." << endl;
|
cout << "Testing Notify(observer-B, topic-B)..." << endl;
|
||||||
rv = anObserverService->Notify( bObserver,
|
rv = anObserverService->Notify( bObserver,
|
||||||
topicB.GetUnicode(),
|
topicB.GetUnicode(),
|
||||||
nsString("Testing Notify(observer-B, topic-B)").GetUnicode() );
|
NS_ConvertASCIItoUCS2("Testing Notify(observer-B, topic-B)").GetUnicode() );
|
||||||
testResult(rv);
|
testResult(rv);
|
||||||
|
|
||||||
cout << "Testing EnumerateObserverList (for topic-A)..." << endl;
|
cout << "Testing EnumerateObserverList (for topic-A)..." << endl;
|
||||||
|
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
|
||||||
rv = inst->QueryInterface(NS_GET_IID(nsIObserver),(void**)&anObserver);
|
rv = inst->QueryInterface(NS_GET_IID(nsIObserver),(void**)&anObserver);
|
||||||
cout << "Calling observe on enumerated observer "
|
cout << "Calling observe on enumerated observer "
|
||||||
<< NS_REINTERPRET_CAST(TestObserver*, NS_REINTERPRET_CAST(void*, inst))->mName << "..." << endl;
|
<< NS_REINTERPRET_CAST(TestObserver*, NS_REINTERPRET_CAST(void*, inst))->mName << "..." << endl;
|
||||||
rv = anObserver->Observe( inst, topicA.GetUnicode(), nsString("during enumeration").GetUnicode() );
|
rv = anObserver->Observe( inst, topicA.GetUnicode(), NS_ConvertASCIItoUCS2("during enumeration").GetUnicode() );
|
||||||
testResult(rv);
|
testResult(rv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче