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

Unified Diff: Source/bindings/templates/dictionary_v8.cpp

Issue 386963003: [WIP][NotForLand] IDL dictionary support (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: sequence and array support Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/templates/dictionary_v8.h ('k') | Source/bindings/templates/templates.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/dictionary_v8.cpp
diff --git a/Source/bindings/templates/dictionary_v8.cpp b/Source/bindings/templates/dictionary_v8.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c49b1ce5bf6e385b9a26c534e99af4f65a6cccec
--- /dev/null
+++ b/Source/bindings/templates/dictionary_v8.cpp
@@ -0,0 +1,48 @@
+// Copyright 2014 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.
+
+// This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
+
+#include "config.h"
+#include "{{v8_class}}.h"
+
+{% for filename in cpp_includes if filename != '%s.h' % v8_class %}
+#include "{{filename}}"
+{% endfor %}
+
+namespace blink {
+
+{{cpp_class}}* {{v8_class}}::toNative(v8::Isolate* isolate, v8::Handle<v8::Value> v8Value)
+{
+ {{cpp_class}}* impl = {{cpp_class}}::create();
+ // FIXME: Do not use Dictionary and DictionaryHelper
+ // https://crbug.com/321462
+ Dictionary dictionary(v8Value, isolate);
+ {% for member in members %}
+ {{member.cpp_type}} {{member.name}};
+ if (DictionaryHelper::get(dictionary, "{{member.name}}", {{member.name}}))
+ impl->{{member.setter_name}}({{member.name}});
+ {% if member.default_value %}
+ else
+ impl->{{member.setter_name}}({{member.default_value}});
+ {% endif %}
+ {% endfor %}
+ return impl;
+}
+
+v8::Handle<v8::Value> toV8({{cpp_class}}* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
+{
+ v8::Handle<v8::Object> v8Object = v8::Object::New(isolate);
+ {% for member in members %}
+ if (impl->{{member.has_name}}())
+ v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.cpp_value_to_v8_value}});
+ {% if member.v8_default_value %}
+ else
+ v8Object->Set(v8String(isolate, "{{member.name}}"), {{member.v8_default_value}});
+ {% endif %}
+ {% endfor %}
+ return v8Object;
+}
+
+} // namespace blink
« no previous file with comments | « Source/bindings/templates/dictionary_v8.h ('k') | Source/bindings/templates/templates.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698