| 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 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1719 | 1719 |
| 1720 | 1720 |
| 1721 /** | 1721 /** |
| 1722 * Returns the value if the setter intercepts the request. | 1722 * Returns the value if the setter intercepts the request. |
| 1723 * Otherwise, returns an empty handle. | 1723 * Otherwise, returns an empty handle. |
| 1724 */ | 1724 */ |
| 1725 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, | 1725 typedef Handle<Value> (*NamedPropertySetter)(Local<String> property, |
| 1726 Local<Value> value, | 1726 Local<Value> value, |
| 1727 const AccessorInfo& info); | 1727 const AccessorInfo& info); |
| 1728 | 1728 |
| 1729 | |
| 1730 /** | 1729 /** |
| 1731 * Returns a non-empty handle if the interceptor intercepts the request. | 1730 * Returns a non-empty handle if the interceptor intercepts the request. |
| 1732 * The result is true if the property exists and false otherwise. | 1731 * The result is either boolean (true if property exists and false |
| 1732 * otherwise) or an integer encoding property attributes. |
| 1733 */ | 1733 */ |
| 1734 #ifdef USE_NEW_QUERY_CALLBACKS |
| 1735 typedef Handle<Integer> (*NamedPropertyQuery)(Local<String> property, |
| 1736 const AccessorInfo& info); |
| 1737 #else |
| 1734 typedef Handle<Boolean> (*NamedPropertyQuery)(Local<String> property, | 1738 typedef Handle<Boolean> (*NamedPropertyQuery)(Local<String> property, |
| 1735 const AccessorInfo& info); | 1739 const AccessorInfo& info); |
| 1740 #endif |
| 1741 |
| 1742 typedef Handle<Value> (*NamedPropertyQueryImpl)(Local<String> property, |
| 1743 const AccessorInfo& info); |
| 1744 |
| 1736 | 1745 |
| 1737 | 1746 |
| 1738 /** | 1747 /** |
| 1739 * Returns a non-empty handle if the deleter intercepts the request. | 1748 * Returns a non-empty handle if the deleter intercepts the request. |
| 1740 * The return value is true if the property could be deleted and false | 1749 * The return value is true if the property could be deleted and false |
| 1741 * otherwise. | 1750 * otherwise. |
| 1742 */ | 1751 */ |
| 1743 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, | 1752 typedef Handle<Boolean> (*NamedPropertyDeleter)(Local<String> property, |
| 1744 const AccessorInfo& info); | 1753 const AccessorInfo& info); |
| 1745 | 1754 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 AccessorGetter getter, | 1986 AccessorGetter getter, |
| 1978 AccessorSetter setter, | 1987 AccessorSetter setter, |
| 1979 Handle<Value> data, | 1988 Handle<Value> data, |
| 1980 AccessControl settings, | 1989 AccessControl settings, |
| 1981 PropertyAttribute attributes); | 1990 PropertyAttribute attributes); |
| 1982 void SetNamedInstancePropertyHandler(NamedPropertyGetter getter, | 1991 void SetNamedInstancePropertyHandler(NamedPropertyGetter getter, |
| 1983 NamedPropertySetter setter, | 1992 NamedPropertySetter setter, |
| 1984 NamedPropertyQuery query, | 1993 NamedPropertyQuery query, |
| 1985 NamedPropertyDeleter remover, | 1994 NamedPropertyDeleter remover, |
| 1986 NamedPropertyEnumerator enumerator, | 1995 NamedPropertyEnumerator enumerator, |
| 1987 Handle<Value> data); | 1996 Handle<Value> data) { |
| 1997 NamedPropertyQueryImpl casted = |
| 1998 reinterpret_cast<NamedPropertyQueryImpl>(query); |
| 1999 SetNamedInstancePropertyHandlerImpl(getter, |
| 2000 setter, |
| 2001 casted, |
| 2002 remover, |
| 2003 enumerator, |
| 2004 data); |
| 2005 } |
| 1988 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, | 2006 void SetIndexedInstancePropertyHandler(IndexedPropertyGetter getter, |
| 1989 IndexedPropertySetter setter, | 2007 IndexedPropertySetter setter, |
| 1990 IndexedPropertyQuery query, | 2008 IndexedPropertyQuery query, |
| 1991 IndexedPropertyDeleter remover, | 2009 IndexedPropertyDeleter remover, |
| 1992 IndexedPropertyEnumerator enumerator, | 2010 IndexedPropertyEnumerator enumerator, |
| 1993 Handle<Value> data); | 2011 Handle<Value> data); |
| 1994 void SetInstanceCallAsFunctionHandler(InvocationCallback callback, | 2012 void SetInstanceCallAsFunctionHandler(InvocationCallback callback, |
| 1995 Handle<Value> data); | 2013 Handle<Value> data); |
| 1996 | 2014 |
| 1997 friend class Context; | 2015 friend class Context; |
| 1998 friend class ObjectTemplate; | 2016 friend class ObjectTemplate; |
| 2017 private: |
| 2018 void SetNamedInstancePropertyHandlerImpl(NamedPropertyGetter getter, |
| 2019 NamedPropertySetter setter, |
| 2020 NamedPropertyQueryImpl query, |
| 2021 NamedPropertyDeleter remover, |
| 2022 NamedPropertyEnumerator enumerator, |
| 2023 Handle<Value> data); |
| 1999 }; | 2024 }; |
| 2000 | 2025 |
| 2001 | 2026 |
| 2002 /** | 2027 /** |
| 2003 * An ObjectTemplate is used to create objects at runtime. | 2028 * An ObjectTemplate is used to create objects at runtime. |
| 2004 * | 2029 * |
| 2005 * Properties added to an ObjectTemplate are added to each object | 2030 * Properties added to an ObjectTemplate are added to each object |
| 2006 * created from the ObjectTemplate. | 2031 * created from the ObjectTemplate. |
| 2007 */ | 2032 */ |
| 2008 class V8EXPORT ObjectTemplate : public Template { | 2033 class V8EXPORT ObjectTemplate : public Template { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 | 2071 |
| 2047 /** | 2072 /** |
| 2048 * Sets a named property handler on the object template. | 2073 * Sets a named property handler on the object template. |
| 2049 * | 2074 * |
| 2050 * Whenever a named property is accessed on objects created from | 2075 * Whenever a named property is accessed on objects created from |
| 2051 * this object template, the provided callback is invoked instead of | 2076 * this object template, the provided callback is invoked instead of |
| 2052 * accessing the property directly on the JavaScript object. | 2077 * accessing the property directly on the JavaScript object. |
| 2053 * | 2078 * |
| 2054 * \param getter The callback to invoke when getting a property. | 2079 * \param getter The callback to invoke when getting a property. |
| 2055 * \param setter The callback to invoke when setting a property. | 2080 * \param setter The callback to invoke when setting a property. |
| 2056 * \param query The callback to invoke to check is an object has a property. | 2081 * \param query The callback to invoke to check if an object has a property. |
| 2057 * \param deleter The callback to invoke when deleting a property. | 2082 * \param deleter The callback to invoke when deleting a property. |
| 2058 * \param enumerator The callback to invoke to enumerate all the named | 2083 * \param enumerator The callback to invoke to enumerate all the named |
| 2059 * properties of an object. | 2084 * properties of an object. |
| 2060 * \param data A piece of data that will be passed to the callbacks | 2085 * \param data A piece of data that will be passed to the callbacks |
| 2061 * whenever they are invoked. | 2086 * whenever they are invoked. |
| 2062 */ | 2087 */ |
| 2063 void SetNamedPropertyHandler(NamedPropertyGetter getter, | 2088 void SetNamedPropertyHandler(NamedPropertyGetter getter, |
| 2064 NamedPropertySetter setter = 0, | 2089 NamedPropertySetter setter = 0, |
| 2065 NamedPropertyQuery query = 0, | 2090 NamedPropertyQuery query = 0, |
| 2066 NamedPropertyDeleter deleter = 0, | 2091 NamedPropertyDeleter deleter = 0, |
| 2067 NamedPropertyEnumerator enumerator = 0, | 2092 NamedPropertyEnumerator enumerator = 0, |
| 2068 Handle<Value> data = Handle<Value>()); | 2093 Handle<Value> data = Handle<Value>()) { |
| 2094 NamedPropertyQueryImpl casted = |
| 2095 reinterpret_cast<NamedPropertyQueryImpl>(query); |
| 2096 SetNamedPropertyHandlerImpl(getter, |
| 2097 setter, |
| 2098 casted, |
| 2099 deleter, |
| 2100 enumerator, |
| 2101 data); |
| 2102 } |
| 2103 |
| 2104 private: |
| 2105 void SetNamedPropertyHandlerImpl(NamedPropertyGetter getter, |
| 2106 NamedPropertySetter setter, |
| 2107 NamedPropertyQueryImpl query, |
| 2108 NamedPropertyDeleter deleter, |
| 2109 NamedPropertyEnumerator enumerator, |
| 2110 Handle<Value> data); |
| 2111 |
| 2112 public: |
| 2069 | 2113 |
| 2070 /** | 2114 /** |
| 2071 * Sets an indexed property handler on the object template. | 2115 * Sets an indexed property handler on the object template. |
| 2072 * | 2116 * |
| 2073 * Whenever an indexed property is accessed on objects created from | 2117 * Whenever an indexed property is accessed on objects created from |
| 2074 * this object template, the provided callback is invoked instead of | 2118 * this object template, the provided callback is invoked instead of |
| 2075 * accessing the property directly on the JavaScript object. | 2119 * accessing the property directly on the JavaScript object. |
| 2076 * | 2120 * |
| 2077 * \param getter The callback to invoke when getting a property. | 2121 * \param getter The callback to invoke when getting a property. |
| 2078 * \param setter The callback to invoke when setting a property. | 2122 * \param setter The callback to invoke when setting a property. |
| (...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3548 | 3592 |
| 3549 } // namespace v8 | 3593 } // namespace v8 |
| 3550 | 3594 |
| 3551 | 3595 |
| 3552 #undef V8EXPORT | 3596 #undef V8EXPORT |
| 3553 #undef V8EXPORT_INLINE | 3597 #undef V8EXPORT_INLINE |
| 3554 #undef TYPE_CHECK | 3598 #undef TYPE_CHECK |
| 3555 | 3599 |
| 3556 | 3600 |
| 3557 #endif // V8_H_ | 3601 #endif // V8_H_ |
| OLD | NEW |