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 |