v8.h   v8.h 
skipping to change at line 604 skipping to change at line 604
/** /**
* Returns true if the source code could not be parsed. * Returns true if the source code could not be parsed.
*/ */
virtual bool HasError() = 0; virtual bool HasError() = 0;
}; };
/** /**
* The origin, within a file, of a script. * The origin, within a file, of a script.
*/ */
class ScriptOrigin { class V8EXPORT ScriptOrigin {
public: public:
V8_INLINE(ScriptOrigin( V8_INLINE(ScriptOrigin(
Handle<Value> resource_name, Handle<Value> resource_name,
Handle<Integer> resource_line_offset = Handle<Integer>(), Handle<Integer> resource_line_offset = Handle<Integer>(),
Handle<Integer> resource_column_offset = Handle<Integer>())) Handle<Integer> resource_column_offset = Handle<Integer>()))
: resource_name_(resource_name), : resource_name_(resource_name),
resource_line_offset_(resource_line_offset), resource_line_offset_(resource_line_offset),
resource_column_offset_(resource_column_offset) { } resource_column_offset_(resource_column_offset) { }
V8_INLINE(Handle<Value> ResourceName() const); V8_INLINE(Handle<Value> ResourceName() const);
V8_INLINE(Handle<Integer> ResourceLineOffset() const); V8_INLINE(Handle<Integer> ResourceLineOffset() const);
skipping to change at line 891 skipping to change at line 891
* constructor via "new". * constructor via "new".
*/ */
bool IsConstructor() const; bool IsConstructor() const;
}; };
// --- Value --- // --- Value ---
/** /**
* The superclass of all JavaScript values and objects. * The superclass of all JavaScript values and objects.
*/ */
class Value : public Data { class V8EXPORT Value : public Data {
public: public:
/** /**
* Returns true if this value is the undefined value. See ECMA-262 * Returns true if this value is the undefined value. See ECMA-262
* 4.3.10. * 4.3.10.
*/ */
V8_INLINE(bool IsUndefined() const); V8_INLINE(bool IsUndefined() const);
/** /**
* Returns true if this value is the null value. See ECMA-262 * Returns true if this value is the null value. See ECMA-262
* 4.3.11. * 4.3.11.
*/ */
V8_INLINE(bool IsNull() const); V8_INLINE(bool IsNull() const);
/** /**
* Returns true if this value is true. * Returns true if this value is true.
*/ */
V8EXPORT bool IsTrue() const; bool IsTrue() const;
/** /**
* Returns true if this value is false. * Returns true if this value is false.
*/ */
V8EXPORT bool IsFalse() const; bool IsFalse() const;
/** /**
* Returns true if this value is an instance of the String type. * Returns true if this value is an instance of the String type.
* See ECMA-262 8.4. * See ECMA-262 8.4.
*/ */
V8_INLINE(bool IsString() const); V8_INLINE(bool IsString() const);
/** /**
* Returns true if this value is a function. * Returns true if this value is a function.
*/ */
V8EXPORT bool IsFunction() const; bool IsFunction() const;
/** /**
* Returns true if this value is an array. * Returns true if this value is an array.
*/ */
V8EXPORT bool IsArray() const; bool IsArray() const;
/** /**
* Returns true if this value is an object. * Returns true if this value is an object.
*/ */
V8EXPORT bool IsObject() const; bool IsObject() const;
/** /**
* Returns true if this value is boolean. * Returns true if this value is boolean.
*/ */
V8EXPORT bool IsBoolean() const; bool IsBoolean() const;
/** /**
* Returns true if this value is a number. * Returns true if this value is a number.
*/ */
V8EXPORT bool IsNumber() const; bool IsNumber() const;
/** /**
* Returns true if this value is external. * Returns true if this value is external.
*/ */
V8EXPORT bool IsExternal() const; bool IsExternal() const;
/** /**
* Returns true if this value is a 32-bit signed integer. * Returns true if this value is a 32-bit signed integer.
*/ */
V8EXPORT bool IsInt32() const; bool IsInt32() const;
/** /**
* Returns true if this value is a 32-bit unsigned integer. * Returns true if this value is a 32-bit unsigned integer.
*/ */
V8EXPORT bool IsUint32() const; bool IsUint32() const;
/** /**
* Returns true if this value is a Date. * Returns true if this value is a Date.
*/ */
V8EXPORT bool IsDate() const; bool IsDate() const;
/** /**
* Returns true if this value is a Boolean object. * Returns true if this value is a Boolean object.
*/ */
V8EXPORT bool IsBooleanObject() const; bool IsBooleanObject() const;
/** /**
* Returns true if this value is a Number object. * Returns true if this value is a Number object.
*/ */
V8EXPORT bool IsNumberObject() const; bool IsNumberObject() const;
/** /**
* Returns true if this value is a String object. * Returns true if this value is a String object.
*/ */
V8EXPORT bool IsStringObject() const; bool IsStringObject() const;
/** /**
* Returns true if this value is a NativeError. * Returns true if this value is a NativeError.
*/ */
V8EXPORT bool IsNativeError() const; bool IsNativeError() const;
/** /**
* Returns true if this value is a RegExp. * Returns true if this value is a RegExp.
*/ */
V8EXPORT bool IsRegExp() const; bool IsRegExp() const;
V8EXPORT Local<Boolean> ToBoolean() const; Local<Boolean> ToBoolean() const;
V8EXPORT Local<Number> ToNumber() const; Local<Number> ToNumber() const;
V8EXPORT Local<String> ToString() const; Local<String> ToString() const;
V8EXPORT Local<String> ToDetailString() const; Local<String> ToDetailString() const;
V8EXPORT Local<Object> ToObject() const; Local<Object> ToObject() const;
V8EXPORT Local<Integer> ToInteger() const; Local<Integer> ToInteger() const;
V8EXPORT Local<Uint32> ToUint32() const; Local<Uint32> ToUint32() const;
V8EXPORT Local<Int32> ToInt32() const; Local<Int32> ToInt32() const;
/** /**
* Attempts to convert a string to an array index. * Attempts to convert a string to an array index.
* Returns an empty handle if the conversion fails. * Returns an empty handle if the conversion fails.
*/ */
V8EXPORT Local<Uint32> ToArrayIndex() const; Local<Uint32> ToArrayIndex() const;
V8EXPORT bool BooleanValue() const; bool BooleanValue() const;
V8EXPORT double NumberValue() const; double NumberValue() const;
V8EXPORT int64_t IntegerValue() const; int64_t IntegerValue() const;
V8EXPORT uint32_t Uint32Value() const; uint32_t Uint32Value() const;
V8EXPORT int32_t Int32Value() const; int32_t Int32Value() const;
/** JS == */ /** JS == */
V8EXPORT bool Equals(Handle<Value> that) const; bool Equals(Handle<Value> that) const;
V8EXPORT bool StrictEquals(Handle<Value> that) const; bool StrictEquals(Handle<Value> that) const;
private: private:
V8_INLINE(bool QuickIsUndefined() const); V8_INLINE(bool QuickIsUndefined() const);
V8_INLINE(bool QuickIsNull() const); V8_INLINE(bool QuickIsNull() const);
V8_INLINE(bool QuickIsString() const); V8_INLINE(bool QuickIsString() const);
V8EXPORT bool FullIsUndefined() const; bool FullIsUndefined() const;
V8EXPORT bool FullIsNull() const; bool FullIsNull() const;
V8EXPORT bool FullIsString() const; bool FullIsString() const;
}; };
/** /**
* The superclass of primitive values. See ECMA-262 4.3.2. * The superclass of primitive values. See ECMA-262 4.3.2.
*/ */
class Primitive : public Value { }; class V8EXPORT Primitive : public Value { };
/** /**
* A primitive boolean value (ECMA-262, 4.3.14). Either the true * A primitive boolean value (ECMA-262, 4.3.14). Either the true
* or false value. * or false value.
*/ */
class Boolean : public Primitive { class V8EXPORT Boolean : public Primitive {
public: public:
V8EXPORT bool Value() const; bool Value() const;
V8_INLINE(static Handle<Boolean> New(bool value)); V8_INLINE(static Handle<Boolean> New(bool value));
}; };
/** /**
* A JavaScript string value (ECMA-262, 4.3.17). * A JavaScript string value (ECMA-262, 4.3.17).
*/ */
class String : public Primitive { class V8EXPORT String : public Primitive {
public: public:
enum Encoding { enum Encoding {
UNKNOWN_ENCODING = 0x1, UNKNOWN_ENCODING = 0x1,
TWO_BYTE_ENCODING = 0x0, TWO_BYTE_ENCODING = 0x0,
ASCII_ENCODING = 0x4 ASCII_ENCODING = 0x4,
ONE_BYTE_ENCODING = 0x4
}; };
/** /**
* Returns the number of characters in this string. * Returns the number of characters in this string.
*/ */
V8EXPORT int Length() const; int Length() const;
/** /**
* Returns the number of bytes in the UTF-8 encoded * Returns the number of bytes in the UTF-8 encoded
* representation of this string. * representation of this string.
*/ */
V8EXPORT int Utf8Length() const; int Utf8Length() const;
/** /**
* A fast conservative check for non-ASCII characters. May * A fast conservative check for non-ASCII characters. May
* return true even for ASCII strings, but if it returns * return true even for ASCII strings, but if it returns
* false you can be sure that all characters are in the range * false you can be sure that all characters are in the range
* 0-127. * 0-127.
*/ */
V8EXPORT bool MayContainNonAscii() const; bool MayContainNonAscii() const;
/**
* Returns whether this string contains only one byte data.
*/
V8EXPORT bool IsOneByte() const;
/** /**
* Write the contents of the string to an external buffer. * Write the contents of the string to an external buffer.
* If no arguments are given, expects the buffer to be large * If no arguments are given, expects the buffer to be large
* enough to hold the entire string and NULL terminator. Copies * enough to hold the entire string and NULL terminator. Copies
* the contents of the string and the NULL terminator into the * the contents of the string and the NULL terminator into the
* buffer. * buffer.
* *
* WriteUtf8 will not write partial UTF-8 sequences, preferring to stop * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop
* before the end of the buffer. * before the end of the buffer.
skipping to change at line 1102 skipping to change at line 1108
* 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,
PRESERVE_ASCII_NULL = 4 PRESERVE_ASCII_NULL = 4
}; };
// 16-bit character codes. // 16-bit character codes.
V8EXPORT int Write(uint16_t* buffer, int Write(uint16_t* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// ASCII characters. // ASCII characters.
V8EXPORT int WriteAscii(char* buffer, int WriteAscii(char* buffer,
int start = 0, int start = 0,
int length = -1, int length = -1,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
// One byte characters.
V8EXPORT int WriteOneByte(uint8_t* buffer,
int start = 0,
int length = -1,
int options = NO_OPTIONS) const;
// UTF-8 encoded characters. // UTF-8 encoded characters.
V8EXPORT int WriteUtf8(char* buffer, int WriteUtf8(char* buffer,
int length = -1, int length = -1,
int* nchars_ref = NULL, int* nchars_ref = NULL,
int options = NO_OPTIONS) const; int options = NO_OPTIONS) const;
/** /**
* A zero length string. * A zero length string.
*/ */
V8EXPORT static v8::Local<v8::String> Empty(); static v8::Local<v8::String> Empty();
V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate)); V8_INLINE(static v8::Local<v8::String> Empty(Isolate* isolate));
/** /**
* Returns true if the string is external * Returns true if the string is external
*/ */
V8EXPORT bool IsExternal() const; 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; bool IsExternalAscii() const;
class V8EXPORT ExternalStringResourceBase { // NOLINT class V8EXPORT ExternalStringResourceBase { // NOLINT
public: public:
virtual ~ExternalStringResourceBase() {} virtual ~ExternalStringResourceBase() {}
protected: protected:
ExternalStringResourceBase() {} ExternalStringResourceBase() {}
/** /**
* Internally V8 will call this Dispose method when the external string * Internally V8 will call this Dispose method when the external string
skipping to change at line 1212 skipping to change at line 1223
*/ */
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() {}
}; };
typedef ExternalAsciiStringResource ExternalOneByteStringResource;
/** /**
* If the string is an external string, return the ExternalStringResource Base * If the string is an external string, return the ExternalStringResource Base
* regardless of the encoding, otherwise return NULL. The encoding of th e * regardless of the encoding, otherwise return NULL. The encoding of th e
* string is returned in encoding_out. * string is returned in encoding_out.
*/ */
V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase( V8_INLINE(ExternalStringResourceBase* GetExternalStringResourceBase(
Encoding* encoding_out) const); Encoding* encoding_out) const);
/** /**
* 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.
*/ */
V8_INLINE(ExternalStringResource* GetExternalStringResource() const); V8_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 const ExternalAsciiStringResource* GetExternalAsciiStringResourc const ExternalAsciiStringResource* GetExternalAsciiStringResource() const
e() ;
const;
V8_INLINE(static String* Cast(v8::Value* obj)); V8_INLINE(static 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. If omitted, * The second parameter 'length' gives the buffer length. If omitted,
* the function calls 'strlen' to determine the buffer length. * the function calls 'strlen' to determine the buffer length.
*/ */
V8EXPORT static Local<String> New(const char* data, int length = -1); static Local<String> New(const char* data, int length = -1);
/** Allocates a new string from 16-bit character codes.*/ /** Allocates a new string from 16-bit character codes.*/
V8EXPORT static Local<String> New(const uint16_t* data, int length = -1); 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 ); 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, static Local<String> Concat(Handle<String> left, Handle<String> right);
Handle<String> right);
/** /**
* Creates a new external string using the data defined in the given * Creates a new external string using the data defined in the given
* 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(ExternalStringResource* resourc e); static Local<String> NewExternal(ExternalStringResource* resource);
/** /**
* Associate an external string resource with this string by transforming it * Associate an external string resource with this string by transforming it
* 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); 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( */
ExternalAsciiStringResource* resource); static Local<String> NewExternal(ExternalAsciiStringResource* resource);
/** /**
* Associate an external string resource with this string by transforming it * Associate an external string resource with this string by transforming it
* 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(ExternalAsciiStringResource* resource); 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(); 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, static Local<String> NewUndetectable(const char* data, int length = -1);
int length = -1);
/** Creates an undetectable string from the supplied 16-bit character cod es.*/ /** Creates an undetectable string from the supplied 16-bit character cod es.*/
V8EXPORT static Local<String> NewUndetectable(const uint16_t* data, static Local<String> NewUndetectable(const uint16_t* data, int length = -
int length = -1); 1);
/** /**
* Converts an object to a UTF-8-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
* (e.g. 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:
skipping to change at line 1379 skipping to change at line 1388
private: private:
uint16_t* str_; uint16_t* str_;
int length_; int length_;
// Disallow copying and assigning. // Disallow copying and assigning.
Value(const Value&); Value(const Value&);
void operator=(const Value&); void operator=(const Value&);
}; };
private: private:
V8EXPORT void VerifyExternalStringResourceBase(ExternalStringResourceBase void VerifyExternalStringResourceBase(ExternalStringResourceBase* v,
* v, Encoding encoding) const;
Encoding encoding) const; void VerifyExternalStringResource(ExternalStringResource* val) const;
V8EXPORT void VerifyExternalStringResource(ExternalStringResource* val) c static void CheckCast(v8::Value* obj);
onst;
V8EXPORT static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript number value (ECMA-262, 4.3.20) * A JavaScript number value (ECMA-262, 4.3.20)
*/ */
class Number : public Primitive { class V8EXPORT Number : public Primitive {
public: public:
V8EXPORT double Value() const; double Value() const;
V8EXPORT static Local<Number> New(double value); static Local<Number> New(double value);
V8_INLINE(static Number* Cast(v8::Value* obj)); V8_INLINE(static Number* Cast(v8::Value* obj));
private: private:
V8EXPORT Number(); Number();
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript value representing a signed integer. * A JavaScript value representing a signed integer.
*/ */
class Integer : public Number { class V8EXPORT Integer : public Number {
public: public:
V8EXPORT static Local<Integer> New(int32_t value); static Local<Integer> New(int32_t value);
V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value); static Local<Integer> NewFromUnsigned(uint32_t value);
V8EXPORT static Local<Integer> New(int32_t value, Isolate*); static Local<Integer> New(int32_t value, Isolate*);
V8EXPORT static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*); static Local<Integer> NewFromUnsigned(uint32_t value, Isolate*);
V8EXPORT int64_t Value() const; int64_t Value() const;
V8_INLINE(static Integer* Cast(v8::Value* obj)); V8_INLINE(static Integer* Cast(v8::Value* obj));
private: private:
V8EXPORT Integer(); Integer();
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript value representing a 32-bit signed integer. * A JavaScript value representing a 32-bit signed integer.
*/ */
class Int32 : public Integer { class V8EXPORT Int32 : public Integer {
public: public:
V8EXPORT int32_t Value() const; int32_t Value() const;
private: private:
V8EXPORT Int32(); Int32();
}; };
/** /**
* A JavaScript value representing a 32-bit unsigned integer. * A JavaScript value representing a 32-bit unsigned integer.
*/ */
class Uint32 : public Integer { class V8EXPORT Uint32 : public Integer {
public: public:
V8EXPORT uint32_t Value() const; uint32_t Value() const;
private: private:
V8EXPORT Uint32(); Uint32();
}; };
enum PropertyAttribute { enum PropertyAttribute {
None = 0, None = 0,
ReadOnly = 1 << 0, ReadOnly = 1 << 0,
DontEnum = 1 << 1, DontEnum = 1 << 1,
DontDelete = 1 << 2 DontDelete = 1 << 2
}; };
enum ExternalArrayType { enum ExternalArrayType {
skipping to change at line 1488 skipping to change at line 1497
enum AccessControl { enum AccessControl {
DEFAULT = 0, DEFAULT = 0,
ALL_CAN_READ = 1, ALL_CAN_READ = 1,
ALL_CAN_WRITE = 1 << 1, ALL_CAN_WRITE = 1 << 1,
PROHIBITS_OVERWRITING = 1 << 2 PROHIBITS_OVERWRITING = 1 << 2
}; };
/** /**
* A JavaScript object (ECMA-262, 4.3.3) * A JavaScript object (ECMA-262, 4.3.3)
*/ */
class Object : public Value { class V8EXPORT Object : public Value {
public: public:
V8EXPORT bool Set(Handle<Value> key, bool Set(Handle<Value> key,
Handle<Value> value, Handle<Value> value,
PropertyAttribute attribs = None); PropertyAttribute attribs = None);
V8EXPORT bool Set(uint32_t index, bool Set(uint32_t index, Handle<Value> value);
Handle<Value> value);
// Sets a local property on this object bypassing interceptors and // Sets a local property on this object bypassing interceptors and
// overriding accessors or read-only properties. // overriding accessors or read-only properties.
// //
// Note that if the object has an interceptor the property will be set // Note that if the object has an interceptor the property will be set
// locally, but since the interceptor takes precedence the local property // locally, but since the interceptor takes precedence the local property
// will only be returned if the interceptor doesn't return a value. // will only be returned if the interceptor doesn't return a value.
// //
// Note also that this only works for named properties. // Note also that this only works for named properties.
V8EXPORT bool ForceSet(Handle<Value> key, bool ForceSet(Handle<Value> key,
Handle<Value> value, Handle<Value> value,
PropertyAttribute attribs = None); PropertyAttribute attribs = None);
V8EXPORT Local<Value> Get(Handle<Value> key); Local<Value> Get(Handle<Value> key);
V8EXPORT Local<Value> Get(uint32_t index); Local<Value> Get(uint32_t index);
/** /**
* Gets the property attributes of a property which can be None or * Gets the property attributes of a property which can be None or
* any combination of ReadOnly, DontEnum and DontDelete. Returns * any combination of ReadOnly, DontEnum and DontDelete. Returns
* None when the property doesn't exist. * None when the property doesn't exist.
*/ */
V8EXPORT PropertyAttribute GetPropertyAttributes(Handle<Value> key); PropertyAttribute GetPropertyAttributes(Handle<Value> key);
// TODO(1245389): Replace the type-specific versions of these // TODO(1245389): Replace the type-specific versions of these
// functions with generic ones that accept a Handle<Value> key. // functions with generic ones that accept a Handle<Value> key.
V8EXPORT bool Has(Handle<String> key); bool Has(Handle<String> key);
V8EXPORT bool Delete(Handle<String> key); bool Delete(Handle<String> key);
// Delete a property on this object bypassing interceptors and // Delete a property on this object bypassing interceptors and
// ignoring dont-delete attributes. // ignoring dont-delete attributes.
V8EXPORT bool ForceDelete(Handle<Value> key); bool ForceDelete(Handle<Value> key);
V8EXPORT bool Has(uint32_t index); bool Has(uint32_t index);
V8EXPORT bool Delete(uint32_t index); bool Delete(uint32_t index);
V8EXPORT bool SetAccessor(Handle<String> name, bool SetAccessor(Handle<String> name,
AccessorGetter getter, AccessorGetter getter,
AccessorSetter setter = 0, AccessorSetter setter = 0,
Handle<Value> data = Handle<Value>(), Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT, AccessControl settings = DEFAULT,
PropertyAttribute attribute = None); PropertyAttribute attribute = None);
/** /**
* Returns an array containing the names of the enumerable properties * Returns an array containing the names of the enumerable properties
* of this object, including properties from prototype objects. The * of this object, including properties from prototype objects. The
* array returned by this method contains the same values as would * array returned by this method contains the same values as would
* be enumerated by a for-in statement over this object. * be enumerated by a for-in statement over this object.
*/ */
V8EXPORT Local<Array> GetPropertyNames(); Local<Array> GetPropertyNames();
/** /**
* This function has the same functionality as GetPropertyNames but * This function has the same functionality as GetPropertyNames but
* the returned array doesn't contain the names of properties from * the returned array doesn't contain the names of properties from
* prototype objects. * prototype objects.
*/ */
V8EXPORT Local<Array> GetOwnPropertyNames(); Local<Array> GetOwnPropertyNames();
/** /**
* Get the prototype object. This does not skip objects marked to * Get the prototype object. This does not skip objects marked to
* be skipped by __proto__ and it does not consult the security * be skipped by __proto__ and it does not consult the security
* handler. * handler.
*/ */
V8EXPORT Local<Value> GetPrototype(); Local<Value> GetPrototype();
/** /**
* Set the prototype object. This does not skip objects marked to * Set the prototype object. This does not skip objects marked to
* be skipped by __proto__ and it does not consult the security * be skipped by __proto__ and it does not consult the security
* handler. * handler.
*/ */
V8EXPORT bool SetPrototype(Handle<Value> prototype); bool SetPrototype(Handle<Value> prototype);
/** /**
* Finds an instance of the given function template in the prototype * Finds an instance of the given function template in the prototype
* chain. * chain.
*/ */
V8EXPORT Local<Object> FindInstanceInPrototypeChain( Local<Object> FindInstanceInPrototypeChain(Handle<FunctionTemplate> tmpl)
Handle<FunctionTemplate> tmpl); ;
/** /**
* Call builtin Object.prototype.toString on this object. * Call builtin Object.prototype.toString on this object.
* This is different from Value::ToString() that may call * This is different from Value::ToString() that may call
* user-defined toString function. This one does not. * user-defined toString function. This one does not.
*/ */
V8EXPORT Local<String> ObjectProtoToString(); Local<String> ObjectProtoToString();
/** /**
* Returns the function invoked as a constructor for this object. * Returns the function invoked as a constructor for this object.
* May be the null value. * May be the null value.
*/ */
V8EXPORT Local<Value> GetConstructor(); Local<Value> GetConstructor();
/** /**
* Returns the name of the function invoked as a constructor for this obj ect. * Returns the name of the function invoked as a constructor for this obj ect.
*/ */
V8EXPORT Local<String> GetConstructorName(); Local<String> GetConstructorName();
/** Gets the number of internal fields for this Object. */ /** Gets the number of internal fields for this Object. */
V8EXPORT int InternalFieldCount(); int InternalFieldCount();
/** Gets the value from an internal field. */ /** Gets the value from an internal field. */
V8_INLINE(Local<Value> GetInternalField(int index)); V8_INLINE(Local<Value> GetInternalField(int index));
/** Sets the value in an internal field. */ /** Sets the value in an internal field. */
V8EXPORT void SetInternalField(int index, Handle<Value> value); void SetInternalField(int index, Handle<Value> value);
/**
* Gets a native pointer from an internal field. Deprecated. If the point
er is
* always 2-byte-aligned, use GetAlignedPointerFromInternalField instead,
* otherwise use a combination of GetInternalField, External::Cast and
* External::Value.
*/
V8EXPORT V8_DEPRECATED(void* GetPointerFromInternalField(int index));
/**
* Sets a native pointer in an internal field. Deprecated. If the pointer
is
* always 2-byte aligned, use SetAlignedPointerInInternalField instead,
* otherwise use a combination of External::New and SetInternalField.
*/
V8_DEPRECATED(V8_INLINE(void SetPointerInInternalField(int index,
void* value)));
/** /**
* Gets a 2-byte-aligned native pointer from an internal field. This fiel d * Gets a 2-byte-aligned native pointer from an internal field. This fiel d
* must have been set by SetAlignedPointerInInternalField, everything els e * must have been set by SetAlignedPointerInInternalField, everything els e
* leads to undefined behavior. * leads to undefined behavior.
*/ */
V8_INLINE(void* GetAlignedPointerFromInternalField(int index)); V8_INLINE(void* GetAlignedPointerFromInternalField(int index));
/** /**
* Sets a 2-byte-aligned native pointer in an internal field. To retrieve such * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such
* a field, GetAlignedPointerFromInternalField must be used, everything e lse * a field, GetAlignedPointerFromInternalField must be used, everything e lse
* leads to undefined behavior. * leads to undefined behavior.
*/ */
V8EXPORT void SetAlignedPointerInInternalField(int index, void* value); void SetAlignedPointerInInternalField(int index, void* value);
// Testers for local properties. // Testers for local properties.
V8EXPORT bool HasOwnProperty(Handle<String> key); bool HasOwnProperty(Handle<String> key);
V8EXPORT bool HasRealNamedProperty(Handle<String> key); bool HasRealNamedProperty(Handle<String> key);
V8EXPORT bool HasRealIndexedProperty(uint32_t index); bool HasRealIndexedProperty(uint32_t index);
V8EXPORT bool HasRealNamedCallbackProperty(Handle<String> key); bool HasRealNamedCallbackProperty(Handle<String> key);
/** /**
* If result.IsEmpty() no real property was located in the prototype chai n. * If result.IsEmpty() no real property was located in the prototype chai n.
* This means interceptors in the prototype chain are not called. * This means interceptors in the prototype chain are not called.
*/ */
V8EXPORT Local<Value> GetRealNamedPropertyInPrototypeChain( Local<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key);
Handle<String> key);
/** /**
* If result.IsEmpty() no real property was located on the object or * If result.IsEmpty() no real property was located on the object or
* in the prototype chain. * in the prototype chain.
* This means interceptors in the prototype chain are not called. * This means interceptors in the prototype chain are not called.
*/ */
V8EXPORT Local<Value> GetRealNamedProperty(Handle<String> key); Local<Value> GetRealNamedProperty(Handle<String> key);
/** Tests for a named lookup interceptor.*/ /** Tests for a named lookup interceptor.*/
V8EXPORT bool HasNamedLookupInterceptor(); bool HasNamedLookupInterceptor();
/** Tests for an index lookup interceptor.*/ /** Tests for an index lookup interceptor.*/
V8EXPORT bool HasIndexedLookupInterceptor(); bool HasIndexedLookupInterceptor();
/** /**
* Turns on access check on the object if the object is an instance of * Turns on access check on the object if the object is an instance of
* a template that has access check callbacks. If an object has no * a template that has access check callbacks. If an object has no
* access check info, the object cannot be accessed by anyone. * access check info, the object cannot be accessed by anyone.
*/ */
V8EXPORT void TurnOnAccessCheck(); void TurnOnAccessCheck();
/** /**
* Returns the identity hash for this object. The current implementation * Returns the identity hash for this object. The current implementation
* uses a hidden property on the object to store the identity hash. * uses a hidden property on the object to store the identity hash.
* *
* The return value will never be 0. Also, it is not guaranteed to be * The return value will never be 0. Also, it is not guaranteed to be
* unique. * unique.
*/ */
V8EXPORT int GetIdentityHash(); int GetIdentityHash();
/** /**
* Access hidden properties on JavaScript objects. These properties are * Access hidden properties on JavaScript objects. These properties are
* hidden from the executing JavaScript and only accessible through the V 8 * hidden from the executing JavaScript and only accessible through the V 8
* C++ API. Hidden properties introduced by V8 internally (for example th e * C++ API. Hidden properties introduced by V8 internally (for example th e
* identity hash) are prefixed with "v8::". * identity hash) are prefixed with "v8::".
*/ */
V8EXPORT bool SetHiddenValue(Handle<String> key, Handle<Value> value); bool SetHiddenValue(Handle<String> key, Handle<Value> value);
V8EXPORT Local<Value> GetHiddenValue(Handle<String> key); Local<Value> GetHiddenValue(Handle<String> key);
V8EXPORT bool DeleteHiddenValue(Handle<String> key); bool DeleteHiddenValue(Handle<String> key);
/** /**
* Returns true if this is an instance of an api function (one * Returns true if this is an instance of an api function (one
* created from a function created from a function template) and has * created from a function created from a function template) and has
* been modified since it was created. Note that this method is * been modified since it was created. Note that this method is
* conservative and may return true for objects that haven't actually * conservative and may return true for objects that haven't actually
* been modified. * been modified.
*/ */
V8EXPORT bool IsDirty(); bool IsDirty();
/** /**
* Clone this object with a fast but shallow copy. Values will point * Clone this object with a fast but shallow copy. Values will point
* to the same values as the original object. * to the same values as the original object.
*/ */
V8EXPORT Local<Object> Clone(); Local<Object> Clone();
/** /**
* Returns the context in which the object was created. * Returns the context in which the object was created.
*/ */
V8EXPORT Local<Context> CreationContext(); Local<Context> CreationContext();
/** /**
* Set the backing store of the indexed properties to be managed by the * Set the backing store of the indexed properties to be managed by the
* embedding layer. Access to the indexed properties will follow the rule s * embedding layer. Access to the indexed properties will follow the rule s
* spelled out in CanvasPixelArray. * spelled out in CanvasPixelArray.
* Note: The embedding program still owns the data and needs to ensure th at * Note: The embedding program still owns the data and needs to ensure th at
* the backing store is preserved while V8 has a reference. * the backing store is preserved while V8 has a reference.
*/ */
V8EXPORT void SetIndexedPropertiesToPixelData(uint8_t* data, int length); void SetIndexedPropertiesToPixelData(uint8_t* data, int length);
V8EXPORT bool HasIndexedPropertiesInPixelData(); bool HasIndexedPropertiesInPixelData();
V8EXPORT uint8_t* GetIndexedPropertiesPixelData(); uint8_t* GetIndexedPropertiesPixelData();
V8EXPORT int GetIndexedPropertiesPixelDataLength(); int GetIndexedPropertiesPixelDataLength();
/** /**
* Set the backing store of the indexed properties to be managed by the * Set the backing store of the indexed properties to be managed by the
* embedding layer. Access to the indexed properties will follow the rule s * embedding layer. Access to the indexed properties will follow the rule s
* spelled out for the CanvasArray subtypes in the WebGL specification. * spelled out for the CanvasArray subtypes in the WebGL specification.
* Note: The embedding program still owns the data and needs to ensure th at * Note: The embedding program still owns the data and needs to ensure th at
* the backing store is preserved while V8 has a reference. * the backing store is preserved while V8 has a reference.
*/ */
V8EXPORT void SetIndexedPropertiesToExternalArrayData( void SetIndexedPropertiesToExternalArrayData(void* data,
void* data, ExternalArrayType array_type
ExternalArrayType array_type, ,
int number_of_elements); int number_of_elements);
V8EXPORT bool HasIndexedPropertiesInExternalArrayData(); bool HasIndexedPropertiesInExternalArrayData();
V8EXPORT void* GetIndexedPropertiesExternalArrayData(); void* GetIndexedPropertiesExternalArrayData();
V8EXPORT ExternalArrayType GetIndexedPropertiesExternalArrayDataType(); ExternalArrayType GetIndexedPropertiesExternalArrayDataType();
V8EXPORT int GetIndexedPropertiesExternalArrayDataLength(); int GetIndexedPropertiesExternalArrayDataLength();
/** /**
* Checks whether a callback is set by the * Checks whether a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method. * ObjectTemplate::SetCallAsFunctionHandler method.
* When an Object is callable this method returns true. * When an Object is callable this method returns true.
*/ */
V8EXPORT bool IsCallable(); bool IsCallable();
/** /**
* Call an Object as a function if a callback is set by the * Call an Object as a function if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method. * ObjectTemplate::SetCallAsFunctionHandler method.
*/ */
V8EXPORT Local<Value> CallAsFunction(Handle<Object> recv, Local<Value> CallAsFunction(Handle<Object> recv,
int argc, int argc,
Handle<Value> argv[]); Handle<Value> argv[]);
/** /**
* Call an Object as a constructor if a callback is set by the * Call an Object as a constructor if a callback is set by the
* ObjectTemplate::SetCallAsFunctionHandler method. * ObjectTemplate::SetCallAsFunctionHandler method.
* Note: This method behaves like the Function::NewInstance method. * Note: This method behaves like the Function::NewInstance method.
*/ */
V8EXPORT Local<Value> CallAsConstructor(int argc, Local<Value> CallAsConstructor(int argc, Handle<Value> argv[]);
Handle<Value> argv[]);
V8EXPORT static Local<Object> New(); static Local<Object> New();
V8_INLINE(static Object* Cast(Value* obj)); V8_INLINE(static Object* Cast(Value* obj));
private: private:
V8EXPORT Object(); Object();
V8EXPORT static void CheckCast(Value* obj); static void CheckCast(Value* obj);
V8EXPORT Local<Value> SlowGetInternalField(int index); Local<Value> SlowGetInternalField(int index);
V8EXPORT void* SlowGetAlignedPointerFromInternalField(int index); void* SlowGetAlignedPointerFromInternalField(int index);
}; };
/** /**
* An instance of the built-in array constructor (ECMA-262, 15.4.2). * An instance of the built-in array constructor (ECMA-262, 15.4.2).
*/ */
class Array : public Object { class V8EXPORT Array : public Object {
public: public:
V8EXPORT uint32_t Length() const; uint32_t Length() const;
/** /**
* Clones an element at index |index|. Returns an empty * Clones an element at index |index|. Returns an empty
* handle if cloning fails (for any reason). * handle if cloning fails (for any reason).
*/ */
V8EXPORT Local<Object> CloneElementAt(uint32_t index); Local<Object> CloneElementAt(uint32_t index);
/** /**
* Creates a JavaScript array with the given length. If the length * Creates a JavaScript array with the given length. If the length
* is negative the returned array will have length 0. * is negative the returned array will have length 0.
*/ */
V8EXPORT static Local<Array> New(int length = 0); static Local<Array> New(int length = 0);
V8_INLINE(static Array* Cast(Value* obj)); V8_INLINE(static Array* Cast(Value* obj));
private: private:
V8EXPORT Array(); Array();
V8EXPORT static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* A JavaScript function object (ECMA-262, 15.3). * A JavaScript function object (ECMA-262, 15.3).
*/ */
class Function : public Object { class V8EXPORT Function : public Object {
public: public:
V8EXPORT Local<Object> NewInstance() const; Local<Object> NewInstance() const;
V8EXPORT Local<Object> NewInstance(int argc, Handle<Value> argv[]) const; Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
V8EXPORT Local<Value> Call(Handle<Object> recv, Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
int argc, void SetName(Handle<String> name);
Handle<Value> argv[]); Handle<Value> GetName() const;
V8EXPORT void SetName(Handle<String> name);
V8EXPORT Handle<Value> GetName() const;
/** /**
* Name inferred from variable or property assignment of this function. * Name inferred from variable or property assignment of this function.
* Used to facilitate debugging and profiling of JavaScript code written * Used to facilitate debugging and profiling of JavaScript code written
* in an OO style, where many functions are anonymous but are assigned * in an OO style, where many functions are anonymous but are assigned
* to object properties. * to object properties.
*/ */
V8EXPORT Handle<Value> GetInferredName() const; Handle<Value> GetInferredName() const;
/** /**
* Returns zero based line number of function body and * Returns zero based line number of function body and
* kLineOffsetNotFound if no information available. * kLineOffsetNotFound if no information available.
*/ */
V8EXPORT int GetScriptLineNumber() const; int GetScriptLineNumber() const;
/** /**
* Returns zero based column number of function body and * Returns zero based column number of function body and
* kLineOffsetNotFound if no information available. * kLineOffsetNotFound if no information available.
*/ */
V8EXPORT int GetScriptColumnNumber() const; int GetScriptColumnNumber() const;
V8EXPORT Handle<Value> GetScriptId() const; Handle<Value> GetScriptId() const;
V8EXPORT ScriptOrigin GetScriptOrigin() const; ScriptOrigin GetScriptOrigin() const;
V8_INLINE(static Function* Cast(Value* obj)); V8_INLINE(static Function* Cast(Value* obj));
V8EXPORT static const int kLineOffsetNotFound; static const int kLineOffsetNotFound;
private: private:
V8EXPORT Function(); Function();
V8EXPORT static void CheckCast(Value* obj); static void CheckCast(Value* obj);
}; };
/** /**
* An instance of the built-in Date constructor (ECMA-262, 15.9). * An instance of the built-in Date constructor (ECMA-262, 15.9).
*/ */
class Date : public Object { class V8EXPORT Date : public Object {
public: public:
V8EXPORT static Local<Value> New(double time); static Local<Value> New(double time);
/** /**
* A specialization of Value::NumberValue that is more efficient * A specialization of Value::NumberValue that is more efficient
* because we know the structure of this object. * because we know the structure of this object.
*/ */
V8EXPORT double NumberValue() const; double NumberValue() const;
V8_INLINE(static Date* Cast(v8::Value* obj)); V8_INLINE(static Date* Cast(v8::Value* obj));
/** /**
* Notification that the embedder has changed the time zone, * Notification that the embedder has changed the time zone,
* daylight savings time, or other date / time configuration * daylight savings time, or other date / time configuration
* parameters. V8 keeps a cache of various values used for * parameters. V8 keeps a cache of various values used for
* date / time computation. This notification will reset * date / time computation. This notification will reset
* those cached values for the current context so that date / * those cached values for the current context so that date /
* time configuration changes would be reflected in the Date * time configuration changes would be reflected in the Date
* object. * object.
* *
* This API should not be called more than needed as it will * This API should not be called more than needed as it will
* negatively impact the performance of date operations. * negatively impact the performance of date operations.
*/ */
V8EXPORT static void DateTimeConfigurationChangeNotification(); static void DateTimeConfigurationChangeNotification();
private: private:
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A Number object (ECMA-262, 4.3.21). * A Number object (ECMA-262, 4.3.21).
*/ */
class NumberObject : public Object { class V8EXPORT NumberObject : public Object {
public: public:
V8EXPORT static Local<Value> New(double value); static Local<Value> New(double value);
/** /**
* Returns the Number held by the object. * Returns the Number held by the object.
*/ */
V8EXPORT double NumberValue() const; double NumberValue() const;
V8_INLINE(static NumberObject* Cast(v8::Value* obj)); V8_INLINE(static NumberObject* Cast(v8::Value* obj));
private: private:
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A Boolean object (ECMA-262, 4.3.15). * A Boolean object (ECMA-262, 4.3.15).
*/ */
class BooleanObject : public Object { class V8EXPORT BooleanObject : public Object {
public: public:
V8EXPORT static Local<Value> New(bool value); static Local<Value> New(bool value);
/** /**
* Returns the Boolean held by the object. * Returns the Boolean held by the object.
*/ */
V8EXPORT bool BooleanValue() const; bool BooleanValue() const;
V8_INLINE(static BooleanObject* Cast(v8::Value* obj)); V8_INLINE(static BooleanObject* Cast(v8::Value* obj));
private: private:
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A String object (ECMA-262, 4.3.18). * A String object (ECMA-262, 4.3.18).
*/ */
class StringObject : public Object { class V8EXPORT StringObject : public Object {
public: public:
V8EXPORT static Local<Value> New(Handle<String> value); static Local<Value> New(Handle<String> value);
/** /**
* Returns the String held by the object. * Returns the String held by the object.
*/ */
V8EXPORT Local<String> StringValue() const; Local<String> StringValue() const;
V8_INLINE(static StringObject* Cast(v8::Value* obj)); V8_INLINE(static StringObject* Cast(v8::Value* obj));
private: private:
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* An instance of the built-in RegExp constructor (ECMA-262, 15.10). * An instance of the built-in RegExp constructor (ECMA-262, 15.10).
*/ */
class RegExp : public Object { class V8EXPORT RegExp : public Object {
public: public:
/** /**
* Regular expression flag bits. They can be or'ed to enable a set * Regular expression flag bits. They can be or'ed to enable a set
* of flags. * of flags.
*/ */
enum Flags { enum Flags {
kNone = 0, kNone = 0,
kGlobal = 1, kGlobal = 1,
kIgnoreCase = 2, kIgnoreCase = 2,
kMultiline = 4 kMultiline = 4
skipping to change at line 1946 skipping to change at line 1932
/** /**
* Creates a regular expression from the given pattern string and * Creates a regular expression from the given pattern string and
* the flags bit field. May throw a JavaScript exception as * the flags bit field. May throw a JavaScript exception as
* described in ECMA-262, 15.10.4.1. * described in ECMA-262, 15.10.4.1.
* *
* For example, * For example,
* RegExp::New(v8::String::New("foo"), * RegExp::New(v8::String::New("foo"),
* static_cast<RegExp::Flags>(kGlobal | kMultiline)) * static_cast<RegExp::Flags>(kGlobal | kMultiline))
* is equivalent to evaluating "/foo/gm". * is equivalent to evaluating "/foo/gm".
*/ */
V8EXPORT static Local<RegExp> New(Handle<String> pattern, static Local<RegExp> New(Handle<String> pattern, Flags flags);
Flags flags);
/** /**
* Returns the value of the source property: a string representing * Returns the value of the source property: a string representing
* the regular expression. * the regular expression.
*/ */
V8EXPORT Local<String> GetSource() const; Local<String> GetSource() const;
/** /**
* Returns the flags bit field. * Returns the flags bit field.
*/ */
V8EXPORT Flags GetFlags() const; Flags GetFlags() const;
V8_INLINE(static RegExp* Cast(v8::Value* obj)); V8_INLINE(static RegExp* Cast(v8::Value* obj));
private: private:
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
/** /**
* A JavaScript value that wraps a C++ void*. This type of value is mainly used * A JavaScript value that wraps a C++ void*. This type of value is mainly used
* to associate C++ data structures with JavaScript objects. * to associate C++ data structures with JavaScript objects.
*/ */
class External : public Value { class V8EXPORT External : public Value {
public: public:
/** Deprecated, use New instead. */ static Local<External> New(void* value);
V8_DEPRECATED(V8_INLINE(static Local<Value> Wrap(void* value)));
/** Deprecated, use a combination of Cast and Value instead. */
V8_DEPRECATED(V8_INLINE(static void* Unwrap(Handle<Value> obj)));
V8EXPORT static Local<External> New(void* value);
V8_INLINE(static External* Cast(Value* obj)); V8_INLINE(static External* Cast(Value* obj));
V8EXPORT void* Value() const; void* Value() const;
private: private:
V8EXPORT static void CheckCast(v8::Value* obj); static void CheckCast(v8::Value* obj);
}; };
// --- Templates --- // --- Templates ---
/** /**
* The superclass of object and function templates. * The superclass of object and function templates.
*/ */
class V8EXPORT Template : public Data { class V8EXPORT Template : public Data {
public: public:
/** Adds a property to each instance created by this template.*/ /** Adds a property to each instance created by this template.*/
skipping to change at line 2009 skipping to change at line 1988
friend class ObjectTemplate; friend class ObjectTemplate;
friend class FunctionTemplate; friend class FunctionTemplate;
}; };
/** /**
* The argument information given to function call callbacks. This * The argument information given to function call callbacks. This
* class provides access to information about the context of the call, * class provides access to information about the context of the call,
* including the receiver, the number and values of arguments, and * including the receiver, the number and values of arguments, and
* the holder of the function. * the holder of the function.
*/ */
class Arguments { class V8EXPORT Arguments {
public: public:
V8_INLINE(int Length() const); V8_INLINE(int Length() const);
V8_INLINE(Local<Value> operator[](int i) const); V8_INLINE(Local<Value> operator[](int i) const);
V8_INLINE(Local<Function> Callee() const); V8_INLINE(Local<Function> Callee() const);
V8_INLINE(Local<Object> This() const); V8_INLINE(Local<Object> This() const);
V8_INLINE(Local<Object> Holder() const); V8_INLINE(Local<Object> Holder() const);
V8_INLINE(bool IsConstructCall() const); V8_INLINE(bool IsConstructCall() const);
V8_INLINE(Local<Value> Data() const); V8_INLINE(Local<Value> Data() const);
V8_INLINE(Isolate* GetIsolate() const); V8_INLINE(Isolate* GetIsolate() const);
skipping to change at line 2879 skipping to change at line 2858
private: private:
Isolate(); Isolate();
Isolate(const Isolate&); Isolate(const Isolate&);
~Isolate(); ~Isolate();
Isolate& operator=(const Isolate&); Isolate& operator=(const Isolate&);
void* operator new(size_t size); void* operator new(size_t size);
void operator delete(void*, size_t); void operator delete(void*, size_t);
}; };
class StartupData { class V8EXPORT StartupData {
public: public:
enum CompressionAlgorithm { enum CompressionAlgorithm {
kUncompressed, kUncompressed,
kBZip2 kBZip2
}; };
const char* data; const char* data;
int compressed_size; int compressed_size;
int raw_size; int raw_size;
}; };
skipping to change at line 3740 skipping to change at line 3719
*/ */
void Exit(); void Exit();
/** Returns true if the context has experienced an out of memory situatio n. */ /** Returns true if the context has experienced an out of memory situatio n. */
bool HasOutOfMemoryException(); bool HasOutOfMemoryException();
/** Returns true if V8 has a current context. */ /** Returns true if V8 has a current context. */
static bool InContext(); static bool InContext();
/** /**
* Gets embedder data with index 0. Deprecated, use GetEmbedderData with
index
* 0 instead.
*/
V8_DEPRECATED(V8_INLINE(Local<Value> GetData()));
/**
* Sets embedder data with index 0. Deprecated, use SetEmbedderData with
index
* 0 instead.
*/
V8_DEPRECATED(V8_INLINE(void SetData(Handle<Value> value)));
/**
* Gets the embedder data with the given index, which must have been set by a * Gets the embedder data with the given index, which must have been set by a
* previous call to SetEmbedderData with the same index. Note that index 0 * previous call to SetEmbedderData with the same index. Note that index 0
* currently has a special meaning for Chrome's debugger. * currently has a special meaning for Chrome's debugger.
*/ */
V8_INLINE(Local<Value> GetEmbedderData(int index)); V8_INLINE(Local<Value> GetEmbedderData(int index));
/** /**
* Sets the embedder data with the given index, growing the data as * Sets the embedder data with the given index, growing the data as
* needed. Note that index 0 currently has a special meaning for Chrome's * needed. Note that index 0 currently has a special meaning for Chrome's
* debugger. * debugger.
skipping to change at line 4411 skipping to change at line 4378
if (I::GetInstanceType(obj) == I::kJSObjectType) { if (I::GetInstanceType(obj) == I::kJSObjectType) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x); int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x);
O* value = I::ReadField<O*>(obj, offset); O* value = I::ReadField<O*>(obj, offset);
O** result = HandleScope::CreateHandle(value); O** result = HandleScope::CreateHandle(value);
return Local<Value>(reinterpret_cast<Value*>(result)); return Local<Value>(reinterpret_cast<Value*>(result));
} }
#endif #endif
return SlowGetInternalField(index); return SlowGetInternalField(index);
} }
void Object::SetPointerInInternalField(int index, void* value) {
SetInternalField(index, External::New(value));
}
void* Object::GetAlignedPointerFromInternalField(int index) { void* Object::GetAlignedPointerFromInternalField(int index) {
#ifndef V8_ENABLE_CHECKS #ifndef V8_ENABLE_CHECKS
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O* obj = *reinterpret_cast<O**>(this); O* obj = *reinterpret_cast<O**>(this);
// Fast path: If the object is a plain JSObject, which is the common case , we // Fast path: If the object is a plain JSObject, which is the common case , we
// know where to find the internal fields and can return the value direct ly. // know where to find the internal fields and can return the value direct ly.
if (I::GetInstanceType(obj) == I::kJSObjectType) { if (I::GetInstanceType(obj) == I::kJSObjectType) {
int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x); int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * inde x);
return I::ReadField<void*>(obj, offset); return I::ReadField<void*>(obj, offset);
skipping to change at line 4601 skipping to change at line 4564
return static_cast<Array*>(value); return static_cast<Array*>(value);
} }
Function* Function::Cast(v8::Value* value) { Function* Function::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckCast(value); CheckCast(value);
#endif #endif
return static_cast<Function*>(value); return static_cast<Function*>(value);
} }
Local<Value> External::Wrap(void* value) {
return External::New(value);
}
void* External::Unwrap(Handle<v8::Value> obj) {
return External::Cast(*obj)->Value();
}
External* External::Cast(v8::Value* value) { External* External::Cast(v8::Value* value) {
#ifdef V8_ENABLE_CHECKS #ifdef V8_ENABLE_CHECKS
CheckCast(value); CheckCast(value);
#endif #endif
return static_cast<External*>(value); return static_cast<External*>(value);
} }
Isolate* AccessorInfo::GetIsolate() const { Isolate* AccessorInfo::GetIsolate() const {
return *reinterpret_cast<Isolate**>(&args_[-3]); return *reinterpret_cast<Isolate**>(&args_[-3]);
} }
skipping to change at line 4674 skipping to change at line 4629
void Isolate::SetData(void* data) { void Isolate::SetData(void* data) {
typedef internal::Internals I; typedef internal::Internals I;
I::SetEmbedderData(this, data); I::SetEmbedderData(this, data);
} }
void* Isolate::GetData() { void* Isolate::GetData() {
typedef internal::Internals I; typedef internal::Internals I;
return I::GetEmbedderData(this); return I::GetEmbedderData(this);
} }
Local<Value> Context::GetData() {
return GetEmbedderData(0);
}
void Context::SetData(Handle<Value> data) {
SetEmbedderData(0, data);
}
Local<Value> Context::GetEmbedderData(int index) { Local<Value> Context::GetEmbedderData(int index) {
#ifndef V8_ENABLE_CHECKS #ifndef V8_ENABLE_CHECKS
typedef internal::Object O; typedef internal::Object O;
typedef internal::Internals I; typedef internal::Internals I;
O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, inde x)); O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, inde x));
return Local<Value>(reinterpret_cast<Value*>(result)); return Local<Value>(reinterpret_cast<Value*>(result));
#else #else
return SlowGetEmbedderData(index); return SlowGetEmbedderData(index);
#endif #endif
} }
 End of changes. 149 change blocks. 
287 lines changed or deleted 231 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/