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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 class Object; | 120 class Object; |
| 121 class ObjectOperationDescriptor; | 121 class ObjectOperationDescriptor; |
| 122 class ObjectTemplate; | 122 class ObjectTemplate; |
| 123 class Primitive; | 123 class Primitive; |
| 124 class RawOperationDescriptor; | 124 class RawOperationDescriptor; |
| 125 class Signature; | 125 class Signature; |
| 126 class StackFrame; | 126 class StackFrame; |
| 127 class StackTrace; | 127 class StackTrace; |
| 128 class String; | 128 class String; |
| 129 class StringObject; | 129 class StringObject; |
| 130 class Symbol; | |
| 131 class SymbolObject; | |
| 130 class Uint32; | 132 class Uint32; |
| 131 class Utils; | 133 class Utils; |
| 132 class Value; | 134 class Value; |
| 133 template <class T> class Handle; | 135 template <class T> class Handle; |
| 134 template <class T> class Local; | 136 template <class T> class Local; |
| 135 template <class T> class Persistent; | 137 template <class T> class Persistent; |
| 136 | 138 |
| 137 namespace internal { | 139 namespace internal { |
| 138 class Arguments; | 140 class Arguments; |
| 139 class Heap; | 141 class Heap; |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 */ | 968 */ |
| 967 bool IsFalse() const; | 969 bool IsFalse() const; |
| 968 | 970 |
| 969 /** | 971 /** |
| 970 * Returns true if this value is an instance of the String type. | 972 * Returns true if this value is an instance of the String type. |
| 971 * See ECMA-262 8.4. | 973 * See ECMA-262 8.4. |
| 972 */ | 974 */ |
| 973 V8_INLINE(bool IsString() const); | 975 V8_INLINE(bool IsString() const); |
| 974 | 976 |
| 975 /** | 977 /** |
| 978 * Returns true if this value is a symbol. | |
| 979 * This is an experimental feature. | |
| 980 */ | |
| 981 bool IsSymbol() const; | |
| 982 | |
| 983 /** | |
| 976 * Returns true if this value is a function. | 984 * Returns true if this value is a function. |
| 977 */ | 985 */ |
| 978 bool IsFunction() const; | 986 bool IsFunction() const; |
| 979 | 987 |
| 980 /** | 988 /** |
| 981 * Returns true if this value is an array. | 989 * Returns true if this value is an array. |
| 982 */ | 990 */ |
| 983 bool IsArray() const; | 991 bool IsArray() const; |
| 984 | 992 |
| 985 /** | 993 /** |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 * Returns true if this value is a Number object. | 1034 * Returns true if this value is a Number object. |
| 1027 */ | 1035 */ |
| 1028 bool IsNumberObject() const; | 1036 bool IsNumberObject() const; |
| 1029 | 1037 |
| 1030 /** | 1038 /** |
| 1031 * Returns true if this value is a String object. | 1039 * Returns true if this value is a String object. |
| 1032 */ | 1040 */ |
| 1033 bool IsStringObject() const; | 1041 bool IsStringObject() const; |
| 1034 | 1042 |
| 1035 /** | 1043 /** |
| 1044 * Returns true if this value is a Symbol object. | |
| 1045 * This is an experimental feature. | |
| 1046 */ | |
| 1047 bool IsSymbolObject() const; | |
| 1048 | |
| 1049 /** | |
| 1036 * Returns true if this value is a NativeError. | 1050 * Returns true if this value is a NativeError. |
| 1037 */ | 1051 */ |
| 1038 bool IsNativeError() const; | 1052 bool IsNativeError() const; |
| 1039 | 1053 |
| 1040 /** | 1054 /** |
| 1041 * Returns true if this value is a RegExp. | 1055 * Returns true if this value is a RegExp. |
| 1042 */ | 1056 */ |
| 1043 bool IsRegExp() const; | 1057 bool IsRegExp() const; |
| 1044 | 1058 |
| 1045 Local<Boolean> ToBoolean() const; | 1059 Local<Boolean> ToBoolean() const; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 /** | 1318 /** |
| 1305 * Allocates a new string from either UTF-8 encoded or ASCII data. | 1319 * Allocates a new string from either UTF-8 encoded or ASCII data. |
| 1306 * The second parameter 'length' gives the buffer length. If omitted, | 1320 * The second parameter 'length' gives the buffer length. If omitted, |
| 1307 * the function calls 'strlen' to determine the buffer length. | 1321 * the function calls 'strlen' to determine the buffer length. |
| 1308 */ | 1322 */ |
| 1309 static Local<String> New(const char* data, int length = -1); | 1323 static Local<String> New(const char* data, int length = -1); |
| 1310 | 1324 |
| 1311 /** Allocates a new string from 16-bit character codes.*/ | 1325 /** Allocates a new string from 16-bit character codes.*/ |
| 1312 static Local<String> New(const uint16_t* data, int length = -1); | 1326 static Local<String> New(const uint16_t* data, int length = -1); |
| 1313 | 1327 |
| 1314 /** Creates a symbol. Returns one if it exists already.*/ | 1328 /** |
| 1329 * Creates an internalized string (historically called a "symbol", | |
| 1330 * not to be confused with ES6 symbols). Returns one if it exists already. | |
| 1331 * TODO(rossberg): Deprecate me when the new string API is here. | |
| 1332 */ | |
| 1315 static Local<String> NewSymbol(const char* data, int length = -1); | 1333 static Local<String> NewSymbol(const char* data, int length = -1); |
| 1316 | 1334 |
| 1317 /** | 1335 /** |
| 1318 * Creates a new string by concatenating the left and the right strings | 1336 * Creates a new string by concatenating the left and the right strings |
| 1319 * passed in as parameters. | 1337 * passed in as parameters. |
| 1320 */ | 1338 */ |
| 1321 static Local<String> Concat(Handle<String> left, Handle<String> right); | 1339 static Local<String> Concat(Handle<String> left, Handle<String> right); |
| 1322 | 1340 |
| 1323 /** | 1341 /** |
| 1324 * Creates a new external string using the data defined in the given | 1342 * Creates a new external string using the data defined in the given |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1443 | 1461 |
| 1444 private: | 1462 private: |
| 1445 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, | 1463 void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, |
| 1446 Encoding encoding) const; | 1464 Encoding encoding) const; |
| 1447 void VerifyExternalStringResource(ExternalStringResource* val) const; | 1465 void VerifyExternalStringResource(ExternalStringResource* val) const; |
| 1448 static void CheckCast(v8::Value* obj); | 1466 static void CheckCast(v8::Value* obj); |
| 1449 }; | 1467 }; |
| 1450 | 1468 |
| 1451 | 1469 |
| 1452 /** | 1470 /** |
| 1471 * A JavaScript symbol (ECMA-262 edition 6) | |
| 1472 * | |
| 1473 * This is an experimental feature. Use at your own risk. | |
| 1474 */ | |
| 1475 class V8EXPORT Symbol : public Primitive { | |
| 1476 public: | |
| 1477 // Returns the print name string of the symbol, or undefined if none. | |
| 1478 Local<Value> Name() const; | |
| 1479 | |
| 1480 // Create a symbol without a print name. | |
| 1481 static Local<Symbol> New(); | |
|
Sven Panne
2013/04/08 14:04:51
Add an Isolate* parameter.
rossberg
2013/04/09 08:55:24
Done.
| |
| 1482 | |
| 1483 // Create a symbol with a print name. | |
| 1484 static Local<Symbol> New(const char* data, int length = -1); | |
|
Sven Panne
2013/04/08 14:04:51
Add an Isolate* parameter.
rossberg
2013/04/09 08:55:24
Done.
| |
| 1485 | |
| 1486 V8_INLINE(static Symbol* Cast(v8::Value* obj)); | |
| 1487 private: | |
| 1488 Symbol(); | |
| 1489 static void CheckCast(v8::Value* obj); | |
| 1490 }; | |
| 1491 | |
| 1492 | |
| 1493 /** | |
| 1453 * A JavaScript number value (ECMA-262, 4.3.20) | 1494 * A JavaScript number value (ECMA-262, 4.3.20) |
| 1454 */ | 1495 */ |
| 1455 class V8EXPORT Number : public Primitive { | 1496 class V8EXPORT Number : public Primitive { |
| 1456 public: | 1497 public: |
| 1457 double Value() const; | 1498 double Value() const; |
| 1458 static Local<Number> New(double value); | 1499 static Local<Number> New(double value); |
| 1459 V8_INLINE(static Number* Cast(v8::Value* obj)); | 1500 V8_INLINE(static Number* Cast(v8::Value* obj)); |
| 1460 private: | 1501 private: |
| 1461 Number(); | 1502 Number(); |
| 1462 static void CheckCast(v8::Value* obj); | 1503 static void CheckCast(v8::Value* obj); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1583 | 1624 |
| 1584 Local<Value> Get(uint32_t index); | 1625 Local<Value> Get(uint32_t index); |
| 1585 | 1626 |
| 1586 /** | 1627 /** |
| 1587 * Gets the property attributes of a property which can be None or | 1628 * Gets the property attributes of a property which can be None or |
| 1588 * any combination of ReadOnly, DontEnum and DontDelete. Returns | 1629 * any combination of ReadOnly, DontEnum and DontDelete. Returns |
| 1589 * None when the property doesn't exist. | 1630 * None when the property doesn't exist. |
| 1590 */ | 1631 */ |
| 1591 PropertyAttribute GetPropertyAttributes(Handle<Value> key); | 1632 PropertyAttribute GetPropertyAttributes(Handle<Value> key); |
| 1592 | 1633 |
| 1593 // TODO(1245389): Replace the type-specific versions of these | 1634 // TODO(1245389): Replace the type-specific versions of these |
|
Sven Panne
2013/04/08 14:04:51
Does this TODO still make sense?
rossberg
2013/04/09 08:55:24
No, deleted.
| |
| 1594 // functions with generic ones that accept a Handle<Value> key. | 1635 // functions with generic ones that accept a Handle<Value> key. |
| 1595 bool Has(Handle<String> key); | 1636 bool Has(Handle<Value> key); |
| 1596 | 1637 |
| 1597 bool Delete(Handle<String> key); | 1638 bool Delete(Handle<Value> key); |
| 1598 | 1639 |
| 1599 // Delete a property on this object bypassing interceptors and | 1640 // Delete a property on this object bypassing interceptors and |
| 1600 // ignoring dont-delete attributes. | 1641 // ignoring dont-delete attributes. |
| 1601 bool ForceDelete(Handle<Value> key); | 1642 bool ForceDelete(Handle<Value> key); |
| 1602 | 1643 |
| 1603 bool Has(uint32_t index); | 1644 bool Has(uint32_t index); |
| 1604 | 1645 |
| 1605 bool Delete(uint32_t index); | 1646 bool Delete(uint32_t index); |
| 1606 | 1647 |
| 1607 bool SetAccessor(Handle<String> name, | 1648 bool SetAccessor(Handle<String> name, |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1975 Local<String> StringValue() const; | 2016 Local<String> StringValue() const; |
| 1976 | 2017 |
| 1977 V8_INLINE(static StringObject* Cast(v8::Value* obj)); | 2018 V8_INLINE(static StringObject* Cast(v8::Value* obj)); |
| 1978 | 2019 |
| 1979 private: | 2020 private: |
| 1980 static void CheckCast(v8::Value* obj); | 2021 static void CheckCast(v8::Value* obj); |
| 1981 }; | 2022 }; |
| 1982 | 2023 |
| 1983 | 2024 |
| 1984 /** | 2025 /** |
| 2026 * A Symbol object (ECMA-262 edition 6). | |
| 2027 * | |
| 2028 * This is an experimental feature. Use at your own risk. | |
| 2029 */ | |
| 2030 class V8EXPORT SymbolObject : public Object { | |
| 2031 public: | |
| 2032 static Local<Value> New(Handle<Symbol> value); | |
|
Sven Panne
2013/04/08 14:04:51
Add an Isolate* parameter.
rossberg
2013/04/09 08:55:24
Done.
| |
| 2033 | |
| 2034 /** | |
| 2035 * Returns the Symbol held by the object. | |
| 2036 */ | |
| 2037 Local<Symbol> SymbolValue() const; | |
| 2038 | |
| 2039 V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); | |
| 2040 | |
| 2041 private: | |
| 2042 static void CheckCast(v8::Value* obj); | |
| 2043 }; | |
| 2044 | |
| 2045 | |
| 2046 /** | |
| 1985 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). | 2047 * An instance of the built-in RegExp constructor (ECMA-262, 15.10). |
| 1986 */ | 2048 */ |
| 1987 class V8EXPORT RegExp : public Object { | 2049 class V8EXPORT RegExp : public Object { |
| 1988 public: | 2050 public: |
| 1989 /** | 2051 /** |
| 1990 * Regular expression flag bits. They can be or'ed to enable a set | 2052 * Regular expression flag bits. They can be or'ed to enable a set |
| 1991 * of flags. | 2053 * of flags. |
| 1992 */ | 2054 */ |
| 1993 enum Flags { | 2055 enum Flags { |
| 1994 kNone = 0, | 2056 kNone = 0, |
| (...skipping 2845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4840 | 4902 |
| 4841 bool Value::QuickIsString() const { | 4903 bool Value::QuickIsString() const { |
| 4842 typedef internal::Object O; | 4904 typedef internal::Object O; |
| 4843 typedef internal::Internals I; | 4905 typedef internal::Internals I; |
| 4844 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); | 4906 O* obj = *reinterpret_cast<O**>(const_cast<Value*>(this)); |
| 4845 if (!I::HasHeapObjectTag(obj)) return false; | 4907 if (!I::HasHeapObjectTag(obj)) return false; |
| 4846 return (I::GetInstanceType(obj) < I::kFirstNonstringType); | 4908 return (I::GetInstanceType(obj) < I::kFirstNonstringType); |
| 4847 } | 4909 } |
| 4848 | 4910 |
| 4849 | 4911 |
| 4912 Symbol* Symbol::Cast(v8::Value* value) { | |
| 4913 #ifdef V8_ENABLE_CHECKS | |
| 4914 CheckCast(value); | |
| 4915 #endif | |
| 4916 return static_cast<Symbol*>(value); | |
| 4917 } | |
| 4918 | |
| 4919 | |
| 4850 Number* Number::Cast(v8::Value* value) { | 4920 Number* Number::Cast(v8::Value* value) { |
| 4851 #ifdef V8_ENABLE_CHECKS | 4921 #ifdef V8_ENABLE_CHECKS |
| 4852 CheckCast(value); | 4922 CheckCast(value); |
| 4853 #endif | 4923 #endif |
| 4854 return static_cast<Number*>(value); | 4924 return static_cast<Number*>(value); |
| 4855 } | 4925 } |
| 4856 | 4926 |
| 4857 | 4927 |
| 4858 Integer* Integer::Cast(v8::Value* value) { | 4928 Integer* Integer::Cast(v8::Value* value) { |
| 4859 #ifdef V8_ENABLE_CHECKS | 4929 #ifdef V8_ENABLE_CHECKS |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 4872 | 4942 |
| 4873 | 4943 |
| 4874 StringObject* StringObject::Cast(v8::Value* value) { | 4944 StringObject* StringObject::Cast(v8::Value* value) { |
| 4875 #ifdef V8_ENABLE_CHECKS | 4945 #ifdef V8_ENABLE_CHECKS |
| 4876 CheckCast(value); | 4946 CheckCast(value); |
| 4877 #endif | 4947 #endif |
| 4878 return static_cast<StringObject*>(value); | 4948 return static_cast<StringObject*>(value); |
| 4879 } | 4949 } |
| 4880 | 4950 |
| 4881 | 4951 |
| 4952 SymbolObject* SymbolObject::Cast(v8::Value* value) { | |
| 4953 #ifdef V8_ENABLE_CHECKS | |
| 4954 CheckCast(value); | |
| 4955 #endif | |
| 4956 return static_cast<SymbolObject*>(value); | |
| 4957 } | |
| 4958 | |
| 4959 | |
| 4882 NumberObject* NumberObject::Cast(v8::Value* value) { | 4960 NumberObject* NumberObject::Cast(v8::Value* value) { |
| 4883 #ifdef V8_ENABLE_CHECKS | 4961 #ifdef V8_ENABLE_CHECKS |
| 4884 CheckCast(value); | 4962 CheckCast(value); |
| 4885 #endif | 4963 #endif |
| 4886 return static_cast<NumberObject*>(value); | 4964 return static_cast<NumberObject*>(value); |
| 4887 } | 4965 } |
| 4888 | 4966 |
| 4889 | 4967 |
| 4890 BooleanObject* BooleanObject::Cast(v8::Value* value) { | 4968 BooleanObject* BooleanObject::Cast(v8::Value* value) { |
| 4891 #ifdef V8_ENABLE_CHECKS | 4969 #ifdef V8_ENABLE_CHECKS |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5038 | 5116 |
| 5039 | 5117 |
| 5040 } // namespace v8 | 5118 } // namespace v8 |
| 5041 | 5119 |
| 5042 | 5120 |
| 5043 #undef V8EXPORT | 5121 #undef V8EXPORT |
| 5044 #undef TYPE_CHECK | 5122 #undef TYPE_CHECK |
| 5045 | 5123 |
| 5046 | 5124 |
| 5047 #endif // V8_H_ | 5125 #endif // V8_H_ |
| OLD | NEW |