diff --git a/mozilla/string/macbuild/string.mcp b/mozilla/string/macbuild/string.mcp index 47734466ebc..7d470586c63 100644 Binary files a/mozilla/string/macbuild/string.mcp and b/mozilla/string/macbuild/string.mcp differ diff --git a/mozilla/string/public/nsAFlatString.h b/mozilla/string/public/nsAFlatString.h index 48c717efc6f..5db9dbc3a50 100644 --- a/mozilla/string/public/nsAFlatString.h +++ b/mozilla/string/public/nsAFlatString.h @@ -26,60 +26,24 @@ #ifndef nsAFlatString_h___ #define nsAFlatString_h___ -#ifndef nsAString_h___ -#include "nsAString.h" +#ifndef nsASingleFragmenttring_h___ +#include "nsASingleFragmentString.h" #endif class NS_COM nsAFlatString - : public nsAString + : public nsASingleFragmentString { public: // don't really want this to be virtual, and won't after |obsolete_nsString| is really dead - virtual const char_type* get() const; - char_type operator[]( PRUint32 i ) const { return get()[ i ]; } - char_type CharAt( PRUint32 ) const; - - virtual PRUint32 Length() const; - -// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatString| - public: - virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const; - virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ); + virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); } }; class NS_COM nsAFlatCString - : public nsACString + : public nsASingleFragmentCString { public: // don't really want this to be virtual, and won't after |obsolete_nsCString| is really dead - virtual const char_type* get() const; - char_type operator[]( PRUint32 i ) const { return get()[ i ]; } - char_type CharAt( PRUint32 ) const; - - virtual PRUint32 Length() const; - -// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatCString| - public: - virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const; - virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ); + virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); } }; -inline -nsAFlatString::char_type -nsAFlatString::CharAt( PRUint32 i ) const - { - NS_ASSERTION(iDataStart() : 0; + } + // deprecated, to be eliminated operator const char_type*() const { return get(); } char_type operator[]( int i ) const { return get()[ i ]; } @@ -209,6 +217,14 @@ class NS_COM nsXPIDLCString void Adopt( char_type* aNewValue ) { *PrepareForUseAsOutParam() = aNewValue; } + // overridden to make getter_Copies mechanism work + const char_type* get() const + { + const buffer_handle_type* handle = GetBufferHandle(); + // NS_ASSERTION(handle, "handle is null!"); + return handle ? handle->DataStart() : 0; + } + // deprecated, to be eliminated operator const char_type*() const { return get(); } char_type operator[]( int i ) const { return get()[ i ]; } diff --git a/mozilla/string/src/nsAFlatString.cpp b/mozilla/string/src/nsAFlatString.cpp index ab4699c77ef..b3722ce4262 100644 --- a/mozilla/string/src/nsAFlatString.cpp +++ b/mozilla/string/src/nsAFlatString.cpp @@ -23,126 +23,3 @@ #include "nsAFlatString.h" -const nsAFlatString::char_type* -nsAFlatString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - const buffer_handle_type* buffer = GetBufferHandle(); - - if ( !buffer ) - return 0; - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -nsAFlatString::char_type* -nsAFlatString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle()); - NS_ASSERTION(buffer, "trouble: no buffer!"); - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -const nsAFlatCString::char_type* -nsAFlatCString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - const buffer_handle_type* buffer = GetBufferHandle(); - NS_ASSERTION(buffer, "trouble: no buffer!"); - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -nsAFlatCString::char_type* -nsAFlatCString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle()); - NS_ASSERTION(buffer, "trouble: no buffer!"); - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -PRUint32 -nsAFlatString::Length() const - { - const buffer_handle_type* handle = GetBufferHandle(); - return PRUint32(handle ? handle->DataLength() : 0); - } - -PRUint32 -nsAFlatCString::Length() const - { - const buffer_handle_type* handle = GetBufferHandle(); - return PRUint32(handle ? handle->DataLength() : 0); - } - -const nsAFlatString::char_type* -nsAFlatString::get() const - { - const buffer_handle_type* handle = GetBufferHandle(); - // NS_ASSERTION(handle, "handle is null!"); - return handle ? handle->DataStart() : 0; - } - -const nsAFlatCString::char_type* -nsAFlatCString::get() const - { - const buffer_handle_type* handle = GetBufferHandle(); - // NS_ASSERTION(handle, "handle is null!"); - return handle ? handle->DataStart() : 0; - } diff --git a/mozilla/xpcom/string/macbuild/string.mcp b/mozilla/xpcom/string/macbuild/string.mcp index 47734466ebc..7d470586c63 100644 Binary files a/mozilla/xpcom/string/macbuild/string.mcp and b/mozilla/xpcom/string/macbuild/string.mcp differ diff --git a/mozilla/xpcom/string/public/nsAFlatString.h b/mozilla/xpcom/string/public/nsAFlatString.h index 48c717efc6f..5db9dbc3a50 100644 --- a/mozilla/xpcom/string/public/nsAFlatString.h +++ b/mozilla/xpcom/string/public/nsAFlatString.h @@ -26,60 +26,24 @@ #ifndef nsAFlatString_h___ #define nsAFlatString_h___ -#ifndef nsAString_h___ -#include "nsAString.h" +#ifndef nsASingleFragmenttring_h___ +#include "nsASingleFragmentString.h" #endif class NS_COM nsAFlatString - : public nsAString + : public nsASingleFragmentString { public: // don't really want this to be virtual, and won't after |obsolete_nsString| is really dead - virtual const char_type* get() const; - char_type operator[]( PRUint32 i ) const { return get()[ i ]; } - char_type CharAt( PRUint32 ) const; - - virtual PRUint32 Length() const; - -// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatString| - public: - virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const; - virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ); + virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); } }; class NS_COM nsAFlatCString - : public nsACString + : public nsASingleFragmentCString { public: // don't really want this to be virtual, and won't after |obsolete_nsCString| is really dead - virtual const char_type* get() const; - char_type operator[]( PRUint32 i ) const { return get()[ i ]; } - char_type CharAt( PRUint32 ) const; - - virtual PRUint32 Length() const; - -// protected: // can't hide these (yet), since I call them from forwarding routines in |nsPromiseFlatCString| - public: - virtual const char_type* GetReadableFragment( const_fragment_type&, nsFragmentRequest, PRUint32 ) const; - virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ); + virtual const char_type* get() const { const char_type* temp; return BeginReading(temp); } }; -inline -nsAFlatString::char_type -nsAFlatString::CharAt( PRUint32 i ) const - { - NS_ASSERTION(iDataStart() : 0; + } + // deprecated, to be eliminated operator const char_type*() const { return get(); } char_type operator[]( int i ) const { return get()[ i ]; } @@ -209,6 +217,14 @@ class NS_COM nsXPIDLCString void Adopt( char_type* aNewValue ) { *PrepareForUseAsOutParam() = aNewValue; } + // overridden to make getter_Copies mechanism work + const char_type* get() const + { + const buffer_handle_type* handle = GetBufferHandle(); + // NS_ASSERTION(handle, "handle is null!"); + return handle ? handle->DataStart() : 0; + } + // deprecated, to be eliminated operator const char_type*() const { return get(); } char_type operator[]( int i ) const { return get()[ i ]; } diff --git a/mozilla/xpcom/string/src/nsAFlatString.cpp b/mozilla/xpcom/string/src/nsAFlatString.cpp index ab4699c77ef..b3722ce4262 100644 --- a/mozilla/xpcom/string/src/nsAFlatString.cpp +++ b/mozilla/xpcom/string/src/nsAFlatString.cpp @@ -23,126 +23,3 @@ #include "nsAFlatString.h" -const nsAFlatString::char_type* -nsAFlatString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - const buffer_handle_type* buffer = GetBufferHandle(); - - if ( !buffer ) - return 0; - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -nsAFlatString::char_type* -nsAFlatString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle()); - NS_ASSERTION(buffer, "trouble: no buffer!"); - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -const nsAFlatCString::char_type* -nsAFlatCString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - const buffer_handle_type* buffer = GetBufferHandle(); - NS_ASSERTION(buffer, "trouble: no buffer!"); - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -nsAFlatCString::char_type* -nsAFlatCString::GetWritableFragment( fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) - { - switch ( aRequest ) - { - case kFirstFragment: - case kLastFragment: - case kFragmentAt: - { - buffer_handle_type* buffer = NS_CONST_CAST(buffer_handle_type*, GetBufferHandle()); - NS_ASSERTION(buffer, "trouble: no buffer!"); - - aFragment.mEnd = buffer->DataEnd(); - return (aFragment.mStart = buffer->DataStart()) + aOffset; - } - - case kPrevFragment: - case kNextFragment: - default: - return 0; - } - } - -PRUint32 -nsAFlatString::Length() const - { - const buffer_handle_type* handle = GetBufferHandle(); - return PRUint32(handle ? handle->DataLength() : 0); - } - -PRUint32 -nsAFlatCString::Length() const - { - const buffer_handle_type* handle = GetBufferHandle(); - return PRUint32(handle ? handle->DataLength() : 0); - } - -const nsAFlatString::char_type* -nsAFlatString::get() const - { - const buffer_handle_type* handle = GetBufferHandle(); - // NS_ASSERTION(handle, "handle is null!"); - return handle ? handle->DataStart() : 0; - } - -const nsAFlatCString::char_type* -nsAFlatCString::get() const - { - const buffer_handle_type* handle = GetBufferHandle(); - // NS_ASSERTION(handle, "handle is null!"); - return handle ? handle->DataStart() : 0; - }