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

Unified Diff: Source/bindings/templates/union.h

Issue 680193003: IDL: Generate union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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
Index: Source/bindings/templates/union.h
diff --git a/Source/bindings/templates/union.h b/Source/bindings/templates/union.h
index 77f70e996654ea5757e4f84fbae58d70f43287f3..651b64757916d250b0e8e4f8a12d5b0f1c6512b0 100644
--- a/Source/bindings/templates/union.h
+++ b/Source/bindings/templates/union.h
@@ -7,13 +7,56 @@
#ifndef {{macro_guard}}
#define {{macro_guard}}
+{% for filename in header_includes %}
+#include "{{filename}}"
+{% endfor %}
+
namespace blink {
+{% for decl in header_forward_decls %}
+class {{decl}};
+{% endfor %}
+
{% for container in containers %}
class {{container.cpp_class}} final {
- // FIXME: Implement
+ ALLOW_ONLY_INLINE_ALLOCATION();
sof 2014/10/31 06:48:20 Looks like this doesn't generate a trace() method,
sof 2014/10/31 06:52:23 Just to be clear(er), s/required/required if t
Jens Widell 2014/10/31 07:24:02 https://codereview.chromium.org/689013002/
+public:
+ {{container.cpp_class}}();
+ bool isNull() const { return m_type == SpecificTypeNone; }
+
+ {% for member in container.members %}
+ bool is{{member.type_name}}() const { return m_type == {{member.specific_type_enum}}; }
+ {{member.rvalue_cpp_type}} getAs{{member.type_name}}();
+ void set{{member.type_name}}({{member.rvalue_cpp_type}});
+
+ {% endfor %}
+private:
+ enum SpecificTypes {
+ SpecificTypeNone,
+ {% for member in container.members %}
+ {{member.specific_type_enum}},
+ {% endfor %}
+ };
+ SpecificTypes m_type;
+
+ {% for member in container.members %}
+ {{member.cpp_type}} m_{{member.cpp_name}};
+ {% endfor %}
+};
+
+class V8{{container.cpp_class}} final {
+public:
+ static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, {{container.cpp_class}}&, ExceptionState&);
};
+v8::Handle<v8::Value> toV8({{container.cpp_class}}&, v8::Handle<v8::Object>, v8::Isolate*);
+
+template <class CallbackInfo>
+inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{container.cpp_class}}& impl)
+{
+ v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
+}
+
{% endfor %}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698