Chromium Code Reviews| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 class ImplementationUtilities; | 118 class ImplementationUtilities; |
| 119 class Signature; | 119 class Signature; |
| 120 class AccessorSignature; | 120 class AccessorSignature; |
| 121 template <class T> class Handle; | 121 template <class T> class Handle; |
| 122 template <class T> class Local; | 122 template <class T> class Local; |
| 123 template <class T> class Persistent; | 123 template <class T> class Persistent; |
| 124 class FunctionTemplate; | 124 class FunctionTemplate; |
| 125 class ObjectTemplate; | 125 class ObjectTemplate; |
| 126 class Data; | 126 class Data; |
| 127 class AccessorInfo; | 127 class AccessorInfo; |
| 128 template<typename T> class PropertyCallbackInfo; | |
| 128 class StackTrace; | 129 class StackTrace; |
| 129 class StackFrame; | 130 class StackFrame; |
| 130 class Isolate; | 131 class Isolate; |
| 131 class DeclaredAccessorDescriptor; | 132 class DeclaredAccessorDescriptor; |
| 132 class ObjectOperationDescriptor; | 133 class ObjectOperationDescriptor; |
| 133 class RawOperationDescriptor; | 134 class RawOperationDescriptor; |
| 134 | 135 |
| 135 namespace internal { | 136 namespace internal { |
| 136 | 137 |
| 137 class Arguments; | 138 class Arguments; |
| (...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1520 kExternalPixelArray | 1521 kExternalPixelArray |
| 1521 }; | 1522 }; |
| 1522 | 1523 |
| 1523 /** | 1524 /** |
| 1524 * Accessor[Getter|Setter] are used as callback functions when | 1525 * Accessor[Getter|Setter] are used as callback functions when |
| 1525 * setting|getting a particular property. See Object and ObjectTemplate's | 1526 * setting|getting a particular property. See Object and ObjectTemplate's |
| 1526 * method SetAccessor. | 1527 * method SetAccessor. |
| 1527 */ | 1528 */ |
| 1528 typedef Handle<Value> (*AccessorGetter)(Local<String> property, | 1529 typedef Handle<Value> (*AccessorGetter)(Local<String> property, |
| 1529 const AccessorInfo& info); | 1530 const AccessorInfo& info); |
| 1531 typedef void (*AccessorGetterCallback)( | |
| 1532 Local<String> property, | |
| 1533 const PropertyCallbackInfo<Value>& info); | |
| 1530 | 1534 |
| 1531 | 1535 |
| 1532 typedef void (*AccessorSetter)(Local<String> property, | 1536 typedef void (*AccessorSetter)(Local<String> property, |
| 1533 Local<Value> value, | 1537 Local<Value> value, |
| 1534 const AccessorInfo& info); | 1538 const AccessorInfo& info); |
| 1539 typedef void (*AccessorSetterCallback)( | |
| 1540 Local<String> property, | |
| 1541 Local<Value> value, | |
| 1542 const PropertyCallbackInfo<void>& info); | |
| 1535 | 1543 |
| 1536 | 1544 |
| 1537 /** | 1545 /** |
| 1538 * Access control specifications. | 1546 * Access control specifications. |
| 1539 * | 1547 * |
| 1540 * Some accessors should be accessible across contexts. These | 1548 * Some accessors should be accessible across contexts. These |
| 1541 * accessors have an explicit access control parameter which specifies | 1549 * accessors have an explicit access control parameter which specifies |
| 1542 * the kind of cross-context access that should be allowed. | 1550 * the kind of cross-context access that should be allowed. |
| 1543 * | 1551 * |
| 1544 * Additionally, for security, accessors can prohibit overwriting by | 1552 * Additionally, for security, accessors can prohibit overwriting by |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1602 bool Has(uint32_t index); | 1610 bool Has(uint32_t index); |
| 1603 | 1611 |
| 1604 bool Delete(uint32_t index); | 1612 bool Delete(uint32_t index); |
| 1605 | 1613 |
| 1606 bool SetAccessor(Handle<String> name, | 1614 bool SetAccessor(Handle<String> name, |
| 1607 AccessorGetter getter, | 1615 AccessorGetter getter, |
| 1608 AccessorSetter setter = 0, | 1616 AccessorSetter setter = 0, |
| 1609 Handle<Value> data = Handle<Value>(), | 1617 Handle<Value> data = Handle<Value>(), |
| 1610 AccessControl settings = DEFAULT, | 1618 AccessControl settings = DEFAULT, |
| 1611 PropertyAttribute attribute = None); | 1619 PropertyAttribute attribute = None); |
| 1620 bool SetAccessor(Handle<String> name, | |
| 1621 AccessorGetterCallback getter, | |
| 1622 AccessorSetterCallback setter = 0, | |
| 1623 Handle<Value> data = Handle<Value>(), | |
| 1624 AccessControl settings = DEFAULT, | |
| 1625 PropertyAttribute attribute = None); | |
| 1612 | 1626 |
| 1613 // This function is not yet stable and should not be used at this time. | 1627 // This function is not yet stable and should not be used at this time. |
| 1614 bool SetAccessor(Handle<String> name, | 1628 bool SetAccessor(Handle<String> name, |
| 1615 Handle<DeclaredAccessorDescriptor> descriptor, | 1629 Handle<DeclaredAccessorDescriptor> descriptor, |
| 1616 AccessControl settings = DEFAULT, | 1630 AccessControl settings = DEFAULT, |
| 1617 PropertyAttribute attribute = None); | 1631 PropertyAttribute attribute = None); |
| 1618 | 1632 |
| 1619 /** | 1633 /** |
| 1620 * Returns an array containing the names of the enumerable properties | 1634 * Returns an array containing the names of the enumerable properties |
| 1621 * of this object, including properties from prototype objects. The | 1635 * of this object, including properties from prototype objects. The |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2053 PropertyAttribute attributes = None); | 2067 PropertyAttribute attributes = None); |
| 2054 V8_INLINE(void Set(const char* name, Handle<Data> value)); | 2068 V8_INLINE(void Set(const char* name, Handle<Data> value)); |
| 2055 private: | 2069 private: |
| 2056 Template(); | 2070 Template(); |
| 2057 | 2071 |
| 2058 friend class ObjectTemplate; | 2072 friend class ObjectTemplate; |
| 2059 friend class FunctionTemplate; | 2073 friend class FunctionTemplate; |
| 2060 }; | 2074 }; |
| 2061 | 2075 |
| 2062 | 2076 |
| 2077 template<typename T> | |
| 2078 class V8EXPORT ReturnHandler { | |
|
Michael Starzinger
2013/03/18 13:57:05
As discussed offline: Let's name this class Return
| |
| 2079 public: | |
| 2080 V8_INLINE(explicit ReturnHandler(T* slot)) : slot_(slot) {} | |
| 2081 V8_INLINE(void SetReturnValue(Persistent<T> handle)) { slot_ = *handle; } | |
|
Michael Starzinger
2013/03/18 13:57:05
As discussed offline: Let's name these setters jus
| |
| 2082 V8_INLINE(void SetReturnValue(Handle<T> handle)) { slot_ = *handle; } | |
| 2083 private: | |
| 2084 T* slot_; | |
| 2085 }; | |
| 2086 | |
| 2087 | |
| 2063 /** | 2088 /** |
| 2064 * The argument information given to function call callbacks. This | 2089 * The argument information given to function call callbacks. This |
| 2065 * class provides access to information about the context of the call, | 2090 * class provides access to information about the context of the call, |
| 2066 * including the receiver, the number and values of arguments, and | 2091 * including the receiver, the number and values of arguments, and |
| 2067 * the holder of the function. | 2092 * the holder of the function. |
| 2068 */ | 2093 */ |
| 2069 class V8EXPORT Arguments { | 2094 template<typename T> |
| 2095 class V8EXPORT FunctionCallbackInfo { | |
| 2070 public: | 2096 public: |
| 2071 V8_INLINE(int Length() const); | 2097 V8_INLINE(int Length() const); |
| 2072 V8_INLINE(Local<Value> operator[](int i) const); | 2098 V8_INLINE(Local<Value> operator[](int i) const); |
| 2073 V8_INLINE(Local<Function> Callee() const); | 2099 V8_INLINE(Local<Function> Callee() const); |
| 2074 V8_INLINE(Local<Object> This() const); | 2100 V8_INLINE(Local<Object> This() const); |
| 2075 V8_INLINE(Local<Object> Holder() const); | 2101 V8_INLINE(Local<Object> Holder() const); |
| 2076 V8_INLINE(bool IsConstructCall() const); | 2102 V8_INLINE(bool IsConstructCall() const); |
| 2077 V8_INLINE(Local<Value> Data() const); | 2103 V8_INLINE(Local<Value> Data() const); |
| 2078 V8_INLINE(Isolate* GetIsolate() const); | 2104 V8_INLINE(Isolate* GetIsolate() const); |
| 2105 V8_INLINE(ReturnHandler<T> GetReturnHandler() const); | |
| 2079 | 2106 |
| 2080 private: | 2107 protected: |
| 2081 static const int kIsolateIndex = 0; | 2108 static const int kIsolateIndex = 0; |
| 2082 static const int kDataIndex = -1; | 2109 static const int kDataIndex = -1; |
| 2083 static const int kCalleeIndex = -2; | 2110 static const int kCalleeIndex = -2; |
| 2084 static const int kHolderIndex = -3; | 2111 static const int kHolderIndex = -3; |
| 2112 static const int kReturnValueIndex = -4; | |
| 2085 | 2113 |
| 2086 friend class ImplementationUtilities; | 2114 friend class ImplementationUtilities; |
| 2087 V8_INLINE(Arguments(internal::Object** implicit_args, | 2115 V8_INLINE(FunctionCallbackInfo(internal::Object** implicit_args, |
| 2088 internal::Object** values, | 2116 internal::Object** values, |
| 2089 int length, | 2117 int length, |
| 2090 bool is_construct_call)); | 2118 bool is_construct_call)); |
| 2091 internal::Object** implicit_args_; | 2119 internal::Object** implicit_args_; |
| 2092 internal::Object** values_; | 2120 internal::Object** values_; |
| 2093 int length_; | 2121 int length_; |
| 2094 bool is_construct_call_; | 2122 bool is_construct_call_; |
| 2095 }; | 2123 }; |
| 2096 | 2124 |
| 2097 | 2125 |
| 2126 class V8EXPORT Arguments : public FunctionCallbackInfo<Value> { | |
| 2127 private: | |
| 2128 friend class ImplementationUtilities; | |
| 2129 V8_INLINE(Arguments(internal::Object** implicit_args, | |
| 2130 internal::Object** values, | |
| 2131 int length, | |
| 2132 bool is_construct_call)); | |
| 2133 }; | |
| 2134 | |
| 2135 | |
| 2098 /** | 2136 /** |
| 2099 * The information passed to an accessor callback about the context | 2137 * The information passed to a property callback about the context |
| 2100 * of the property access. | 2138 * of the property access. |
| 2101 */ | 2139 */ |
| 2102 class V8EXPORT AccessorInfo { | 2140 template<typename T> |
| 2141 class V8EXPORT PropertyCallbackInfo { | |
| 2103 public: | 2142 public: |
| 2104 V8_INLINE(AccessorInfo(internal::Object** args)) | 2143 V8_INLINE(PropertyCallbackInfo(internal::Object** args)) |
| 2105 : args_(args) { } | 2144 : args_(args) { } |
| 2106 V8_INLINE(Isolate* GetIsolate() const); | 2145 V8_INLINE(Isolate* GetIsolate() const); |
| 2107 V8_INLINE(Local<Value> Data() const); | 2146 V8_INLINE(Local<Value> Data() const); |
| 2108 V8_INLINE(Local<Object> This() const); | 2147 V8_INLINE(Local<Object> This() const); |
| 2109 V8_INLINE(Local<Object> Holder() const); | 2148 V8_INLINE(Local<Object> Holder() const); |
| 2149 V8_INLINE(ReturnHandler<T> GetReturnHandler() const); | |
| 2110 | 2150 |
| 2111 private: | 2151 private: |
| 2152 static const int kIsolateIndex = -3; | |
| 2153 static const int kDataIndex = -2; | |
| 2154 static const int kThisIndex = 0; | |
| 2155 static const int kHolderIndex = -1; | |
| 2156 static const int kReturnValueIndex = -4; | |
| 2157 | |
| 2112 internal::Object** args_; | 2158 internal::Object** args_; |
| 2113 }; | 2159 }; |
| 2114 | 2160 |
| 2115 | 2161 |
| 2162 class V8EXPORT AccessorInfo : public PropertyCallbackInfo<Value> { | |
| 2163 public: | |
| 2164 V8_INLINE(AccessorInfo(internal::Object** args)) | |
| 2165 : PropertyCallbackInfo<Value>(args) { } | |
| 2166 }; | |
| 2167 | |
| 2168 | |
| 2116 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | 2169 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); |
| 2170 typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); | |
| 2171 | |
| 2117 | 2172 |
| 2118 /** | 2173 /** |
| 2119 * NamedProperty[Getter|Setter] are used as interceptors on object. | 2174 * NamedProperty[Getter|Setter] are used as interceptors on object. |
| 2120 * See ObjectTemplate::SetNamedPropertyHandler. | 2175 * See ObjectTemplate::SetNamedPropertyHandler. |
| 2121 */ | 2176 */ |
| 2122 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, | 2177 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, |
| 2123 const AccessorInfo& info); | 2178 const AccessorInfo& info); |
| 2179 typedef void (*NamedPropertyGetterCallback)( | |
| 2180 Local<String> property, | |
| 2181 const PropertyCallbackInfo<Value>& info); | |
| 2124 | 2182 |
| 2125 | 2183 |
| 2126 /** | 2184 /** |
| 2127 * Returns the value if the setter intercepts the request. | 2185 * Returns the value if the setter intercepts the request. |
| 2128 * Otherwise, returns an empty handle. | 2186 * Otherwise, returns an empty handle. |
| 2129 */ | 2187 */ |
| 2130 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, | 2188 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, |
| 2131 Local<Value> value, | 2189 Local<Value> value, |
| 2132 const AccessorInfo& info); | 2190 const AccessorInfo& info); |
| 2191 typedef void (*NamedPropertySetterCallback)( | |
| 2192 Local<String> property, | |
| 2193 Local<Value> value, | |
| 2194 const PropertyCallbackInfo<Value>& info); | |
| 2195 | |
| 2133 | 2196 |
| 2134 /** | 2197 /** |
| 2135 * Returns a non-empty handle if the interceptor intercepts the request. | 2198 * Returns a non-empty handle if the interceptor intercepts the request. |
| 2136 * The result is an integer encoding property attributes (like v8::None, | 2199 * The result is an integer encoding property attributes (like v8::None, |
| 2137 * v8::DontEnum, etc.) | 2200 * v8::DontEnum, etc.) |
| 2138 */ | 2201 */ |
| 2139 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, | 2202 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, |
| 2140 const AccessorInfo& info); | 2203 const AccessorInfo& info); |
| 2204 typedef void (*NamedPropertyQueryCallback)( | |
| 2205 Local<String> property, | |
| 2206 const PropertyCallbackInfo<Integer>& info); | |
| 2141 | 2207 |
| 2142 | 2208 |
| 2143 /** | 2209 /** |
| 2144 * Returns a non-empty handle if the deleter intercepts the request. | 2210 * Returns a non-empty handle if the deleter intercepts the request. |
| 2145 * The return value is true if the property could be deleted and false | 2211 * The return value is true if the property could be deleted and false |
| 2146 * otherwise. | 2212 * otherwise. |
| 2147 */ | 2213 */ |
| 2148 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, | 2214 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, |
| 2149 const AccessorInfo& info); | 2215 const AccessorInfo& info); |
| 2216 typedef void (*NamedPropertyDeleterCallback)( | |
| 2217 Local<String> property, | |
| 2218 const PropertyCallbackInfo<Boolean>& info); | |
| 2219 | |
| 2150 | 2220 |
| 2151 /** | 2221 /** |
| 2152 * Returns an array containing the names of the properties the named | 2222 * Returns an array containing the names of the properties the named |
| 2153 * property getter intercepts. | 2223 * property getter intercepts. |
| 2154 */ | 2224 */ |
| 2155 typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info); | 2225 typedef Handle<Array> (*NamedPropertyEnumerator)(const AccessorInfo& info); |
| 2226 typedef void (*NamedPropertyEnumeratorCallback)( | |
| 2227 const PropertyCallbackInfo<Array>& info); | |
| 2156 | 2228 |
| 2157 | 2229 |
| 2158 /** | 2230 /** |
| 2159 * Returns the value of the property if the getter intercepts the | 2231 * Returns the value of the property if the getter intercepts the |
| 2160 * request. Otherwise, returns an empty handle. | 2232 * request. Otherwise, returns an empty handle. |
| 2161 */ | 2233 */ |
| 2162 typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index, | 2234 typedef Handle<Value> (*IndexedPropertyGetter)(uint32_t index, |
| 2163 const AccessorInfo& info); | 2235 const AccessorInfo& info); |
| 2236 typedef void (*IndexedPropertyGetterCallback)( | |
| 2237 uint32_t index, | |
| 2238 const PropertyCallbackInfo<Value>& info); | |
| 2164 | 2239 |
| 2165 | 2240 |
| 2166 /** | 2241 /** |
| 2167 * Returns the value if the setter intercepts the request. | 2242 * Returns the value if the setter intercepts the request. |
| 2168 * Otherwise, returns an empty handle. | 2243 * Otherwise, returns an empty handle. |
| 2169 */ | 2244 */ |
| 2170 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, | 2245 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, |
| 2171 Local<Value> value, | 2246 Local<Value> value, |
| 2172 const AccessorInfo& info); | 2247 const AccessorInfo& info); |
| 2248 typedef void (*IndexedPropertySetterCallback)( | |
| 2249 uint32_t index, | |
| 2250 Local<Value> value, | |
| 2251 const PropertyCallbackInfo<Value>& info); | |
| 2173 | 2252 |
| 2174 | 2253 |
| 2175 /** | 2254 /** |
| 2176 * Returns a non-empty handle if the interceptor intercepts the request. | 2255 * Returns a non-empty handle if the interceptor intercepts the request. |
| 2177 * The result is an integer encoding property attributes. | 2256 * The result is an integer encoding property attributes. |
| 2178 */ | 2257 */ |
| 2179 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, | 2258 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, |
| 2180 const AccessorInfo& info); | 2259 const AccessorInfo& info); |
| 2260 typedef void (*IndexedPropertyQueryCallback)( | |
| 2261 uint32_t index, | |
| 2262 const PropertyCallbackInfo<Integer>& info); | |
| 2263 | |
| 2181 | 2264 |
| 2182 /** | 2265 /** |
| 2183 * Returns a non-empty handle if the deleter intercepts the request. | 2266 * Returns a non-empty handle if the deleter intercepts the request. |
| 2184 * The return value is true if the property could be deleted and false | 2267 * The return value is true if the property could be deleted and false |
| 2185 * otherwise. | 2268 * otherwise. |
| 2186 */ | 2269 */ |
| 2187 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, | 2270 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, |
| 2188 const AccessorInfo& info); | 2271 const AccessorInfo& info); |
| 2272 typedef void (*IndexedPropertyDeleterCallback)( | |
| 2273 uint32_t index, | |
| 2274 const PropertyCallbackInfo<Boolean>& info); | |
| 2275 | |
| 2189 | 2276 |
| 2190 /** | 2277 /** |
| 2191 * Returns an array containing the indices of the properties the | 2278 * Returns an array containing the indices of the properties the |
| 2192 * indexed property getter intercepts. | 2279 * indexed property getter intercepts. |
| 2193 */ | 2280 */ |
| 2194 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info); | 2281 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info); |
| 2282 typedef void (*IndexedPropertyEnumeratorCallback)( | |
| 2283 const PropertyCallbackInfo<Array>& info); | |
| 2195 | 2284 |
| 2196 | 2285 |
| 2197 /** | 2286 /** |
| 2198 * Access type specification. | 2287 * Access type specification. |
| 2199 */ | 2288 */ |
| 2200 enum AccessType { | 2289 enum AccessType { |
| 2201 ACCESS_GET, | 2290 ACCESS_GET, |
| 2202 ACCESS_SET, | 2291 ACCESS_SET, |
| 2203 ACCESS_HAS, | 2292 ACCESS_HAS, |
| 2204 ACCESS_DELETE, | 2293 ACCESS_DELETE, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2319 * \endcode | 2408 * \endcode |
| 2320 */ | 2409 */ |
| 2321 class V8EXPORT FunctionTemplate : public Template { | 2410 class V8EXPORT FunctionTemplate : public Template { |
| 2322 public: | 2411 public: |
| 2323 /** Creates a function template.*/ | 2412 /** Creates a function template.*/ |
| 2324 static Local<FunctionTemplate> New( | 2413 static Local<FunctionTemplate> New( |
| 2325 InvocationCallback callback = 0, | 2414 InvocationCallback callback = 0, |
| 2326 Handle<Value> data = Handle<Value>(), | 2415 Handle<Value> data = Handle<Value>(), |
| 2327 Handle<Signature> signature = Handle<Signature>(), | 2416 Handle<Signature> signature = Handle<Signature>(), |
| 2328 int length = 0); | 2417 int length = 0); |
| 2418 static Local<FunctionTemplate> New( | |
| 2419 FunctionCallback callback, // TODO(dcarney): add back default param. | |
| 2420 Handle<Value> data = Handle<Value>(), | |
| 2421 Handle<Signature> signature = Handle<Signature>(), | |
| 2422 int length = 0); | |
| 2423 | |
| 2329 /** Returns the unique function instance in the current execution context.*/ | 2424 /** Returns the unique function instance in the current execution context.*/ |
| 2330 Local<Function> GetFunction(); | 2425 Local<Function> GetFunction(); |
| 2331 | 2426 |
| 2332 /** | 2427 /** |
| 2333 * Set the call-handler callback for a FunctionTemplate. This | 2428 * Set the call-handler callback for a FunctionTemplate. This |
| 2334 * callback is called whenever the function created from this | 2429 * callback is called whenever the function created from this |
| 2335 * FunctionTemplate is called. | 2430 * FunctionTemplate is called. |
| 2336 */ | 2431 */ |
| 2337 void SetCallHandler(InvocationCallback callback, | 2432 void SetCallHandler(InvocationCallback callback, |
| 2338 Handle<Value> data = Handle<Value>()); | 2433 Handle<Value> data = Handle<Value>()); |
| 2434 void SetCallHandler(FunctionCallback callback, | |
| 2435 Handle<Value> data = Handle<Value>()); | |
| 2339 | 2436 |
| 2340 /** Set the predefined length property for the FunctionTemplate. */ | 2437 /** Set the predefined length property for the FunctionTemplate. */ |
| 2341 void SetLength(int length); | 2438 void SetLength(int length); |
| 2342 | 2439 |
| 2343 /** Get the InstanceTemplate. */ | 2440 /** Get the InstanceTemplate. */ |
| 2344 Local<ObjectTemplate> InstanceTemplate(); | 2441 Local<ObjectTemplate> InstanceTemplate(); |
| 2345 | 2442 |
| 2346 /** Causes the function template to inherit from a parent function template.*/ | 2443 /** Causes the function template to inherit from a parent function template.*/ |
| 2347 void Inherit(Handle<FunctionTemplate> parent); | 2444 void Inherit(Handle<FunctionTemplate> parent); |
| 2348 | 2445 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2451 * thrown and no callback is invoked. | 2548 * thrown and no callback is invoked. |
| 2452 */ | 2549 */ |
| 2453 void SetAccessor(Handle<String> name, | 2550 void SetAccessor(Handle<String> name, |
| 2454 AccessorGetter getter, | 2551 AccessorGetter getter, |
| 2455 AccessorSetter setter = 0, | 2552 AccessorSetter setter = 0, |
| 2456 Handle<Value> data = Handle<Value>(), | 2553 Handle<Value> data = Handle<Value>(), |
| 2457 AccessControl settings = DEFAULT, | 2554 AccessControl settings = DEFAULT, |
| 2458 PropertyAttribute attribute = None, | 2555 PropertyAttribute attribute = None, |
| 2459 Handle<AccessorSignature> signature = | 2556 Handle<AccessorSignature> signature = |
| 2460 Handle<AccessorSignature>()); | 2557 Handle<AccessorSignature>()); |
| 2558 void SetAccessor(Handle<String> name, | |
| 2559 AccessorGetterCallback getter, | |
| 2560 AccessorSetterCallback setter = 0, | |
| 2561 Handle<Value> data = Handle<Value>(), | |
| 2562 AccessControl settings = DEFAULT, | |
| 2563 PropertyAttribute attribute = None, | |
| 2564 Handle<AccessorSignature> signature = | |
| 2565 Handle<AccessorSignature>()); | |
| 2461 | 2566 |
| 2462 // This function is not yet stable and should not be used at this time. | 2567 // This function is not yet stable and should not be used at this time. |
| 2463 bool SetAccessor(Handle<String> name, | 2568 bool SetAccessor(Handle<String> name, |
| 2464 Handle<DeclaredAccessorDescriptor> descriptor, | 2569 Handle<DeclaredAccessorDescriptor> descriptor, |
| 2465 AccessControl settings = DEFAULT, | 2570 AccessControl settings = DEFAULT, |
| 2466 PropertyAttribute attribute = None, | 2571 PropertyAttribute attribute = None, |
| 2467 Handle<AccessorSignature> signature = | 2572 Handle<AccessorSignature> signature = |
| 2468 Handle<AccessorSignature>()); | 2573 Handle<AccessorSignature>()); |
| 2469 | 2574 |
| 2470 /** | 2575 /** |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 2483 * properties of an object. | 2588 * properties of an object. |
| 2484 * \param data A piece of data that will be passed to the callbacks | 2589 * \param data A piece of data that will be passed to the callbacks |
| 2485 * whenever they are invoked. | 2590 * whenever they are invoked. |
| 2486 */ | 2591 */ |
| 2487 void SetNamedPropertyHandler(NamedPropertyGetter getter, | 2592 void SetNamedPropertyHandler(NamedPropertyGetter getter, |
| 2488 NamedPropertySetter setter = 0, | 2593 NamedPropertySetter setter = 0, |
| 2489 NamedPropertyQuery query = 0, | 2594 NamedPropertyQuery query = 0, |
| 2490 NamedPropertyDeleter deleter = 0, | 2595 NamedPropertyDeleter deleter = 0, |
| 2491 NamedPropertyEnumerator enumerator = 0, | 2596 NamedPropertyEnumerator enumerator = 0, |
| 2492 Handle<Value> data = Handle<Value>()); | 2597 Handle<Value> data = Handle<Value>()); |
| 2598 void SetNamedPropertyHandler( | |
| 2599 NamedPropertyGetterCallback getter, | |
| 2600 NamedPropertySetterCallback setter = 0, | |
| 2601 NamedPropertyQueryCallback query = 0, | |
| 2602 NamedPropertyDeleterCallback deleter = 0, | |
| 2603 NamedPropertyEnumeratorCallback enumerator = 0, | |
| 2604 Handle<Value> data = Handle<Value>()); | |
| 2493 | 2605 |
| 2494 /** | 2606 /** |
| 2495 * Sets an indexed property handler on the object template. | 2607 * Sets an indexed property handler on the object template. |
| 2496 * | 2608 * |
| 2497 * Whenever an indexed property is accessed on objects created from | 2609 * Whenever an indexed property is accessed on objects created from |
| 2498 * this object template, the provided callback is invoked instead of | 2610 * this object template, the provided callback is invoked instead of |
| 2499 * accessing the property directly on the JavaScript object. | 2611 * accessing the property directly on the JavaScript object. |
| 2500 * | 2612 * |
| 2501 * \param getter The callback to invoke when getting a property. | 2613 * \param getter The callback to invoke when getting a property. |
| 2502 * \param setter The callback to invoke when setting a property. | 2614 * \param setter The callback to invoke when setting a property. |
| 2503 * \param query The callback to invoke to check if an object has a property. | 2615 * \param query The callback to invoke to check if an object has a property. |
| 2504 * \param deleter The callback to invoke when deleting a property. | 2616 * \param deleter The callback to invoke when deleting a property. |
| 2505 * \param enumerator The callback to invoke to enumerate all the indexed | 2617 * \param enumerator The callback to invoke to enumerate all the indexed |
| 2506 * properties of an object. | 2618 * properties of an object. |
| 2507 * \param data A piece of data that will be passed to the callbacks | 2619 * \param data A piece of data that will be passed to the callbacks |
| 2508 * whenever they are invoked. | 2620 * whenever they are invoked. |
| 2509 */ | 2621 */ |
| 2510 void SetIndexedPropertyHandler(IndexedPropertyGetter getter, | 2622 void SetIndexedPropertyHandler(IndexedPropertyGetter getter, |
| 2511 IndexedPropertySetter setter = 0, | 2623 IndexedPropertySetter setter = 0, |
| 2512 IndexedPropertyQuery query = 0, | 2624 IndexedPropertyQuery query = 0, |
| 2513 IndexedPropertyDeleter deleter = 0, | 2625 IndexedPropertyDeleter deleter = 0, |
| 2514 IndexedPropertyEnumerator enumerator = 0, | 2626 IndexedPropertyEnumerator enumerator = 0, |
| 2515 Handle<Value> data = Handle<Value>()); | 2627 Handle<Value> data = Handle<Value>()); |
| 2628 void SetIndexedPropertyHandler( | |
| 2629 IndexedPropertyGetterCallback getter, | |
| 2630 IndexedPropertySetterCallback setter = 0, | |
| 2631 IndexedPropertyQueryCallback query = 0, | |
| 2632 IndexedPropertyDeleterCallback deleter = 0, | |
| 2633 IndexedPropertyEnumeratorCallback enumerator = 0, | |
| 2634 Handle<Value> data = Handle<Value>()); | |
| 2516 | 2635 |
| 2517 /** | 2636 /** |
| 2518 * Sets the callback to be used when calling instances created from | 2637 * Sets the callback to be used when calling instances created from |
| 2519 * this template as a function. If no callback is set, instances | 2638 * this template as a function. If no callback is set, instances |
| 2520 * behave like normal JavaScript objects that cannot be called as a | 2639 * behave like normal JavaScript objects that cannot be called as a |
| 2521 * function. | 2640 * function. |
| 2522 */ | 2641 */ |
| 2523 void SetCallAsFunctionHandler(InvocationCallback callback, | 2642 void SetCallAsFunctionHandler(InvocationCallback callback, |
| 2524 Handle<Value> data = Handle<Value>()); | 2643 Handle<Value> data = Handle<Value>()); |
| 2644 void SetCallAsFunctionHandler(FunctionCallback callback, | |
| 2645 Handle<Value> data = Handle<Value>()); | |
| 2525 | 2646 |
| 2526 /** | 2647 /** |
| 2527 * Mark object instances of the template as undetectable. | 2648 * Mark object instances of the template as undetectable. |
| 2528 * | 2649 * |
| 2529 * In many ways, undetectable objects behave as though they are not | 2650 * In many ways, undetectable objects behave as though they are not |
| 2530 * there. They behave like 'undefined' in conditionals and when | 2651 * there. They behave like 'undefined' in conditionals and when |
| 2531 * printed. However, properties can be accessed and called as on | 2652 * printed. However, properties can be accessed and called as on |
| 2532 * normal objects. | 2653 * normal objects. |
| 2533 */ | 2654 */ |
| 2534 void MarkAsUndetectable(); | 2655 void MarkAsUndetectable(); |
| (...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4601 template <class T> | 4722 template <class T> |
| 4602 uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const { | 4723 uint16_t Persistent<T>::WrapperClassId(Isolate* isolate) const { |
| 4603 typedef internal::Internals I; | 4724 typedef internal::Internals I; |
| 4604 if (this->IsEmpty()) return 0; | 4725 if (this->IsEmpty()) return 0; |
| 4605 if (!I::IsInitialized(isolate)) return 0; | 4726 if (!I::IsInitialized(isolate)) return 0; |
| 4606 internal::Object** obj = reinterpret_cast<internal::Object**>(**this); | 4727 internal::Object** obj = reinterpret_cast<internal::Object**>(**this); |
| 4607 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; | 4728 uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; |
| 4608 return *reinterpret_cast<uint16_t*>(addr); | 4729 return *reinterpret_cast<uint16_t*>(addr); |
| 4609 } | 4730 } |
| 4610 | 4731 |
| 4611 Arguments::Arguments(internal::Object** implicit_args, | 4732 template<typename T> |
| 4612 internal::Object** values, int length, | 4733 FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, |
| 4613 bool is_construct_call) | 4734 internal::Object** values, |
| 4735 int length, | |
| 4736 bool is_construct_call) | |
| 4614 : implicit_args_(implicit_args), | 4737 : implicit_args_(implicit_args), |
| 4615 values_(values), | 4738 values_(values), |
| 4616 length_(length), | 4739 length_(length), |
| 4617 is_construct_call_(is_construct_call) { } | 4740 is_construct_call_(is_construct_call) { } |
| 4618 | 4741 |
| 4619 | 4742 |
| 4620 Local<Value> Arguments::operator[](int i) const { | 4743 Arguments::Arguments(internal::Object** args, |
| 4744 internal::Object** values, | |
| 4745 int length, | |
| 4746 bool is_construct_call) | |
| 4747 : FunctionCallbackInfo<Value>(args, values, length, is_construct_call) { } | |
| 4748 | |
| 4749 | |
| 4750 template<typename T> | |
| 4751 Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { | |
| 4621 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); | 4752 if (i < 0 || length_ <= i) return Local<Value>(*Undefined()); |
| 4622 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); | 4753 return Local<Value>(reinterpret_cast<Value*>(values_ - i)); |
| 4623 } | 4754 } |
| 4624 | 4755 |
| 4625 | 4756 |
| 4626 Local<Function> Arguments::Callee() const { | 4757 template<typename T> |
| 4758 Local<Function> FunctionCallbackInfo<T>::Callee() const { | |
| 4627 return Local<Function>(reinterpret_cast<Function*>( | 4759 return Local<Function>(reinterpret_cast<Function*>( |
| 4628 &implicit_args_[kCalleeIndex])); | 4760 &implicit_args_[kCalleeIndex])); |
| 4629 } | 4761 } |
| 4630 | 4762 |
| 4631 | 4763 |
| 4632 Local<Object> Arguments::This() const { | 4764 template<typename T> |
| 4765 Local<Object> FunctionCallbackInfo<T>::This() const { | |
| 4633 return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); | 4766 return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); |
| 4634 } | 4767 } |
| 4635 | 4768 |
| 4636 | 4769 |
| 4637 Local<Object> Arguments::Holder() const { | 4770 template<typename T> |
| 4771 Local<Object> FunctionCallbackInfo<T>::Holder() const { | |
| 4638 return Local<Object>(reinterpret_cast<Object*>( | 4772 return Local<Object>(reinterpret_cast<Object*>( |
| 4639 &implicit_args_[kHolderIndex])); | 4773 &implicit_args_[kHolderIndex])); |
| 4640 } | 4774 } |
| 4641 | 4775 |
| 4642 | 4776 |
| 4643 Local<Value> Arguments::Data() const { | 4777 template<typename T> |
| 4778 Local<Value> FunctionCallbackInfo<T>::Data() const { | |
| 4644 return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); | 4779 return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); |
| 4645 } | 4780 } |
| 4646 | 4781 |
| 4647 | 4782 |
| 4648 Isolate* Arguments::GetIsolate() const { | 4783 template<typename T> |
| 4784 Isolate* FunctionCallbackInfo<T>::GetIsolate() const { | |
| 4649 return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]); | 4785 return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]); |
| 4650 } | 4786 } |
| 4651 | 4787 |
| 4652 | 4788 |
| 4653 bool Arguments::IsConstructCall() const { | 4789 template<typename T> |
| 4790 ReturnHandler<T> FunctionCallbackInfo<T>::GetReturnHandler() const { | |
| 4791 return ReturnHandler<T>( | |
| 4792 reinterpret_cast<T*>(&implicit_args_[kReturnValueIndex])); | |
| 4793 } | |
| 4794 | |
| 4795 | |
| 4796 template<typename T> | |
| 4797 bool FunctionCallbackInfo<T>::IsConstructCall() const { | |
| 4654 return is_construct_call_; | 4798 return is_construct_call_; |
| 4655 } | 4799 } |
| 4656 | 4800 |
| 4657 | 4801 |
| 4658 int Arguments::Length() const { | 4802 template<typename T> |
| 4803 int FunctionCallbackInfo<T>::Length() const { | |
| 4659 return length_; | 4804 return length_; |
| 4660 } | 4805 } |
| 4661 | 4806 |
| 4662 | 4807 |
| 4663 template <class T> | 4808 template <class T> |
| 4664 Local<T> HandleScope::Close(Handle<T> value) { | 4809 Local<T> HandleScope::Close(Handle<T> value) { |
| 4665 internal::Object** before = reinterpret_cast<internal::Object**>(*value); | 4810 internal::Object** before = reinterpret_cast<internal::Object**>(*value); |
| 4666 internal::Object** after = RawClose(before); | 4811 internal::Object** after = RawClose(before); |
| 4667 return Local<T>(reinterpret_cast<T*>(after)); | 4812 return Local<T>(reinterpret_cast<T*>(after)); |
| 4668 } | 4813 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4915 | 5060 |
| 4916 | 5061 |
| 4917 External* External::Cast(v8::Value* value) { | 5062 External* External::Cast(v8::Value* value) { |
| 4918 #ifdef V8_ENABLE_CHECKS | 5063 #ifdef V8_ENABLE_CHECKS |
| 4919 CheckCast(value); | 5064 CheckCast(value); |
| 4920 #endif | 5065 #endif |
| 4921 return static_cast<External*>(value); | 5066 return static_cast<External*>(value); |
| 4922 } | 5067 } |
| 4923 | 5068 |
| 4924 | 5069 |
| 4925 Isolate* AccessorInfo::GetIsolate() const { | 5070 template<typename T> |
| 4926 return *reinterpret_cast<Isolate**>(&args_[-3]); | 5071 Isolate* PropertyCallbackInfo<T>::GetIsolate() const { |
| 5072 return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]); | |
| 4927 } | 5073 } |
| 4928 | 5074 |
| 4929 | 5075 |
| 4930 Local<Value> AccessorInfo::Data() const { | 5076 template<typename T> |
| 4931 return Local<Value>(reinterpret_cast<Value*>(&args_[-2])); | 5077 Local<Value> PropertyCallbackInfo<T>::Data() const { |
| 5078 return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex])); | |
| 4932 } | 5079 } |
| 4933 | 5080 |
| 4934 | 5081 |
| 4935 Local<Object> AccessorInfo::This() const { | 5082 template<typename T> |
| 4936 return Local<Object>(reinterpret_cast<Object*>(&args_[0])); | 5083 Local<Object> PropertyCallbackInfo<T>::This() const { |
| 5084 return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex])); | |
| 4937 } | 5085 } |
| 4938 | 5086 |
| 4939 | 5087 |
| 4940 Local<Object> AccessorInfo::Holder() const { | 5088 template<typename T> |
| 4941 return Local<Object>(reinterpret_cast<Object*>(&args_[-1])); | 5089 Local<Object> PropertyCallbackInfo<T>::Holder() const { |
| 5090 return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex])); | |
| 4942 } | 5091 } |
| 4943 | 5092 |
| 4944 | 5093 |
| 5094 template<typename T> | |
| 5095 ReturnHandler<T> PropertyCallbackInfo<T>::GetReturnHandler() const { | |
| 5096 return ReturnHandler<T>( | |
| 5097 reinterpret_cast<T*>(&args_[kReturnValueIndex])); | |
| 5098 } | |
| 5099 | |
| 5100 | |
| 4945 Handle<Primitive> Undefined(Isolate* isolate) { | 5101 Handle<Primitive> Undefined(Isolate* isolate) { |
| 4946 typedef internal::Object* S; | 5102 typedef internal::Object* S; |
| 4947 typedef internal::Internals I; | 5103 typedef internal::Internals I; |
| 4948 if (!I::IsInitialized(isolate)) return Undefined(); | 5104 if (!I::IsInitialized(isolate)) return Undefined(); |
| 4949 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); | 5105 S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); |
| 4950 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); | 5106 return Handle<Primitive>(reinterpret_cast<Primitive*>(slot)); |
| 4951 } | 5107 } |
| 4952 | 5108 |
| 4953 | 5109 |
| 4954 Handle<Primitive> Null(Isolate* isolate) { | 5110 Handle<Primitive> Null(Isolate* isolate) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5025 | 5181 |
| 5026 | 5182 |
| 5027 } // namespace v8 | 5183 } // namespace v8 |
| 5028 | 5184 |
| 5029 | 5185 |
| 5030 #undef V8EXPORT | 5186 #undef V8EXPORT |
| 5031 #undef TYPE_CHECK | 5187 #undef TYPE_CHECK |
| 5032 | 5188 |
| 5033 | 5189 |
| 5034 #endif // V8_H_ | 5190 #endif // V8_H_ |
| OLD | NEW |