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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 class Function; | 119 class Function; |
120 class Date; | 120 class Date; |
121 class ImplementationUtilities; | 121 class ImplementationUtilities; |
122 class Signature; | 122 class Signature; |
123 template <class T> class Handle; | 123 template <class T> class Handle; |
124 template <class T> class Local; | 124 template <class T> class Local; |
125 template <class T> class Persistent; | 125 template <class T> class Persistent; |
126 class FunctionTemplate; | 126 class FunctionTemplate; |
127 class ObjectTemplate; | 127 class ObjectTemplate; |
128 class Data; | 128 class Data; |
| 129 class AccessorInfo; |
129 class StackTrace; | 130 class StackTrace; |
130 class StackFrame; | 131 class StackFrame; |
131 | 132 |
132 namespace internal { | 133 namespace internal { |
133 | 134 |
134 class Arguments; | 135 class Arguments; |
135 class Object; | 136 class Object; |
136 class Top; | 137 class Top; |
137 | 138 |
138 } | 139 } |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 kExternalByteArray = 1, | 1300 kExternalByteArray = 1, |
1300 kExternalUnsignedByteArray, | 1301 kExternalUnsignedByteArray, |
1301 kExternalShortArray, | 1302 kExternalShortArray, |
1302 kExternalUnsignedShortArray, | 1303 kExternalUnsignedShortArray, |
1303 kExternalIntArray, | 1304 kExternalIntArray, |
1304 kExternalUnsignedIntArray, | 1305 kExternalUnsignedIntArray, |
1305 kExternalFloatArray | 1306 kExternalFloatArray |
1306 }; | 1307 }; |
1307 | 1308 |
1308 /** | 1309 /** |
| 1310 * Accessor[Getter|Setter] are used as callback functions when |
| 1311 * setting|getting a particular property. See Object and ObjectTemplate's |
| 1312 * method SetAccessor. |
| 1313 */ |
| 1314 typedef Handle<Value> (*AccessorGetter)(Local<String> property, |
| 1315 const AccessorInfo& info); |
| 1316 |
| 1317 |
| 1318 typedef void (*AccessorSetter)(Local<String> property, |
| 1319 Local<Value> value, |
| 1320 const AccessorInfo& info); |
| 1321 |
| 1322 |
| 1323 /** |
| 1324 * Access control specifications. |
| 1325 * |
| 1326 * Some accessors should be accessible across contexts. These |
| 1327 * accessors have an explicit access control parameter which specifies |
| 1328 * the kind of cross-context access that should be allowed. |
| 1329 * |
| 1330 * Additionally, for security, accessors can prohibit overwriting by |
| 1331 * accessors defined in JavaScript. For objects that have such |
| 1332 * accessors either locally or in their prototype chain it is not |
| 1333 * possible to overwrite the accessor by using __defineGetter__ or |
| 1334 * __defineSetter__ from JavaScript code. |
| 1335 */ |
| 1336 enum AccessControl { |
| 1337 DEFAULT = 0, |
| 1338 ALL_CAN_READ = 1, |
| 1339 ALL_CAN_WRITE = 1 << 1, |
| 1340 PROHIBITS_OVERWRITING = 1 << 2 |
| 1341 }; |
| 1342 |
| 1343 |
| 1344 /** |
1309 * A JavaScript object (ECMA-262, 4.3.3) | 1345 * A JavaScript object (ECMA-262, 4.3.3) |
1310 */ | 1346 */ |
1311 class V8EXPORT Object : public Value { | 1347 class V8EXPORT Object : public Value { |
1312 public: | 1348 public: |
1313 bool Set(Handle<Value> key, | 1349 bool Set(Handle<Value> key, |
1314 Handle<Value> value, | 1350 Handle<Value> value, |
1315 PropertyAttribute attribs = None); | 1351 PropertyAttribute attribs = None); |
1316 | 1352 |
1317 bool Set(uint32_t index, | 1353 bool Set(uint32_t index, |
1318 Handle<Value> value); | 1354 Handle<Value> value); |
(...skipping 21 matching lines...) Expand all Loading... |
1340 bool Delete(Handle<String> key); | 1376 bool Delete(Handle<String> key); |
1341 | 1377 |
1342 // Delete a property on this object bypassing interceptors and | 1378 // Delete a property on this object bypassing interceptors and |
1343 // ignoring dont-delete attributes. | 1379 // ignoring dont-delete attributes. |
1344 bool ForceDelete(Handle<Value> key); | 1380 bool ForceDelete(Handle<Value> key); |
1345 | 1381 |
1346 bool Has(uint32_t index); | 1382 bool Has(uint32_t index); |
1347 | 1383 |
1348 bool Delete(uint32_t index); | 1384 bool Delete(uint32_t index); |
1349 | 1385 |
| 1386 bool SetAccessor(Handle<String> name, |
| 1387 AccessorGetter getter, |
| 1388 AccessorSetter setter = 0, |
| 1389 Handle<Value> data = Handle<Value>(), |
| 1390 AccessControl settings = DEFAULT, |
| 1391 PropertyAttribute attribute = None); |
| 1392 |
1350 /** | 1393 /** |
1351 * Returns an array containing the names of the enumerable properties | 1394 * Returns an array containing the names of the enumerable properties |
1352 * of this object, including properties from prototype objects. The | 1395 * of this object, including properties from prototype objects. The |
1353 * array returned by this method contains the same values as would | 1396 * array returned by this method contains the same values as would |
1354 * be enumerated by a for-in statement over this object. | 1397 * be enumerated by a for-in statement over this object. |
1355 */ | 1398 */ |
1356 Local<Array> GetPropertyNames(); | 1399 Local<Array> GetPropertyNames(); |
1357 | 1400 |
1358 /** | 1401 /** |
1359 * Get the prototype object. This does not skip objects marked to | 1402 * Get the prototype object. This does not skip objects marked to |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 private: | 1678 private: |
1636 internal::Object** args_; | 1679 internal::Object** args_; |
1637 }; | 1680 }; |
1638 | 1681 |
1639 | 1682 |
1640 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); | 1683 typedef Handle<Value> (*InvocationCallback)(const Arguments& args); |
1641 | 1684 |
1642 typedef int (*LookupCallback)(Local<Object> self, Local<String> name); | 1685 typedef int (*LookupCallback)(Local<Object> self, Local<String> name); |
1643 | 1686 |
1644 /** | 1687 /** |
1645 * Accessor[Getter|Setter] are used as callback functions when | |
1646 * setting|getting a particular property. See objectTemplate::SetAccessor. | |
1647 */ | |
1648 typedef Handle<Value> (*AccessorGetter)(Local<String> property, | |
1649 const AccessorInfo& info); | |
1650 | |
1651 | |
1652 typedef void (*AccessorSetter)(Local<String> property, | |
1653 Local<Value> value, | |
1654 const AccessorInfo& info); | |
1655 | |
1656 | |
1657 /** | |
1658 * NamedProperty[Getter|Setter] are used as interceptors on object. | 1688 * NamedProperty[Getter|Setter] are used as interceptors on object. |
1659 * See ObjectTemplate::SetNamedPropertyHandler. | 1689 * See ObjectTemplate::SetNamedPropertyHandler. |
1660 */ | 1690 */ |
1661 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, | 1691 typedef Handle<Value> (*NamedPropertyGetter)(Local<String> property, |
1662 const AccessorInfo& info); | 1692 const AccessorInfo& info); |
1663 | 1693 |
1664 | 1694 |
1665 /** | 1695 /** |
1666 * Returns the value if the setter intercepts the request. | 1696 * Returns the value if the setter intercepts the request. |
1667 * Otherwise, returns an empty handle. | 1697 * Otherwise, returns an empty handle. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 const AccessorInfo& info); | 1757 const AccessorInfo& info); |
1728 | 1758 |
1729 /** | 1759 /** |
1730 * Returns an array containing the indices of the properties the | 1760 * Returns an array containing the indices of the properties the |
1731 * indexed property getter intercepts. | 1761 * indexed property getter intercepts. |
1732 */ | 1762 */ |
1733 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info); | 1763 typedef Handle<Array> (*IndexedPropertyEnumerator)(const AccessorInfo& info); |
1734 | 1764 |
1735 | 1765 |
1736 /** | 1766 /** |
1737 * Access control specifications. | |
1738 * | |
1739 * Some accessors should be accessible across contexts. These | |
1740 * accessors have an explicit access control parameter which specifies | |
1741 * the kind of cross-context access that should be allowed. | |
1742 * | |
1743 * Additionally, for security, accessors can prohibit overwriting by | |
1744 * accessors defined in JavaScript. For objects that have such | |
1745 * accessors either locally or in their prototype chain it is not | |
1746 * possible to overwrite the accessor by using __defineGetter__ or | |
1747 * __defineSetter__ from JavaScript code. | |
1748 */ | |
1749 enum AccessControl { | |
1750 DEFAULT = 0, | |
1751 ALL_CAN_READ = 1, | |
1752 ALL_CAN_WRITE = 1 << 1, | |
1753 PROHIBITS_OVERWRITING = 1 << 2 | |
1754 }; | |
1755 | |
1756 | |
1757 /** | |
1758 * Access type specification. | 1767 * Access type specification. |
1759 */ | 1768 */ |
1760 enum AccessType { | 1769 enum AccessType { |
1761 ACCESS_GET, | 1770 ACCESS_GET, |
1762 ACCESS_SET, | 1771 ACCESS_SET, |
1763 ACCESS_HAS, | 1772 ACCESS_HAS, |
1764 ACCESS_DELETE, | 1773 ACCESS_DELETE, |
1765 ACCESS_KEYS | 1774 ACCESS_KEYS |
1766 }; | 1775 }; |
1767 | 1776 |
(...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3508 | 3517 |
3509 } // namespace v8 | 3518 } // namespace v8 |
3510 | 3519 |
3511 | 3520 |
3512 #undef V8EXPORT | 3521 #undef V8EXPORT |
3513 #undef V8EXPORT_INLINE | 3522 #undef V8EXPORT_INLINE |
3514 #undef TYPE_CHECK | 3523 #undef TYPE_CHECK |
3515 | 3524 |
3516 | 3525 |
3517 #endif // V8_H_ | 3526 #endif // V8_H_ |
OLD | NEW |