summaryrefslogtreecommitdiff
path: root/chromium/gin/dictionary.cc
blob: 95e00072700cb325e967b266801e60dbe347868c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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 file.

#include "gin/dictionary.h"

namespace gin {

Dictionary::Dictionary(v8::Isolate* isolate)
    : isolate_(isolate) {
}

Dictionary::Dictionary(v8::Isolate* isolate,
                       v8::Local<v8::Object> object)
    : isolate_(isolate),
      object_(object) {
}

Dictionary::Dictionary(const Dictionary& other) = default;

Dictionary::~Dictionary() = default;

Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
  Dictionary dictionary(isolate);
  dictionary.object_ = v8::Object::New(isolate);
  return dictionary;
}

v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
                                                  Dictionary val) {
  return val.object_;
}

bool Converter<Dictionary>::FromV8(v8::Isolate* isolate,
                                   v8::Local<v8::Value> val,
                                   Dictionary* out) {
  if (!val->IsObject())
    return false;
  *out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val));
  return true;
}

}  // namespace gin