Chromium Code Reviews| Index: include/v8.h |
| diff --git a/include/v8.h b/include/v8.h |
| index 9adb1c041cf20bd2ed12d7a04dfe07c53cd1712b..708ff6ef06f3b3c7564c4889cda105d722078bef 100644 |
| --- a/include/v8.h |
| +++ b/include/v8.h |
| @@ -127,6 +127,8 @@ class StackFrame; |
| class StackTrace; |
| class String; |
| class StringObject; |
| +class Symbol; |
| +class SymbolObject; |
| class Uint32; |
| class Utils; |
| class Value; |
| @@ -973,6 +975,12 @@ class V8EXPORT Value : public Data { |
| V8_INLINE(bool IsString() const); |
| /** |
| + * Returns true if this value is a symbol. |
| + * This is an experimental feature. |
| + */ |
| + bool IsSymbol() const; |
| + |
| + /** |
| * Returns true if this value is a function. |
| */ |
| bool IsFunction() const; |
| @@ -1033,6 +1041,12 @@ class V8EXPORT Value : public Data { |
| bool IsStringObject() const; |
| /** |
| + * Returns true if this value is a Symbol object. |
| + * This is an experimental feature. |
| + */ |
| + bool IsSymbolObject() const; |
| + |
| + /** |
| * Returns true if this value is a NativeError. |
| */ |
| bool IsNativeError() const; |
| @@ -1311,7 +1325,11 @@ class V8EXPORT String : public Primitive { |
| /** Allocates a new string from 16-bit character codes.*/ |
| static Local<String> New(const uint16_t* data, int length = -1); |
| - /** Creates a symbol. Returns one if it exists already.*/ |
| + /** |
| + * Creates an internalized string (historically called a "symbol", |
| + * not to be confused with ES6 symbols). Returns one if it exists already. |
| + * TODO(rossberg): Deprecate me when the new string API is here. |
| + */ |
| static Local<String> NewSymbol(const char* data, int length = -1); |
| /** |
| @@ -1450,6 +1468,29 @@ class V8EXPORT String : public Primitive { |
| /** |
| + * A JavaScript symbol (ECMA-262 edition 6) |
| + * |
| + * This is an experimental feature. Use at your own risk. |
| + */ |
| +class V8EXPORT Symbol : public Primitive { |
| + public: |
| + // Returns the print name string of the symbol, or undefined if none. |
| + Local<Value> Name() const; |
| + |
| + // Create a symbol without a print name. |
| + static Local<Symbol> New(); |
|
Sven Panne
2013/04/08 14:04:51
Add an Isolate* parameter.
rossberg
2013/04/09 08:55:24
Done.
|
| + |
| + // Create a symbol with a print name. |
| + 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.
|
| + |
| + V8_INLINE(static Symbol* Cast(v8::Value* obj)); |
| + private: |
| + Symbol(); |
| + static void CheckCast(v8::Value* obj); |
| +}; |
| + |
| + |
| +/** |
| * A JavaScript number value (ECMA-262, 4.3.20) |
| */ |
| class V8EXPORT Number : public Primitive { |
| @@ -1592,9 +1633,9 @@ class V8EXPORT Object : public Value { |
| // 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.
|
| // functions with generic ones that accept a Handle<Value> key. |
| - bool Has(Handle<String> key); |
| + bool Has(Handle<Value> key); |
| - bool Delete(Handle<String> key); |
| + bool Delete(Handle<Value> key); |
| // Delete a property on this object bypassing interceptors and |
| // ignoring dont-delete attributes. |
| @@ -1982,6 +2023,27 @@ class V8EXPORT StringObject : public Object { |
| /** |
| + * A Symbol object (ECMA-262 edition 6). |
| + * |
| + * This is an experimental feature. Use at your own risk. |
| + */ |
| +class V8EXPORT SymbolObject : public Object { |
| + public: |
| + 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.
|
| + |
| + /** |
| + * Returns the Symbol held by the object. |
| + */ |
| + Local<Symbol> SymbolValue() const; |
| + |
| + V8_INLINE(static SymbolObject* Cast(v8::Value* obj)); |
| + |
| + private: |
| + static void CheckCast(v8::Value* obj); |
| +}; |
| + |
| + |
| +/** |
| * An instance of the built-in RegExp constructor (ECMA-262, 15.10). |
| */ |
| class V8EXPORT RegExp : public Object { |
| @@ -4847,6 +4909,14 @@ bool Value::QuickIsString() const { |
| } |
| +Symbol* Symbol::Cast(v8::Value* value) { |
| +#ifdef V8_ENABLE_CHECKS |
| + CheckCast(value); |
| +#endif |
| + return static_cast<Symbol*>(value); |
| +} |
| + |
| + |
| Number* Number::Cast(v8::Value* value) { |
| #ifdef V8_ENABLE_CHECKS |
| CheckCast(value); |
| @@ -4879,6 +4949,14 @@ StringObject* StringObject::Cast(v8::Value* value) { |
| } |
| +SymbolObject* SymbolObject::Cast(v8::Value* value) { |
| +#ifdef V8_ENABLE_CHECKS |
| + CheckCast(value); |
| +#endif |
| + return static_cast<SymbolObject*>(value); |
| +} |
| + |
| + |
| NumberObject* NumberObject::Cast(v8::Value* value) { |
| #ifdef V8_ENABLE_CHECKS |
| CheckCast(value); |