Add --disable-v1-string-abi option to remove backwards-compatible support for the nsAString vtable. Bug 273424, r+sr=darin.

git-svn-id: svn://10.0.0.236/trunk@168238 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bryner%brianryner.com 2005-01-24 16:44:41 +00:00
parent 645712b67e
commit 348b3c5fdb
24 changed files with 923 additions and 826 deletions

View File

@ -509,3 +509,5 @@ MACOS_SDK_DIR = @MACOS_SDK_DIR@
VISIBILITY_FLAGS = @VISIBILITY_FLAGS@
WRAP_SYSTEM_INCLUDES = @WRAP_SYSTEM_INCLUDES@
MOZ_V1_STRING_ABI = @MOZ_V1_STRING_ABI@

1454
mozilla/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -5777,6 +5777,19 @@ fi
dnl NECKO_ configuration options are not global
_NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_"
dnl ========================================================
dnl string api compatibility
dnl ========================================================
MOZ_V1_STRING_ABI=1
MOZ_ARG_DISABLE_BOOL(v1-string-abi,
[ --disable-v1-string-abi Disable binary compatibility layer for strings],
MOZ_V1_STRING_ABI=,
MOZ_V1_STRING_ABI=1)
AC_SUBST(MOZ_V1_STRING_ABI)
if test "$MOZ_V1_STRING_ABI"; then
AC_DEFINE(MOZ_V1_STRING_ABI)
fi
dnl ========================================================
dnl =
dnl = Cleanup section for misc ordering snafus
@ -6224,6 +6237,7 @@ HAVE_SYS_MOUNT_H
HAVE_SYS_VFS_H
HAVE_WCRTOMB
ENABLE_STATIC_COMPONENT_LOADER
MOZ_V1_STRING_ABI
"
AC_CONFIG_HEADER(

View File

@ -112,6 +112,7 @@ public:
}
};
#ifdef MOZ_V1_STRING_ABI
void
ToLowerCase( nsAString& aString )
{
@ -119,6 +120,7 @@ ToLowerCase( nsAString& aString )
ConvertToLowerCase converter;
copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter);
}
#endif
void
ToLowerCase( nsASingleFragmentString& aString )
@ -196,6 +198,7 @@ public:
}
};
#ifdef MOZ_V1_STRING_ABI
void
ToUpperCase( nsAString& aString )
{
@ -203,6 +206,7 @@ ToUpperCase( nsAString& aString )
ConvertToUpperCase converter;
copy_string(aString.BeginWriting(fromBegin), aString.EndWriting(fromEnd), converter);
}
#endif
void
ToUpperCase( nsASingleFragmentString& aString )

View File

@ -47,9 +47,11 @@
#include "nsStringIterator.h"
#endif
#ifdef MOZ_V1_STRING_ABI
#ifndef nsObsoleteAString_h___
#include "nsObsoleteAString.h"
#endif
#endif
// If some platform(s) can't handle our template that matches literal strings,
// then we'll disable it on those platforms.

View File

@ -52,7 +52,9 @@
class nsAString;
class nsObsoleteAString;
#ifdef MOZ_V1_STRING_ABI
class nsSubstring;
#endif
class nsSubstringTuple;
class nsString;
class nsAutoString;
@ -70,7 +72,9 @@ class nsXPIDLString;
class nsACString;
class nsObsoleteACString;
#ifdef MOZ_V1_STRING_ABI
class nsCSubstring;
#endif
class nsCSubstringTuple;
class nsCString;
class nsCAutoString;
@ -86,6 +90,11 @@ class nsXPIDLCString;
* typedefs for backwards compatibility
*/
#ifndef MOZ_V1_STRING_ABI
typedef nsAString nsSubstring;
typedef nsACString nsCSubstring;
#endif
typedef nsString nsAFlatString;
typedef nsSubstring nsASingleFragmentString;

View File

