electron/native_mate/dictionary.cc

45 lines
1.1 KiB
C++
Raw Normal View History

2014-04-15 03:04:36 +00: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 03:04:36 +00:00
}
Dictionary::Dictionary(v8::Isolate* isolate,
2015-05-22 11:11:02 +00:00
v8::Local<v8::Object> object)
2014-04-15 03:04:36 +00:00
: isolate_(isolate),
object_(object) {
}
Dictionary::~Dictionary() {
}
2015-08-12 13:18:59 +00:00
Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
return Dictionary(isolate, v8::Object::New(isolate));;
}
2015-05-22 11:11:02 +00:00
v8::Local<v8::Object> Dictionary::GetHandle() const {
2014-09-09 06:12:59 +00:00
return object_;
}
2015-05-22 11:11:02 +00:00
v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
2014-04-15 03:04:36 +00:00
Dictionary val) {
2014-09-09 06:12:59 +00:00
return val.GetHandle();
2014-04-15 03:04:36 +00:00
}
bool Converter<Dictionary>::FromV8(v8::Isolate* isolate,
2015-05-22 11:11:02 +00:00
v8::Local<v8::Value> val,
2014-04-15 03:04:36 +00:00
Dictionary* out) {
2015-08-12 13:31:45 +00:00
if (!val->IsObject() || val->IsFunction())
2014-04-15 03:04:36 +00:00
return false;
2015-05-22 11:11:02 +00:00
*out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val));
2014-04-15 03:04:36 +00:00
return true;
}
} // namespace mate