| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** \mainpage V8 API Reference Guide | 5 /** \mainpage V8 API Reference Guide |
| 6 * | 6 * |
| 7 * V8 is Google's open source JavaScript engine. | 7 * V8 is Google's open source JavaScript engine. |
| 8 * | 8 * |
| 9 * This set of documents provides reference material generated from the | 9 * This set of documents provides reference material generated from the |
| 10 * V8 header file, include/v8.h. | 10 * V8 header file, include/v8.h. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 class Date; | 70 class Date; |
| 71 class DeclaredAccessorDescriptor; | 71 class DeclaredAccessorDescriptor; |
| 72 class External; | 72 class External; |
| 73 class Function; | 73 class Function; |
| 74 class FunctionTemplate; | 74 class FunctionTemplate; |
| 75 class HeapProfiler; | 75 class HeapProfiler; |
| 76 class ImplementationUtilities; | 76 class ImplementationUtilities; |
| 77 class Int32; | 77 class Int32; |
| 78 class Integer; | 78 class Integer; |
| 79 class Isolate; | 79 class Isolate; |
| 80 class Name; |
| 80 class Number; | 81 class Number; |
| 81 class NumberObject; | 82 class NumberObject; |
| 82 class Object; | 83 class Object; |
| 83 class ObjectOperationDescriptor; | 84 class ObjectOperationDescriptor; |
| 84 class ObjectTemplate; | 85 class ObjectTemplate; |
| 85 class Platform; | 86 class Platform; |
| 86 class Primitive; | 87 class Primitive; |
| 87 class RawOperationDescriptor; | 88 class RawOperationDescriptor; |
| 88 class Script; | 89 class Script; |
| 89 class Signature; | 90 class Signature; |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 * Returns true if this value is true. | 1323 * Returns true if this value is true. |
| 1323 */ | 1324 */ |
| 1324 bool IsTrue() const; | 1325 bool IsTrue() const; |
| 1325 | 1326 |
| 1326 /** | 1327 /** |
| 1327 * Returns true if this value is false. | 1328 * Returns true if this value is false. |
| 1328 */ | 1329 */ |
| 1329 bool IsFalse() const; | 1330 bool IsFalse() const; |
| 1330 | 1331 |
| 1331 /** | 1332 /** |
| 1333 * Returns true if this value is a symbol or a string. |
| 1334 * This is an experimental feature. |
| 1335 */ |
| 1336 bool IsName() const; |
| 1337 |
| 1338 /** |
| 1332 * Returns true if this value is an instance of the String type. | 1339 * Returns true if this value is an instance of the String type. |
| 1333 * See ECMA-262 8.4. | 1340 * See ECMA-262 8.4. |
| 1334 */ | 1341 */ |
| 1335 V8_INLINE bool IsString() const; | 1342 V8_INLINE bool IsString() const; |
| 1336 | 1343 |
| 1337 /** | 1344 /** |
| 1338 * Returns true if this value is a symbol. | 1345 * Returns true if this value is a symbol. |
| 1339 * This is an experimental feature. | 1346 * This is an experimental feature. |
| 1340 */ | 1347 */ |
| 1341 bool IsSymbol() const; | 1348 bool IsSymbol() const; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 * or false value. | 1556 * or false value. |
| 1550 */ | 1557 */ |
| 1551 class V8_EXPORT Boolean : public Primitive { | 1558 class V8_EXPORT Boolean : public Primitive { |
| 1552 public: | 1559 public: |
| 1553 bool Value() const; | 1560 bool Value() const; |
| 1554 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); | 1561 V8_INLINE static Handle<Boolean> New(Isolate* isolate, bool value); |
| 1555 }; | 1562 }; |
| 1556 | 1563 |
| 1557 | 1564 |
| 1558 /** | 1565 /** |
| 1566 * A superclass for symbols and strings. |
| 1567 */ |
| 1568 class V8_EXPORT Name : public Primitive { |
| 1569 public: |
| 1570 V8_INLINE static Name* Cast(v8::Value* obj); |
| 1571 private: |
| 1572 static void CheckCast(v8::Value* obj); |
| 1573 }; |
| 1574 |
| 1575 |
| 1576 /** |
| 1559 * A JavaScript string value (ECMA-262, 4.3.17). | 1577 * A JavaScript string value (ECMA-262, 4.3.17). |
| 1560 */ | 1578 */ |
| 1561 class V8_EXPORT String : public Primitive { | 1579 class V8_EXPORT String : public Name { |
| 1562 public: | 1580 public: |
| 1563 enum Encoding { | 1581 enum Encoding { |
| 1564 UNKNOWN_ENCODING = 0x1, | 1582 UNKNOWN_ENCODING = 0x1, |
| 1565 TWO_BYTE_ENCODING = 0x0, | 1583 TWO_BYTE_ENCODING = 0x0, |
| 1566 ASCII_ENCODING = 0x4, | 1584 ASCII_ENCODING = 0x4, |
| 1567 ONE_BYTE_ENCODING = 0x4 | 1585 ONE_BYTE_ENCODING = 0x4 |
| 1568 }; | 1586 }; |
| 1569 /** | 1587 /** |
| 1570 * Returns the number of characters in this string. | 1588 * Returns the number of characters in this string. |
| 1571 */ | 1589 */ |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 void VerifyExternalStringResource(ExternalStringResource* val) const; | 1908 void VerifyExternalStringResource(ExternalStringResource* val) const; |
| 1891 static void CheckCast(v8::Value* obj); | 1909 static void CheckCast(v8::Value* obj); |
| 1892 }; | 1910 }; |
| 1893 | 1911 |
| 1894 | 1912 |
| 1895 /** | 1913 /** |
| 1896 * A JavaScript symbol (ECMA-262 edition 6) | 1914 * A JavaScript symbol (ECMA-262 edition 6) |
| 1897 * | 1915 * |
| 1898 * This is an experimental feature. Use at your own risk. | 1916 * This is an experimental feature. Use at your own risk. |
| 1899 */ | 1917 */ |
| 1900 class V8_EXPORT Symbol : public Primitive { | 1918 class V8_EXPORT Symbol : public Name { |
| 1901 public: | 1919 public: |
| 1902 // Returns the print name string of the symbol, or undefined if none. | 1920 // Returns the print name string of the symbol, or undefined if none. |
| 1903 Local<Value> Name() const; | 1921 Local<Value> Name() const; |
| 1904 | 1922 |
| 1905 // Create a symbol. If name is not empty, it will be used as the description. | 1923 // Create a symbol. If name is not empty, it will be used as the description. |
| 1906 static Local<Symbol> New( | 1924 static Local<Symbol> New( |
| 1907 Isolate *isolate, Local<String> name = Local<String>()); | 1925 Isolate *isolate, Local<String> name = Local<String>()); |
| 1908 | 1926 |
| 1909 // Access global symbol registry. | 1927 // Access global symbol registry. |
| 1910 // Note that symbols created this way are never collected, so | 1928 // Note that symbols created this way are never collected, so |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 }; | 2052 }; |
| 2035 | 2053 |
| 2036 /** | 2054 /** |
| 2037 * Accessor[Getter|Setter] are used as callback functions when | 2055 * Accessor[Getter|Setter] are used as callback functions when |
| 2038 * setting|getting a particular property. See Object and ObjectTemplate's | 2056 * setting|getting a particular property. See Object and ObjectTemplate's |
| 2039 * method SetAccessor. | 2057 * method SetAccessor. |
| 2040 */ | 2058 */ |
| 2041 typedef void (*AccessorGetterCallback)( | 2059 typedef void (*AccessorGetterCallback)( |
| 2042 Local<String> property, | 2060 Local<String> property, |
| 2043 const PropertyCallbackInfo<Value>& info); | 2061 const PropertyCallbackInfo<Value>& info); |
| 2062 typedef void (*AccessorSymbolGetterCallback)( |
| 2063 Local<Symbol> property, |
| 2064 const PropertyCallbackInfo<Value>& info); |
| 2044 | 2065 |
| 2045 | 2066 |
| 2046 typedef void (*AccessorSetterCallback)( | 2067 typedef void (*AccessorSetterCallback)( |
| 2047 Local<String> property, | 2068 Local<String> property, |
| 2048 Local<Value> value, | 2069 Local<Value> value, |
| 2049 const PropertyCallbackInfo<void>& info); | 2070 const PropertyCallbackInfo<void>& info); |
| 2071 typedef void (*AccessorSymbolSetterCallback)( |
| 2072 Local<Symbol> property, |
| 2073 Local<Value> value, |
| 2074 const PropertyCallbackInfo<void>& info); |
| 2050 | 2075 |
| 2051 | 2076 |
| 2052 /** | 2077 /** |
| 2053 * Access control specifications. | 2078 * Access control specifications. |
| 2054 * | 2079 * |
| 2055 * Some accessors should be accessible across contexts. These | 2080 * Some accessors should be accessible across contexts. These |
| 2056 * accessors have an explicit access control parameter which specifies | 2081 * accessors have an explicit access control parameter which specifies |
| 2057 * the kind of cross-context access that should be allowed. | 2082 * the kind of cross-context access that should be allowed. |
| 2058 * | 2083 * |
| 2059 * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused. | 2084 * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 bool Has(uint32_t index); | 2136 bool Has(uint32_t index); |
| 2112 | 2137 |
| 2113 bool Delete(uint32_t index); | 2138 bool Delete(uint32_t index); |
| 2114 | 2139 |
| 2115 bool SetAccessor(Handle<String> name, | 2140 bool SetAccessor(Handle<String> name, |
| 2116 AccessorGetterCallback getter, | 2141 AccessorGetterCallback getter, |
| 2117 AccessorSetterCallback setter = 0, | 2142 AccessorSetterCallback setter = 0, |
| 2118 Handle<Value> data = Handle<Value>(), | 2143 Handle<Value> data = Handle<Value>(), |
| 2119 AccessControl settings = DEFAULT, | 2144 AccessControl settings = DEFAULT, |
| 2120 PropertyAttribute attribute = None); | 2145 PropertyAttribute attribute = None); |
| 2146 bool SetAccessor(Handle<Symbol> name, |
| 2147 AccessorSymbolGetterCallback getter, |
| 2148 AccessorSymbolSetterCallback setter = 0, |
| 2149 Handle<Value> data = Handle<Value>(), |
| 2150 AccessControl settings = DEFAULT, |
| 2151 PropertyAttribute attribute = None); |
| 2121 | 2152 |
| 2122 // This function is not yet stable and should not be used at this time. | 2153 // This function is not yet stable and should not be used at this time. |
| 2123 bool SetDeclaredAccessor(Local<String> name, | 2154 bool SetDeclaredAccessor(Local<Name> name, |
| 2124 Local<DeclaredAccessorDescriptor> descriptor, | 2155 Local<DeclaredAccessorDescriptor> descriptor, |
| 2125 PropertyAttribute attribute = None, | 2156 PropertyAttribute attribute = None, |
| 2126 AccessControl settings = DEFAULT); | 2157 AccessControl settings = DEFAULT); |
| 2127 | 2158 |
| 2128 void SetAccessorProperty(Local<String> name, | 2159 void SetAccessorProperty(Local<Name> name, |
| 2129 Local<Function> getter, | 2160 Local<Function> getter, |
| 2130 Handle<Function> setter = Handle<Function>(), | 2161 Handle<Function> setter = Handle<Function>(), |
| 2131 PropertyAttribute attribute = None, | 2162 PropertyAttribute attribute = None, |
| 2132 AccessControl settings = DEFAULT); | 2163 AccessControl settings = DEFAULT); |
| 2133 | 2164 |
| 2134 /** | 2165 /** |
| 2135 * Functionality for private properties. | 2166 * Functionality for private properties. |
| 2136 * This is an experimental feature, use at your own risk. | 2167 * This is an experimental feature, use at your own risk. |
| 2137 * Note: Private properties are inherited. Do not rely on this, since it may | 2168 * Note: Private properties are inherited. Do not rely on this, since it may |
| 2138 * change. | 2169 * change. |
| (...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 | 3157 |
| 3127 // --- Templates --- | 3158 // --- Templates --- |
| 3128 | 3159 |
| 3129 | 3160 |
| 3130 /** | 3161 /** |
| 3131 * The superclass of object and function templates. | 3162 * The superclass of object and function templates. |
| 3132 */ | 3163 */ |
| 3133 class V8_EXPORT Template : public Data { | 3164 class V8_EXPORT Template : public Data { |
| 3134 public: | 3165 public: |
| 3135 /** Adds a property to each instance created by this template.*/ | 3166 /** Adds a property to each instance created by this template.*/ |
| 3136 void Set(Handle<String> name, Handle<Data> value, | 3167 void Set(Handle<Name> name, Handle<Data> value, |
| 3137 PropertyAttribute attributes = None); | 3168 PropertyAttribute attributes = None); |
| 3138 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); | 3169 V8_INLINE void Set(Isolate* isolate, const char* name, Handle<Data> value); |
| 3139 | 3170 |
| 3140 void SetAccessorProperty( | 3171 void SetAccessorProperty( |
| 3141 Local<String> name, | 3172 Local<Name> name, |
| 3142 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), | 3173 Local<FunctionTemplate> getter = Local<FunctionTemplate>(), |
| 3143 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), | 3174 Local<FunctionTemplate> setter = Local<FunctionTemplate>(), |
| 3144 PropertyAttribute attribute = None, | 3175 PropertyAttribute attribute = None, |
| 3145 AccessControl settings = DEFAULT); | 3176 AccessControl settings = DEFAULT); |
| 3146 | 3177 |
| 3147 /** | 3178 /** |
| 3148 * Whenever the property with the given name is accessed on objects | 3179 * Whenever the property with the given name is accessed on objects |
| 3149 * created from this Template the getter and setter callbacks | 3180 * created from this Template the getter and setter callbacks |
| 3150 * are called instead of getting and setting the property directly | 3181 * are called instead of getting and setting the property directly |
| 3151 * on the JavaScript object. | 3182 * on the JavaScript object. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3173 */ | 3204 */ |
| 3174 void SetNativeDataProperty(Local<String> name, | 3205 void SetNativeDataProperty(Local<String> name, |
| 3175 AccessorGetterCallback getter, | 3206 AccessorGetterCallback getter, |
| 3176 AccessorSetterCallback setter = 0, | 3207 AccessorSetterCallback setter = 0, |
| 3177 // TODO(dcarney): gcc can't handle Local below | 3208 // TODO(dcarney): gcc can't handle Local below |
| 3178 Handle<Value> data = Handle<Value>(), | 3209 Handle<Value> data = Handle<Value>(), |
| 3179 PropertyAttribute attribute = None, | 3210 PropertyAttribute attribute = None, |
| 3180 Local<AccessorSignature> signature = | 3211 Local<AccessorSignature> signature = |
| 3181 Local<AccessorSignature>(), | 3212 Local<AccessorSignature>(), |
| 3182 AccessControl settings = DEFAULT); | 3213 AccessControl settings = DEFAULT); |
| 3214 void SetNativeDataProperty(Local<Symbol> name, |
| 3215 AccessorSymbolGetterCallback getter, |
| 3216 AccessorSymbolSetterCallback setter = 0, |
| 3217 // TODO(dcarney): gcc can't handle Local below |
| 3218 Handle<Value> data = Handle<Value>(), |
| 3219 PropertyAttribute attribute = None, |
| 3220 Local<AccessorSignature> signature = |
| 3221 Local<AccessorSignature>(), |
| 3222 AccessControl settings = DEFAULT); |
| 3183 | 3223 |
| 3184 // This function is not yet stable and should not be used at this time. | 3224 // This function is not yet stable and should not be used at this time. |
| 3185 bool SetDeclaredAccessor(Local<String> name, | 3225 bool SetDeclaredAccessor(Local<Name> name, |
| 3186 Local<DeclaredAccessorDescriptor> descriptor, | 3226 Local<DeclaredAccessorDescriptor> descriptor, |
| 3187 PropertyAttribute attribute = None, | 3227 PropertyAttribute attribute = None, |
| 3188 Local<AccessorSignature> signature = | 3228 Local<AccessorSignature> signature = |
| 3189 Local<AccessorSignature>(), | 3229 Local<AccessorSignature>(), |
| 3190 AccessControl settings = DEFAULT); | 3230 AccessControl settings = DEFAULT); |
| 3191 | 3231 |
| 3192 private: | 3232 private: |
| 3193 Template(); | 3233 Template(); |
| 3194 | 3234 |
| 3195 friend class ObjectTemplate; | 3235 friend class ObjectTemplate; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3237 | 3277 |
| 3238 | 3278 |
| 3239 /** | 3279 /** |
| 3240 * Returns an array containing the names of the properties the named | 3280 * Returns an array containing the names of the properties the named |
| 3241 * property getter intercepts. | 3281 * property getter intercepts. |
| 3242 */ | 3282 */ |
| 3243 typedef void (*NamedPropertyEnumeratorCallback)( | 3283 typedef void (*NamedPropertyEnumeratorCallback)( |
| 3244 const PropertyCallbackInfo<Array>& info); | 3284 const PropertyCallbackInfo<Array>& info); |
| 3245 | 3285 |
| 3246 | 3286 |
| 3287 // TODO(wingo): Deprecate and remove previous typedefs, and replace |
| 3288 // GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. |
| 3289 /** |
| 3290 * GenericNamedProperty[Getter|Setter] are used as interceptors on object. |
| 3291 * See ObjectTemplate::SetGenericNamedPropertyHandler. |
| 3292 */ |
| 3293 typedef void (*GenericNamedPropertyGetterCallback)( |
| 3294 Local<Name> property, |
| 3295 const PropertyCallbackInfo<Value>& info); |
| 3296 |
| 3297 |
| 3298 /** |
| 3299 * Returns the value if the setter intercepts the request. |
| 3300 * Otherwise, returns an empty handle. |
| 3301 */ |
| 3302 typedef void (*GenericNamedPropertySetterCallback)( |
| 3303 Local<Name> property, |
| 3304 Local<Value> value, |
| 3305 const PropertyCallbackInfo<Value>& info); |
| 3306 |
| 3307 |
| 3308 /** |
| 3309 * Returns a non-empty handle if the interceptor intercepts the request. |
| 3310 * The result is an integer encoding property attributes (like v8::None, |
| 3311 * v8::DontEnum, etc.) |
| 3312 */ |
| 3313 typedef void (*GenericNamedPropertyQueryCallback)( |
| 3314 Local<Name> property, |
| 3315 const PropertyCallbackInfo<Integer>& info); |
| 3316 |
| 3317 |
| 3318 /** |
| 3319 * Returns a non-empty handle if the deleter intercepts the request. |
| 3320 * The return value is true if the property could be deleted and false |
| 3321 * otherwise. |
| 3322 */ |
| 3323 typedef void (*GenericNamedPropertyDeleterCallback)( |
| 3324 Local<Name> property, |
| 3325 const PropertyCallbackInfo<Boolean>& info); |
| 3326 |
| 3327 |
| 3328 /** |
| 3329 * Returns an array containing the names of the properties the named |
| 3330 * property getter intercepts. |
| 3331 */ |
| 3332 typedef void (*GenericNamedPropertyEnumeratorCallback)( |
| 3333 const PropertyCallbackInfo<Array>& info); |
| 3334 |
| 3335 |
| 3247 /** | 3336 /** |
| 3248 * Returns the value of the property if the getter intercepts the | 3337 * Returns the value of the property if the getter intercepts the |
| 3249 * request. Otherwise, returns an empty handle. | 3338 * request. Otherwise, returns an empty handle. |
| 3250 */ | 3339 */ |
| 3251 typedef void (*IndexedPropertyGetterCallback)( | 3340 typedef void (*IndexedPropertyGetterCallback)( |
| 3252 uint32_t index, | 3341 uint32_t index, |
| 3253 const PropertyCallbackInfo<Value>& info); | 3342 const PropertyCallbackInfo<Value>& info); |
| 3254 | 3343 |
| 3255 | 3344 |
| 3256 /** | 3345 /** |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3544 void SetAccessor(Handle<String> name, | 3633 void SetAccessor(Handle<String> name, |
| 3545 AccessorGetterCallback getter, | 3634 AccessorGetterCallback getter, |
| 3546 AccessorSetterCallback setter = 0, | 3635 AccessorSetterCallback setter = 0, |
| 3547 Handle<Value> data = Handle<Value>(), | 3636 Handle<Value> data = Handle<Value>(), |
| 3548 AccessControl settings = DEFAULT, | 3637 AccessControl settings = DEFAULT, |
| 3549 PropertyAttribute attribute = None, | 3638 PropertyAttribute attribute = None, |
| 3550 Handle<AccessorSignature> signature = | 3639 Handle<AccessorSignature> signature = |
| 3551 Handle<AccessorSignature>()); | 3640 Handle<AccessorSignature>()); |
| 3552 | 3641 |
| 3553 /** | 3642 /** |
| 3643 * A version of SetAccessor for properties whose names are symbols. |
| 3644 * |
| 3645 * Whenever the property with the given name is accessed on objects |
| 3646 * created from this ObjectTemplate the getter and setter callbacks |
| 3647 * are called instead of getting and setting the property directly |
| 3648 * on the JavaScript object. |
| 3649 * |
| 3650 * \param name The name of the property for which an accessor is added. |
| 3651 * \param getter The callback to invoke when getting the property. |
| 3652 * \param setter The callback to invoke when setting the property. |
| 3653 * \param data A piece of data that will be passed to the getter and setter |
| 3654 * callbacks whenever they are invoked. |
| 3655 * \param settings Access control settings for the accessor. This is a bit |
| 3656 * field consisting of one of more of |
| 3657 * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2. |
| 3658 * The default is to not allow cross-context access. |
| 3659 * ALL_CAN_READ means that all cross-context reads are allowed. |
| 3660 * ALL_CAN_WRITE means that all cross-context writes are allowed. |
| 3661 * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all |
| 3662 * cross-context access. |
| 3663 * \param attribute The attributes of the property for which an accessor |
| 3664 * is added. |
| 3665 * \param signature The signature describes valid receivers for the accessor |
| 3666 * and is used to perform implicit instance checks against them. If the |
| 3667 * receiver is incompatible (i.e. is not an instance of the constructor as |
| 3668 * defined by FunctionTemplate::HasInstance()), an implicit TypeError is |
| 3669 * thrown and no callback is invoked. |
| 3670 */ |
| 3671 void SetAccessor(Handle<Symbol> name, |
| 3672 AccessorSymbolGetterCallback getter, |
| 3673 AccessorSymbolSetterCallback setter = 0, |
| 3674 Handle<Value> data = Handle<Value>(), |
| 3675 AccessControl settings = DEFAULT, |
| 3676 PropertyAttribute attribute = None, |
| 3677 Handle<AccessorSignature> signature = |
| 3678 Handle<AccessorSignature>()); |
| 3679 |
| 3680 /** |
| 3554 * Sets a named property handler on the object template. | 3681 * Sets a named property handler on the object template. |
| 3555 * | 3682 * |
| 3556 * Whenever a named property is accessed on objects created from | 3683 * Whenever a property whose name is a string is accessed on objects created |
| 3557 * this object template, the provided callback is invoked instead of | 3684 * from this object template, the provided callback is invoked instead of |
| 3558 * accessing the property directly on the JavaScript object. | 3685 * accessing the property directly on the JavaScript object. |
| 3559 * | 3686 * |
| 3560 * \param getter The callback to invoke when getting a property. | 3687 * \param getter The callback to invoke when getting a property. |
| 3561 * \param setter The callback to invoke when setting a property. | 3688 * \param setter The callback to invoke when setting a property. |
| 3562 * \param query The callback to invoke to check if a property is present, | 3689 * \param query The callback to invoke to check if a property is present, |
| 3563 * and if present, get its attributes. | 3690 * and if present, get its attributes. |
| 3564 * \param deleter The callback to invoke when deleting a property. | 3691 * \param deleter The callback to invoke when deleting a property. |
| 3565 * \param enumerator The callback to invoke to enumerate all the named | 3692 * \param enumerator The callback to invoke to enumerate all the named |
| 3566 * properties of an object. | 3693 * properties of an object. |
| 3567 * \param data A piece of data that will be passed to the callbacks | 3694 * \param data A piece of data that will be passed to the callbacks |
| 3568 * whenever they are invoked. | 3695 * whenever they are invoked. |
| 3569 */ | 3696 */ |
| 3570 void SetNamedPropertyHandler( | 3697 void SetNamedPropertyHandler( |
| 3571 NamedPropertyGetterCallback getter, | 3698 NamedPropertyGetterCallback getter, |
| 3572 NamedPropertySetterCallback setter = 0, | 3699 NamedPropertySetterCallback setter = 0, |
| 3573 NamedPropertyQueryCallback query = 0, | 3700 NamedPropertyQueryCallback query = 0, |
| 3574 NamedPropertyDeleterCallback deleter = 0, | 3701 NamedPropertyDeleterCallback deleter = 0, |
| 3575 NamedPropertyEnumeratorCallback enumerator = 0, | 3702 NamedPropertyEnumeratorCallback enumerator = 0, |
| 3576 Handle<Value> data = Handle<Value>()); | 3703 Handle<Value> data = Handle<Value>()); |
| 3577 | 3704 |
| 3578 /** | 3705 /** |
| 3706 * Sets a named property handler on the object template. |
| 3707 * |
| 3708 * Whenever a property is accessed on objects created from this object |
| 3709 * template, the provided callback is invoked instead of accessing the |
| 3710 * property directly on the JavaScript object. |
| 3711 * |
| 3712 * Unlike SetNamedPropertyHandler, this version also intercepts values whose |
| 3713 * names are symbols. |
| 3714 * |
| 3715 * \param getter The callback to invoke when getting a property. |
| 3716 * \param setter The callback to invoke when setting a property. |
| 3717 * \param query The callback to invoke to check if a property is present, |
| 3718 * and if present, get its attributes. |
| 3719 * \param deleter The callback to invoke when deleting a property. |
| 3720 * \param enumerator The callback to invoke to enumerate all the named |
| 3721 * properties of an object. |
| 3722 * \param data A piece of data that will be passed to the callbacks |
| 3723 * whenever they are invoked. |
| 3724 */ |
| 3725 void SetGenericNamedPropertyHandler( |
| 3726 GenericNamedPropertyGetterCallback getter, |
| 3727 GenericNamedPropertySetterCallback setter = 0, |
| 3728 GenericNamedPropertyQueryCallback query = 0, |
| 3729 GenericNamedPropertyDeleterCallback deleter = 0, |
| 3730 GenericNamedPropertyEnumeratorCallback enumerator = 0, |
| 3731 Handle<Value> data = Handle<Value>()); |
| 3732 |
| 3733 /** |
| 3579 * Sets an indexed property handler on the object template. | 3734 * Sets an indexed property handler on the object template. |
| 3580 * | 3735 * |
| 3581 * Whenever an indexed property is accessed on objects created from | 3736 * Whenever an indexed property is accessed on objects created from |
| 3582 * this object template, the provided callback is invoked instead of | 3737 * this object template, the provided callback is invoked instead of |
| 3583 * accessing the property directly on the JavaScript object. | 3738 * accessing the property directly on the JavaScript object. |
| 3584 * | 3739 * |
| 3585 * \param getter The callback to invoke when getting a property. | 3740 * \param getter The callback to invoke when getting a property. |
| 3586 * \param setter The callback to invoke when setting a property. | 3741 * \param setter The callback to invoke when setting a property. |
| 3587 * \param query The callback to invoke to check if an object has a property. | 3742 * \param query The callback to invoke to check if an object has a property. |
| 3588 * \param deleter The callback to invoke when deleting a property. | 3743 * \param deleter The callback to invoke when deleting a property. |
| (...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6253 if (!I::HasHeapObjectTag(obj)) return false; | 6408 if (!I::HasHeapObjectTag(obj)) return false; |
| 6254 return (I::GetInstanceType(obj) < I::kFirstNonstringType); | 6409 return (I::GetInstanceType(obj) < I::kFirstNonstringType); |
| 6255 } | 6410 } |
| 6256 | 6411 |
| 6257 | 6412 |
| 6258 template <class T> Value* Value::Cast(T* value) { | 6413 template <class T> Value* Value::Cast(T* value) { |
| 6259 return static_cast<Value*>(value); | 6414 return static_cast<Value*>(value); |
| 6260 } | 6415 } |
| 6261 | 6416 |
| 6262 | 6417 |
| 6418 Name* Name::Cast(v8::Value* value) { |
| 6419 #ifdef V8_ENABLE_CHECKS |
| 6420 CheckCast(value); |
| 6421 #endif |
| 6422 return static_cast<Name*>(value); |
| 6423 } |
| 6424 |
| 6425 |
| 6263 Symbol* Symbol::Cast(v8::Value* value) { | 6426 Symbol* Symbol::Cast(v8::Value* value) { |
| 6264 #ifdef V8_ENABLE_CHECKS | 6427 #ifdef V8_ENABLE_CHECKS |
| 6265 CheckCast(value); | 6428 CheckCast(value); |
| 6266 #endif | 6429 #endif |
| 6267 return static_cast<Symbol*>(value); | 6430 return static_cast<Symbol*>(value); |
| 6268 } | 6431 } |
| 6269 | 6432 |
| 6270 | 6433 |
| 6271 Number* Number::Cast(v8::Value* value) { | 6434 Number* Number::Cast(v8::Value* value) { |
| 6272 #ifdef V8_ENABLE_CHECKS | 6435 #ifdef V8_ENABLE_CHECKS |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6654 */ | 6817 */ |
| 6655 | 6818 |
| 6656 | 6819 |
| 6657 } // namespace v8 | 6820 } // namespace v8 |
| 6658 | 6821 |
| 6659 | 6822 |
| 6660 #undef TYPE_CHECK | 6823 #undef TYPE_CHECK |
| 6661 | 6824 |
| 6662 | 6825 |
| 6663 #endif // V8_H_ | 6826 #endif // V8_H_ |
| OLD | NEW |