@ -68,8 +68,10 @@ class nsReadingIterator
private:
friend class nsAString;
friend class nsACString;
#ifdef MOZ_V1_STRING_ABI
friend class nsSubstring;
friend class nsCSubstring;
#endif
// unfortunately, the API for nsReadingIterator requires that the
// iterator know its start and end positions. this was needed when
@ -204,8 +206,10 @@ class nsWritingIterator
private:
friend class nsAString;
friend class nsACString;
#ifdef MOZ_V1_STRING_ABI
friend class nsSubstring;
friend class nsCSubstring;
#endif
// unfortunately, the API for nsWritingIterator requires that the
// iterator know its start and end positions. this was needed when

View File

@ -123,6 +123,7 @@ class nsTAString_CharT
typedef PRUint32 size_type;
typedef PRUint32 index_type;
#ifdef MOZ_V1_STRING_ABI
public:
// this acts like a virtual destructor
@ -574,45 +575,5 @@ class nsTAString_CharT
void operator+= ( incompatible_char_type );
void Append ( incompatible_char_type );
void Insert ( incompatible_char_type, index_type );
#endif
};
NS_COM
int NS_FASTCALL Compare( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs, const nsTStringComparator_CharT& = nsTDefaultStringComparator_CharT() );
inline
PRBool operator!=( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
{
return !lhs.Equals(rhs);
}
inline
PRBool operator< ( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
{
return Compare(lhs, rhs)< 0;
}
inline
PRBool operator<=( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
{
return Compare(lhs, rhs)<=0;
}
inline
PRBool operator==( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
{
return lhs.Equals(rhs);
}
inline
PRBool operator>=( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
{
return Compare(lhs, rhs)>=0;
}
inline
PRBool operator> ( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs )
{
return Compare(lhs, rhs)> 0;
}

View File

@ -128,5 +128,7 @@ class nsTDependentString_CharT : public nsTString_CharT
// NOT USED
nsTDependentString_CharT( const substring_tuple_type& );
#ifdef MOZ_V1_STRING_ABI
nsTDependentString_CharT( const abstract_string_type& );
#endif
};

View File

@ -49,16 +49,20 @@ class nsTDependentSubstring_CharT : public nsTSubstring_CharT
public:
#ifdef MOZ_V1_STRING_ABI
NS_COM void Rebind( const abstract_string_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
#endif
NS_COM void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
NS_COM void Rebind( const char_type* start, const char_type* end );
#ifdef MOZ_V1_STRING_ABI
nsTDependentSubstring_CharT( const abstract_string_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
: substring_type()
{
Rebind(str, startPos, length);
}
#endif
nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
: substring_type()
@ -83,12 +87,14 @@ class nsTDependentSubstring_CharT : public nsTSubstring_CharT
void operator=( const self_type& ); // we're immutable, you can't assign into a substring
};
#ifdef MOZ_V1_STRING_ABI
inline
const nsTDependentSubstring_CharT
Substring( const nsTAString_CharT& str, PRUint32 startPos, PRUint32 length = PRUint32(-1) )
{
return nsTDependentSubstring_CharT(str, startPos, length);
}
#endif
inline
const nsTDependentSubstring_CharT
@ -111,12 +117,14 @@ Substring( const CharT* start, const CharT* end )
return nsTDependentSubstring_CharT(start, end);
}
#ifdef MOZ_V1_STRING_ABI
inline
const nsTDependentSubstring_CharT
StringHead( const nsTAString_CharT& str, PRUint32 count )
{
return nsTDependentSubstring_CharT(str, 0, count);
}
#endif
inline
const nsTDependentSubstring_CharT
@ -125,12 +133,14 @@ StringHead( const nsTSubstring_CharT& str, PRUint32 count )
return nsTDependentSubstring_CharT(str, 0, count);
}
#ifdef MOZ_V1_STRING_ABI
inline
const nsTDependentSubstring_CharT
StringTail( const nsTAString_CharT& str, PRUint32 count )
{
return nsTDependentSubstring_CharT(str, str.Length() - count, count);
}
#endif
inline
const nsTDependentSubstring_CharT

View File

@ -100,7 +100,9 @@ class nsTPromiseFlatString_CharT : public nsTString_CharT
private:
NS_COM void Init( const substring_type& );
#ifdef MOZ_V1_STRING_ABI
NS_COM void Init( const abstract_string_type& );
#endif
// NOT TO BE IMPLEMENTED
void operator=( const self_type& );
@ -117,12 +119,14 @@ class nsTPromiseFlatString_CharT : public nsTString_CharT
Init(str);
}
#ifdef MOZ_V1_STRING_ABI
explicit
nsTPromiseFlatString_CharT( const abstract_string_type& readable )
: string_type()
{
Init(readable);
}
#endif
explicit
nsTPromiseFlatString_CharT( const substring_tuple_type& tuple )
@ -134,12 +138,14 @@ class nsTPromiseFlatString_CharT : public nsTString_CharT
}
};
#ifdef MOZ_V1_STRING_ABI
inline
const nsTPromiseFlatString_CharT
TPromiseFlatString_CharT( const nsTAString_CharT& str )
{
return nsTPromiseFlatString_CharT(str);
}
#endif
// e.g., PromiseFlatCString(Substring(s))
inline

