OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 * Returns the value if the setter intercepts the request. | 1817 * Returns the value if the setter intercepts the request. |
1818 * Otherwise, returns an empty handle. | 1818 * Otherwise, returns an empty handle. |
1819 */ | 1819 */ |
1820 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, | 1820 typedef Handle<Value> (*IndexedPropertySetter)(uint32_t index, |
1821 Local<Value> value, | 1821 Local<Value> value, |
1822 const AccessorInfo& info); | 1822 const AccessorInfo& info); |
1823 | 1823 |
1824 | 1824 |
1825 /** | 1825 /** |
1826 * Returns a non-empty handle if the interceptor intercepts the request. | 1826 * Returns a non-empty handle if the interceptor intercepts the request. |
1827 * The result is true if either a boolean (true if property exists and false | 1827 * The result is an integer encoding property attributes. |
1828 * otherwise) or an integer encoding property attributes. | |
1829 */ | 1828 */ |
1830 #ifdef USE_NEW_QUERY_CALLBACKS | |
1831 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, | 1829 typedef Handle<Integer> (*IndexedPropertyQuery)(uint32_t index, |
1832 const AccessorInfo& info); | 1830 const AccessorInfo& info); |
1833 #else | |
1834 typedef Handle<Boolean> (*IndexedPropertyQuery)(uint32_t index, | |
1835 const AccessorInfo& info); | |
1836 #endif | |
1837 | |
1838 typedef Handle<Value> (*IndexedPropertyQueryImpl)(uint32_t index, | |
1839 const AccessorInfo& info); | |
1840 | 1831 |
1841 /** | 1832 /** |
1842 * Returns a non-empty handle if the deleter intercepts the request. | 1833 * Returns a non-empty handle if the deleter intercepts the request. |
1843 * The return value is true if the property could be deleted and false | 1834 * The return value is true if the property could be deleted and false |
1844 * otherwise. | 1835 * otherwise. |
1845 */ | 1836 */ |
1846 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, | 1837 typedef Handle<Boolean> (*IndexedPropertyDeleter)(uint32_t index, |
1847 const AccessorInfo& info); | 1838 const AccessorInfo& info); |
1848 | 1839 |
1849 /** | 1840 /** |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 NamedPropertySetter setter, | 2038 NamedPropertySetter setter, |
2048 NamedPropertyQuery query, | 2039 NamedPropertyQuery query, |
2049 NamedPropertyDeleter remover, | 2040 NamedPropertyDeleter remover, |
2050 NamedPropertyEnumerator enumerator, | 2041 NamedPropertyEnumerator enumerator, |
2051 Handle<Value> data); | 2042 Handle<Value> data); |
2052 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, | 2043 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, |
2053 IndexedPropertySetter setter, | 2044 IndexedPropertySetter setter, |
2054 IndexedPropertyQuery query, | 2045 IndexedPropertyQuery query, |
2055 IndexedPropertyDeleter remover, | 2046 IndexedPropertyDeleter remover, |
2056 IndexedPropertyEnumerator enumerator, | 2047 IndexedPropertyEnumerator enumerator, |
2057 Handle<Value> data) { | 2048 Handle<Value> data); |
2058 IndexedPropertyQueryImpl casted = | |
2059 reinterpret_cast<IndexedPropertyQueryImpl>(query); | |
2060 SetIndexedInstancePropertyHandlerImpl(getter, | |
2061 setter, | |
2062 casted, | |
2063 remover, | |
2064 enumerator, | |
2065 data); | |
2066 } | |
2067 void SetIndexedInstancePropertyHandlerImpl( | |
2068 IndexedPropertyGetter getter, | |
2069 IndexedPropertySetter setter, | |
2070 IndexedPropertyQueryImpl query, | |
2071 IndexedPropertyDeleter remover, | |
2072 IndexedPropertyEnumerator enumerator, | |
2073 Handle<Value> data); | |
2074 void SetInstanceCallAsFunctionHandler(InvocationCallback callback, | 2049 void SetInstanceCallAsFunctionHandler(InvocationCallback callback, |
2075 Handle<Value> data); | 2050 Handle<Value> data); |
2076 | 2051 |
2077 friend class Context; | 2052 friend class Context; |
2078 friend class ObjectTemplate; | 2053 friend class ObjectTemplate; |
2079 }; | 2054 }; |
2080 | 2055 |
2081 | 2056 |
2082 /** | 2057 /** |
2083 * An ObjectTemplate is used to create objects at runtime. | 2058 * An ObjectTemplate is used to create objects at runtime. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2162 * \param enumerator The callback to invoke to enumerate all the indexed | 2137 * \param enumerator The callback to invoke to enumerate all the indexed |
2163 * properties of an object. | 2138 * properties of an object. |
2164 * \param data A piece of data that will be passed to the callbacks | 2139 * \param data A piece of data that will be passed to the callbacks |
2165 * whenever they are invoked. | 2140 * whenever they are invoked. |
2166 */ | 2141 */ |
2167 void SetIndexedPropertyHandler(IndexedPropertyGetter getter, | 2142 void SetIndexedPropertyHandler(IndexedPropertyGetter getter, |
2168 IndexedPropertySetter setter = 0, | 2143 IndexedPropertySetter setter = 0, |
2169 IndexedPropertyQuery query = 0, | 2144 IndexedPropertyQuery query = 0, |
2170 IndexedPropertyDeleter deleter = 0, | 2145 IndexedPropertyDeleter deleter = 0, |
2171 IndexedPropertyEnumerator enumerator = 0, | 2146 IndexedPropertyEnumerator enumerator = 0, |
2172 Handle<Value> data = Handle<Value>()) { | 2147 Handle<Value> data = Handle<Value>()); |
2173 IndexedPropertyQueryImpl casted = | |
2174 reinterpret_cast<IndexedPropertyQueryImpl>(query); | |
2175 SetIndexedPropertyHandlerImpl(getter, | |
2176 setter, | |
2177 casted, | |
2178 deleter, | |
2179 enumerator, | |
2180 data); | |
2181 } | |
2182 private: | |
2183 void SetIndexedPropertyHandlerImpl(IndexedPropertyGetter getter, | |
2184 IndexedPropertySetter setter, | |
2185 IndexedPropertyQueryImpl query, | |
2186 IndexedPropertyDeleter deleter, | |
2187 IndexedPropertyEnumerator enumerator, | |
2188 Handle<Value> data); | |
2189 public: | |
2190 | 2148 |
2191 /** | 2149 /** |
2192 * Sets the callback to be used when calling instances created from | 2150 * Sets the callback to be used when calling instances created from |
2193 * this template as a function. If no callback is set, instances | 2151 * this template as a function. If no callback is set, instances |
2194 * behave like normal JavaScript objects that cannot be called as a | 2152 * behave like normal JavaScript objects that cannot be called as a |
2195 * function. | 2153 * function. |
2196 */ | 2154 */ |
2197 void SetCallAsFunctionHandler(InvocationCallback callback, | 2155 void SetCallAsFunctionHandler(InvocationCallback callback, |
2198 Handle<Value> data = Handle<Value>()); | 2156 Handle<Value> data = Handle<Value>()); |
2199 | 2157 |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3655 | 3613 |
3656 | 3614 |
3657 } // namespace v8 | 3615 } // namespace v8 |
3658 | 3616 |
3659 | 3617 |
3660 #undef V8EXPORT | 3618 #undef V8EXPORT |
3661 #undef TYPE_CHECK | 3619 #undef TYPE_CHECK |
3662 | 3620 |
3663 | 3621 |
3664 #endif // V8_H_ | 3622 #endif // V8_H_ |
OLD | NEW |