Index: include/v8.h |
diff --git a/include/v8.h b/include/v8.h |
index 8fab761615d322e874a8eaed7b2ee3f7db263ffe..d578414c2b838ac7dd57e8998d8e0a4a8ae3236c 100644 |
--- a/include/v8.h |
+++ b/include/v8.h |
@@ -1296,18 +1296,45 @@ class V8EXPORT String : public Primitive { |
V8_INLINE(static String* Cast(v8::Value* obj)); |
+ // TODO(dcarney): deprecate |
/** |
* Allocates a new string from either UTF-8 encoded or ASCII data. |
* The second parameter 'length' gives the buffer length. If omitted, |
* the function calls 'strlen' to determine the buffer length. |
*/ |
- static Local<String> New(const char* data, int length = -1); |
+ V8_INLINE(static Local<String> New(const char* data, int length = -1)); |
+ // TODO(dcarney): deprecate |
/** Allocates a new string from 16-bit character codes.*/ |
- static Local<String> New(const uint16_t* data, int length = -1); |
+ V8_INLINE(static Local<String> New(const uint16_t* data, int length = -1)); |
+ // TODO(dcarney): deprecate |
/** Creates a symbol. Returns one if it exists already.*/ |
- static Local<String> NewSymbol(const char* data, int length = -1); |
+ V8_INLINE(static Local<String> NewSymbol(const char* data, int length = -1)); |
+ |
+ enum NewStringType { |
+ kNormalString, kInternalizedString, kUndetectableString |
+ }; |
+ |
+ /** Allocates a new string from UTF-8 data.*/ |
+ static Local<String> NewFromUtf8(Isolate* isolate, |
+ const char* data, |
+ NewStringType type = kNormalString, |
+ int length = -1); |
+ |
+ /** Allocates a new string from Latin-1 data.*/ |
+ static Local<String> NewFromOneByte( |
+ Isolate* isolate, |
+ const uint8_t* data, |
+ NewStringType type = kNormalString, |
+ int length = -1); |
+ |
+ /** Allocates a new string from UTF-16 data.*/ |
+ static Local<String> NewFromTwoByte( |
+ Isolate* isolate, |
+ const uint16_t* data, |
+ NewStringType type = kNormalString, |
+ int length = -1); |
/** |
* Creates a new string by concatenating the left and the right strings |
@@ -1362,11 +1389,15 @@ class V8EXPORT String : public Primitive { |
*/ |
bool CanMakeExternal(); |
+ // TODO(dcarney): deprecate |
/** Creates an undetectable string from the supplied ASCII or UTF-8 data.*/ |
- static Local<String> NewUndetectable(const char* data, int length = -1); |
+ V8_INLINE( |
+ static Local<String> NewUndetectable(const char* data, int length = -1)); |
+ // TODO(dcarney): deprecate |
/** Creates an undetectable string from the supplied 16-bit character codes.*/ |
- static Local<String> NewUndetectable(const uint16_t* data, int length = -1); |
+ V8_INLINE(static Local<String> NewUndetectable( |
+ const uint16_t* data, int length = -1)); |
/** |
* Converts an object to a UTF-8-encoded character array. Useful if |
@@ -4739,6 +4770,32 @@ Local<String> String::Empty(Isolate* isolate) { |
} |
+Local<String> String::New(const char* data, int length) { |
+ return NewFromUtf8(Isolate::GetCurrent(), data, kNormalString, length); |
+} |
+ |
+ |
+Local<String> String::New(const uint16_t* data, int length) { |
+ return NewFromTwoByte(Isolate::GetCurrent(), data, kNormalString, length); |
+} |
+ |
+ |
+Local<String> String::NewSymbol(const char* data, int length) { |
+ return NewFromUtf8(Isolate::GetCurrent(), data, kInternalizedString, length); |
+} |
+ |
+ |
+Local<String> String::NewUndetectable(const char* data, int length) { |
+ return NewFromUtf8(Isolate::GetCurrent(), data, kUndetectableString, length); |
+} |
+ |
+ |
+Local<String> String::NewUndetectable(const uint16_t* data, int length) { |
+ return NewFromTwoByte( |
+ Isolate::GetCurrent(), data, kUndetectableString, length); |
+} |
+ |
+ |
String::ExternalStringResource* String::GetExternalStringResource() const { |
typedef internal::Object O; |
typedef internal::Internals I; |