зеркало из https://github.com/mozilla/pjs.git
fixes bug 324058 "Fix nsStringStream compilation warning about multiple SetData versions" r=biesi sr=bzbarsky
This commit is contained in:
Родитель
de06ca735d
Коммит
46dacadd3b
|
@ -104,6 +104,7 @@
|
|||
|
||||
#include "nsStringStream.h"
|
||||
extern NS_METHOD nsStringInputStreamConstructor(nsISupports *, REFNSIID, void **);
|
||||
NS_DECL_CLASSINFO(nsStringInputStream)
|
||||
|
||||
#include "nsFastLoadService.h"
|
||||
|
||||
|
@ -387,7 +388,8 @@ static const nsModuleComponentInfo components[] = {
|
|||
COMPONENT(PROCESS, nsProcessConstructor),
|
||||
COMPONENT(ENVIRONMENT, nsEnvironment::Create),
|
||||
|
||||
COMPONENT(STRINGINPUTSTREAM, nsStringInputStreamConstructor),
|
||||
COMPONENT_CI_FLAGS(STRINGINPUTSTREAM, nsStringInputStreamConstructor,
|
||||
nsStringInputStream, nsIClassInfo::THREADSAFE),
|
||||
COMPONENT(MULTIPLEXINPUTSTREAM, nsMultiplexInputStreamConstructor),
|
||||
|
||||
#ifndef MOZ_NO_FAST_LOAD
|
||||
|
|
|
@ -93,22 +93,3 @@ interface nsIStringInputStream : nsIInputStream
|
|||
*/
|
||||
[noscript] void shareData(in string data, in long dataLen);
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface provides a convenient attribute for setting and getting the
|
||||
* stream's data.
|
||||
*/
|
||||
[scriptable, uuid(0e36fe9e-ecbe-4088-b616-45672d1c3e94)]
|
||||
interface nsIStringInputStream2 : nsIStringInputStream
|
||||
{
|
||||
/**
|
||||
* Set or get this stream's data. The data may contain null characters.
|
||||
*
|
||||
* NOTE: JS callers should understand that assigning a JS string to this
|
||||
* attribute results in the high-byte of each character being discarded.
|
||||
* Likewise, assigning this attribute into a JS string results in the
|
||||
* high-byte of each character in the resulting JS string being set to
|
||||
* zero.
|
||||
*/
|
||||
attribute ACString data;
|
||||
};
|
||||
|
|
|
@ -54,27 +54,29 @@
|
|||
|
||||
#include "nsStringStream.h"
|
||||
#include "nsStreamUtils.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsCRT.h"
|
||||
#include "prerror.h"
|
||||
#include "plstr.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsISeekableStream.h"
|
||||
#include "nsInt64.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// nsIStringInputStream implementation
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class nsStringInputStream : public nsIStringInputStream2
|
||||
class nsStringInputStream : public nsIStringInputStream
|
||||
, public nsISeekableStream
|
||||
, public nsISupportsCString
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINPUTSTREAM
|
||||
NS_DECL_NSISTRINGINPUTSTREAM
|
||||
NS_DECL_NSISTRINGINPUTSTREAM2
|
||||
NS_DECL_NSISEEKABLESTREAM
|
||||
NS_DECL_NSISUPPORTSPRIMITIVE
|
||||
NS_DECL_NSISUPPORTSCSTRING
|
||||
|
||||
nsStringInputStream()
|
||||
: mData(nsnull)
|
||||
|
@ -113,20 +115,38 @@ private:
|
|||
|
||||
// This class needs to support threadsafe refcounting since people often
|
||||
// allocate a string stream, and then read it from a background thread.
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS4(nsStringInputStream,
|
||||
nsIStringInputStream,
|
||||
nsIStringInputStream2,
|
||||
nsIInputStream,
|
||||
nsISeekableStream)
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsStringInputStream)
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsStringInputStream)
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE4_CI(nsStringInputStream,
|
||||
nsIStringInputStream,
|
||||
nsIInputStream,
|
||||
nsISupportsCString,
|
||||
nsISeekableStream)
|
||||
NS_IMPL_CI_INTERFACE_GETTER4(nsStringInputStream,
|
||||
nsIStringInputStream,
|
||||
nsIInputStream,
|
||||
nsISupportsCString,
|
||||
nsISeekableStream)
|
||||
|
||||
/////////
|
||||
// nsIStringInputStream2 implementation
|
||||
// nsISupportsCString implementation
|
||||
/////////
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringInputStream::GetType(PRUint16 *type)
|
||||
{
|
||||
*type = TYPE_CSTRING;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringInputStream::GetData(nsACString &data)
|
||||
{
|
||||
NS_ENSURE_TRUE(mData, NS_ERROR_NOT_INITIALIZED);
|
||||
// The stream doesn't have any data when it is closed. We could fake it
|
||||
// and return an empty string here, but it seems better to keep this return
|
||||
// value consistent with the behavior of the other 'getter' methods.
|
||||
NS_ENSURE_TRUE(mData, NS_BASE_STREAM_CLOSED);
|
||||
|
||||
data.Assign(mData, mLength);
|
||||
return NS_OK;
|
||||
|
@ -140,6 +160,13 @@ nsStringInputStream::SetData(const nsACString &data)
|
|||
return SetData(iter.get(), iter.size_forward());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStringInputStream::ToString(char **result)
|
||||
{
|
||||
// NOTE: This method may result in data loss, so we do not implement it.
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/////////
|
||||
// nsIStringInputStream implementation
|
||||
/////////
|
||||
|
|
Загрузка…
Ссылка в новой задаче