electron/native_mate/mate/dictionary.cc

45 lines
1.1 KiB
C++
Raw Normal View History

2014-04-15 11:04:36 +08:00
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE.chromium file.
#include "native_mate/dictionary.h"
namespace mate {
Dictionary::Dictionary()
: isolate_(NULL) {
2014-04-15 11:04:36 +08:00
}
Dictionary::Dictionary(v8::Isolate* isolate,
2015-05-22 19:11:02 +08:00
v8::Local<v8::Object> object)
2014-04-15 11:04:36 +08:00
: isolate_(isolate),
object_(object) {
}
Dictionary::~Dictionary() {
}
2015-08-12 21:18:59 +08:00
Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
2018-03-28 11:32:10 +11:00
return Dictionary(isolate, v8::Object::New(isolate));
2015-08-12 21:18:59 +08:00
}
2015-05-22 19:11:02 +08:00
v8::Local<v8::Object> Dictionary::GetHandle() const {
2014-09-09 14:12:59 +08:00
return object_;
}
2015-05-22 19:11:02 +08:00
v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
2014-04-15 11:04:36 +08:00
Dictionary val) {
2014-09-09 14:12:59 +08:00
return val.GetHandle();
2014-04-15 11:04:36 +08:00
}
bool Converter<Dictionary>::FromV8(v8::Isolate* isolate,
2015-05-22 19:11:02 +08:00
v8::Local<v8::Value> val,
2014-04-15 11:04:36 +08:00
Dictionary* out) {
2015-08-12 21:31:45 +08:00
if (!val->IsObject() || val->IsFunction())
2014-04-15 11:04:36 +08:00
return false;
2015-05-22 19:11:02 +08:00
*out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val));
2014-04-15 11:04:36 +08:00
return true;
}
} // namespace mate