Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: gin/dictionary.h

Issue 59153005: Begin implementing V8 bindings for Mojo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix skipped comment Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 #ifndef GIN_DICTIONARY_H_
6 #define GIN_DICTIONARY_H_
7
8 #include "gin/converter.h"
9
10 namespace gin {
11
12 class Dictionary {
13 public:
14 explicit Dictionary(v8::Isolate* isolate);
15 Dictionary(v8::Isolate* isolate, v8::Handle<v8::Object> object);
16 ~Dictionary();
17
18 static Dictionary CreateEmpty(v8::Isolate* isolate);
19
20 template<typename T>
21 bool Get(const std::string& key, T* out) {
22 v8::Handle<v8::Value> val = object_->Get(StringToV8(isolate_, key));
23 return ConvertFromV8(val, out);
24 }
25
26 template<typename T>
27 bool Set(const std::string& key, T val) {
28 return object_->Set(StringToV8(isolate_, key), ConvertToV8(isolate_, val));
29 }
30
31 v8::Isolate* isolate() const { return isolate_; }
32
33 private:
34 friend struct Converter<Dictionary>;
35
36 v8::Isolate* isolate_;
37 v8::Handle<v8::Object> object_;
38 };
39
40 template<>
41 struct Converter<Dictionary> {
42 static v8::Handle<v8::Value> ToV8(v8::Isolate* isolate,
43 Dictionary val);
44 static bool FromV8(v8::Handle<v8::Value> val,
45 Dictionary* out);
46 };
47
48 } // namespace gin
49
50 #endif // GIN_DICTIONARY_H_
OLDNEW
« gin/arguments.cc ('K') | « gin/converter.cc ('k') | gin/dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698