electron/native_mate/persistent_dictionary.cc

35 lines
1,014 B
C++
Raw Normal View History

2014-09-09 06:12:59 +00:00
// Copyright 2014 Cheng Zhao. All rights reserved.
// Use of this source code is governed by MIT license that can be found in the
// LICENSE file.
#include "native_mate/persistent_dictionary.h"
namespace mate {
PersistentDictionary::PersistentDictionary() {
}
PersistentDictionary::PersistentDictionary(v8::Isolate* isolate,
2015-05-22 11:11:02 +00:00
v8::Local<v8::Object> object)
2014-09-09 06:12:59 +00:00
: handle_(new RefCountedPersistent<v8::Object>(isolate, object)) {
isolate_ = isolate;
}
PersistentDictionary::~PersistentDictionary() {
}
2015-05-22 11:11:02 +00:00
v8::Local<v8::Object> PersistentDictionary::GetHandle() const {
2014-09-09 06:12:59 +00:00
return handle_->NewHandle();
}
bool Converter<PersistentDictionary>::FromV8(v8::Isolate* isolate,
2015-05-22 11:11:02 +00:00
v8::Local<v8::Value> val,
2014-09-09 06:12:59 +00:00
PersistentDictionary* out) {
if (!val->IsObject())
return false;
2015-05-22 11:11:02 +00:00
*out = PersistentDictionary(isolate, v8::Local<v8::Object>::Cast(val));
2014-09-09 06:12:59 +00:00
return true;
}
} // namespace mate