v8.h   v8.h 
skipping to change at line 1035 skipping to change at line 1035
* \return The number of characters copied to the buffer excluding the nu ll * \return The number of characters copied to the buffer excluding the nu ll
* terminator. For WriteUtf8: The number of bytes copied to the buffe r * terminator. For WriteUtf8: The number of bytes copied to the buffe r
* including the null terminator (if written). * including the null terminator (if written).
*/ */
enum WriteOptions { enum WriteOptions {
NO_OPTIONS = 0, NO_OPTIONS = 0,
HINT_MANY_WRITES_EXPECTED = 1, HINT_MANY_WRITES_EXPECTED = 1,
NO_NULL_TERMINATION = 2 NO_NULL_TERMINATION = 2
}; };
// 16-bit character codes.
V8EXPORT int Write(uint16_t* buffer, V8EXPORT int Write(uint16_t* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; // UTF-16 int options = NO_OPTIONS) const;
// ASCII characters.
V8EXPORT int WriteAscii(char* buffer, V8EXPORT int WriteAscii(char* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; // ASCII int options = NO_OPTIONS) const;
// UTF-8 encoded characters.
V8EXPORT int WriteUtf8(char* buffer, V8EXPORT int WriteUtf8(char* buffer,
int length = -1, int length = -1,
int* nchars_ref = NULL, int* nchars_ref = NULL,
int options = NO_OPTIONS) const; // UTF-8 int options = NO_OPTIONS) const;
/** /**
* A zero length string. * A zero length string.
*/ */
V8EXPORT static v8::Local<v8::String> Empty(); V8EXPORT static v8::Local<v8::String> Empty();
/** /**
* Returns true if the string is external * Returns true if the string is external
*/ */
V8EXPORT bool IsExternal() const; V8EXPORT bool IsExternal() const;
/** /**
* Returns true if the string is both external and ascii * Returns true if the string is both external and ASCII
*/ */
V8EXPORT bool IsExternalAscii() const; V8EXPORT bool IsExternalAscii() const;
class V8EXPORT ExternalStringResourceBase { // NOLINT class V8EXPORT ExternalStringResourceBase { // NOLINT
public: public:
virtual ~ExternalStringResourceBase() {} virtual ~ExternalStringResourceBase() {}
protected: protected:
ExternalStringResourceBase() {} ExternalStringResourceBase() {}
skipping to change at line 1116 skipping to change at line 1119
/** /**
* The length of the string. That is, the number of two-byte characters . * The length of the string. That is, the number of two-byte characters .
*/ */
virtual size_t length() const = 0; virtual size_t length() const = 0;
protected: protected:
ExternalStringResource() {} ExternalStringResource() {}
}; };
/** /**
* An ExternalAsciiStringResource is a wrapper around an ascii * An ExternalAsciiStringResource is a wrapper around an ASCII
* string buffer that resides outside V8's heap. Implement an * string buffer that resides outside V8's heap. Implement an
* ExternalAsciiStringResource to manage the life cycle of the * ExternalAsciiStringResource to manage the life cycle of the
* underlying buffer. Note that the string data must be immutable * underlying buffer. Note that the string data must be immutable
* and that the data must be strict 7-bit ASCII, not Latin1 or * and that the data must be strict (7-bit) ASCII, not Latin-1 or
* UTF-8, which would require special treatment internally in the * UTF-8, which would require special treatment internally in the
* engine and, in the case of UTF-8, do not allow efficient indexing. * engine and, in the case of UTF-8, do not allow efficient indexing.
* Use String::New or convert to 16 bit data for non-ASCII. * Use String::New or convert to 16 bit data for non-ASCII.
*/ */
class V8EXPORT ExternalAsciiStringResource class V8EXPORT ExternalAsciiStringResource
: public ExternalStringResourceBase { : public ExternalStringResourceBase {
public: public:
/** /**
* Override the destructor to manage the life cycle of the underlying * Override the destructor to manage the life cycle of the underlying
* buffer. * buffer.
*/ */
virtual ~ExternalAsciiStringResource() {} virtual ~ExternalAsciiStringResource() {}
/** The string data from the underlying buffer.*/ /** The string data from the underlying buffer.*/
virtual const char* data() const = 0; virtual const char* data() const = 0;
/** The number of ascii characters in the string.*/ /** The number of ASCII characters in the string.*/
virtual size_t length() const = 0; virtual size_t length() const = 0;
protected: protected:
ExternalAsciiStringResource() {} ExternalAsciiStringResource() {}
}; };
/** /**
* Get the ExternalStringResource for an external string. Returns * Get the ExternalStringResource for an external string. Returns
* NULL if IsExternal() doesn't return true. * NULL if IsExternal() doesn't return true.
*/ */
inline ExternalStringResource* GetExternalStringResource() const; inline ExternalStringResource* GetExternalStringResource() const;
/** /**
* Get the ExternalAsciiStringResource for an external ascii string. * Get the ExternalAsciiStringResource for an external ASCII string.
* Returns NULL if IsExternalAscii() doesn't return true. * Returns NULL if IsExternalAscii() doesn't return true.
*/ */
V8EXPORT ExternalAsciiStringResource* GetExternalAsciiStringResource() co nst; V8EXPORT ExternalAsciiStringResource* GetExternalAsciiStringResource() co nst;
static inline String* Cast(v8::Value* obj); static inline String* Cast(v8::Value* obj);
/** /**
* Allocates a new string from either utf-8 encoded or ascii data. * Allocates a new string from either UTF-8 encoded or ASCII data.
* The second parameter 'length' gives the buffer length. * The second parameter 'length' gives the buffer length.
* If the data is utf-8 encoded, the caller must * If the data is UTF-8 encoded, the caller must
* be careful to supply the length parameter. * be careful to supply the length parameter.
* If it is not given, the function calls * If it is not given, the function calls
* 'strlen' to determine the buffer length, it might be * 'strlen' to determine the buffer length, it might be
* wrong if 'data' contains a null character. * wrong if 'data' contains a null character.
*/ */
V8EXPORT static Local<String> New(const char* data, int length = -1); V8EXPORT static Local<String> New(const char* data, int length = -1);
/** Allocates a new string from utf16 data.*/ /** Allocates a new string from 16-bit character codes.*/
V8EXPORT static Local<String> New(const uint16_t* data, int length = -1); V8EXPORT static Local<String> New(const uint16_t* data, int length = -1);
/** Creates a symbol. Returns one if it exists already.*/ /** Creates a symbol. Returns one if it exists already.*/
V8EXPORT static Local<String> NewSymbol(const char* data, int length = -1 ); V8EXPORT static Local<String> NewSymbol(const char* data, int length = -1 );
/** /**
* Creates a new string by concatenating the left and the right strings * Creates a new string by concatenating the left and the right strings
* passed in as parameters. * passed in as parameters.
*/ */
V8EXPORT static Local<String> Concat(Handle<String> left, V8EXPORT static Local<String> Concat(Handle<String> left,
skipping to change at line 1202 skipping to change at line 1205
* in place so that existing references to this string in the JavaScript heap * in place so that existing references to this string in the JavaScript heap
* will use the external string resource. The external string resource's * will use the external string resource. The external string resource's
* character contents need to be equivalent to this string. * character contents need to be equivalent to this string.
* Returns true if the string has been changed to be an external string. * Returns true if the string has been changed to be an external string.
* The string is not modified if the operation fails. See NewExternal for * The string is not modified if the operation fails. See NewExternal for
* information on the lifetime of the resource. * information on the lifetime of the resource.
*/ */
V8EXPORT bool MakeExternal(ExternalStringResource* resource); V8EXPORT bool MakeExternal(ExternalStringResource* resource);
/** /**
* Creates a new external string using the ascii data defined in the give n * Creates a new external string using the ASCII data defined in the give n
* resource. When the external string is no longer live on V8's heap the * resource. When the external string is no longer live on V8's heap the
* resource will be disposed by calling its Dispose method. The caller of * resource will be disposed by calling its Dispose method. The caller of
* this function should not otherwise delete or modify the resource. Neit her * this function should not otherwise delete or modify the resource. Neit her
* should the underlying buffer be deallocated or modified except through the * should the underlying buffer be deallocated or modified except through the
* destructor of the external string resource. * destructor of the external string resource.
*/ */
V8EXPORT static Local<String> NewExternal( V8EXPORT static Local<String> NewExternal(
ExternalAsciiStringResource* resource); ExternalAsciiStringResource* resource);
/** /**
skipping to change at line 1228 skipping to change at line 1231
* The string is not modified if the operation fails. See NewExternal for * The string is not modified if the operation fails. See NewExternal for
* information on the lifetime of the resource. * information on the lifetime of the resource.
*/ */
V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource); V8EXPORT bool MakeExternal(ExternalAsciiStringResource* resource);
/** /**
* Returns true if this string can be made external. * Returns true if this string can be made external.
*/ */
V8EXPORT bool CanMakeExternal(); V8EXPORT bool CanMakeExternal();
/** Creates an undetectable string from the supplied ascii or utf-8 data. */ /** Creates an undetectable string from the supplied ASCII or UTF-8 data. */
V8EXPORT static Local<String> NewUndetectable(const char* data, V8EXPORT static Local<String> NewUndetectable(const char* data,
int length = -1); int length = -1);
/** Creates an undetectable string from the supplied utf-16 data.*/ /** Creates an undetectable string from the supplied 16-bit character cod es.*/
V8EXPORT static Local<String> NewUndetectable(const uint16_t* data, V8EXPORT static Local<String> NewUndetectable(const uint16_t* data,
int length = -1); int length = -1);
/** /**
* Converts an object to a utf8-encoded character array. Useful if * Converts an object to a UTF-8-encoded character array. Useful if
* you want to print the object. If conversion to a string fails * you want to print the object. If conversion to a string fails
* (eg. due to an exception in the toString() method of the object) * (e.g. due to an exception in the toString() method of the object)
* then the length() method returns 0 and the * operator returns * then the length() method returns 0 and the * operator returns
* NULL. * NULL.
*/ */
class V8EXPORT Utf8Value { class V8EXPORT Utf8Value {
public: public:
explicit Utf8Value(Handle<v8::Value> obj); explicit Utf8Value(Handle<v8::Value> obj);
~Utf8Value(); ~Utf8Value();
char* operator*() { return str_; } char* operator*() { return str_; }
const char* operator*() const { return str_; } const char* operator*() const { return str_; }
int length() const { return length_; } int length() const { return length_; }
private: private:
char* str_; char* str_;
int length_; int length_;
// Disallow copying and assigning. // Disallow copying and assigning.
Utf8Value(const Utf8Value&); Utf8Value(const Utf8Value&);
void operator=(const Utf8Value&); void operator=(const Utf8Value&);
}; };
/** /**
* Converts an object to an ascii string. * Converts an object to an ASCII string.
* Useful if you want to print the object. * Useful if you want to print the object.
* If conversion to a string fails (eg. due to an exception in the toStri ng() * If conversion to a string fails (eg. due to an exception in the toStri ng()
* method of the object) then the length() method returns 0 and the * ope rator * method of the object) then the length() method returns 0 and the * ope rator
* returns NULL. * returns NULL.
*/ */
class V8EXPORT AsciiValue { class V8EXPORT AsciiValue {
public: public:
explicit AsciiValue(Handle<v8::Value> obj); explicit AsciiValue(Handle<v8::Value> obj);
~AsciiValue(); ~AsciiValue();
char* operator*() { return str_; } char* operator*() { return str_; }
 End of changes. 18 change blocks. 
17 lines changed or deleted 20 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/