Add Dictionary::CreateEmpty

This commit is contained in:
Cheng Zhao 2015-08-12 21:18:59 +08:00
parent 67d9eaa215
commit b6c353ee80
2 changed files with 6 additions and 0 deletions

View file

@ -19,6 +19,10 @@ Dictionary::Dictionary(v8::Isolate* isolate,
Dictionary::~Dictionary() { Dictionary::~Dictionary() {
} }
Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
return Dictionary(isolate, v8::Object::New(isolate));;
}
v8::Local<v8::Object> Dictionary::GetHandle() const { v8::Local<v8::Object> Dictionary::GetHandle() const {
return object_; return object_;
} }

View file

@ -28,6 +28,8 @@ class Dictionary {
Dictionary(v8::Isolate* isolate, v8::Local<v8::Object> object); Dictionary(v8::Isolate* isolate, v8::Local<v8::Object> object);
~Dictionary(); ~Dictionary();
static Dictionary CreateEmpty(v8::Isolate* isolate);
template<typename T> template<typename T>
bool Get(const base::StringPiece& key, T* out) const { bool Get(const base::StringPiece& key, T* out) const {
v8::Local<v8::Value> val = GetHandle()->Get(StringToV8(isolate_, key)); v8::Local<v8::Value> val = GetHandle()->Get(StringToV8(isolate_, key));