View File

@ -89,7 +89,11 @@ class nsTString_CharT : public nsTSubstring_CharT
}
explicit
#ifdef MOZ_V1_STRING_ABI
nsTString_CharT( const abstract_string_type& readable )
#else
nsTString_CharT( const substring_type& readable )
#endif
: substring_type()
{
Assign(readable);
@ -102,7 +106,9 @@ class nsTString_CharT : public nsTSubstring_CharT
self_type& operator=( const self_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
#endif
/**
@ -472,7 +478,9 @@ class nsTFixedString_CharT : public nsTString_CharT
self_type& operator=( const char_type* data ) { Assign(data); return *this; }
self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
#endif
protected:
@ -538,12 +546,14 @@ class nsTAutoString_CharT : public nsTFixedString_CharT
Assign(tuple);
}
#ifdef MOZ_V1_STRING_ABI
explicit
nsTAutoString_CharT( const abstract_string_type& readable )
: fixed_string_type(mStorage, kDefaultStorageSize, 0)
{
Assign(readable);
}
#endif
// |operator=| does not inherit, so we must define our own
self_type& operator=( char_type c ) { Assign(c); return *this; }
@ -551,7 +561,9 @@ class nsTAutoString_CharT : public nsTFixedString_CharT
self_type& operator=( const self_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
#endif
enum { kDefaultStorageSize = 64 };
@ -611,7 +623,9 @@ class nsTXPIDLString_CharT : public nsTString_CharT
self_type& operator=( const self_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
#endif
};
@ -692,7 +706,9 @@ class nsTAdoptingString_CharT : public nsTXPIDLString_CharT
// |operator=| does not inherit, so we must define our own
self_type& operator=( const substring_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
#endif
// Adopt(), if possible, when assigning to a self_type&. Note
// that this violates the constness of str, str is always

View File

@ -62,8 +62,19 @@ class nsTSubstring_CharT : public nsTAString_CharT
typedef char_type* char_iterator;
typedef const char_type* const_char_iterator;
#ifdef MOZ_V1_STRING_ABI
typedef nsTAString_CharT base_string_type;
#else
typedef nsTSubstring_CharT base_string_type;
#endif
public:
#ifndef MOZ_V1_STRING_ABI
// this acts like a virtual destructor
NS_COM NS_FASTCALL ~nsTSubstring_CharT();
#endif
/**
* reading iterators
*/
@ -209,8 +220,10 @@ class nsTSubstring_CharT : public nsTAString_CharT
NS_COM PRBool NS_FASTCALL Equals( const self_type& ) const;
NS_COM PRBool NS_FASTCALL Equals( const self_type&, const comparator_type& ) const;
#ifdef MOZ_V1_STRING_ABI
NS_COM PRBool NS_FASTCALL Equals( const abstract_string_type& readable ) const;
NS_COM PRBool NS_FASTCALL Equals( const abstract_string_type& readable, const comparator_type& comp ) const;
#endif
NS_COM PRBool NS_FASTCALL Equals( const char_type* data ) const;
NS_COM PRBool NS_FASTCALL Equals( const char_type* data, const comparator_type& comp ) const;
@ -291,7 +304,9 @@ class nsTSubstring_CharT : public nsTAString_CharT
NS_COM void NS_FASTCALL Assign( const char_type* data, size_type length = size_type(-1) );
NS_COM void NS_FASTCALL Assign( const self_type& );
NS_COM void NS_FASTCALL Assign( const substring_tuple_type& );
#ifdef MOZ_V1_STRING_ABI
NS_COM void NS_FASTCALL Assign( const abstract_string_type& );
#endif
NS_COM void NS_FASTCALL AssignASCII( const char* data, size_type length );
NS_COM void NS_FASTCALL AssignASCII( const char* data );
@ -315,7 +330,9 @@ class nsTSubstring_CharT : public nsTAString_CharT
self_type& operator=( const char_type* data ) { Assign(data); return *this; }
self_type& operator=( const self_type& str ) { Assign(str); return *this; }
self_type& operator=( const substring_tuple_type& tuple ) { Assign(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator=( const abstract_string_type& readable ) { Assign(readable); return *this; }
#endif
NS_COM void NS_FASTCALL Adopt( char_type* data, size_type length = size_type(-1) );
@ -328,7 +345,9 @@ class nsTSubstring_CharT : public nsTAString_CharT
NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const char_type* data, size_type length = size_type(-1) );
void Replace( index_type cutStart, size_type cutLength, const self_type& str ) { Replace(cutStart, cutLength, str.Data(), str.Length()); }
NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const substring_tuple_type& tuple );
#ifdef MOZ_V1_STRING_ABI
NS_COM void NS_FASTCALL Replace( index_type cutStart, size_type cutLength, const abstract_string_type& readable );
#endif
NS_COM void NS_FASTCALL ReplaceASCII( index_type cutStart, size_type cutLength, const char* data, size_type length = size_type(-1) );
@ -336,7 +355,9 @@ class nsTSubstring_CharT : public nsTAString_CharT
void Append( const char_type* data, size_type length = size_type(-1) ) { Replace(mLength, 0, data, length); }
void Append( const self_type& str ) { Replace(mLength, 0, str); }
void Append( const substring_tuple_type& tuple ) { Replace(mLength, 0, tuple); }
#ifdef MOZ_V1_STRING_ABI
void Append( const abstract_string_type& readable ) { Replace(mLength, 0, readable); }
#endif
void AppendASCII( const char* data, size_type length = size_type(-1) ) { ReplaceASCII(mLength, 0, data, length); }
@ -359,13 +380,17 @@ class nsTSubstring_CharT : public nsTAString_CharT
self_type& operator+=( const char_type* data ) { Append(data); return *this; }
self_type& operator+=( const self_type& str ) { Append(str); return *this; }
self_type& operator+=( const substring_tuple_type& tuple ) { Append(tuple); return *this; }
#ifdef MOZ_V1_STRING_ABI
self_type& operator+=( const abstract_string_type& readable ) { Append(readable); return *this; }
#endif
void Insert( char_type c, index_type pos ) { Replace(pos, 0, c); }
void Insert( const char_type* data, index_type pos, size_type length = size_type(-1) ) { Replace(pos, 0, data, length); }
void Insert( const self_type& str, index_type pos ) { Replace(pos, 0, str); }
void Insert( const substring_tuple_type& tuple, index_type pos ) { Replace(pos, 0, tuple); }
#ifdef MOZ_V1_STRING_ABI
void Insert( const abstract_string_type& readable, index_type pos ) { Replace(pos, 0, readable); }
#endif
void Cut( index_type cutStart, size_type cutLength ) { Replace(cutStart, cutLength, char_traits::sEmptyBuffer, 0); }
@ -410,7 +435,13 @@ class nsTSubstring_CharT : public nsTAString_CharT
* base type, which helps avoid converting to nsTAString.
*/
nsTSubstring_CharT(const substring_tuple_type& tuple)
#ifdef MOZ_V1_STRING_ABI
: abstract_string_type(nsnull, 0, F_NONE)
#else
: mData(nsnull),
mLength(0),
mFlags(F_NONE)
#endif
{
Assign(tuple);
}
@ -422,7 +453,13 @@ class nsTSubstring_CharT : public nsTAString_CharT
* inside the string implementation.
*/
nsTSubstring_CharT( char_type *data, size_type length, PRUint32 flags )
#ifdef MOZ_V1_STRING_ABI
: abstract_string_type(data, length, flags) {}
#else
: mData(data),
mLength(length),
mFlags(flags) {}
#endif
protected:
@ -434,21 +471,42 @@ class nsTSubstring_CharT : public nsTAString_CharT
// XXX GCC 3.4 needs this :-(
friend class nsTPromiseFlatString_CharT;
#ifndef MOZ_V1_STRING_ABI
char_type* mData;
size_type mLength;
PRUint32 mFlags;
#endif
// default initialization
nsTSubstring_CharT()
#ifdef MOZ_V1_STRING_ABI
: abstract_string_type(
NS_CONST_CAST(char_type*, char_traits::sEmptyBuffer), 0, F_TERMINATED) {}
#else
: mData(NS_CONST_CAST(char_type*, char_traits::sEmptyBuffer)),
mLength(0),
mFlags(F_TERMINATED) {}
#endif
// version of constructor that leaves mData and mLength uninitialized
explicit
nsTSubstring_CharT( PRUint32 flags )
#ifdef MOZ_V1_STRING_ABI
: abstract_string_type(flags) {}
#else
: mFlags(flags) {}
#endif
// copy-constructor, constructs as dependent on given object
// (NOTE: this is for internal use only)
nsTSubstring_CharT( const self_type& str )
: abstract_string_type(
str.mData, str.mLength, str.mFlags & (F_TERMINATED | F_VOIDED)) {}
#ifdef MOZ_V1_STRING_ABI
: abstract_string_type(str.mData, str.mLength, str.mFlags & (F_TERMINATED | F_VOIDED)) {}
#else
: mData(str.mData),
mLength(str.mLength),
mFlags(str.mFlags & (F_TERMINATED | F_VOIDED)) {}
#endif
/**
* this function releases mData and does not change the value of
@ -589,3 +647,43 @@ class nsTSubstring_CharT : public nsTAString_CharT
// mutually exclusive with F_SHARED, F_OWNED, and F_FIXED.
//
};
NS_COM
int NS_FASTCALL Compare( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs, const nsTStringComparator_CharT& = nsTDefaultStringComparator_CharT() );
inline
PRBool operator!=( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs )
{
return !lhs.Equals(rhs);
}
inline
PRBool operator< ( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs )
{
return Compare(lhs, rhs)< 0;
}
inline
PRBool operator<=( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs )
{
return Compare(lhs, rhs)<=0;
}
inline
PRBool operator==( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs )
{
return lhs.Equals(rhs);
}
inline
PRBool operator>=( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs )
{
return Compare(lhs, rhs)>=0;
}
inline
PRBool operator> ( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs )
{
return Compare(lhs, rhs)> 0;
}

View File

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
//* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -55,20 +55,22 @@ class nsTSubstringTuple_CharT
typedef nsTSubstringTuple_CharT self_type;
typedef nsTSubstring_CharT substring_type;
typedef nsTString_CharT string_type;
typedef nsTAString_CharT abstract_string_type;
#ifdef MOZ_V1_STRING_ABI
typedef nsTAString_CharT base_string_type;
typedef nsTObsoleteAString_CharT obsolete_string_type;
#else
typedef nsTSubstring_CharT base_string_type;
#endif
typedef PRUint32 size_type;
public:
nsTSubstringTuple_CharT(const abstract_string_type* a, const abstract_string_type* b)
nsTSubstringTuple_CharT(const base_string_type* a, const base_string_type* b)
: mHead(nsnull)
, mFragA(a)
, mFragB(b) {}
nsTSubstringTuple_CharT(const self_type& head, const abstract_string_type* b)
nsTSubstringTuple_CharT(const self_type& head, const base_string_type* b)
: mHead(&head)
, mFragA(nsnull) // this fragment is ignored when head != nsnull
, mFragB(b) {}
@ -93,21 +95,21 @@ class nsTSubstringTuple_CharT
private:
const self_type* mHead;
const abstract_string_type* mFragA;
const abstract_string_type* mFragB;
const self_type* mHead;
const base_string_type* mFragA;
const base_string_type* mFragB;
};
inline
const nsTSubstringTuple_CharT
operator+(const nsTAString_CharT& a, const nsTAString_CharT& b)
operator+(const nsTSubstringTuple_CharT::base_string_type& a, const nsTSubstringTuple_CharT::base_string_type& b)
{
return nsTSubstringTuple_CharT(&a, &b);
}
inline
const nsTSubstringTuple_CharT
operator+(const nsTSubstringTuple_CharT& head, const nsTAString_CharT& b)
operator+(const nsTSubstringTuple_CharT& head, const nsTSubstringTuple_CharT::base_string_type& b)
{
return nsTSubstringTuple_CharT(head, &b);
}

View File

@ -40,12 +40,20 @@
#define CharT_is_char 1
#define nsTObsoleteAString_CharT nsObsoleteACString
#define nsTObsoleteAStringThunk_CharT nsObsoleteACStringThunk
#ifdef MOZ_V1_STRING_ABI
#define nsTAString_CharT nsACString
#else
#define nsTAString_CharT nsCSubstring_base
#endif
#define nsTAString_IncompatibleCharT nsAString
#define nsTString_CharT nsCString
#define nsTFixedString_CharT nsFixedCString
#define nsTAutoString_CharT nsCAutoString
#ifdef MOZ_V1_STRING_ABI
#define nsTSubstring_CharT nsCSubstring
#else
#define nsTSubstring_CharT nsACString
#endif
#define nsTSubstringTuple_CharT nsCSubstringTuple
#define nsTStringComparator_CharT nsCStringComparator
#define nsTDefaultStringComparator_CharT nsDefaultCStringComparator

View File

@ -40,12 +40,20 @@
#define CharT_is_PRUnichar 1
#define nsTObsoleteAString_CharT nsObsoleteAString
#define nsTObsoleteAStringThunk_CharT nsObsoleteAStringThunk
#ifdef MOZ_V1_STRING_ABI
#define nsTAString_CharT nsAString
#else
#define nsTAString_CharT nsSubstring_base
#endif
#define nsTAString_IncompatibleCharT nsACString
#define nsTString_CharT nsString
#define nsTFixedString_CharT nsFixedString
#define nsTAutoString_CharT nsAutoString
#ifdef MOZ_V1_STRING_ABI
#define nsTSubstring_CharT nsSubstring
#else
#define nsTSubstring_CharT nsAString
#endif
#define nsTSubstringTuple_CharT nsSubstringTuple
#define nsTStringComparator_CharT nsStringComparator
#define nsTDefaultStringComparator_CharT nsDefaultStringComparator

View File

@ -52,10 +52,8 @@ REQUIRES = xpcom \
$(NULL)
CPPSRCS = \
nsAString.cpp \
nsDependentString.cpp \
nsDependentSubstring.cpp \
nsObsoleteAStringThunk.cpp \
nsPrintfCString.cpp \
nsPromiseFlatString.cpp \
nsReadableUtils.cpp \
@ -66,6 +64,13 @@ CPPSRCS = \
nsStringObsolete.cpp \
$(NULL)
ifdef MOZ_V1_STRING_ABI
CPPSRCS += \
nsAString.cpp \
nsObsoleteAStringThunk.cpp \
$(NULL)
endif
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1

View File

@ -628,6 +628,7 @@ class ConvertToUpperCase
}
};
#ifdef MOZ_V1_STRING_ABI
NS_COM
void
ToUpperCase( nsACString& aCString )
@ -636,6 +637,7 @@ ToUpperCase( nsACString& aCString )
ConvertToUpperCase converter;
copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter);
}
#endif
NS_COM
void
@ -716,6 +718,7 @@ class ConvertToLowerCase
}
};
#ifdef MOZ_V1_STRING_ABI
NS_COM
void
ToLowerCase( nsACString& aCString )
@ -724,6 +727,7 @@ ToLowerCase( nsACString& aCString )
ConvertToLowerCase converter;
copy_string(aCString.BeginWriting(fromBegin), aCString.EndWriting(fromEnd), converter);
}
#endif
NS_COM
void

View File

@ -48,10 +48,14 @@
#endif
// convert fragment to |const substring_type&|
#ifdef MOZ_V1_STRING_ABI
#define TO_SUBSTRING(_v) \
( (_v)->mVTable == obsolete_string_type::sCanonicalVTable \
? *(_v)->AsSubstring() \
: (_v)->ToSubstring() )
#else
#define TO_SUBSTRING(_v) (*(_v))
#endif
// define nsSubstringTuple
#include "string-template-def-unichar.h"

View File

@ -36,6 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_V1_STRING_ABI
void
nsTDependentSubstring_CharT::Rebind( const abstract_string_type& readable, PRUint32 startPos, PRUint32 length )
{
@ -52,6 +53,7 @@ nsTDependentSubstring_CharT::Rebind( const abstract_string_type& readable, PRUin
SetDataFlags(F_NONE);
}
#endif
void
nsTDependentSubstring_CharT::Rebind( const substring_type& str, PRUint32 startPos, PRUint32 length )

View File

@ -39,9 +39,11 @@
void
nsTPromiseFlatString_CharT::Init(const substring_type& str)
{
#ifdef MOZ_V1_STRING_ABI
// we have to manually set this here since we are being called on an
// unitialized object.
mVTable = nsTObsoleteAString_CharT::sCanonicalVTable;
#endif
if (str.IsTerminated())
{
@ -56,6 +58,7 @@ nsTPromiseFlatString_CharT::Init(const substring_type& str)
}
// this function is non-inline to minimize codesize
#ifdef MOZ_V1_STRING_ABI
void
nsTPromiseFlatString_CharT::Init(const abstract_string_type& readable)
{
@ -64,3 +67,4 @@ nsTPromiseFlatString_CharT::Init(const abstract_string_type& readable)
else
Init(readable.ToSubstring());
}
#endif

View File

@ -37,7 +37,7 @@
* ***** END LICENSE BLOCK ***** */
NS_COM int
Compare( const nsTAString_CharT& lhs, const nsTAString_CharT& rhs, const nsTStringComparator_CharT& comp )
Compare( const nsTSubstring_CharT::base_string_type& lhs, const nsTSubstring_CharT::base_string_type& rhs, const nsTStringComparator_CharT& comp )
{
typedef nsTAString_CharT::size_type size_type;

View File

@ -175,6 +175,13 @@ nsTSubstring_CharT::Finalize()
// mData, mLength, and mFlags are purposefully left dangling
}
#ifndef MOZ_V1_STRING_ABI
nsTSubstring_CharT::~nsTSubstring_CharT()
{
Finalize();
}
#endif
void
nsTSubstring_CharT::ReplacePrep( index_type cutStart, size_type cutLen, size_type fragLen )
{
@ -383,6 +390,7 @@ nsTSubstring_CharT::Assign( const substring_tuple_type& tuple )
}
// this is non-inline to reduce codesize at the callsite
#ifdef MOZ_V1_STRING_ABI
void
nsTSubstring_CharT::Assign( const abstract_string_type& readable )
{
@ -392,6 +400,7 @@ nsTSubstring_CharT::Assign( const abstract_string_type& readable )
else
Assign(readable.ToSubstring());
}
#endif
void
@ -491,11 +500,13 @@ nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const sub
tuple.WriteTo(mData + cutStart, length);
}
#ifdef MOZ_V1_STRING_ABI
void
nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const abstract_string_type& readable )
{
Replace(cutStart, cutLength, readable.ToSubstring());
}
#endif
void
nsTSubstring_CharT::SetCapacity( size_type capacity )
@ -572,6 +583,7 @@ nsTSubstring_CharT::Equals( const self_type& str, const comparator_type& comp )
return mLength == str.mLength && comp(mData, str.mData, mLength) == 0;
}
#ifdef MOZ_V1_STRING_ABI
PRBool
nsTSubstring_CharT::Equals( const abstract_string_type& readable ) const
{
@ -589,6 +601,7 @@ nsTSubstring_CharT::Equals( const abstract_string_type& readable, const comparat
return mLength == length && comp(mData, data, mLength) == 0;
}
#endif
PRBool
nsTSubstring_CharT::Equals( const char_type* data ) const

View File

@ -62,4 +62,7 @@
/* Define to either <new> or <new.h> */
#undef NEW_H
/* Define if binary compatibility with Mozilla 1.x string code is desired */
#undef MOZ_V1_STRING_ABI
#endif /* _XPCOM_CONFIG_H_ */