blob: 95e00072700cb325e967b266801e60dbe347868c [file] [log] [blame]
[email protected]e87f3122013-11-12 00:41:271// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "gin/dictionary.h"
6
7namespace gin {
8
9Dictionary::Dictionary(v8::Isolate* isolate)
10 : isolate_(isolate) {
11}
12
13Dictionary::Dictionary(v8::Isolate* isolate,
deepak.sfaaa1b62015-04-30 07:30:4814 v8::Local<v8::Object> object)
[email protected]e87f3122013-11-12 00:41:2715 : isolate_(isolate),
16 object_(object) {
17}
18
vmpstr8ed6f862016-02-25 20:25:1419Dictionary::Dictionary(const Dictionary& other) = default;
20
Chris Watkins756035a2017-12-01 03:03:2721Dictionary::~Dictionary() = default;
[email protected]e87f3122013-11-12 00:41:2722
23Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
24 Dictionary dictionary(isolate);
[email protected]91cd4fe2013-11-28 09:31:5825 dictionary.object_ = v8::Object::New(isolate);
[email protected]e87f3122013-11-12 00:41:2726 return dictionary;
27}
28
deepak.sfaaa1b62015-04-30 07:30:4829v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
[email protected]e87f3122013-11-12 00:41:2730 Dictionary val) {
31 return val.object_;
32}
33
[email protected]7618ebbb2013-11-27 03:38:2634bool Converter<Dictionary>::FromV8(v8::Isolate* isolate,
deepak.sfaaa1b62015-04-30 07:30:4835 v8::Local<v8::Value> val,
[email protected]93f9f3602013-11-21 18:38:5136 Dictionary* out) {
[email protected]e87f3122013-11-12 00:41:2737 if (!val->IsObject())
38 return false;
deepak.sfaaa1b62015-04-30 07:30:4839 *out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val));
[email protected]e87f3122013-11-12 00:41:2740 return true;
41}
42
43} // namespace gin