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 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 /** | 1754 /** |
1755 * Returns the value if the setter intercepts the request. | 1755 * Returns the value if the setter intercepts the request. |
1756 * Otherwise, returns an empty handle. | 1756 * Otherwise, returns an empty handle. |
1757 */ | 1757 */ |
1758 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, | 1758 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, |
1759 Local<Value> value, | 1759 Local<Value> value, |
1760 const AccessorInfo& info); | 1760 const AccessorInfo& info); |
1761 | 1761 |
1762 /** | 1762 /** |
1763 * Returns a non-empty handle if the interceptor intercepts the request. | 1763 * Returns a non-empty handle if the interceptor intercepts the request. |
1764 * The result is either boolean (true if property exists and false | 1764 * The result is an integer encoding property attributes (like v8::None, |
1765 * otherwise) or an integer encoding property attributes. | 1765 * v8::DontEnum, etc.) |
1766 */ | 1766 */ |
1767 #ifdef USE_NEW_QUERY_CALLBACKS | |
1768 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, | 1767 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, |
1769 const AccessorInfo& info); | 1768 const AccessorInfo& info); |
1770 #else | |
1771 typedef Handle<Boolean> (*NamedPropertyQuery)(Local<String> property, | |
1772 const AccessorInfo& info); | |
1773 #endif | |
1774 | |
1775 typedef Handle<Value> (*NamedPropertyQueryImpl)(Local<String> property, | |
1776 const AccessorInfo& info); | |
1777 | |
1778 | 1769 |
1779 | 1770 |
1780 /** | 1771 /** |
1781 * Returns a non-empty handle if the deleter intercepts the request. | 1772 * Returns a non-empty handle if the deleter intercepts the request. |
1782 * The return value is true if the property could be deleted and false | 1773 * The return value is true if the property could be deleted and false |
1783 * otherwise. | 1774 * otherwise. |
1784 */ | 1775 */ |
1785 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, | 1776 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, |
1786 const AccessorInfo& info); | 1777 const AccessorInfo& info); |
1787 | 1778 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 AccessorGetter getter, | 2010 AccessorGetter getter, |
2020 AccessorSetter setter, | 2011 AccessorSetter setter, |
2021 Handle<Value> data, | 2012 Handle<Value> data, |
2022 AccessControl settings, | 2013 AccessControl settings, |
2023 PropertyAttribute attributes); | 2014 PropertyAttribute attributes); |
2024 void SetNamedInstancePropertyHandler(NamedPropertyGetter getter, | 2015 void SetNamedInstancePropertyHandler(NamedPropertyGetter getter, |
2025 NamedPropertySetter setter, | 2016 NamedPropertySetter setter, |
2026 NamedPropertyQuery query, | 2017 NamedPropertyQuery query, |
2027 NamedPropertyDeleter remover, | 2018 NamedPropertyDeleter remover, |
2028 NamedPropertyEnumerator enumerator, | 2019 NamedPropertyEnumerator enumerator, |
2029 Handle<Value> data) { | 2020 Handle<Value> data); |
2030 NamedPropertyQueryImpl casted = | |
2031 reinterpret_cast<NamedPropertyQueryImpl>(query); | |
2032 SetNamedInstancePropertyHandlerImpl(getter, | |
2033 setter, | |
2034 casted, | |
2035 remover, | |
2036 enumerator, | |
2037 data); | |
2038 } | |
2039 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, | 2021 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, |
2040 IndexedPropertySetter setter, | 2022 IndexedPropertySetter setter, |
2041 IndexedPropertyQuery query, | 2023 IndexedPropertyQuery query, |
2042 IndexedPropertyDeleter remover, | 2024 IndexedPropertyDeleter remover, |
2043 IndexedPropertyEnumerator enumerator, | 2025 IndexedPropertyEnumerator enumerator, |
2044 Handle<Value> data); | 2026 Handle<Value> data); |
2045 void SetInstanceCallAsFunctionHandler(InvocationCallback callback, | 2027 void SetInstanceCallAsFunctionHandler(InvocationCallback callback, |
2046 Handle<Value> data); | 2028 Handle<Value> data); |
2047 | 2029 |
2048 friend class Context; | 2030 friend class Context; |
2049 friend class ObjectTemplate; | 2031 friend class ObjectTemplate; |
2050 private: | |
2051 void SetNamedInstancePropertyHandlerImpl(NamedPropertyGetter getter, | |
2052 NamedPropertySetter setter, | |
2053 NamedPropertyQueryImpl query, | |
2054 NamedPropertyDeleter remover, | |
2055 NamedPropertyEnumerator enumerator, | |
2056 Handle<Value> data); | |
2057 }; | 2032 }; |
2058 | 2033 |
2059 | 2034 |
2060 /** | 2035 /** |
2061 * An ObjectTemplate is used to create objects at runtime. | 2036 * An ObjectTemplate is used to create objects at runtime. |
2062 * | 2037 * |
2063 * Properties added to an ObjectTemplate are added to each object | 2038 * Properties added to an ObjectTemplate are added to each object |
2064 * created from the ObjectTemplate. | 2039 * created from the ObjectTemplate. |
2065 */ | 2040 */ |
2066 class V8EXPORT ObjectTemplate : public Template { | 2041 class V8EXPORT ObjectTemplate : public Template { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 | 2079 |
2105 /** | 2080 /** |
2106 * Sets a named property handler on the object template. | 2081 * Sets a named property handler on the object template. |
2107 * | 2082 * |
2108 * Whenever a named property is accessed on objects created from | 2083 * Whenever a named property is accessed on objects created from |
2109 * this object template, the provided callback is invoked instead of | 2084 * this object template, the provided callback is invoked instead of |
2110 * accessing the property directly on the JavaScript object. | 2085 * accessing the property directly on the JavaScript object. |
2111 * | 2086 * |
2112 * \param getter The callback to invoke when getting a property. | 2087 * \param getter The callback to invoke when getting a property. |
2113 * \param setter The callback to invoke when setting a property. | 2088 * \param setter The callback to invoke when setting a property. |
2114 * \param query The callback to invoke to check if an object has a property. | 2089 * \param query The callback to invoke to check if a property is present, |
| 2090 * and if present, get its attributes. |
2115 * \param deleter The callback to invoke when deleting a property. | 2091 * \param deleter The callback to invoke when deleting a property. |
2116 * \param enumerator The callback to invoke to enumerate all the named | 2092 * \param enumerator The callback to invoke to enumerate all the named |
2117 * properties of an object. | 2093 * properties of an object. |
2118 * \param data A piece of data that will be passed to the callbacks | 2094 * \param data A piece of data that will be passed to the callbacks |
2119 * whenever they are invoked. | 2095 * whenever they are invoked. |
2120 */ | 2096 */ |
2121 void SetNamedPropertyHandler(NamedPropertyGetter getter, | 2097 void SetNamedPropertyHandler(NamedPropertyGetter getter, |
2122 NamedPropertySetter setter = 0, | 2098 NamedPropertySetter setter = 0, |
2123 NamedPropertyQuery query = 0, | 2099 NamedPropertyQuery query = 0, |
2124 NamedPropertyDeleter deleter = 0, | 2100 NamedPropertyDeleter deleter = 0, |
2125 NamedPropertyEnumerator enumerator = 0, | 2101 NamedPropertyEnumerator enumerator = 0, |
2126 Handle<Value> data = Handle<Value>()) { | 2102 Handle<Value> data = Handle<Value>()); |
2127 NamedPropertyQueryImpl casted = | |
2128 reinterpret_cast<NamedPropertyQueryImpl>(query); | |
2129 SetNamedPropertyHandlerImpl(getter, | |
2130 setter, | |
2131 casted, | |
2132 deleter, | |
2133 enumerator, | |
2134 data); | |
2135 } | |
2136 | |
2137 private: | |
2138 void SetNamedPropertyHandlerImpl(NamedPropertyGetter getter, | |
2139 NamedPropertySetter setter, | |
2140 NamedPropertyQueryImpl query, | |
2141 NamedPropertyDeleter deleter, | |
2142 NamedPropertyEnumerator enumerator, | |
2143 Handle<Value> data); | |
2144 | |
2145 public: | |
2146 | 2103 |
2147 /** | 2104 /** |
2148 * Sets an indexed property handler on the object template. | 2105 * Sets an indexed property handler on the object template. |
2149 * | 2106 * |
2150 * Whenever an indexed property is accessed on objects created from | 2107 * Whenever an indexed property is accessed on objects created from |
2151 * this object template, the provided callback is invoked instead of | 2108 * this object template, the provided callback is invoked instead of |
2152 * accessing the property directly on the JavaScript object. | 2109 * accessing the property directly on the JavaScript object. |
2153 * | 2110 * |
2154 * \param getter The callback to invoke when getting a property. | 2111 * \param getter The callback to invoke when getting a property. |
2155 * \param setter The callback to invoke when setting a property. | 2112 * \param setter The callback to invoke when setting a property. |
(...skipping 1460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3616 | 3573 |
3617 } // namespace v8 | 3574 } // namespace v8 |
3618 | 3575 |
3619 | 3576 |
3620 #undef V8EXPORT | 3577 #undef V8EXPORT |
3621 #undef V8EXPORT_INLINE | 3578 #undef V8EXPORT_INLINE |
3622 #undef TYPE_CHECK | 3579 #undef TYPE_CHECK |
3623 | 3580 |
3624 | 3581 |
3625 #endif // V8_H_ | 3582 #endif // V8_H_ |
OLD | NEW |