Add converter for const char*.

This commit is contained in:
Cheng Zhao 2014-06-23 21:24:18 +08:00
parent 730acd59c7
commit 1884b9a235
2 changed files with 10 additions and 0 deletions

View file

@ -103,6 +103,11 @@ bool Converter<double>::FromV8(Isolate* isolate, Handle<Value> val,
return true; return true;
} }
Handle<Value> Converter<const char*>::ToV8(
Isolate* isolate, const char* val) {
return MATE_STRING_NEW_FROM_UTF8(isolate, val, -1);
}
Handle<Value> Converter<base::StringPiece>::ToV8( Handle<Value> Converter<base::StringPiece>::ToV8(
Isolate* isolate, const base::StringPiece& val) { Isolate* isolate, const base::StringPiece& val) {
return MATE_STRING_NEW_FROM_UTF8(isolate, val.data(), return MATE_STRING_NEW_FROM_UTF8(isolate, val.data(),

View file

@ -88,6 +88,11 @@ struct Converter<double> {
double* out); double* out);
}; };
template<>
struct Converter<const char*> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, const char* val);
};
template<> template<>
struct Converter<base::StringPiece> { struct Converter<base::StringPiece> {
static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate, static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,