あなたは正しいです。それはクラスのstatic
メソッドNew
を呼び出すことです。String
C ++(またはSTL)にはネイティブクラスString
がなく、クラスはありますが、メソッドはありません。正しいドキュメントを読んでいることを確認する必要があります:)string
::New
String
基本クラスから継承されている可能性があるため、が継承階層の一部であるかどうかを確認してください。
これがv8の文字列の扱いです。それは面白い。
2つの実装があります。
内部文字列ソースコードのString
参照は、実際にはJavascript文字列を表すヒープ割り当てオブジェクトです。
Google CodeのUIが壊れていることがわかりました(おそらく最大文字数がありますか?)。v8 :: internal :: HeapObjectソースコードはにあるはずsrc/objects.h
ですが、ファイルは切り捨てられます。また、外部から見えるv8 :: Stringソースコードはにあるはずですがinclude/v8.h
、それも切り捨てられています。
ソースをダウンロードしてファイルを表示できます。これがそれが言うことです:
/**
* A JavaScript string value (ECMA-262, 4.3.17).
*/
class V8EXPORT String : public Primitive {
public:
...
/**
* Allocates a new string from either utf-8 encoded or ascii data.
* The second parameter 'length' gives the buffer length.
* If the data is utf-8 encoded, the caller must
* be careful to supply the length parameter.
* If it is not given, the function calls
* 'strlen' to determine the buffer length, it might be
* wrong if 'data' contains a null character.
*/
static Local<String> New(const char* data, int length = -1);
/** Allocates a new string from utf16 data.*/
static Local<String> New(const uint16_t* data, int length = -1);
...
};