v8.h   v8.h 
skipping to change at line 129 skipping to change at line 129
class Data; class Data;
// --- W e a k H a n d l e s // --- W e a k H a n d l e s
/** /**
* A weak reference callback function. * A weak reference callback function.
* *
* \param object the weak global object to be reclaimed by the garbage coll ector * \param object the weak global object to be reclaimed by the garbage coll ector
* \param parameter the value passed in when making the weak global object * \param parameter the value passed in when making the weak global object
*/ */
typedef void (*WeakReferenceCallback)(Persistent<Object> object, typedef void (*WeakReferenceCallback)(Persistent<Value> object,
void* parameter); void* parameter);
// --- H a n d l e s --- // --- H a n d l e s ---
#define TYPE_CHECK(T, S) \ #define TYPE_CHECK(T, S) \
while (false) { \ while (false) { \
*(static_cast<T**>(0)) = static_cast<S*>(0); \ *(static_cast<T**>(0)) = static_cast<S*>(0); \
} }
/** /**
skipping to change at line 200 skipping to change at line 200
* This check fails when trying to convert between incompatible * This check fails when trying to convert between incompatible
* handles. For example, converting from a Handle<String> to a * handles. For example, converting from a Handle<String> to a
* Handle<Number>. * Handle<Number>.
*/ */
TYPE_CHECK(T, S); TYPE_CHECK(T, S);
} }
/** /**
* Returns true if the handle is empty. * Returns true if the handle is empty.
*/ */
bool IsEmpty() { return val_ == 0; } bool IsEmpty() const { return val_ == 0; }
T* operator->(); T* operator->() const;
T* operator*(); T* operator*() const;
/** /**
* Sets the handle to be empty. IsEmpty() will then return true. * Sets the handle to be empty. IsEmpty() will then return true.
*/ */
void Clear() { this->val_ = 0; } void Clear() { this->val_ = 0; }
/** /**
* Checks whether two handles are the same. * Checks whether two handles are the same.
* Returns true if both are empty, or if the objects * Returns true if both are empty, or if the objects
* to which they refer are identical. * to which they refer are identical.
* The handles' references are not checked. * The handles' references are not checked.
*/ */
template <class S> bool operator==(Handle<S> that) { template <class S> bool operator==(Handle<S> that) const {
void** a = reinterpret_cast<void**>(**this); void** a = reinterpret_cast<void**>(**this);
void** b = reinterpret_cast<void**>(*that); void** b = reinterpret_cast<void**>(*that);
if (a == 0) return b == 0; if (a == 0) return b == 0;
if (b == 0) return false; if (b == 0) return false;
return *a == *b; return *a == *b;
} }
/** /**
* Checks whether two handles are different. * Checks whether two handles are different.
* Returns true if only one of the handles is empty, or if * Returns true if only one of the handles is empty, or if
* the objects to which they refer are different. * the objects to which they refer are different.
* The handles' references are not checked. * The handles' references are not checked.
*/ */
template <class S> bool operator!=(Handle<S> that) { template <class S> bool operator!=(Handle<S> that) const {
return !operator==(that); return !operator==(that);
} }
template <class S> static inline Handle<T> Cast(Handle<S> that) { template <class S> static inline Handle<T> Cast(Handle<S> that) {
if (that.IsEmpty()) return Handle<T>(); if (that.IsEmpty()) return Handle<T>();
return Handle<T>(T::Cast(*that)); return Handle<T>(T::Cast(*that));
} }
private: private:
T* val_; T* val_;
skipping to change at line 365 skipping to change at line 365
* it the object reference and the given parameters. * it the object reference and the given parameters.
*/ */
void MakeWeak(void* parameters, WeakReferenceCallback callback); void MakeWeak(void* parameters, WeakReferenceCallback callback);
/** Clears the weak reference to this object.*/ /** Clears the weak reference to this object.*/
void ClearWeak(); void ClearWeak();
/** /**
*Checks if the handle holds the only reference to an object. *Checks if the handle holds the only reference to an object.
*/ */
bool IsNearDeath(); bool IsNearDeath() const;
/** /**
* Returns true if the handle's reference is weak. * Returns true if the handle's reference is weak.
*/ */
bool IsWeak(); bool IsWeak() const;
private: private:
friend class ImplementationUtilities; friend class ImplementationUtilities;
friend class ObjectTemplate; friend class ObjectTemplate;
}; };
/** /**
* A stack-allocated class that governs a number of local handles. * A stack-allocated class that governs a number of local handles.
* After a handle scope has been created, all local handles will be * After a handle scope has been created, all local handles will be
* allocated within that handle scope until either the handle scope is * allocated within that handle scope until either the handle scope is
skipping to change at line 393 skipping to change at line 393
* place in the new handle scope until it is deleted. After that, * place in the new handle scope until it is deleted. After that,
* new handles will again be allocated in the original handle scope. * new handles will again be allocated in the original handle scope.
* *
* After the handle scope of a local handle has been deleted the * After the handle scope of a local handle has been deleted the
* garbage collector will no longer track the object stored in the * garbage collector will no longer track the object stored in the
* handle and may deallocate it. The behavior of accessing a handle * handle and may deallocate it. The behavior of accessing a handle
* for which the handle scope has been deleted is undefined. * for which the handle scope has been deleted is undefined.
*/ */
class EXPORT HandleScope { class EXPORT HandleScope {
public: public:
HandleScope() : previous_(current_), is_closed_(false) { HandleScope();
current_.extensions = 0;
}
~HandleScope() { ~HandleScope();
// TODO(1245391): In a perfect world, there would be a way of not
// having to check for explicitly closed scopes maybe through
// subclassing HandleScope?
if (!is_closed_) RestorePreviousState();
}
/** /**
* TODO(1245391): Consider introducing a subclass for this.
* Closes the handle scope and returns the value as a handle in the * Closes the handle scope and returns the value as a handle in the
* previous scope, which is the new current scope after the call. * previous scope, which is the new current scope after the call.
*/ */
template <class T> Local<T> Close(Handle<T> value); template <class T> Local<T> Close(Handle<T> value);
/** /**
* Counts the number of allocated handles. * Counts the number of allocated handles.
*/ */
static int NumberOfHandles(); static int NumberOfHandles();
skipping to change at line 429 skipping to change at line 421
static void** CreateHandle(void* value); static void** CreateHandle(void* value);
private: private:
// Make it impossible to create heap-allocated or illegal handle // Make it impossible to create heap-allocated or illegal handle
// scopes by disallowing certain operations. // scopes by disallowing certain operations.
HandleScope(const HandleScope&); HandleScope(const HandleScope&);
void operator=(const HandleScope&); void operator=(const HandleScope&);
void* operator new(size_t size); void* operator new(size_t size);
void operator delete(void*, size_t); void operator delete(void*, size_t);
// This Data class is accessible internally through a typedef in the
// ImplementationUtilities class.
class EXPORT Data { class EXPORT Data {
public: public:
int extensions; int extensions;
void** next; void** next;
void** limit; void** limit;
inline void Initialize() { inline void Initialize() {
extensions = -1; extensions = -1;
next = limit = NULL; next = limit = NULL;
} }
}; };
static Data current_; Data previous_;
const Data previous_;
/**
* Re-establishes the previous scope state. Should be called only
* once, and only for the current scope.
*/
void RestorePreviousState() {
if (current_.extensions > 0) DeleteExtensions();
current_ = previous_;
#ifdef DEBUG
ZapRange(current_.next, current_.limit);
#endif
}
// TODO(1245391): Consider creating a subclass for this. // Allow for the active closing of HandleScopes which allows to pass a ha
ndle
// from the HandleScope being closed to the next top most HandleScope.
bool is_closed_; bool is_closed_;
void** RawClose(void** value); void** RawClose(void** value);
/** Deallocates any extensions used by the current scope.*/
static void DeleteExtensions();
// Zaps the handles in the half-open interval [start, end).
static void ZapRange(void** start, void** end);
friend class ImplementationUtilities; friend class ImplementationUtilities;
}; };
// --- S p e c i a l o b j e c t s --- // --- S p e c i a l o b j e c t s ---
/** /**
* The superclass of values and API object templates. * The superclass of values and API object templates.
*/ */
class EXPORT Data { class EXPORT Data {
private: private:
skipping to change at line 505 skipping to change at line 481
* The origin, within a file, of a script. * The origin, within a file, of a script.
*/ */
class EXPORT ScriptOrigin { class EXPORT ScriptOrigin {
public: public:
ScriptOrigin(Handle<Value> resource_name, ScriptOrigin(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) { }
inline Handle<Value> ResourceName(); inline Handle<Value> ResourceName() const;
inline Handle<Integer> ResourceLineOffset(); inline Handle<Integer> ResourceLineOffset() const;
inline Handle<Integer> ResourceColumnOffset(); inline Handle<Integer> ResourceColumnOffset() const;
private: private:
Handle<Value> resource_name_; Handle<Value> resource_name_;
Handle<Integer> resource_line_offset_; Handle<Integer> resource_line_offset_;
Handle<Integer> resource_column_offset_; Handle<Integer> resource_column_offset_;
}; };
/** /**
* A compiled JavaScript script. * A compiled JavaScript script.
*/ */
class EXPORT Script { class EXPORT Script {
skipping to change at line 547 skipping to change at line 523
* Runs the script returning the resulting value. * Runs the script returning the resulting value.
*/ */
Local<Value> Run(); Local<Value> Run();
}; };
/** /**
* An error message. * An error message.
*/ */
class EXPORT Message { class EXPORT Message {
public: public:
Local<String> Get(); Local<String> Get() const;
Local<String> GetSourceLine(); Local<String> GetSourceLine() const;
// TODO(1241256): Rewrite (or remove) this method. We don't want to Handle<Value> GetScriptResourceName() const;
// deal with ownership of the returned string and we want to use
// JavaScript data structures exclusively.
char* GetUnderline(char* source_line, char underline_char);
Handle<String> GetScriptResourceName();
// TODO(1240903): Remove this when no longer used in WebKit V8
// bindings.
Handle<Value> GetSourceData();
/** /**
* Returns the number, 1-based, of the line where the error occurred. * Returns the number, 1-based, of the line where the error occurred.
*/ */
int GetLineNumber(); int GetLineNumber() const;
/** /**
* Returns the index within the script of the first character where * Returns the index within the script of the first character where
* the error occurred. * the error occurred.
*/ */
int GetStartPosition(); int GetStartPosition() const;
/** /**
* Returns the index within the script of the last character where * Returns the index within the script of the last character where
* the error occurred. * the error occurred.
*/ */
int GetEndPosition(); int GetEndPosition() const;
/** /**
* Returns the index within the line of the first character where * Returns the index within the line of the first character where
* the error occurred. * the error occurred.
*/ */
int GetStartColumn(); int GetStartColumn() const;
/** /**
* Returns the index within the line of the last character where * Returns the index within the line of the last character where
* the error occurred. * the error occurred.
*/ */
int GetEndColumn(); int GetEndColumn() const;
// TODO(1245381): Print to a string instead of on a FILE. // TODO(1245381): Print to a string instead of on a FILE.
static void PrintCurrentStackTrace(FILE* out); static void PrintCurrentStackTrace(FILE* out);
}; };
// --- V a l u e --- // --- V a l u e ---
/** /**
* The superclass of all JavaScript values and objects. * The superclass of all JavaScript values and objects.
*/ */
class EXPORT Value : public Data { class EXPORT 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.
*/ */
bool IsUndefined(); 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.
*/ */
bool IsNull(); bool IsNull() const;
/** /**
* Returns true if this value is true. * Returns true if this value is true.
*/ */
bool IsTrue(); bool IsTrue() const;
/** /**
* Returns true if this value is false. * Returns true if this value is false.
*/ */
bool IsFalse(); 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.
*/ */
bool IsString(); bool IsString() const;
/** /**
* Returns true if this value is a function. * Returns true if this value is a function.
*/ */
bool IsFunction(); bool IsFunction() const;
/** /**
* Returns true if this value is an array. * Returns true if this value is an array.
*/ */
bool IsArray(); bool IsArray() const;
/** /**
* Returns true if this value is an object. * Returns true if this value is an object.
*/ */
bool IsObject(); bool IsObject() const;
/** /**
* Returns true if this value is boolean. * Returns true if this value is boolean.
*/ */
bool IsBoolean(); bool IsBoolean() const;
/** /**
* Returns true if this value is a number. * Returns true if this value is a number.
*/ */
bool IsNumber(); bool IsNumber() const;
/** /**
* Returns true if this value is external. * Returns true if this value is external.
*/ */
bool IsExternal(); 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.
*/ */
bool IsInt32(); bool IsInt32() const;
/**
* Returns true if this value is a Date.
*/
bool IsDate() const;
Local<Boolean> ToBoolean(); Local<Boolean> ToBoolean() const;
Local<Number> ToNumber(); Local<Number> ToNumber() const;
Local<String> ToString(); Local<String> ToString() const;
Local<String> ToDetailString(); Local<String> ToDetailString() const;
Local<Object> ToObject(); Local<Object> ToObject() const;
Local<Integer> ToInteger(); Local<Integer> ToInteger() const;
Local<Uint32> ToUint32(); Local<Uint32> ToUint32() const;
Local<Int32> ToInt32(); 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.
*/ */
Local<Uint32> ToArrayIndex(); Local<Uint32> ToArrayIndex() const;
bool BooleanValue(); bool BooleanValue() const;
double NumberValue(); double NumberValue() const;
int64_t IntegerValue(); int64_t IntegerValue() const;
uint32_t Uint32Value(); uint32_t Uint32Value() const;
int32_t Int32Value(); int32_t Int32Value() const;
/** JS == */ /** JS == */
bool Equals(Handle<Value> that); bool Equals(Handle<Value> that) const;
bool StrictEquals(Handle<Value> that); bool StrictEquals(Handle<Value> that) const;
}; };
/** /**
* The superclass of primitive values. See ECMA-262 4.3.2. * The superclass of primitive values. See ECMA-262 4.3.2.
*/ */
class EXPORT Primitive : public Value { }; class EXPORT 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 EXPORT Boolean : public Primitive { class EXPORT Boolean : public Primitive {
public: public:
bool Value(); bool Value() const;
static inline Handle<Boolean> New(bool value); static inline Handle<Boolean> New(bool value);
}; };
/** /**
* A JavaScript string value (ECMA-262, 4.3.17). * A JavaScript string value (ECMA-262, 4.3.17).
*/ */
class EXPORT String : public Primitive { class EXPORT String : public Primitive {
public: public:
/** /**
* Returns the number of characters in this string. * Returns the number of characters in this string.
*/ */
int Length(); 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.
*/ */
int Utf8Length(); int Utf8Length() 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.
* *
* Copies up to length characters into the output buffer. * Copies up to length characters into the output buffer.
* Only null-terminates if there is enough space in the buffer. * Only null-terminates if there is enough space in the buffer.
* *
* \param buffer The buffer into which the string will be copied. * \param buffer The buffer into which the string will be copied.
* \param start The starting position within the string at which * \param start The starting position within the string at which
* copying begins. * copying begins.
* \param length The number of bytes to copy from the string. * \param length The number of bytes to copy from the string.
* \return The number of characters copied to the buffer * \return The number of characters copied to the buffer
* excluding the NULL terminator. * excluding the NULL terminator.
*/ */
int Write(uint16_t* buffer, int start = 0, int length = -1); // UTF-16 int Write(uint16_t* buffer, int start = 0, int length = -1) const; // UT
int WriteAscii(char* buffer, int start = 0, int length = -1); // ASCII F-16
int WriteUtf8(char* buffer, int length = -1); // UTF-8 int WriteAscii(char* buffer, int start = 0, int length = -1) const; // A
SCII
int WriteUtf8(char* buffer, int length = -1) const; // UTF-8
/** /**
* Returns true if the string is external * Returns true if the string is external
*/ */
bool IsExternal(); bool IsExternal() const;
/** /**
* Returns true if the string is both external and ascii * Returns true if the string is both external and ascii
*/ */
bool IsExternalAscii(); bool IsExternalAscii() const;
/** /**
* An ExternalStringResource is a wrapper around a two-byte string * An ExternalStringResource is a wrapper around a two-byte string
* buffer that resides outside V8's heap. Implement an * buffer that resides outside V8's heap. Implement an
* ExternalStringResource to manage the life cycle of the underlying * ExternalStringResource to manage the life cycle of the underlying
* buffer. Note that the string data must be immutable. * buffer. Note that the string data must be immutable.
*/ */
class EXPORT ExternalStringResource { // NOLINT class EXPORT ExternalStringResource { // NOLINT
public: public:
/** /**
* Override the destructor to manage the life cycle of the underlying * Override the destructor to manage the life cycle of the underlying
skipping to change at line 812 skipping to change at line 784
private: private:
// Disallow copying and assigning. // Disallow copying and assigning.
ExternalAsciiStringResource(const ExternalAsciiStringResource&); ExternalAsciiStringResource(const ExternalAsciiStringResource&);
void operator=(const ExternalAsciiStringResource&); void operator=(const ExternalAsciiStringResource&);
}; };
/** /**
* Get the ExternalStringResource for an external string. Only * Get the ExternalStringResource for an external string. Only
* valid if IsExternal() returns true. * valid if IsExternal() returns true.
*/ */
ExternalStringResource* GetExternalStringResource(); ExternalStringResource* GetExternalStringResource() const;
/** /**
* Get the ExternalAsciiStringResource for an external ascii string. * Get the ExternalAsciiStringResource for an external ascii string.
* Only valid if IsExternalAscii() returns true. * Only valid if IsExternalAscii() returns true.
*/ */
ExternalAsciiStringResource* GetExternalAsciiStringResource(); ExternalAsciiStringResource* GetExternalAsciiStringResource() const;
static String* Cast(v8::Value* obj); 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. * 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
skipping to change at line 927 skipping to change at line 899
Value(const Value&); Value(const Value&);
void operator=(const Value&); void operator=(const Value&);
}; };
}; };
/** /**
* A JavaScript number value (ECMA-262, 4.3.20) * A JavaScript number value (ECMA-262, 4.3.20)
*/ */
class EXPORT Number : public Primitive { class EXPORT Number : public Primitive {
public: public:
double Value(); double Value() const;
static Local<Number> New(double value); static Local<Number> New(double value);
static Number* Cast(v8::Value* obj); static Number* Cast(v8::Value* obj);
private: private:
Number(); Number();
}; };
/** /**
* A JavaScript value representing a signed integer. * A JavaScript value representing a signed integer.
*/ */
class EXPORT Integer : public Number { class EXPORT Integer : public Number {
public: public:
static Local<Integer> New(int32_t value); static Local<Integer> New(int32_t value);
int64_t Value(); int64_t Value() const;
static Integer* Cast(v8::Value* obj); static Integer* Cast(v8::Value* obj);
private: private:
Integer(); Integer();
}; };
/** /**
* A JavaScript value representing a 32-bit signed integer. * A JavaScript value representing a 32-bit signed integer.
*/ */
class EXPORT Int32 : public Integer { class EXPORT Int32 : public Integer {
public: public:
int32_t Value(); int32_t Value() const;
private: private:
Int32(); Int32();
}; };
/** /**
* A JavaScript value representing a 32-bit unsigned integer. * A JavaScript value representing a 32-bit unsigned integer.
*/ */
class EXPORT Uint32 : public Integer { class EXPORT Uint32 : public Integer {
public: public:
uint32_t Value(); uint32_t Value() const;
private: private:
Uint32(); Uint32();
}; };
/** /**
* 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 EXPORT Date : public Value { class EXPORT Date : public Value {
public: public:
static Local<Value> New(double time); static Local<Value> New(double time);
/**
* A specialization of Value::NumberValue that is more efficient
* because we know the structure of this object.
*/
double NumberValue() const;
static Date* Cast(v8::Value* obj);
}; };
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
}; };
/** /**
skipping to change at line 999 skipping to change at line 979
Local<Value> Get(Handle<Value> key); Local<Value> Get(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.
bool Has(Handle<String> key); bool Has(Handle<String> key);
bool Delete(Handle<String> key); bool Delete(Handle<String> key);
bool Has(uint32_t index); bool Has(uint32_t index);
bool Delete(uint32_t index); bool Delete(uint32_t index);
/** /**
* Returns an array containing the names of the enumerable properties
* of this object, including properties from prototype objects. The
* array returned by this method contains the same values as would
* be enumerated by a for-in statement over this object.
*/
Local<Array> GetPropertyNames();
/**
* 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.
*/ */
Local<Value> GetPrototype(); Local<Value> GetPrototype();
/** /**
* 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.
skipping to change at line 1036 skipping to change at line 1024
* This means interceptors in the prototype chain are not called. * This means interceptors in the prototype chain are not called.
*/ */
Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key); Handle<Value> GetRealNamedPropertyInPrototypeChain(Handle<String> key);
/** Tests for a named lookup interceptor.*/ /** Tests for a named lookup interceptor.*/
bool HasNamedLookupInterceptor(); bool HasNamedLookupInterceptor();
/** Tests for an index lookup interceptor.*/ /** Tests for an index lookup interceptor.*/
bool HasIndexedLookupInterceptor(); bool HasIndexedLookupInterceptor();
/**
* 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
* access check info, the object cannot be accessed by anyone.
*/
void TurnOnAccessCheck();
static Local<Object> New(); static Local<Object> New();
static Object* Cast(Value* obj); static Object* Cast(Value* obj);
private: private:
Object(); Object();
}; };
/** /**
* 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 EXPORT Array : public Object { class EXPORT Array : public Object {
public: public:
uint32_t Length(); uint32_t Length() const;
static Local<Array> New(int length = 0); static Local<Array> New(int length = 0);
static Array* Cast(Value* obj); static Array* Cast(Value* obj);
private: private:
Array(); Array();
}; };
/** /**
* A JavaScript function object (ECMA-262, 15.3). * A JavaScript function object (ECMA-262, 15.3).
*/ */
class EXPORT Function : public Object { class EXPORT Function : public Object {
public: public:
Local<Object> NewInstance(); Local<Object> NewInstance() const;
Local<Object> NewInstance(int argc, Handle<Value> argv[]); Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]); Local<Value> Call(Handle<Object> recv, int argc, Handle<Value> argv[]);
void SetName(Handle<String> name); void SetName(Handle<String> name);
Handle<Value> GetName(); Handle<Value> GetName() const;
static Function* Cast(Value* obj); static Function* Cast(Value* obj);
private: private:
Function(); Function();
}; };
/** /**
* A JavaScript value that wraps a c++ void*. This type of value is * A JavaScript value that wraps a c++ void*. This type of value is
* mainly used to associate c++ data structures with JavaScript * mainly used to associate c++ data structures with JavaScript
* objects. * objects.
*/ */
class EXPORT External : public Value { class EXPORT External : public Value {
public: public:
static Local<External> New(void* value); static Local<External> New(void* value);
static External* Cast(Value* obj); static External* Cast(Value* obj);
void* Value(); void* Value() const;
private: private:
External(); External();
}; };
// --- T e m p l a t e s --- // --- T e m p l a t e s ---
/** /**
* The superclass of object and function templates. * The superclass of object and function templates.
*/ */
class EXPORT Template : public Data { class EXPORT Template : public Data {
skipping to change at line 1576 skipping to change at line 1571
* normal objects. * normal objects.
*/ */
void MarkAsUndetectable(); void MarkAsUndetectable();
/** /**
* Sets access check callbacks on the object template. * Sets access check callbacks on the object template.
* *
* When accessing properties on instances of this object template, * When accessing properties on instances of this object template,
* the access check callback will be called to determine whether or * the access check callback will be called to determine whether or
* not to allow cross-context access to the properties. * not to allow cross-context access to the properties.
* The last parameter specifies whether access checks are turned
* on by default on instances. If access checks are off by default,
* they can be turned on on individual instances by calling
* Object::TurnOnAccessCheck().
*/ */
void SetAccessCheckCallbacks(NamedSecurityCallback named_handler, void SetAccessCheckCallbacks(NamedSecurityCallback named_handler,
IndexedSecurityCallback indexed_handler, IndexedSecurityCallback indexed_handler,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>(),
bool turned_on_by_default = true);
/** /**
* Gets the number of internal fields for objects generated from * Gets the number of internal fields for objects generated from
* this template. * this template.
*/ */
int InternalFieldCount(); int InternalFieldCount();
/** /**
* Sets the number of internal fields for objects generated from * Sets the number of internal fields for objects generated from
* this template. * this template.
skipping to change at line 1688 skipping to change at line 1688
Handle<Boolean> EXPORT True(); Handle<Boolean> EXPORT True();
Handle<Boolean> EXPORT False(); Handle<Boolean> EXPORT False();
/** /**
* A set of constraints that specifies the limits of the runtime's * A set of constraints that specifies the limits of the runtime's
* memory use. * memory use.
*/ */
class EXPORT ResourceConstraints { class EXPORT ResourceConstraints {
public: public:
ResourceConstraints(); ResourceConstraints();
int max_young_space_size() { return max_young_space_size_; } int max_young_space_size() const { return max_young_space_size_; }
void set_max_young_space_size(int value) { max_young_space_size_ = value; } void set_max_young_space_size(int value) { max_young_space_size_ = value; }
int max_old_space_size() { return max_old_space_size_; } int max_old_space_size() const { return max_old_space_size_; }
void set_max_old_space_size(int value) { max_old_space_size_ = value; } void set_max_old_space_size(int value) { max_old_space_size_ = value; }
uint32_t* stack_limit() { return stack_limit_; } uint32_t* stack_limit() const { return stack_limit_; }
void set_stack_limit(uint32_t* value) { stack_limit_ = value; } void set_stack_limit(uint32_t* value) { stack_limit_ = value; }
private: private:
int max_young_space_size_; int max_young_space_size_;
int max_old_space_size_; int max_old_space_size_;
uint32_t* stack_limit_; uint32_t* stack_limit_;
}; };
bool SetResourceConstraints(ResourceConstraints* constraints); bool SetResourceConstraints(ResourceConstraints* constraints);
// --- E x c e p t i o n s --- // --- E x c e p t i o n s ---
skipping to change at line 1729 skipping to change at line 1729
*/ */
class EXPORT Exception { class EXPORT Exception {
public: public:
static Local<Value> RangeError(Handle<String> message); static Local<Value> RangeError(Handle<String> message);
static Local<Value> ReferenceError(Handle<String> message); static Local<Value> ReferenceError(Handle<String> message);
static Local<Value> SyntaxError(Handle<String> message); static Local<Value> SyntaxError(Handle<String> message);
static Local<Value> TypeError(Handle<String> message); static Local<Value> TypeError(Handle<String> message);
static Local<Value> Error(Handle<String> message); static Local<Value> Error(Handle<String> message);
}; };
// --- C o u n t e r s C a l l b a c k s // --- C o u n t e r s C a l l b a c k s ---
typedef int* (*CounterLookupCallback)(const wchar_t* name); typedef int* (*CounterLookupCallback)(const char* name);
// --- F a i l e d A c c e s s C h e c k C a l l b a c k --- // --- F a i l e d A c c e s s C h e c k C a l l b a c k ---
typedef void (*FailedAccessCheckCallback)(Local<Object> target, typedef void (*FailedAccessCheckCallback)(Local<Object> target,
AccessType type, AccessType type,
Local<Value> data); Local<Value> data);
// --- G a r b a g e C o l l e c t i o n C a l l b a c k s // --- G a r b a g e C o l l e c t i o n C a l l b a c k s
/** /**
* Applications can register a callback function which is called * Applications can register a callback function which is called
* before and after a major garbage collection. Allocations are not * before and after a major garbage collection. Allocations are not
* allowed in the callback function, you therefore cannot manipulate * allowed in the callback function, you therefore cannot manipulate
* objects (set or delete properties for example) since it is possible * objects (set or delete properties for example) since it is possible
* such operations will result in the allocation of objects. * such operations will result in the allocation of objects.
*/ */
typedef void (*GCCallback)(); typedef void (*GCCallback)();
// --- C o n t e x t G e n e r a t o r // --- E x t e r n a l S y m b o l C a l l b a c k ---
/**
* Callback used to allocate certain V8 symbols as external strings.
*
* The data passed to the callback is utf8 encoded.
*
* Allocations are not allowed in the callback function, you therefore
* cannot manipulate objects (set or delete properties for example)
* since it is possible such operations will result in the allocation
* of objects.
*/
typedef String::ExternalStringResource* (*ExternalSymbolCallback)(
const char* utf8,
size_t length);
// --- C o n t e x t G e n e r a t o r ---
/** /**
* Applications must provide a callback function which is called to generat e * Applications must provide a callback function which is called to generat e
* a context if a context was not deserialized from the snapshot. * a context if a context was not deserialized from the snapshot.
*/ */
typedef Persistent<Context> (*ContextGenerator)(); typedef Persistent<Context> (*ContextGenerator)();
/** /**
* Container class for static utility functions. * Container class for static utility functions.
*/ */
skipping to change at line 1848 skipping to change at line 1864
/** /**
* Enables the host application to receive a notification after a * Enables the host application to receive a notification after a
* major garbage collection. Allocations are not allowed in the * major garbage collection. Allocations are not allowed in the
* callback function, you therefore cannot manipulate objects (set * callback function, you therefore cannot manipulate objects (set
* or delete properties for example) since it is possible such * or delete properties for example) since it is possible such
* operations will result in the allocation of objects. * operations will result in the allocation of objects.
*/ */
static void SetGlobalGCEpilogueCallback(GCCallback); static void SetGlobalGCEpilogueCallback(GCCallback);
/** /**
* Applications can register a callback that will be used when
* allocating most of the V8 symbols. The callback must return an
* external string resource that represents the symbols.
*
* Most often when performing a property lookup the key will be a
* symbol. Allocating symbols as external strings can reduce the
* amount of string conversions needed when using interceptors and
* accessors.
*
* \note This is an experimental feature and it might be removed.
*/
static void SetExternalSymbolCallback(ExternalSymbolCallback);
/**
* Allows the host application to group objects together. If one * Allows the host application to group objects together. If one
* object in the group is alive, all objects in the group are alive. * object in the group is alive, all objects in the group are alive.
* After each garbage collection, object groups are removed. It is * After each garbage collection, object groups are removed. It is
* intended to be used in the before-garbage-collection callback * intended to be used in the before-garbage-collection callback
* function for istance to simulate DOM tree connections among JS * function, for instance to simulate DOM tree connections among JS
* wrapper objects. * wrapper objects.
*/ */
static void AddObjectToGroup(void* id, Persistent<Object> obj); static void AddObjectGroup(Persistent<Value>* objects, size_t length);
/** /**
* Initializes from snapshot if possible. Otherwise, attempts to * Initializes from snapshot if possible. Otherwise, attempts to
* initialize from scratch. * initialize from scratch.
*/ */
static bool Initialize(); static bool Initialize();
/** /**
* Adjusts the amount of registered external memory. Used to give * Adjusts the amount of registered external memory. Used to give
* V8 an indication of the amount of externally allocated memory * V8 an indication of the amount of externally allocated memory
skipping to change at line 1914 skipping to change at line 1944
TryCatch(); TryCatch();
/** /**
* Unregisters and deletes this try/catch block. * Unregisters and deletes this try/catch block.
*/ */
~TryCatch(); ~TryCatch();
/** /**
* Returns true if an exception has been caught by this try/catch block. * Returns true if an exception has been caught by this try/catch block.
*/ */
bool HasCaught(); bool HasCaught() const;
/** /**
* Returns the exception caught by this try/catch block. If no exception has * Returns the exception caught by this try/catch block. If no exception has
* been caught an empty handle is returned. * been caught an empty handle is returned.
* *
* The returned handle is valid until this TryCatch block has been destro yed. * The returned handle is valid until this TryCatch block has been destro yed.
*/ */
Local<Value> Exception(); Local<Value> Exception() const;
/** /**
* Returns the message associated with this exception. If there is * Returns the message associated with this exception. If there is
* no message associated an empty handle is returned. * no message associated an empty handle is returned.
* *
* The returned handle is valid until this TryCatch block has been * The returned handle is valid until this TryCatch block has been
* destroyed. * destroyed.
*/ */
Local<v8::Message> Message(); Local<v8::Message> Message() const;
/** /**
* Clears any exceptions that may have been caught by this try/catch bloc k. * Clears any exceptions that may have been caught by this try/catch bloc k.
* After this method has been called, HasCaught() will return false. * After this method has been called, HasCaught() will return false.
* *
* It is not necessary to clear a try/catch block before using it again; if * It is not necessary to clear a try/catch block before using it again; if
* another exception is thrown the previously caught exception will just be * another exception is thrown the previously caught exception will just be
* overwritten. However, it is often a good idea since it makes it easie r * overwritten. However, it is often a good idea since it makes it easie r
* to determine which operation threw a given exception. * to determine which operation threw a given exception.
*/ */
skipping to change at line 1967 skipping to change at line 1997
* occurred. True by default. * occurred. True by default.
*/ */
void SetCaptureMessage(bool value); void SetCaptureMessage(bool value);
public: public:
TryCatch* next_; TryCatch* next_;
void* exception_; void* exception_;
void* message_; void* message_;
bool is_verbose_; bool is_verbose_;
bool capture_message_; bool capture_message_;
void* js_handler_;
}; };
// --- C o n t e x t --- // --- C o n t e x t ---
/** /**
* Ignore * Ignore
*/ */
class EXPORT ExtensionConfiguration { class EXPORT ExtensionConfiguration {
public: public:
ExtensionConfiguration(int name_count, const char* names[]) ExtensionConfiguration(int name_count, const char* names[])
skipping to change at line 1990 skipping to change at line 2021
int name_count_; int name_count_;
const char** names_; const char** names_;
}; };
/** /**
* A sandboxed execution context with its own set of built-in objects * A sandboxed execution context with its own set of built-in objects
* and functions. * and functions.
*/ */
class EXPORT Context { class EXPORT Context {
public: public:
/** Returns the global object of the context. */
Local<Object> Global(); Local<Object> Global();
/**
* Detaches the global object from its context before
* the global object can be reused to create a new context.
*/
void DetachGlobal();
/** Creates a new context. */ /** Creates a new context. */
static Persistent<Context> New( static Persistent<Context> New(
ExtensionConfiguration* extensions = 0, ExtensionConfiguration* extensions = 0,
Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(), Handle<ObjectTemplate> global_template = Handle<ObjectTemplate>(),
Handle<Value> global_object = Handle<Value>()); Handle<Value> global_object = Handle<Value>());
/** Returns the last entered context. */ /** Returns the last entered context. */
static Local<Context> GetEntered(); static Local<Context> GetEntered();
/** Returns the context that is on the top of the stack. */ /** Returns the context that is on the top of the stack. */
static Local<Context> GetCurrent(); static Local<Context> GetCurrent();
/** Returns the security context that is currently used. */
static Local<Context> GetCurrentSecurityContext();
/** /**
* Sets the security token for the context. To access an object in * Sets the security token for the context. To access an object in
* another context, the security tokens must match. * another context, the security tokens must match.
*/ */
void SetSecurityToken(Handle<Value> token); void SetSecurityToken(Handle<Value> token);
/** Restores the security token to the default value. */
void UseDefaultSecurityToken();
/** Returns the security token of this context.*/ /** Returns the security token of this context.*/
Handle<Value> GetSecurityToken(); Handle<Value> GetSecurityToken();
/** /**
* Enter this context. After entering a context, all code compiled * Enter this context. After entering a context, all code compiled
* and run is compiled and run in this context. If another context * and run is compiled and run in this context. If another context
* is already entered, this old context is saved so it can be * is already entered, this old context is saved so it can be
* restored when the new context is exited. * restored when the new context is exited.
*/ */
void Enter(); void Enter();
skipping to change at line 2036 skipping to change at line 2074
* context that was in place when entering the current context. * context that was in place when entering the current context.
*/ */
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();
/** Returns true if V8 has a current security context. */
static bool InSecurityContext();
/** /**
* Stack-allocated class which sets the execution context for all * Stack-allocated class which sets the execution context for all
* operations executed within a local scope. * operations executed within a local scope.
*/ */
class EXPORT Scope { class EXPORT Scope {
public: public:
inline Scope(Handle<Context> context) : context_(context) { inline Scope(Handle<Context> context) : context_(context) {
context_->Enter(); context_->Enter();
} }
inline ~Scope() { context_->Exit(); } inline ~Scope() { context_->Exit(); }
skipping to change at line 2158 skipping to change at line 2193
/** /**
* Stop preemption. * Stop preemption.
*/ */
static void StopPreemption(); static void StopPreemption();
/** /**
* Returns whether or not the locker is locked by the current thread. * Returns whether or not the locker is locked by the current thread.
*/ */
static bool IsLocked(); static bool IsLocked();
/**
* Returns whether v8::Locker is being used by this V8 instance.
*/
static bool IsActive() { return active_; }
private: private:
bool has_lock_; bool has_lock_;
bool top_level_; bool top_level_;
static bool active_;
// Disallow copying and assigning. // Disallow copying and assigning.
Locker(const Locker&); Locker(const Locker&);
void operator=(const Locker&); void operator=(const Locker&);
}; };
// --- I m p l e m e n t a t i o n --- // --- I m p l e m e n t a t i o n ---
template <class T> template <class T>
Handle<T>::Handle() : val_(0) { } Handle<T>::Handle() : val_(0) { }
skipping to change at line 2190 skipping to change at line 2232
} }
template <class T> template <class T>
Persistent<T> Persistent<T>::New(Handle<T> that) { Persistent<T> Persistent<T>::New(Handle<T> that) {
if (that.IsEmpty()) return Persistent<T>(); if (that.IsEmpty()) return Persistent<T>();
void** p = reinterpret_cast<void**>(*that); void** p = reinterpret_cast<void**>(*that);
return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p)));
} }
template <class T> template <class T>
bool Persistent<T>::IsNearDeath() { bool Persistent<T>::IsNearDeath() const {
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
return V8::IsGlobalNearDeath(reinterpret_cast<void**>(**this)); return V8::IsGlobalNearDeath(reinterpret_cast<void**>(**this));
} }
template <class T> template <class T>
bool Persistent<T>::IsWeak() { bool Persistent<T>::IsWeak() const {
if (this->IsEmpty()) return false; if (this->IsEmpty()) return false;
return V8::IsGlobalWeak(reinterpret_cast<void**>(**this)); return V8::IsGlobalWeak(reinterpret_cast<void**>(**this));
} }
template <class T> template <class T>
void Persistent<T>::Dispose() { void Persistent<T>::Dispose() {
if (this->IsEmpty()) return; if (this->IsEmpty()) return;
V8::DisposeGlobal(reinterpret_cast<void**>(**this)); V8::DisposeGlobal(reinterpret_cast<void**>(**this));
} }
skipping to change at line 2221 skipping to change at line 2263
void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba ck) { void Persistent<T>::MakeWeak(void* parameters, WeakReferenceCallback callba ck) {
V8::MakeWeak(reinterpret_cast<void**>(**this), parameters, callback); V8::MakeWeak(reinterpret_cast<void**>(**this), parameters, callback);
} }
template <class T> template <class T>
void Persistent<T>::ClearWeak() { void Persistent<T>::ClearWeak() {
V8::ClearWeak(reinterpret_cast<void**>(**this)); V8::ClearWeak(reinterpret_cast<void**>(**this));
} }
template <class T> template <class T>
T* Handle<T>::operator->() { T* Handle<T>::operator->() const {
return val_; return val_;
} }
template <class T> template <class T>
T* Handle<T>::operator*() { T* Handle<T>::operator*() const {
return val_; return val_;
} }
Local<Value> Arguments::operator[](int i) const { Local<Value> Arguments::operator[](int i) const {
if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); if (i < 0 || length_ <= i) return Local<Value>(*Undefined());
return Local<Value>(reinterpret_cast<Value*>(values_ - i)); return Local<Value>(reinterpret_cast<Value*>(values_ - i));
} }
Local<Function> Arguments::Callee() const { Local<Function> Arguments::Callee() const {
return callee_; return callee_;
skipping to change at line 2277 skipping to change at line 2319
Local<Object> AccessorInfo::Holder() const { Local<Object> AccessorInfo::Holder() const {
return holder_; return holder_;
} }
template <class T> template <class T>
Local<T> HandleScope::Close(Handle<T> value) { Local<T> HandleScope::Close(Handle<T> value) {
void** after = RawClose(reinterpret_cast<void**>(*value)); void** after = RawClose(reinterpret_cast<void**>(*value));
return Local<T>(reinterpret_cast<T*>(after)); return Local<T>(reinterpret_cast<T*>(after));
} }
Handle<Value> ScriptOrigin::ResourceName() { Handle<Value> ScriptOrigin::ResourceName() const {
return resource_name_; return resource_name_;
} }
Handle<Integer> ScriptOrigin::ResourceLineOffset() { Handle<Integer> ScriptOrigin::ResourceLineOffset() const {
return resource_line_offset_; return resource_line_offset_;
} }
Handle<Integer> ScriptOrigin::ResourceColumnOffset() { Handle<Integer> ScriptOrigin::ResourceColumnOffset() const {
return resource_column_offset_; return resource_column_offset_;
} }
Handle<Boolean> Boolean::New(bool value) { Handle<Boolean> Boolean::New(bool value) {
return value ? True() : False(); return value ? True() : False();
} }
void Template::Set(const char* name, v8::Handle<Data> value) { void Template::Set(const char* name, v8::Handle<Data> value) {
Set(v8::String::New(name), value); Set(v8::String::New(name), value);
} }
 End of changes. 87 change blocks. 
131 lines changed or deleted 176 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/