dictionary.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include "gin/dictionary.h"
  5. namespace gin {
  6. Dictionary::Dictionary(v8::Isolate* isolate)
  7. : isolate_(isolate) {
  8. }
  9. Dictionary::Dictionary(v8::Isolate* isolate,
  10. v8::Local<v8::Object> object)
  11. : isolate_(isolate),
  12. object_(object) {
  13. }
  14. Dictionary::Dictionary(const Dictionary& other) = default;
  15. Dictionary::~Dictionary() = default;
  16. Dictionary Dictionary::CreateEmpty(v8::Isolate* isolate) {
  17. Dictionary dictionary(isolate);
  18. dictionary.object_ = v8::Object::New(isolate);
  19. return dictionary;
  20. }
  21. v8::Local<v8::Value> Converter<Dictionary>::ToV8(v8::Isolate* isolate,
  22. Dictionary val) {
  23. return val.object_;
  24. }
  25. bool Converter<Dictionary>::FromV8(v8::Isolate* isolate,
  26. v8::Local<v8::Value> val,
  27. Dictionary* out) {
  28. if (!val->IsObject())
  29. return false;
  30. *out = Dictionary(isolate, v8::Local<v8::Object>::Cast(val));
  31. return true;
  32. }
  33. } // namespace gin