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

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..5c2a2a1a51b166568d28de52460f79cec22b6267 100644
--- a/Source/bindings/templates/union.h
+++ b/Source/bindings/templates/union.h
@@ -7,13 +7,50 @@
#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();
+public:
+ {{container.cpp_class}}();
+ bool isNull() const { return m_specificTypeFlag == 0; }
+
+ {% for member in container.members %}
+ bool is{{member.type_name}}() const { return m_specificTypeFlag == {{member.index}}; }
+ {{member.rvalue_cpp_type}} getAs{{member.type_name}}();
Jens Widell 2014/10/28 11:31:38 Might be a good idea to inline these?
bashi 2014/10/29 01:34:33 Unfortunately, forward declarations are used for i
+ void set{{member.type_name}}({{member.rvalue_cpp_type}});
+
+ {% endfor %}
+private:
+ unsigned m_specificTypeFlag;
Jens Widell 2014/10/28 11:31:38 For bonus points (nice when debugging) you could u
bashi 2014/10/29 01:34:33 Done.
+
+ {% for member in container.members %}
+ {{member.cpp_type}} m_{{member.cpp_name}};
+ {% endfor %}
+};
+
+class V8{{container.cpp_class}} {
+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