Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / templates / union.h
1 // Copyright 2014 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 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
6
7 #ifndef {{macro_guard}}
8 #define {{macro_guard}}
9
10 {% for filename in header_includes %}
11 #include "{{filename}}"
12 {% endfor %}
13
14 namespace blink {
15
16 {% for decl in header_forward_decls %}
17 class {{decl}};
18 {% endfor %}
19
20 {% for container in containers %}
21 class {{container.cpp_class}} final {
22     ALLOW_ONLY_INLINE_ALLOCATION();
23 public:
24     {{container.cpp_class}}();
25     bool isNull() const { return m_type == SpecificTypeNone; }
26
27     {% for member in container.members %}
28     bool is{{member.type_name}}() const { return m_type == {{member.specific_type_enum}}; }
29     {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const;
30     void set{{member.type_name}}({{member.rvalue_cpp_type}});
31
32     {% endfor %}
33     {% if container.needs_trace %}
34     void trace(Visitor*);
35
36     {% endif %}
37 private:
38     enum SpecificTypes {
39         SpecificTypeNone,
40         {% for member in container.members %}
41         {{member.specific_type_enum}},
42         {% endfor %}
43     };
44     SpecificTypes m_type;
45
46     {% for member in container.members %}
47     {{member.cpp_type}} m_{{member.cpp_name}};
48     {% endfor %}
49
50     friend v8::Handle<v8::Value> toV8({{container.cpp_class}}&, v8::Handle<v8::Object>, v8::Isolate*);
51 };
52
53 class V8{{container.cpp_class}} final {
54 public:
55     static void toImpl(v8::Isolate*, v8::Handle<v8::Value>, {{container.cpp_class}}&, ExceptionState&);
56 };
57
58 v8::Handle<v8::Value> toV8({{container.cpp_class}}&, v8::Handle<v8::Object>, v8::Isolate*);
59
60 template <class CallbackInfo>
61 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{container.cpp_class}}& impl)
62 {
63     v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInfo.GetIsolate()));
64 }
65
66 {% endfor %}
67 } // namespace blink
68
69 #endif // {{macro_guard}}