1.如何將js的字符串轉化為C++的字符串
const char* ToCString(const String::Utf8Value& value)
{
return *value ? *value: "string conversion failed";
}
Handle<Value>Open(const Arguments&args)
{
HandleScope scope;
String::Utf8Value str(args[0]);//
const char * pstr = ToCString(str);
Handle<Boolean>b = Boolean::New(bRet);
return scope.Close(b);
}
2.基本類型
int i;
Handle<Number> num = Number::New(i)
bool b;
Handle<Boolean>b = Boolean::New(bRet);
//數組
Handle<Array> array =Array::New(10);
Local<Object> obj = Object::New();//對象
obj->Set(String::NewSymbol("hello"),String::New("World"));
array->Set(0,obj);