v8.h   v8.h 
skipping to change at line 147 skipping to change at line 147
class String; class String;
class StringObject; class StringObject;
class Symbol; class Symbol;
class SymbolObject; class SymbolObject;
class Uint32; class Uint32;
class Utils; class Utils;
class Value; class Value;
template <class T> class Handle; template <class T> class Handle;
template <class T> class Local; template <class T> class Local;
template <class T> class Persistent; template <class T> class Persistent;
class FunctionTemplate;
class ObjectTemplate;
class Data;
class AccessorInfo;
template<typename T> class PropertyCallbackInfo;
class StackTrace;
class StackFrame;
class Isolate;
class DeclaredAccessorDescriptor;
class ObjectOperationDescriptor;
class RawOperationDescriptor;
namespace internal { namespace internal {
class Arguments; class Arguments;
class Heap; class Heap;
class HeapObject; class HeapObject;
class Isolate; class Isolate;
class Object; class Object;
template<typename T>
class CustomArguments;
class PropertyCallbackArguments;
class FunctionCallbackArguments;
} }
/** /**
* General purpose unique identifier. * General purpose unique identifier.
*/ */
class UniqueId { class UniqueId {
public: public:
explicit UniqueId(intptr_t data) explicit UniqueId(intptr_t data)
: data_(data) {} : data_(data) {}
skipping to change at line 1844 skipping to change at line 1859
static void CheckCast(v8::Value* obj); 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 V8EXPORT Number : public Primitive { class V8EXPORT Number : public Primitive {
public: public:
double Value() const; double Value() const;
static Local<Number> New(double value); static Local<Number> New(double value);
static Local<Number> New(Isolate* isolate, double value);
V8_INLINE(static Number* Cast(v8::Value* obj)); V8_INLINE(static Number* Cast(v8::Value* obj));
private: private:
Number(); Number();
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 V8EXPORT Integer : public Number { class V8EXPORT Integer : public Number {
skipping to change at line 1912 skipping to change at line 1928
kExternalPixelArray kExternalPixelArray
}; };
/** /**
* Accessor[Getter|Setter] are used as callback functions when * Accessor[Getter|Setter] are used as callback functions when
* setting|getting a particular property. See Object and ObjectTemplate's * setting|getting a particular property. See Object and ObjectTemplate's
* method SetAccessor. * method SetAccessor.
*/ */
typedef Handle<Value> (*AccessorGetter)(Local<String> property, typedef Handle<Value> (*AccessorGetter)(Local<String> property,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*AccessorGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
typedef void (*AccessorSetter)(Local<String> property, typedef void (*AccessorSetter)(Local<String> property,
Local<Value> value, Local<Value> value,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*AccessorSetterCallback)(
Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<void>& info);
/** /**
* Access control specifications. * Access control specifications.
* *
* Some accessors should be accessible across contexts. These * Some accessors should be accessible across contexts. These
* accessors have an explicit access control parameter which specifies * accessors have an explicit access control parameter which specifies
* the kind of cross-context access that should be allowed. * the kind of cross-context access that should be allowed.
* *
* Additionally, for security, accessors can prohibit overwriting by * Additionally, for security, accessors can prohibit overwriting by
* accessors defined in JavaScript. For objects that have such * accessors defined in JavaScript. For objects that have such
skipping to change at line 1983 skipping to change at line 2006
bool Delete(Handle<Value> key); bool Delete(Handle<Value> 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.
bool ForceDelete(Handle<Value> key); bool ForceDelete(Handle<Value> key);
bool Has(uint32_t index); bool Has(uint32_t index);
bool Delete(uint32_t index); bool Delete(uint32_t index);
// TODO(dcarney): deprecate
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);
bool SetAccessor(Handle<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None);
// This function is not yet stable and should not be used at this time. // This function is not yet stable and should not be used at this time.
bool SetAccessor(Handle<String> name, bool SetAccessor(Handle<String> name,
Handle<DeclaredAccessorDescriptor> descriptor, Handle<DeclaredAccessorDescriptor> descriptor,
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
skipping to change at line 2655 skipping to change at line 2685
void Set(Handle<String> name, Handle<Data> value, void Set(Handle<String> name, Handle<Data> value,
PropertyAttribute attributes = None); PropertyAttribute attributes = None);
V8_INLINE(void Set(const char* name, Handle<Data> value)); V8_INLINE(void Set(const char* name, Handle<Data> value));
private: private:
Template(); Template();
friend class ObjectTemplate; friend class ObjectTemplate;
friend class FunctionTemplate; friend class FunctionTemplate;
}; };
template<typename T>
class V8EXPORT ReturnValue {
public:
V8_INLINE(explicit ReturnValue(internal::Object** slot));
// Handle setters
V8_INLINE(void Set(const Persistent<T>& handle));
V8_INLINE(void Set(const Handle<T> handle));
// Fast primitive setters
V8_INLINE(void Set(Isolate* isolate, bool value));
V8_INLINE(void Set(Isolate* isolate, double i));
V8_INLINE(void Set(Isolate* isolate, int32_t i));
V8_INLINE(void Set(Isolate* isolate, uint32_t i));
// Fast JS primitive setters
V8_INLINE(void SetNull(Isolate* isolate));
V8_INLINE(void SetUndefined(Isolate* isolate));
private:
V8_INLINE(void SetTrue(Isolate* isolate));
V8_INLINE(void SetFalse(Isolate* isolate));
internal::Object** value_;
};
/** /**
* 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 V8EXPORT Arguments { template<typename T>
class V8EXPORT FunctionCallbackInfo {
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);
V8_INLINE(ReturnValue<T> GetReturnValue() const);
// This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 5;
private: protected:
static const int kIsolateIndex = 0; friend class internal::FunctionCallbackArguments;
static const int kDataIndex = -1; friend class internal::CustomArguments<FunctionCallbackInfo>;
static const int kCalleeIndex = -2; static const int kReturnValueIndex = 0;
static const int kHolderIndex = -3; static const int kIsolateIndex = -1;
static const int kDataIndex = -2;
static const int kCalleeIndex = -3;
static const int kHolderIndex = -4;
friend class ImplementationUtilities; V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args,
V8_INLINE(Arguments(internal::Object** implicit_args,
internal::Object** values, internal::Object** values,
int length, int length,
bool is_construct_call)); bool is_construct_call));
internal::Object** implicit_args_; internal::Object** implicit_args_;
internal::Object** values_; internal::Object** values_;
int length_; int length_;
bool is_construct_call_; bool is_construct_call_;
}; };
class V8EXPORT Arguments : public FunctionCallbackInfo<Value> {
private:
friend class internal::FunctionCallbackArguments;
V8_INLINE(Arguments(internal::Object** implicit_args,
internal::Object** values,
int length,
bool is_construct_call));
};
/** /**
* The information passed to an accessor callback about the context * The information passed to a property callback about the context
* of the property access. * of the property access.
*/ */
class V8EXPORT AccessorInfo { template<typename T>
class V8EXPORT PropertyCallbackInfo {
public: public:
V8_INLINE(AccessorInfo(internal::Object** args))
: args_(args) { }
V8_INLINE(Isolate* GetIsolate() const); V8_INLINE(Isolate* GetIsolate() const);
V8_INLINE(Local<Value> Data() const); V8_INLINE(Local<Value> Data() 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(ReturnValue<T> GetReturnValue() const);
// This shouldn't be public, but the arm compiler needs it.
static const int kArgsLength = 5;
private: protected:
friend class MacroAssembler;
friend class internal::PropertyCallbackArguments;
friend class internal::CustomArguments<PropertyCallbackInfo>;
static const int kThisIndex = 0;
static const int kHolderIndex = -1;
static const int kDataIndex = -2;
static const int kIsolateIndex = -3;
static const int kReturnValueIndex = -4;
V8_INLINE(PropertyCallbackInfo(internal::Object** args))
: args_(args) { }
internal::Object** args_; internal::Object** args_;
}; };
class V8EXPORT AccessorInfo : public PropertyCallbackInfo<Value> {
private:
friend class internal::PropertyCallbackArguments;
V8_INLINE(AccessorInfo(internal::Object** args))
: PropertyCallbackInfo<Value>(args) { }
};
typedef Handle<Value> (*InvocationCallback)(const Arguments& args); typedef Handle<Value> (*InvocationCallback)(const Arguments& args);
typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info);
/** /**
* NamedProperty[Getter|Setter] are used as interceptors on object. * NamedProperty[Getter|Setter] are used as interceptors on object.
* See ObjectTemplate::SetNamedPropertyHandler. * See ObjectTemplate::SetNamedPropertyHandler.
*/ */
typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*NamedPropertyGetterCallback)(
Local<String> property,
const PropertyCallbackInfo<Value>& info);
/** /**
* Returns the value if the setter intercepts the request. * Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle. * Otherwise, returns an empty handle.
*/ */
typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, typedef Handle<Value> (*NamedPropertySetter)(Local<String> property,
Local<Value> value, Local<Value> value,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*NamedPropertySetterCallback)(
Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/** /**
* Returns a non-empty handle if the interceptor intercepts the request. * Returns a non-empty handle if the interceptor intercepts the request.
* The result is an integer encoding property attributes (like v8::None, * The result is an integer encoding property attributes (like v8::None,
* v8::DontEnum, etc.) * v8::DontEnum, etc.)
*/ */
typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*NamedPropertyQueryCallback)(
Local<String> property,
const PropertyCallbackInfo<Integer>& info);
/** /**
* Returns a non-empty handle if the deleter intercepts the request. * Returns a non-empty handle if the deleter intercepts the request.
* The return value is true if the property could be deleted and false * The return value is true if the property could be deleted and false
* otherwise. * otherwise.
*/ */
typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*NamedPropertyDeleterCallback)(
Local<String> property,
const PropertyCallbackInfo<Boolean>& info);
/** /**
* Returns an array containing the names of the properties the named * Returns an array containing the names of the properties the named
* property getter intercepts. * property getter intercepts.
*/ */
typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info); typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info);
typedef void (*NamedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
/** /**
* Returns the value of the property if the getter intercepts the * Returns the value of the property if the getter intercepts the
* request. Otherwise, returns an empty handle. * request. Otherwise, returns an empty handle.
*/ */
typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index, typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*IndexedPropertyGetterCallback)(
uint32_t index,
const PropertyCallbackInfo<Value>& info);
/** /**
* Returns the value if the setter intercepts the request. * Returns the value if the setter intercepts the request.
* Otherwise, returns an empty handle. * Otherwise, returns an empty handle.
*/ */
typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index,
Local<Value> value, Local<Value> value,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*IndexedPropertySetterCallback)(
uint32_t index,
Local<Value> value,
const PropertyCallbackInfo<Value>& info);
/** /**
* Returns a non-empty handle if the interceptor intercepts the request. * Returns a non-empty handle if the interceptor intercepts the request.
* The result is an integer encoding property attributes. * The result is an integer encoding property attributes.
*/ */
typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index,
const AccessorInfo& info); const AccessorInfo& info);
typedef void (*IndexedPropertyQueryCallback)(
uint32_t index,
const PropertyCallbackInfo<Integer>& info);
/** /**
* Returns a non-empty handle if the deleter intercepts the request. * Returns a non-empty handle if the deleter intercepts the request.
* The return value is true if the property could be deleted and false * The return value is true if the property could be deleted and false
* otherwise. * otherwise.
*/ */
typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index,
const AccessorInfo& info) ; const AccessorInfo& info) ;
typedef void (*IndexedPropertyDeleterCallback)(
uint32_t index,
const PropertyCallbackInfo<Boolean>& info);
/** /**
* Returns an array containing the indices of the properties the * Returns an array containing the indices of the properties the
* indexed property getter intercepts. * indexed property getter intercepts.
*/ */
typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info ); typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info );
typedef void (*IndexedPropertyEnumeratorCallback)(
const PropertyCallbackInfo<Array>& info);
/** /**
* Access type specification. * Access type specification.
*/ */
enum AccessType { enum AccessType {
ACCESS_GET, ACCESS_GET,
ACCESS_SET, ACCESS_SET,
ACCESS_HAS, ACCESS_HAS,
ACCESS_DELETE, ACCESS_DELETE,
ACCESS_KEYS ACCESS_KEYS
skipping to change at line 2905 skipping to change at line 3022
* *
* \code * \code
* child_func.prototype.__proto__ == function.prototype; * child_func.prototype.__proto__ == function.prototype;
* child_instance.instance_accessor calls 'InstanceAccessorCallback' * child_instance.instance_accessor calls 'InstanceAccessorCallback'
* child_instance.instance_property == 3; * child_instance.instance_property == 3;
* \endcode * \endcode
*/ */
class V8EXPORT FunctionTemplate : public Template { class V8EXPORT FunctionTemplate : public Template {
public: public:
/** Creates a function template.*/ /** Creates a function template.*/
// TODO(dcarney): deprecate
static Local<FunctionTemplate> New( static Local<FunctionTemplate> New(
InvocationCallback callback = 0, InvocationCallback callback = 0,
Handle<Value> data = Handle<Value>(), Handle<Value> data = Handle<Value>(),
Handle<Signature> signature = Handle<Signature>(), Handle<Signature> signature = Handle<Signature>(),
int length = 0); int length = 0);
static Local<FunctionTemplate> New(
FunctionCallback callback, // TODO(dcarney): add back default param.
Handle<Value> data = Handle<Value>(),
Handle<Signature> signature = Handle<Signature>(),
int length = 0);
/** Returns the unique function instance in the current execution context .*/ /** Returns the unique function instance in the current execution context .*/
Local<Function> GetFunction(); Local<Function> GetFunction();
/** /**
* Set the call-handler callback for a FunctionTemplate. This * Set the call-handler callback for a FunctionTemplate. This
* callback is called whenever the function created from this * callback is called whenever the function created from this
* FunctionTemplate is called. * FunctionTemplate is called.
*/ */
// TODO(dcarney): deprecate
void SetCallHandler(InvocationCallback callback, void SetCallHandler(InvocationCallback callback,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>());
void SetCallHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>());
/** Set the predefined length property for the FunctionTemplate. */ /** Set the predefined length property for the FunctionTemplate. */
void SetLength(int length); void SetLength(int length);
/** Get the InstanceTemplate. */ /** Get the InstanceTemplate. */
Local<ObjectTemplate> InstanceTemplate(); Local<ObjectTemplate> InstanceTemplate();
/** Causes the function template to inherit from a parent function templa te.*/ /** Causes the function template to inherit from a parent function templa te.*/
void Inherit(Handle<FunctionTemplate> parent); void Inherit(Handle<FunctionTemplate> parent);
skipping to change at line 2971 skipping to change at line 3098
void ReadOnlyPrototype(); void ReadOnlyPrototype();
/** /**
* Returns true if the given object is an instance of this function * Returns true if the given object is an instance of this function
* template. * template.
*/ */
bool HasInstance(Handle<Value> object); bool HasInstance(Handle<Value> object);
private: private:
FunctionTemplate(); FunctionTemplate();
void SetNamedInstancePropertyHandler(NamedPropertyGetter getter,
NamedPropertySetter setter,
NamedPropertyQuery query,
NamedPropertyDeleter remover,
NamedPropertyEnumerator enumerator,
Handle<Value> data);
void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter,
IndexedPropertySetter setter,
IndexedPropertyQuery query,
IndexedPropertyDeleter remover,
IndexedPropertyEnumerator enumerat
or,
Handle<Value> data);
void SetInstanceCallAsFunctionHandler(InvocationCallback callback,
Handle<Value> data);
friend class Context; friend class Context;
friend class ObjectTemplate; friend class ObjectTemplate;
}; };
/** /**
* An ObjectTemplate is used to create objects at runtime. * An ObjectTemplate is used to create objects at runtime.
* *
* Properties added to an ObjectTemplate are added to each object * Properties added to an ObjectTemplate are added to each object
* created from the ObjectTemplate. * created from the ObjectTemplate.
*/ */
skipping to change at line 3033 skipping to change at line 3145
* The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow al l * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow al l
* cross-context access. * cross-context access.
* \param attribute The attributes of the property for which an accessor * \param attribute The attributes of the property for which an accessor
* is added. * is added.
* \param signature The signature describes valid receivers for the acces sor * \param signature The signature describes valid receivers for the acces sor
* and is used to perform implicit instance checks against them. If the * and is used to perform implicit instance checks against them. If the
* receiver is incompatible (i.e. is not an instance of the constructor as * receiver is incompatible (i.e. is not an instance of the constructor as
* defined by FunctionTemplate::HasInstance()), an implicit TypeError i s * defined by FunctionTemplate::HasInstance()), an implicit TypeError i s
* thrown and no callback is invoked. * thrown and no callback is invoked.
*/ */
// TODO(dcarney): deprecate
void SetAccessor(Handle<String> name, void 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,
Handle<AccessorSignature> signature = Handle<AccessorSignature> signature =
Handle<AccessorSignature>()); Handle<AccessorSignature>());
void SetAccessor(Handle<String> name,
AccessorGetterCallback getter,
AccessorSetterCallback setter = 0,
Handle<Value> data = Handle<Value>(),
AccessControl settings = DEFAULT,
PropertyAttribute attribute = None,
Handle<AccessorSignature> signature =
Handle<AccessorSignature>());
// This function is not yet stable and should not be used at this time. // This function is not yet stable and should not be used at this time.
bool SetAccessor(Handle<String> name, bool SetAccessor(Handle<String> name,
Handle<DeclaredAccessorDescriptor> descriptor, Handle<DeclaredAccessorDescriptor> descriptor,
AccessControl settings = DEFAULT, AccessControl settings = DEFAULT,
PropertyAttribute attribute = None, PropertyAttribute attribute = None,
Handle<AccessorSignature> signature = Handle<AccessorSignature> signature =
Handle<AccessorSignature>()); Handle<AccessorSignature>());
/** /**
skipping to change at line 3067 skipping to change at line 3188
* \param getter The callback to invoke when getting a property. * \param getter The callback to invoke when getting a property.
* \param setter The callback to invoke when setting a property. * \param setter The callback to invoke when setting a property.
* \param query The callback to invoke to check if a property is present, * \param query The callback to invoke to check if a property is present,
* and if present, get its attributes. * and if present, get its attributes.
* \param deleter The callback to invoke when deleting a property. * \param deleter The callback to invoke when deleting a property.
* \param enumerator The callback to invoke to enumerate all the named * \param enumerator The callback to invoke to enumerate all the named
* properties of an object. * properties of an object.
* \param data A piece of data that will be passed to the callbacks * \param data A piece of data that will be passed to the callbacks
* whenever they are invoked. * whenever they are invoked.
*/ */
// TODO(dcarney): deprecate
void SetNamedPropertyHandler(NamedPropertyGetter getter, void SetNamedPropertyHandler(NamedPropertyGetter getter,
NamedPropertySetter setter = 0, NamedPropertySetter setter = 0,
NamedPropertyQuery query = 0, NamedPropertyQuery query = 0,
NamedPropertyDeleter deleter = 0, NamedPropertyDeleter deleter = 0,
NamedPropertyEnumerator enumerator = 0, NamedPropertyEnumerator enumerator = 0,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>());
void SetNamedPropertyHandler(
NamedPropertyGetterCallback getter,
NamedPropertySetterCallback setter = 0,
NamedPropertyQueryCallback query = 0,
NamedPropertyDeleterCallback deleter = 0,
NamedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>());
/** /**
* Sets an indexed property handler on the object template. * Sets an indexed property handler on the object template.
* *
* Whenever an indexed property is accessed on objects created from * Whenever an indexed property is accessed on objects created from
* this object template, the provided callback is invoked instead of * this object template, the provided callback is invoked instead of
* accessing the property directly on the JavaScript object. * accessing the property directly on the JavaScript object.
* *
* \param getter The callback to invoke when getting a property. * \param getter The callback to invoke when getting a property.
* \param setter The callback to invoke when setting a property. * \param setter The callback to invoke when setting a property.
* \param query The callback to invoke to check if an object has a proper ty. * \param query The callback to invoke to check if an object has a proper ty.
* \param deleter The callback to invoke when deleting a property. * \param deleter The callback to invoke when deleting a property.
* \param enumerator The callback to invoke to enumerate all the indexed * \param enumerator The callback to invoke to enumerate all the indexed
* properties of an object. * properties of an object.
* \param data A piece of data that will be passed to the callbacks * \param data A piece of data that will be passed to the callbacks
* whenever they are invoked. * whenever they are invoked.
*/ */
// TODO(dcarney): deprecate
void SetIndexedPropertyHandler(IndexedPropertyGetter getter, void SetIndexedPropertyHandler(IndexedPropertyGetter getter,
IndexedPropertySetter setter = 0, IndexedPropertySetter setter = 0,
IndexedPropertyQuery query = 0, IndexedPropertyQuery query = 0,
IndexedPropertyDeleter deleter = 0, IndexedPropertyDeleter deleter = 0,
IndexedPropertyEnumerator enumerator = 0, IndexedPropertyEnumerator enumerator = 0,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>());
void SetIndexedPropertyHandler(
IndexedPropertyGetterCallback getter,
IndexedPropertySetterCallback setter = 0,
IndexedPropertyQueryCallback query = 0,
IndexedPropertyDeleterCallback deleter = 0,
IndexedPropertyEnumeratorCallback enumerator = 0,
Handle<Value> data = Handle<Value>());
/** /**
* Sets the callback to be used when calling instances created from * Sets the callback to be used when calling instances created from
* this template as a function. If no callback is set, instances * this template as a function. If no callback is set, instances
* behave like normal JavaScript objects that cannot be called as a * behave like normal JavaScript objects that cannot be called as a
* function. * function.
*/ */
// TODO(dcarney): deprecate
void SetCallAsFunctionHandler(InvocationCallback callback, void SetCallAsFunctionHandler(InvocationCallback callback,
Handle<Value> data = Handle<Value>()); Handle<Value> data = Handle<Value>());
void SetCallAsFunctionHandler(FunctionCallback callback,
Handle<Value> data = Handle<Value>());
/** /**
* Mark object instances of the template as undetectable. * Mark object instances of the template as undetectable.
* *
* In many ways, undetectable objects behave as though they are not * In many ways, undetectable objects behave as though they are not
* there. They behave like 'undefined' in conditionals and when * there. They behave like 'undefined' in conditionals and when
* printed. However, properties can be accessed and called as on * printed. However, properties can be accessed and called as on
* normal objects. * normal objects.
*/ */
void MarkAsUndetectable(); void MarkAsUndetectable();
skipping to change at line 4892 skipping to change at line 5032
const int kHeapObjectTagSize = 2; const int kHeapObjectTagSize = 2;
const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1;
// Tag information for Smi. // Tag information for Smi.
const int kSmiTag = 0; const int kSmiTag = 0;
const int kSmiTagSize = 1; const int kSmiTagSize = 1;
const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1;
template <size_t ptr_size> struct SmiTagging; template <size_t ptr_size> struct SmiTagging;
template<int kSmiShiftSize>
V8_INLINE(internal::Object* IntToSmi(int value)) {
int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
intptr_t tagged_value =
(static_cast<intptr_t>(value) << smi_shift_bits) | kSmiTag;
return reinterpret_cast<internal::Object*>(tagged_value);
}
// Smi constants for 32-bit systems. // Smi constants for 32-bit systems.
template <> struct SmiTagging<4> { template <> struct SmiTagging<4> {
static const int kSmiShiftSize = 0; static const int kSmiShiftSize = 0;
static const int kSmiValueSize = 31; static const int kSmiValueSize = 31;
V8_INLINE(static int SmiToInt(internal::Object* value)) { V8_INLINE(static int SmiToInt(internal::Object* value)) {
int shift_bits = kSmiTagSize + kSmiShiftSize; int shift_bits = kSmiTagSize + kSmiShiftSize;
// Throw away top 32 bits and shift down (requires >> to be sign extend ing). // Throw away top 32 bits and shift down (requires >> to be sign extend ing).
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit s; return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bit s;
} }
V8_INLINE(static internal::Object* IntToSmi(int value)) {
return internal::IntToSmi<kSmiShiftSize>(value);
}
V8_INLINE(static bool IsValidSmi(intptr_t value)) {
// To be representable as an tagged small integer, the two
// most-significant bits of 'value' must be either 00 or 11 due to
// sign-extension. To check this we add 01 to the two
// most-significant bits, and check if the most-significant bit is 0
//
// CAUTION: The original code below:
// bool result = ((value + 0x40000000) & 0x80000000) == 0;
// may lead to incorrect results according to the C language spec, and
// in fact doesn't work correctly with gcc4.1.1 in some cases: The
// compiler may produce undefined results in case of signed integer
// overflow. The computation must be done w/ unsigned ints.
return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U;
}
}; };
// Smi constants for 64-bit systems. // Smi constants for 64-bit systems.
template <> struct SmiTagging<8> { template <> struct SmiTagging<8> {
static const int kSmiShiftSize = 31; static const int kSmiShiftSize = 31;
static const int kSmiValueSize = 32; static const int kSmiValueSize = 32;
V8_INLINE(static int SmiToInt(internal::Object* value)) { V8_INLINE(static int SmiToInt(internal::Object* value)) {
int shift_bits = kSmiTagSize + kSmiShiftSize; int shift_bits = kSmiTagSize + kSmiShiftSize;
// Shift down and throw away top 32 bits. // Shift down and throw away top 32 bits.
return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits ); return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits );
} }
V8_INLINE(static internal::Object* IntToSmi(int value)) {
return internal::IntToSmi<kSmiShiftSize>(value);
}
V8_INLINE(static bool IsValidSmi(intptr_t value)) {
// To be representable as a long smi, the value must be a 32-bit intege
r.
return (value == static_cast<int32_t>(value));
}
}; };
typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; typedef SmiTagging<kApiPointerSize> PlatformSmiTagging;
const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize;
const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize;
/** /**
* This class exports constants and functionality from within v8 that * This class exports constants and functionality from within v8 that
* is necessary to implement inline functions in the v8 api. Don't * is necessary to implement inline functions in the v8 api. Don't
* depend on functions and constants defined here. * depend on functions and constants defined here.
skipping to change at line 4976 skipping to change at line 5148
V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) { V8_INLINE(static bool HasHeapObjectTag(internal::Object* value)) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
kHeapObjectTag); kHeapObjectTag);
} }
V8_INLINE(static int SmiValue(internal::Object* value)) { V8_INLINE(static int SmiValue(internal::Object* value)) {
return PlatformSmiTagging::SmiToInt(value); return PlatformSmiTagging::SmiToInt(value);
} }
V8_INLINE(static internal::Object* IntToSmi(int value)) {
return PlatformSmiTagging::IntToSmi(value);
}
V8_INLINE(static bool IsValidSmi(intptr_t value)) {
return PlatformSmiTagging::IsValidSmi(value);
}
V8_INLINE(static int GetInstanceType(internal::Object* obj)) { V8_INLINE(static int GetInstanceType(internal::Object* obj)) {
typedef internal::Object O; typedef internal::Object O;
O* map = ReadField<O*>(obj, kHeapObjectMapOffset); O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
return ReadField<uint8_t>(map, kMapInstanceTypeOffset); return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
} }
V8_INLINE(static int GetOddballKind(internal::Object* obj)) { V8_INLINE(static int GetOddballKind(internal::Object* obj)) {
typedef internal::Object O; typedef internal::Object O;
return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
} }
skipping to change at line 5331 skipping to change at line 5511
template <class T> template <class T>
uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const { uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const {
typedef internal::Internals I; typedef internal::Internals I;
if (this->IsEmpty()) return 0; if (this->IsEmpty()) return 0;
if (!I::IsInitialized(isolate)) return 0; if (!I::IsInitialized(isolate)) return 0;
internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_) ; internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_) ;
uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
return *reinterpret_cast<uint16_t*>(addr); return *reinterpret_cast<uint16_t*>(addr);
} }
Arguments::Arguments(internal::Object** implicit_args, template<typename T>
internal::Object** values, int length, ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {}
bool is_construct_call)
template<typename T>
void ReturnValue<T>::Set(const Persistent<T>& handle) {
*value_ = *reinterpret_cast<internal::Object**>(*handle);
}
template<typename T>
void ReturnValue<T>::Set(const Handle<T> handle) {
*value_ = *reinterpret_cast<internal::Object**>(*handle);
}
template<typename T>
void ReturnValue<T>::Set(Isolate* isolate, double i) {
Set(Number::New(isolate, i));
}
template<typename T>
void ReturnValue<T>::Set(Isolate* isolate, int32_t i) {
typedef internal::Internals I;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
return;
}
Set(Integer::New(i, isolate));
}
template<typename T>
void ReturnValue<T>::Set(Isolate* isolate, uint32_t i) {
typedef internal::Internals I;
if (V8_LIKELY(I::IsValidSmi(i))) {
*value_ = I::IntToSmi(i);
return;
}
Set(Integer::NewFromUnsigned(i, isolate));
}
template<typename T>
void ReturnValue<T>::Set(Isolate* isolate, bool value) {
if (value) {
SetTrue(isolate);
} else {
SetFalse(isolate);
}
}
template<typename T>
void ReturnValue<T>::SetTrue(Isolate* isolate) {
typedef internal::Internals I;
*value_ = *I::GetRoot(isolate, I::kTrueValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetFalse(Isolate* isolate) {
typedef internal::Internals I;
*value_ = *I::GetRoot(isolate, I::kFalseValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetNull(Isolate* isolate) {
typedef internal::Internals I;
*value_ = *I::GetRoot(isolate, I::kNullValueRootIndex);
}
template<typename T>
void ReturnValue<T>::SetUndefined(Isolate* isolate) {
typedef internal::Internals I;
*value_ = *I::GetRoot(isolate, I::kUndefinedValueRootIndex);
}
template<typename T>
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_a
rgs,
internal::Object** values,
int length,
bool is_construct_call)
: implicit_args_(implicit_args), : implicit_args_(implicit_args),
values_(values), values_(values),
length_(length), length_(length),
is_construct_call_(is_construct_call) { } is_construct_call_(is_construct_call) { }
Local<Value> Arguments::operator[](int i) const { Arguments::Arguments(internal::Object** args,
internal::Object** values,
int length,
bool is_construct_call)
: FunctionCallbackInfo<Value>(args, values, length, is_construct_call)
{ }
template<typename T>
Local<Value> FunctionCallbackInfo<T>::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 { template<typename T>
Local<Function> FunctionCallbackInfo<T>::Callee() const {
return Local<Function>(reinterpret_cast<Function*>( return Local<Function>(reinterpret_cast<Function*>(
&implicit_args_[kCalleeIndex])); &implicit_args_[kCalleeIndex]));
} }
Local<Object> Arguments::This() const { template<typename T>
Local<Object> FunctionCallbackInfo<T>::This() const {
return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); return Local<Object>(reinterpret_cast<Object*>(values_ + 1));
} }
Local<Object> Arguments::Holder() const { template<typename T>
Local<Object> FunctionCallbackInfo<T>::Holder() const {
return Local<Object>(reinterpret_cast<Object*>( return Local<Object>(reinterpret_cast<Object*>(
&implicit_args_[kHolderIndex])); &implicit_args_[kHolderIndex]));
} }
Local<Value> Arguments::Data() const { template<typename T>
Local<Value> FunctionCallbackInfo<T>::Data() const {
return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]) ); return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex]) );
} }
Isolate* Arguments::GetIsolate() const { template<typename T>
Isolate* FunctionCallbackInfo<T>::GetIsolate() const {
return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]); return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
} }
bool Arguments::IsConstructCall() const { template<typename T>
ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const {
return ReturnValue<T>(&implicit_args_[kReturnValueIndex]);
}
template<typename T>
bool FunctionCallbackInfo<T>::IsConstructCall() const {
return is_construct_call_; return is_construct_call_;
} }
int Arguments::Length() const { template<typename T>
int FunctionCallbackInfo<T>::Length() const {
return length_; return length_;
} }
template <class T> template <class T>
Local<T> HandleScope::Close(Handle<T> value) { Local<T> HandleScope::Close(Handle<T> value) {
internal::Object** before = reinterpret_cast<internal::Object**>(*value); internal::Object** before = reinterpret_cast<internal::Object**>(*value);
internal::Object** after = RawClose(before); internal::Object** after = RawClose(before);
return Local<T>(reinterpret_cast<T*>(after)); return Local<T>(reinterpret_cast<T*>(after));
} }
skipping to change at line 5716 skipping to change at line 5988
return static_cast<Function*>(value); return static_cast<Function*>(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 { template<typename T>
return *reinterpret_cast<Isolate**>(&args_[-3]); Isolate* PropertyCallbackInfo<T>::GetIsolate() const {
return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
}
template<typename T>
Local<Value> PropertyCallbackInfo<T>::Data() const {
return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex]));
} }
Local<Value> AccessorInfo::Data() const { template<typename T>
return Local<Value>(reinterpret_cast<Value*>(&args_[-2])); Local<Object> PropertyCallbackInfo<T>::This() const {
return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex]));
} }
Local<Object> AccessorInfo::This() const { template<typename T>
return Local<Object>(reinterpret_cast<Object*>(&args_[0])); Local<Object> PropertyCallbackInfo<T>::Holder() const {
return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex]));
} }
Local<Object> AccessorInfo::Holder() const { template<typename T>
return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
return ReturnValue<T>(&args_[kReturnValueIndex]);
} }
Handle<Primitive> Undefined(Isolate* isolate) { Handle<Primitive> Undefined(Isolate* isolate) {
typedef internal::Object* S; typedef internal::Object* S;
typedef internal::Internals I; typedef internal::Internals I;
if (!I::IsInitialized(isolate)) return Undefined(); if (!I::IsInitialized(isolate)) return Undefined();
S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); return Handle<Primitive>(reinterpret_cast<Primitive*>(slot));
} }
 End of changes. 60 change blocks. 
48 lines changed or deleted 331 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/