| Index: include/v8.h
|
| diff --git a/include/v8.h b/include/v8.h
|
| index 9adb1c041cf20bd2ed12d7a04dfe07c53cd1712b..d0c4f5409c3503b1c02f58e97fb8fc38f8c2d3df 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(Isolate* isolate);
|
| +
|
| + // Create a symbol with a print name.
|
| + static Local<Symbol> New(Isolate *isolate, const char* data, int length = -1);
|
| +
|
| + 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 {
|
| @@ -1590,11 +1631,9 @@ class V8EXPORT Object : public Value {
|
| */
|
| PropertyAttribute GetPropertyAttributes(Handle<Value> key);
|
|
|
| - // TODO(1245389): Replace the type-specific versions of these
|
| - // 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 +2021,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(Isolate* isolate, Handle<Symbol> value);
|
| +
|
| + /**
|
| + * 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 +4907,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 +4947,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);
|
|
|