[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 1 | // 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 | |||||
7 | namespace gin { | ||||
8 | |||||
9 | Dictionary::Dictionary(v8::Isolate* isolate) | ||||
10 | : isolate_(isolate) { | ||||
11 | } | ||||
12 | |||||
13 | Dictionary::Dictionary(v8::Isolate* isolate, | ||||
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 14 | v8::Local<v8::Object> object) |
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 15 | : isolate_(isolate), |
16 | object_(object) { | ||||
17 | } | ||||
18 | |||||
vmpstr | 8ed6f86 | 2016-02-25 20:25:14 | [diff] [blame] | 19 | Dictionary::Dictionary(const Dictionary& other) = default; |
20 | |||||
Chris Watkins | 756035a | 2017-12-01 03:03:27 | [diff] [blame] | 21 | Dictionary::~Dictionary() = default; |
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 22 | |
23 | Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) { | ||||
24 | Dictionary dictionary(isolate); | ||||
[email protected] | 91cd4fe | 2013-11-28 09:31:58 | [diff] [blame] | 25 | dictionary.object_ = v8::Object::New(isolate); |
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 26 | return dictionary; |
27 | } | ||||
28 | |||||
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 29 | v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate, |
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 30 | Dictionary val) { |
31 | return val.object_; | ||||
32 | } | ||||
33 | |||||
[email protected] | 7618ebbb | 2013-11-27 03:38:26 | [diff] [blame] | 34 | bool Converter<Dictionary>::FromV8(v8::Isolate* isolate, |
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 35 | v8::Local<v8::Value> val, |
[email protected] | 93f9f360 | 2013-11-21 18:38:51 | [diff] [blame] | 36 | Dictionary* out) { |
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 37 | if (!val->IsObject()) |
38 | return false; | ||||
deepak.s | faaa1b6 | 2015-04-30 07:30:48 | [diff] [blame] | 39 | *out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val)); |
[email protected] | e87f312 | 2013-11-12 00:41:27 | [diff] [blame] | 40 | return true; |
41 | } | ||||
42 | |||||
43 | } // namespace gin |