OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! | 5 // This file has been auto-generated by {{code_generator}}. DO NOT MODIFY! |
6 | 6 |
7 #ifndef {{macro_guard}} | 7 #ifndef {{macro_guard}} |
8 #define {{macro_guard}} | 8 #define {{macro_guard}} |
9 | 9 |
10 {% for filename in header_includes %} | 10 {% for filename in header_includes %} |
11 #include "{{filename}}" | 11 #include "{{filename}}" |
12 {% endfor %} | 12 {% endfor %} |
13 | 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_typ
e_enum}}; } | |
29 {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const; | |
30 void set{{member.type_name}}({{member.rvalue_cpp_type}}); | |
31 static {{container.cpp_class}} from{{member.type_name}}({{member.rvalue_cpp_
type}}); | |
32 | |
33 {% endfor %} | |
34 {% if container.needs_trace %} | |
35 DECLARE_TRACE(); | |
36 | |
37 {% endif %} | |
38 private: | |
39 enum SpecificTypes { | |
40 SpecificTypeNone, | |
41 {% for member in container.members %} | |
42 {{member.specific_type_enum}}, | |
43 {% endfor %} | |
44 }; | |
45 SpecificTypes m_type; | |
46 | |
47 {% for member in container.members %} | |
48 {{member.cpp_type}} m_{{member.cpp_name}}; | |
49 {% endfor %} | |
50 | |
51 friend v8::Local<v8::Value> toV8(const {{container.cpp_class}}&, v8::Local<v
8::Object>, v8::Isolate*); | |
52 }; | |
53 | |
54 class V8{{container.cpp_class}} final { | |
55 public: | |
56 static void toImpl(v8::Isolate*, v8::Local<v8::Value>, {{container.cpp_class
}}&, ExceptionState&); | |
57 }; | |
58 | |
59 v8::Local<v8::Value> toV8(const {{container.cpp_class}}&, v8::Local<v8::Object>,
v8::Isolate*); | |
60 | |
61 template <class CallbackInfo> | |
62 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{container.cpp_c
lass}}& impl) | |
63 { | |
64 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | |
65 } | |
66 | |
67 template <> | |
68 struct NativeValueTraits<{{container.cpp_class}}> { | |
69 static {{container.cpp_class}} nativeValue(const v8::Local<v8::Value>&, v8::
Isolate*, ExceptionState&); | |
70 }; | |
71 | |
72 {% endfor %} | |
73 {% for cpp_type in nullable_cpp_types %} | |
74 class V8{{cpp_type}}OrNull final { | |
75 public: | |
76 static void toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{cpp
_type}}& impl, ExceptionState& exceptionState) | |
77 { | |
78 {# http://heycam.github.io/webidl/#es-union #} | |
79 {# 1. null or undefined #} | |
80 if (isUndefinedOrNull(v8Value)) | |
81 return; | |
82 V8{{cpp_type}}::toImpl(isolate, v8Value, impl, exceptionState); | |
83 } | |
84 }; | |
85 | |
86 {% endfor %} | |
87 } // namespace blink | |
88 | |
89 #endif // {{macro_guard}} | 14 #endif // {{macro_guard}} |
OLD | NEW |