| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 # define V8_EXPORT | 76 # define V8_EXPORT |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 #endif // V8_OS_WIN | 79 #endif // V8_OS_WIN |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * The v8 JavaScript engine. | 82 * The v8 JavaScript engine. |
| 83 */ | 83 */ |
| 84 namespace v8 { | 84 namespace v8 { |
| 85 | 85 |
| 86 class AccessorInfo; | |
| 87 class AccessorSignature; | 86 class AccessorSignature; |
| 88 class Array; | 87 class Array; |
| 89 class Boolean; | 88 class Boolean; |
| 90 class BooleanObject; | 89 class BooleanObject; |
| 91 class Context; | 90 class Context; |
| 92 class CpuProfiler; | 91 class CpuProfiler; |
| 93 class Data; | 92 class Data; |
| 94 class Date; | 93 class Date; |
| 95 class DeclaredAccessorDescriptor; | 94 class DeclaredAccessorDescriptor; |
| 96 class External; | 95 class External; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 118 class Uint32; | 117 class Uint32; |
| 119 class Utils; | 118 class Utils; |
| 120 class Value; | 119 class Value; |
| 121 template <class T> class Handle; | 120 template <class T> class Handle; |
| 122 template <class T> class Local; | 121 template <class T> class Local; |
| 123 template <class T> class Eternal; | 122 template <class T> class Eternal; |
| 124 template <class T> class Persistent; | 123 template <class T> class Persistent; |
| 125 class FunctionTemplate; | 124 class FunctionTemplate; |
| 126 class ObjectTemplate; | 125 class ObjectTemplate; |
| 127 class Data; | 126 class Data; |
| 128 class AccessorInfo; | |
| 129 template<typename T> class PropertyCallbackInfo; | 127 template<typename T> class PropertyCallbackInfo; |
| 130 class StackTrace; | 128 class StackTrace; |
| 131 class StackFrame; | 129 class StackFrame; |
| 132 class Isolate; | 130 class Isolate; |
| 133 class DeclaredAccessorDescriptor; | 131 class DeclaredAccessorDescriptor; |
| 134 class ObjectOperationDescriptor; | 132 class ObjectOperationDescriptor; |
| 135 class RawOperationDescriptor; | 133 class RawOperationDescriptor; |
| 136 class CallHandlerHelper; | 134 class CallHandlerHelper; |
| 137 | 135 |
| 138 namespace internal { | 136 namespace internal { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 /** | 342 /** |
| 345 * Creates a new handle for the specified value. | 343 * Creates a new handle for the specified value. |
| 346 */ | 344 */ |
| 347 V8_INLINE(explicit Handle(T* val)) : val_(val) {} | 345 V8_INLINE(explicit Handle(T* val)) : val_(val) {} |
| 348 #endif | 346 #endif |
| 349 | 347 |
| 350 private: | 348 private: |
| 351 friend class Utils; | 349 friend class Utils; |
| 352 template<class F> friend class Persistent; | 350 template<class F> friend class Persistent; |
| 353 template<class F> friend class Local; | 351 template<class F> friend class Local; |
| 354 friend class Arguments; | |
| 355 template<class F> friend class FunctionCallbackInfo; | 352 template<class F> friend class FunctionCallbackInfo; |
| 356 template<class F> friend class PropertyCallbackInfo; | 353 template<class F> friend class PropertyCallbackInfo; |
| 357 template<class F> friend class internal::CustomArguments; | 354 template<class F> friend class internal::CustomArguments; |
| 358 friend class AccessorInfo; | |
| 359 friend Handle<Primitive> Undefined(Isolate* isolate); | 355 friend Handle<Primitive> Undefined(Isolate* isolate); |
| 360 friend Handle<Primitive> Null(Isolate* isolate); | 356 friend Handle<Primitive> Null(Isolate* isolate); |
| 361 friend Handle<Boolean> True(Isolate* isolate); | 357 friend Handle<Boolean> True(Isolate* isolate); |
| 362 friend Handle<Boolean> False(Isolate* isolate); | 358 friend Handle<Boolean> False(Isolate* isolate); |
| 363 friend class Context; | 359 friend class Context; |
| 364 friend class HandleScope; | 360 friend class HandleScope; |
| 365 | 361 |
| 366 #ifndef V8_USE_UNSAFE_HANDLES | 362 #ifndef V8_USE_UNSAFE_HANDLES |
| 367 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); | 363 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); |
| 368 #endif | 364 #endif |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 private: | 428 private: |
| 433 #endif | 429 #endif |
| 434 template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } | 430 template <class S> V8_INLINE(Local(S* that) : Handle<T>(that)) { } |
| 435 #endif | 431 #endif |
| 436 | 432 |
| 437 private: | 433 private: |
| 438 friend class Utils; | 434 friend class Utils; |
| 439 template<class F> friend class Eternal; | 435 template<class F> friend class Eternal; |
| 440 template<class F> friend class Persistent; | 436 template<class F> friend class Persistent; |
| 441 template<class F> friend class Handle; | 437 template<class F> friend class Handle; |
| 442 friend class Arguments; | |
| 443 template<class F> friend class FunctionCallbackInfo; | 438 template<class F> friend class FunctionCallbackInfo; |
| 444 template<class F> friend class PropertyCallbackInfo; | 439 template<class F> friend class PropertyCallbackInfo; |
| 445 friend class String; | 440 friend class String; |
| 446 friend class Object; | 441 friend class Object; |
| 447 friend class AccessorInfo; | |
| 448 friend class Context; | 442 friend class Context; |
| 449 template<class F> friend class internal::CustomArguments; | 443 template<class F> friend class internal::CustomArguments; |
| 450 friend class HandleScope; | 444 friend class HandleScope; |
| 451 | 445 |
| 452 V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); | 446 V8_INLINE(static Local<T> New(Isolate* isolate, T* that)); |
| 453 }; | 447 }; |
| 454 | 448 |
| 455 | 449 |
| 456 // Eternal handles are set-once handles that live for the life of the isolate. | 450 // Eternal handles are set-once handles that live for the life of the isolate. |
| 457 template <class T> class Eternal { | 451 template <class T> class Eternal { |
| (...skipping 1570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 kExternalFloatArray, | 2022 kExternalFloatArray, |
| 2029 kExternalDoubleArray, | 2023 kExternalDoubleArray, |
| 2030 kExternalPixelArray | 2024 kExternalPixelArray |
| 2031 }; | 2025 }; |
| 2032 | 2026 |
| 2033 /** | 2027 /** |
| 2034 * Accessor[Getter|Setter] are used as callback functions when | 2028 * Accessor[Getter|Setter] are used as callback functions when |
| 2035 * setting|getting a particular property. See Object and ObjectTemplate's | 2029 * setting|getting a particular property. See Object and ObjectTemplate's |
| 2036 * method SetAccessor. | 2030 * method SetAccessor. |
| 2037 */ | 2031 */ |
| 2038 typedef Handle<Value> (*AccessorGetter)(Local<String> property, | |
| 2039 const AccessorInfo& info); | |
| 2040 typedef void (*AccessorGetterCallback)( | 2032 typedef void (*AccessorGetterCallback)( |
| 2041 Local<String> property, | 2033 Local<String> property, |
| 2042 const PropertyCallbackInfo<Value>& info); | 2034 const PropertyCallbackInfo<Value>& info); |
| 2043 | 2035 |
| 2044 | 2036 |
| 2045 typedef void (*AccessorSetter)(Local<String> property, | |
| 2046 Local<Value> value, | |
| 2047 const AccessorInfo& info); | |
| 2048 typedef void (*AccessorSetterCallback)( | 2037 typedef void (*AccessorSetterCallback)( |
| 2049 Local<String> property, | 2038 Local<String> property, |
| 2050 Local<Value> value, | 2039 Local<Value> value, |
| 2051 const PropertyCallbackInfo<void>& info); | 2040 const PropertyCallbackInfo<void>& info); |
| 2052 | 2041 |
| 2053 | 2042 |
| 2054 /** | 2043 /** |
| 2055 * Access control specifications. | 2044 * Access control specifications. |
| 2056 * | 2045 * |
| 2057 * Some accessors should be accessible across contexts. These | 2046 * Some accessors should be accessible across contexts. These |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 bool Delete(Handle<Value> key); | 2100 bool Delete(Handle<Value> key); |
| 2112 | 2101 |
| 2113 // Delete a property on this object bypassing interceptors and | 2102 // Delete a property on this object bypassing interceptors and |
| 2114 // ignoring dont-delete attributes. | 2103 // ignoring dont-delete attributes. |
| 2115 bool ForceDelete(Handle<Value> key); | 2104 bool ForceDelete(Handle<Value> key); |
| 2116 | 2105 |
| 2117 bool Has(uint32_t index); | 2106 bool Has(uint32_t index); |
| 2118 | 2107 |
| 2119 bool Delete(uint32_t index); | 2108 bool Delete(uint32_t index); |
| 2120 | 2109 |
| 2121 V8_DEPRECATED(bool SetAccessor(Handle<String> name, | |
| 2122 AccessorGetter getter, | |
| 2123 AccessorSetter setter = 0, | |
| 2124 Handle<Value> data = Handle<Value>(), | |
| 2125 AccessControl settings = DEFAULT, | |
| 2126 PropertyAttribute attribute = None)); | |
| 2127 bool SetAccessor(Handle<String> name, | 2110 bool SetAccessor(Handle<String> name, |
| 2128 AccessorGetterCallback getter, | 2111 AccessorGetterCallback getter, |
| 2129 AccessorSetterCallback setter = 0, | 2112 AccessorSetterCallback setter = 0, |
| 2130 Handle<Value> data = Handle<Value>(), | 2113 Handle<Value> data = Handle<Value>(), |
| 2131 AccessControl settings = DEFAULT, | 2114 AccessControl settings = DEFAULT, |
| 2132 PropertyAttribute attribute = None); | 2115 PropertyAttribute attribute = None); |
| 2133 | 2116 |
| 2134 // This function is not yet stable and should not be used at this time. | 2117 // This function is not yet stable and should not be used at this time. |
| 2135 bool SetAccessor(Handle<String> name, | 2118 bool SetAccessor(Handle<String> name, |
| 2136 Handle<DeclaredAccessorDescriptor> descriptor, | 2119 Handle<DeclaredAccessorDescriptor> descriptor, |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3065 internal::Object** values, | 3048 internal::Object** values, |
| 3066 int length, | 3049 int length, |
| 3067 bool is_construct_call)); | 3050 bool is_construct_call)); |
| 3068 internal::Object** implicit_args_; | 3051 internal::Object** implicit_args_; |
| 3069 internal::Object** values_; | 3052 internal::Object** values_; |
| 3070 int length_; | 3053 int length_; |
| 3071 bool is_construct_call_; | 3054 bool is_construct_call_; |
| 3072 }; | 3055 }; |
| 3073 | 3056 |
| 3074 | 3057 |
| 3075 class V8_EXPORT Arguments : public FunctionCallbackInfo<Value> { | |
| 3076 private: | |
| 3077 friend class internal::FunctionCallbackArguments; | |
| 3078 V8_INLINE(Arguments(internal::Object** implicit_args, | |
| 3079 internal::Object** values, | |
| 3080 int length, | |
| 3081 bool is_construct_call)); | |
| 3082 }; | |
| 3083 | |
| 3084 /** | 3058 /** |
| 3085 * The information passed to a property callback about the context | 3059 * The information passed to a property callback about the context |
| 3086 * of the property access. | 3060 * of the property access. |
| 3087 */ | 3061 */ |
| 3088 template<typename T> | 3062 template<typename T> |
| 3089 class PropertyCallbackInfo { | 3063 class PropertyCallbackInfo { |
| 3090 public: | 3064 public: |
| 3091 V8_INLINE(Isolate* GetIsolate() const); | 3065 V8_INLINE(Isolate* GetIsolate() const); |
| 3092 V8_INLINE(Local<Value> Data() const); | 3066 V8_INLINE(Local<Value> Data() const); |
| 3093 V8_INLINE(Local<Object> This() const); | 3067 V8_INLINE(Local<Object> This() const); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3106 static const int kReturnValueIndex = -3; | 3080 static const int kReturnValueIndex = -3; |
| 3107 static const int kReturnValueDefaultValueIndex = -4; | 3081 static const int kReturnValueDefaultValueIndex = -4; |
| 3108 static const int kIsolateIndex = -5; | 3082 static const int kIsolateIndex = -5; |
| 3109 | 3083 |
| 3110 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) | 3084 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) |
| 3111 : args_(args) { } | 3085 : args_(args) { } |
| 3112 internal::Object** args_; | 3086 internal::Object** args_; |
| 3113 }; | 3087 }; |
| 3114 | 3088 |
| 3115 | 3089 |
| 3116 class V8_EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { | |
| 3117 private: | |
| 3118 friend class internal::PropertyCallbackArguments; | |
| 3119 V8_INLINE(AccessorInfo(internal::Object** args)) | |
| 3120 : PropertyCallbackInfo<Value>(args) { } | |
| 3121 }; | |
| 3122 | |
| 3123 | |
| 3124 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | |
| 3125 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); | 3090 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); |
| 3126 | 3091 |
| 3127 /** | 3092 /** |
| 3128 * NamedProperty[Getter|Setter] are used as interceptors on object. | 3093 * NamedProperty[Getter|Setter] are used as interceptors on object. |
| 3129 * See ObjectTemplate::SetNamedPropertyHandler. | 3094 * See ObjectTemplate::SetNamedPropertyHandler. |
| 3130 */ | 3095 */ |
| 3131 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, | |
| 3132 const AccessorInfo& info); | |
| 3133 typedef void (*NamedPropertyGetterCallback)( | 3096 typedef void (*NamedPropertyGetterCallback)( |
| 3134 Local<String> property, | 3097 Local<String> property, |
| 3135 const PropertyCallbackInfo<Value>& info); | 3098 const PropertyCallbackInfo<Value>& info); |
| 3136 | 3099 |
| 3137 | 3100 |
| 3138 /** | 3101 /** |
| 3139 * Returns the value if the setter intercepts the request. | 3102 * Returns the value if the setter intercepts the request. |
| 3140 * Otherwise, returns an empty handle. | 3103 * Otherwise, returns an empty handle. |
| 3141 */ | 3104 */ |
| 3142 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, | |
| 3143 Local<Value> value, | |
| 3144 const AccessorInfo& info); | |
| 3145 typedef void (*NamedPropertySetterCallback)( | 3105 typedef void (*NamedPropertySetterCallback)( |
| 3146 Local<String> property, | 3106 Local<String> property, |
| 3147 Local<Value> value, | 3107 Local<Value> value, |
| 3148 const PropertyCallbackInfo<Value>& info); | 3108 const PropertyCallbackInfo<Value>& info); |
| 3149 | 3109 |
| 3150 | 3110 |
| 3151 /** | 3111 /** |
| 3152 * Returns a non-empty handle if the interceptor intercepts the request. | 3112 * Returns a non-empty handle if the interceptor intercepts the request. |
| 3153 * The result is an integer encoding property attributes (like v8::None, | 3113 * The result is an integer encoding property attributes (like v8::None, |
| 3154 * v8::DontEnum, etc.) | 3114 * v8::DontEnum, etc.) |
| 3155 */ | 3115 */ |
| 3156 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, | |
| 3157 const AccessorInfo& info); | |
| 3158 typedef void (*NamedPropertyQueryCallback)( | 3116 typedef void (*NamedPropertyQueryCallback)( |
| 3159 Local<String> property, | 3117 Local<String> property, |
| 3160 const PropertyCallbackInfo<Integer>& info); | 3118 const PropertyCallbackInfo<Integer>& info); |
| 3161 | 3119 |
| 3162 | 3120 |
| 3163 /** | 3121 /** |
| 3164 * Returns a non-empty handle if the deleter intercepts the request. | 3122 * Returns a non-empty handle if the deleter intercepts the request. |
| 3165 * The return value is true if the property could be deleted and false | 3123 * The return value is true if the property could be deleted and false |
| 3166 * otherwise. | 3124 * otherwise. |
| 3167 */ | 3125 */ |
| 3168 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, | |
| 3169 const AccessorInfo& info); | |
| 3170 typedef void (*NamedPropertyDeleterCallback)( | 3126 typedef void (*NamedPropertyDeleterCallback)( |
| 3171 Local<String> property, | 3127 Local<String> property, |
| 3172 const PropertyCallbackInfo<Boolean>& info); | 3128 const PropertyCallbackInfo<Boolean>& info); |
| 3173 | 3129 |
| 3174 | 3130 |
| 3175 /** | 3131 /** |
| 3176 * Returns an array containing the names of the properties the named | 3132 * Returns an array containing the names of the properties the named |
| 3177 * property getter intercepts. | 3133 * property getter intercepts. |
| 3178 */ | 3134 */ |
| 3179 typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info); | |
| 3180 typedef void (*NamedPropertyEnumeratorCallback)( | 3135 typedef void (*NamedPropertyEnumeratorCallback)( |
| 3181 const PropertyCallbackInfo<Array>& info); | 3136 const PropertyCallbackInfo<Array>& info); |
| 3182 | 3137 |
| 3183 | 3138 |
| 3184 /** | 3139 /** |
| 3185 * Returns the value of the property if the getter intercepts the | 3140 * Returns the value of the property if the getter intercepts the |
| 3186 * request. Otherwise, returns an empty handle. | 3141 * request. Otherwise, returns an empty handle. |
| 3187 */ | 3142 */ |
| 3188 typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index, | |
| 3189 const AccessorInfo& info); | |
| 3190 typedef void (*IndexedPropertyGetterCallback)( | 3143 typedef void (*IndexedPropertyGetterCallback)( |
| 3191 uint32_t index, | 3144 uint32_t index, |
| 3192 const PropertyCallbackInfo<Value>& info); | 3145 const PropertyCallbackInfo<Value>& info); |
| 3193 | 3146 |
| 3194 | 3147 |
| 3195 /** | 3148 /** |
| 3196 * Returns the value if the setter intercepts the request. | 3149 * Returns the value if the setter intercepts the request. |
| 3197 * Otherwise, returns an empty handle. | 3150 * Otherwise, returns an empty handle. |
| 3198 */ | 3151 */ |
| 3199 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, | |
| 3200 Local<Value> value, | |
| 3201 const AccessorInfo& info); | |
| 3202 typedef void (*IndexedPropertySetterCallback)( | 3152 typedef void (*IndexedPropertySetterCallback)( |
| 3203 uint32_t index, | 3153 uint32_t index, |
| 3204 Local<Value> value, | 3154 Local<Value> value, |
| 3205 const PropertyCallbackInfo<Value>& info); | 3155 const PropertyCallbackInfo<Value>& info); |
| 3206 | 3156 |
| 3207 | 3157 |
| 3208 /** | 3158 /** |
| 3209 * Returns a non-empty handle if the interceptor intercepts the request. | 3159 * Returns a non-empty handle if the interceptor intercepts the request. |
| 3210 * The result is an integer encoding property attributes. | 3160 * The result is an integer encoding property attributes. |
| 3211 */ | 3161 */ |
| 3212 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, | |
| 3213 const AccessorInfo& info); | |
| 3214 typedef void (*IndexedPropertyQueryCallback)( | 3162 typedef void (*IndexedPropertyQueryCallback)( |
| 3215 uint32_t index, | 3163 uint32_t index, |
| 3216 const PropertyCallbackInfo<Integer>& info); | 3164 const PropertyCallbackInfo<Integer>& info); |
| 3217 | 3165 |
| 3218 | 3166 |
| 3219 /** | 3167 /** |
| 3220 * Returns a non-empty handle if the deleter intercepts the request. | 3168 * Returns a non-empty handle if the deleter intercepts the request. |
| 3221 * The return value is true if the property could be deleted and false | 3169 * The return value is true if the property could be deleted and false |
| 3222 * otherwise. | 3170 * otherwise. |
| 3223 */ | 3171 */ |
| 3224 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, | |
| 3225 const AccessorInfo& info); | |
| 3226 typedef void (*IndexedPropertyDeleterCallback)( | 3172 typedef void (*IndexedPropertyDeleterCallback)( |
| 3227 uint32_t index, | 3173 uint32_t index, |
| 3228 const PropertyCallbackInfo<Boolean>& info); | 3174 const PropertyCallbackInfo<Boolean>& info); |
| 3229 | 3175 |
| 3230 | 3176 |
| 3231 /** | 3177 /** |
| 3232 * Returns an array containing the indices of the properties the | 3178 * Returns an array containing the indices of the properties the |
| 3233 * indexed property getter intercepts. | 3179 * indexed property getter intercepts. |
| 3234 */ | 3180 */ |
| 3235 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info); | |
| 3236 typedef void (*IndexedPropertyEnumeratorCallback)( | 3181 typedef void (*IndexedPropertyEnumeratorCallback)( |
| 3237 const PropertyCallbackInfo<Array>& info); | 3182 const PropertyCallbackInfo<Array>& info); |
| 3238 | 3183 |
| 3239 | 3184 |
| 3240 /** | 3185 /** |
| 3241 * Access type specification. | 3186 * Access type specification. |
| 3242 */ | 3187 */ |
| 3243 enum AccessType { | 3188 enum AccessType { |
| 3244 ACCESS_GET, | 3189 ACCESS_GET, |
| 3245 ACCESS_SET, | 3190 ACCESS_SET, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3357 * | 3302 * |
| 3358 * \code | 3303 * \code |
| 3359 * child_func.prototype.__proto__ == function.prototype; | 3304 * child_func.prototype.__proto__ == function.prototype; |
| 3360 * child_instance.instance_accessor calls 'InstanceAccessorCallback' | 3305 * child_instance.instance_accessor calls 'InstanceAccessorCallback' |
| 3361 * child_instance.instance_property == 3; | 3306 * child_instance.instance_property == 3; |
| 3362 * \endcode | 3307 * \endcode |
| 3363 */ | 3308 */ |
| 3364 class V8_EXPORT FunctionTemplate : public Template { | 3309 class V8_EXPORT FunctionTemplate : public Template { |
| 3365 public: | 3310 public: |
| 3366 /** Creates a function template.*/ | 3311 /** Creates a function template.*/ |
| 3367 V8_DEPRECATED(static Local<FunctionTemplate> New( | |
| 3368 InvocationCallback callback, | |
| 3369 Handle<Value> data = Handle<Value>(), | |
| 3370 Handle<Signature> signature = Handle<Signature>(), | |
| 3371 int length = 0)); | |
| 3372 static Local<FunctionTemplate> New( | 3312 static Local<FunctionTemplate> New( |
| 3373 FunctionCallback callback = 0, | 3313 FunctionCallback callback = 0, |
| 3374 Handle<Value> data = Handle<Value>(), | 3314 Handle<Value> data = Handle<Value>(), |
| 3375 Handle<Signature> signature = Handle<Signature>(), | 3315 Handle<Signature> signature = Handle<Signature>(), |
| 3376 int length = 0); | 3316 int length = 0); |
| 3377 | 3317 |
| 3378 /** Returns the unique function instance in the current execution context.*/ | 3318 /** Returns the unique function instance in the current execution context.*/ |
| 3379 Local<Function> GetFunction(); | 3319 Local<Function> GetFunction(); |
| 3380 | 3320 |
| 3381 /** | 3321 /** |
| 3382 * Set the call-handler callback for a FunctionTemplate. This | 3322 * Set the call-handler callback for a FunctionTemplate. This |
| 3383 * callback is called whenever the function created from this | 3323 * callback is called whenever the function created from this |
| 3384 * FunctionTemplate is called. | 3324 * FunctionTemplate is called. |
| 3385 */ | 3325 */ |
| 3386 V8_DEPRECATED(void SetCallHandler(InvocationCallback callback, | |
| 3387 Handle<Value> data = Handle<Value>())); | |
| 3388 void SetCallHandler(FunctionCallback callback, | 3326 void SetCallHandler(FunctionCallback callback, |
| 3389 Handle<Value> data = Handle<Value>()); | 3327 Handle<Value> data = Handle<Value>()); |
| 3390 | 3328 |
| 3391 /** Set the predefined length property for the FunctionTemplate. */ | 3329 /** Set the predefined length property for the FunctionTemplate. */ |
| 3392 void SetLength(int length); | 3330 void SetLength(int length); |
| 3393 | 3331 |
| 3394 /** Get the InstanceTemplate. */ | 3332 /** Get the InstanceTemplate. */ |
| 3395 Local<ObjectTemplate> InstanceTemplate(); | 3333 Local<ObjectTemplate> InstanceTemplate(); |
| 3396 | 3334 |
| 3397 /** Causes the function template to inherit from a parent function template.*/ | 3335 /** Causes the function template to inherit from a parent function template.*/ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3437 void RemovePrototype(); | 3375 void RemovePrototype(); |
| 3438 | 3376 |
| 3439 /** | 3377 /** |
| 3440 * Returns true if the given object is an instance of this function | 3378 * Returns true if the given object is an instance of this function |
| 3441 * template. | 3379 * template. |
| 3442 */ | 3380 */ |
| 3443 bool HasInstance(Handle<Value> object); | 3381 bool HasInstance(Handle<Value> object); |
| 3444 | 3382 |
| 3445 private: | 3383 private: |
| 3446 FunctionTemplate(); | 3384 FunctionTemplate(); |
| 3447 // TODO(dcarney): Remove with SetCallHandler. | |
| 3448 friend class v8::CallHandlerHelper; | |
| 3449 void SetCallHandlerInternal(InvocationCallback callback, Handle<Value> data); | |
| 3450 friend class Context; | 3385 friend class Context; |
| 3451 friend class ObjectTemplate; | 3386 friend class ObjectTemplate; |
| 3452 }; | 3387 }; |
| 3453 | 3388 |
| 3454 | 3389 |
| 3455 /** | 3390 /** |
| 3456 * An ObjectTemplate is used to create objects at runtime. | 3391 * An ObjectTemplate is used to create objects at runtime. |
| 3457 * | 3392 * |
| 3458 * Properties added to an ObjectTemplate are added to each object | 3393 * Properties added to an ObjectTemplate are added to each object |
| 3459 * created from the ObjectTemplate. | 3394 * created from the ObjectTemplate. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3488 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all | 3423 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all |
| 3489 * cross-context access. | 3424 * cross-context access. |
| 3490 * \param attribute The attributes of the property for which an accessor | 3425 * \param attribute The attributes of the property for which an accessor |
| 3491 * is added. | 3426 * is added. |
| 3492 * \param signature The signature describes valid receivers for the accessor | 3427 * \param signature The signature describes valid receivers for the accessor |
| 3493 * and is used to perform implicit instance checks against them. If the | 3428 * and is used to perform implicit instance checks against them. If the |
| 3494 * receiver is incompatible (i.e. is not an instance of the constructor as | 3429 * receiver is incompatible (i.e. is not an instance of the constructor as |
| 3495 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is | 3430 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is |
| 3496 * thrown and no callback is invoked. | 3431 * thrown and no callback is invoked. |
| 3497 */ | 3432 */ |
| 3498 V8_DEPRECATED(void SetAccessor(Handle<String> name, | |
| 3499 AccessorGetter getter, | |
| 3500 AccessorSetter setter = 0, | |
| 3501 Handle<Value> data = Handle<Value>(), | |
| 3502 AccessControl settings = DEFAULT, | |
| 3503 PropertyAttribute attribute = None, | |
| 3504 Handle<AccessorSignature> signature = | |
| 3505 Handle<AccessorSignature>())); | |
| 3506 void SetAccessor(Handle<String> name, | 3433 void SetAccessor(Handle<String> name, |
| 3507 AccessorGetterCallback getter, | 3434 AccessorGetterCallback getter, |
| 3508 AccessorSetterCallback setter = 0, | 3435 AccessorSetterCallback setter = 0, |
| 3509 Handle<Value> data = Handle<Value>(), | 3436 Handle<Value> data = Handle<Value>(), |
| 3510 AccessControl settings = DEFAULT, | 3437 AccessControl settings = DEFAULT, |
| 3511 PropertyAttribute attribute = None, | 3438 PropertyAttribute attribute = None, |
| 3512 Handle<AccessorSignature> signature = | 3439 Handle<AccessorSignature> signature = |
| 3513 Handle<AccessorSignature>()); | 3440 Handle<AccessorSignature>()); |
| 3514 | 3441 |
| 3515 // This function is not yet stable and should not be used at this time. | 3442 // This function is not yet stable and should not be used at this time. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3530 * \param getter The callback to invoke when getting a property. | 3457 * \param getter The callback to invoke when getting a property. |
| 3531 * \param setter The callback to invoke when setting a property. | 3458 * \param setter The callback to invoke when setting a property. |
| 3532 * \param query The callback to invoke to check if a property is present, | 3459 * \param query The callback to invoke to check if a property is present, |
| 3533 * and if present, get its attributes. | 3460 * and if present, get its attributes. |
| 3534 * \param deleter The callback to invoke when deleting a property. | 3461 * \param deleter The callback to invoke when deleting a property. |
| 3535 * \param enumerator The callback to invoke to enumerate all the named | 3462 * \param enumerator The callback to invoke to enumerate all the named |
| 3536 * properties of an object. | 3463 * properties of an object. |
| 3537 * \param data A piece of data that will be passed to the callbacks | 3464 * \param data A piece of data that will be passed to the callbacks |
| 3538 * whenever they are invoked. | 3465 * whenever they are invoked. |
| 3539 */ | 3466 */ |
| 3540 V8_DEPRECATED(void SetNamedPropertyHandler( | |
| 3541 NamedPropertyGetter getter, | |
| 3542 NamedPropertySetter setter = 0, | |
| 3543 NamedPropertyQuery query = 0, | |
| 3544 NamedPropertyDeleter deleter = 0, | |
| 3545 NamedPropertyEnumerator enumerator = 0, | |
| 3546 Handle<Value> data = Handle<Value>())); | |
| 3547 void SetNamedPropertyHandler( | 3467 void SetNamedPropertyHandler( |
| 3548 NamedPropertyGetterCallback getter, | 3468 NamedPropertyGetterCallback getter, |
| 3549 NamedPropertySetterCallback setter = 0, | 3469 NamedPropertySetterCallback setter = 0, |
| 3550 NamedPropertyQueryCallback query = 0, | 3470 NamedPropertyQueryCallback query = 0, |
| 3551 NamedPropertyDeleterCallback deleter = 0, | 3471 NamedPropertyDeleterCallback deleter = 0, |
| 3552 NamedPropertyEnumeratorCallback enumerator = 0, | 3472 NamedPropertyEnumeratorCallback enumerator = 0, |
| 3553 Handle<Value> data = Handle<Value>()); | 3473 Handle<Value> data = Handle<Value>()); |
| 3554 | 3474 |
| 3555 /** | 3475 /** |
| 3556 * Sets an indexed property handler on the object template. | 3476 * Sets an indexed property handler on the object template. |
| 3557 * | 3477 * |
| 3558 * Whenever an indexed property is accessed on objects created from | 3478 * Whenever an indexed property is accessed on objects created from |
| 3559 * this object template, the provided callback is invoked instead of | 3479 * this object template, the provided callback is invoked instead of |
| 3560 * accessing the property directly on the JavaScript object. | 3480 * accessing the property directly on the JavaScript object. |
| 3561 * | 3481 * |
| 3562 * \param getter The callback to invoke when getting a property. | 3482 * \param getter The callback to invoke when getting a property. |
| 3563 * \param setter The callback to invoke when setting a property. | 3483 * \param setter The callback to invoke when setting a property. |
| 3564 * \param query The callback to invoke to check if an object has a property. | 3484 * \param query The callback to invoke to check if an object has a property. |
| 3565 * \param deleter The callback to invoke when deleting a property. | 3485 * \param deleter The callback to invoke when deleting a property. |
| 3566 * \param enumerator The callback to invoke to enumerate all the indexed | 3486 * \param enumerator The callback to invoke to enumerate all the indexed |
| 3567 * properties of an object. | 3487 * properties of an object. |
| 3568 * \param data A piece of data that will be passed to the callbacks | 3488 * \param data A piece of data that will be passed to the callbacks |
| 3569 * whenever they are invoked. | 3489 * whenever they are invoked. |
| 3570 */ | 3490 */ |
| 3571 V8_DEPRECATED(void SetIndexedPropertyHandler( | |
| 3572 IndexedPropertyGetter getter, | |
| 3573 IndexedPropertySetter setter = 0, | |
| 3574 IndexedPropertyQuery query = 0, | |
| 3575 IndexedPropertyDeleter deleter = 0, | |
| 3576 IndexedPropertyEnumerator enumerator = 0, | |
| 3577 Handle<Value> data = Handle<Value>())); | |
| 3578 void SetIndexedPropertyHandler( | 3491 void SetIndexedPropertyHandler( |
| 3579 IndexedPropertyGetterCallback getter, | 3492 IndexedPropertyGetterCallback getter, |
| 3580 IndexedPropertySetterCallback setter = 0, | 3493 IndexedPropertySetterCallback setter = 0, |
| 3581 IndexedPropertyQueryCallback query = 0, | 3494 IndexedPropertyQueryCallback query = 0, |
| 3582 IndexedPropertyDeleterCallback deleter = 0, | 3495 IndexedPropertyDeleterCallback deleter = 0, |
| 3583 IndexedPropertyEnumeratorCallback enumerator = 0, | 3496 IndexedPropertyEnumeratorCallback enumerator = 0, |
| 3584 Handle<Value> data = Handle<Value>()); | 3497 Handle<Value> data = Handle<Value>()); |
| 3585 | 3498 |
| 3586 /** | 3499 /** |
| 3587 * Sets the callback to be used when calling instances created from | 3500 * Sets the callback to be used when calling instances created from |
| 3588 * this template as a function. If no callback is set, instances | 3501 * this template as a function. If no callback is set, instances |
| 3589 * behave like normal JavaScript objects that cannot be called as a | 3502 * behave like normal JavaScript objects that cannot be called as a |
| 3590 * function. | 3503 * function. |
| 3591 */ | 3504 */ |
| 3592 V8_DEPRECATED(void SetCallAsFunctionHandler( | |
| 3593 InvocationCallback callback, | |
| 3594 Handle<Value> data = Handle<Value>())); | |
| 3595 void SetCallAsFunctionHandler(FunctionCallback callback, | 3505 void SetCallAsFunctionHandler(FunctionCallback callback, |
| 3596 Handle<Value> data = Handle<Value>()); | 3506 Handle<Value> data = Handle<Value>()); |
| 3597 | 3507 |
| 3598 /** | 3508 /** |
| 3599 * Mark object instances of the template as undetectable. | 3509 * Mark object instances of the template as undetectable. |
| 3600 * | 3510 * |
| 3601 * In many ways, undetectable objects behave as though they are not | 3511 * In many ways, undetectable objects behave as though they are not |
| 3602 * there. They behave like 'undefined' in conditionals and when | 3512 * there. They behave like 'undefined' in conditionals and when |
| 3603 * printed. However, properties can be accessed and called as on | 3513 * printed. However, properties can be accessed and called as on |
| 3604 * normal objects. | 3514 * normal objects. |
| (...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6006 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, | 5916 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, |
| 6007 internal::Object** values, | 5917 internal::Object** values, |
| 6008 int length, | 5918 int length, |
| 6009 bool is_construct_call) | 5919 bool is_construct_call) |
| 6010 : implicit_args_(implicit_args), | 5920 : implicit_args_(implicit_args), |
| 6011 values_(values), | 5921 values_(values), |
| 6012 length_(length), | 5922 length_(length), |
| 6013 is_construct_call_(is_construct_call) { } | 5923 is_construct_call_(is_construct_call) { } |
| 6014 | 5924 |
| 6015 | 5925 |
| 6016 Arguments::Arguments(internal::Object** args, | |
| 6017 internal::Object** values, | |
| 6018 int length, | |
| 6019 bool is_construct_call) | |
| 6020 : FunctionCallbackInfo<Value>(args, values, length, is_construct_call) { } | |
| 6021 | |
| 6022 | |
| 6023 template<typename T> | 5926 template<typename T> |
| 6024 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { | 5927 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { |
| 6025 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); | 5928 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); |
| 6026 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); | 5929 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); |
| 6027 } | 5930 } |
| 6028 | 5931 |
| 6029 | 5932 |
| 6030 template<typename T> | 5933 template<typename T> |
| 6031 Local<Function> FunctionCallbackInfo<T>::Callee() const { | 5934 Local<Function> FunctionCallbackInfo<T>::Callee() const { |
| 6032 return Local<Function>(reinterpret_cast<Function*>( | 5935 return Local<Function>(reinterpret_cast<Function*>( |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6606 */ | 6509 */ |
| 6607 | 6510 |
| 6608 | 6511 |
| 6609 } // namespace v8 | 6512 } // namespace v8 |
| 6610 | 6513 |
| 6611 | 6514 |
| 6612 #undef TYPE_CHECK | 6515 #undef TYPE_CHECK |
| 6613 | 6516 |
| 6614 | 6517 |
| 6615 #endif // V8_H_ | 6518 #endif // V8_H_ |
| OLD | NEW |