| 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 {{cpp_class}}_h |
| 8 #define {{macro_guard}} | 8 #define {{cpp_class}}_h |
| 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 { | 14 namespace blink { |
| 15 | 15 |
| 16 {% for decl in header_forward_decls %} | 16 class {{cpp_class}} final { |
| 17 class {{decl}}; | |
| 18 {% endfor %} | |
| 19 | |
| 20 {% for container in containers %} | |
| 21 class {{container.cpp_class}} final { | |
| 22 ALLOW_ONLY_INLINE_ALLOCATION(); | 17 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 23 public: | 18 public: |
| 24 {{container.cpp_class}}(); | 19 {{cpp_class}}(); |
| 25 bool isNull() const { return m_type == SpecificTypeNone; } | 20 bool isNull() const { return m_type == SpecificTypeNone; } |
| 26 | 21 |
| 27 {% for member in container.members %} | 22 {% for member in members %} |
| 28 bool is{{member.type_name}}() const { return m_type == {{member.specific_typ
e_enum}}; } | 23 bool is{{member.type_name}}() const { return m_type == {{member.specific_typ
e_enum}}; } |
| 29 {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const; | 24 {{member.rvalue_cpp_type}} getAs{{member.type_name}}() const; |
| 30 void set{{member.type_name}}({{member.rvalue_cpp_type}}); | 25 void set{{member.type_name}}({{member.rvalue_cpp_type}}); |
| 31 static {{container.cpp_class}} from{{member.type_name}}({{member.rvalue_cpp_
type}}); | 26 static {{cpp_class}} from{{member.type_name}}({{member.rvalue_cpp_type}}); |
| 32 | 27 |
| 33 {% endfor %} | 28 {% endfor %} |
| 34 {% if container.needs_trace %} | 29 {% if needs_trace %} |
| 35 DECLARE_TRACE(); | 30 DECLARE_TRACE(); |
| 36 | 31 |
| 37 {% endif %} | 32 {% endif %} |
| 38 private: | 33 private: |
| 39 enum SpecificTypes { | 34 enum SpecificTypes { |
| 40 SpecificTypeNone, | 35 SpecificTypeNone, |
| 41 {% for member in container.members %} | 36 {% for member in members %} |
| 42 {{member.specific_type_enum}}, | 37 {{member.specific_type_enum}}, |
| 43 {% endfor %} | 38 {% endfor %} |
| 44 }; | 39 }; |
| 45 SpecificTypes m_type; | 40 SpecificTypes m_type; |
| 46 | 41 |
| 47 {% for member in container.members %} | 42 {% for member in members %} |
| 48 {{member.cpp_type}} m_{{member.cpp_name}}; | 43 {{member.cpp_type}} m_{{member.cpp_name}}; |
| 49 {% endfor %} | 44 {% endfor %} |
| 50 | 45 |
| 51 friend v8::Local<v8::Value> toV8(const {{container.cpp_class}}&, v8::Local<v
8::Object>, v8::Isolate*); | 46 friend v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local<v8::Object>
, v8::Isolate*); |
| 52 }; | 47 }; |
| 53 | 48 |
| 54 class V8{{container.cpp_class}} final { | 49 class {{v8_class}} final { |
| 55 public: | 50 public: |
| 56 static void toImpl(v8::Isolate*, v8::Local<v8::Value>, {{container.cpp_class
}}&, ExceptionState&); | 51 static void toImpl(v8::Isolate*, v8::Local<v8::Value>, {{cpp_class}}&, Excep
tionState&); |
| 57 }; | 52 }; |
| 58 | 53 |
| 59 v8::Local<v8::Value> toV8(const {{container.cpp_class}}&, v8::Local<v8::Object>,
v8::Isolate*); | 54 v8::Local<v8::Value> toV8(const {{cpp_class}}&, v8::Local<v8::Object>, v8::Isola
te*); |
| 60 | 55 |
| 61 template <class CallbackInfo> | 56 template <class CallbackInfo> |
| 62 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{container.cpp_c
lass}}& impl) | 57 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, {{cpp_class}}& im
pl) |
| 63 { | 58 { |
| 64 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); | 59 v8SetReturnValue(callbackInfo, toV8(impl, callbackInfo.Holder(), callbackInf
o.GetIsolate())); |
| 65 } | 60 } |
| 66 | 61 |
| 67 template <> | 62 template <> |
| 68 struct NativeValueTraits<{{container.cpp_class}}> { | 63 struct NativeValueTraits<{{cpp_class}}> { |
| 69 static {{container.cpp_class}} nativeValue(const v8::Local<v8::Value>&, v8::
Isolate*, ExceptionState&); | 64 static {{cpp_class}} nativeValue(const v8::Local<v8::Value>&, v8::Isolate*,
ExceptionState&); |
| 70 }; | 65 }; |
| 71 | 66 |
| 72 {% endfor %} | 67 {% if needs_ornull_converter %} |
| 73 {% for cpp_type in nullable_cpp_types %} | 68 class {{v8_class}}OrNull final { |
| 74 class V8{{cpp_type}}OrNull final { | |
| 75 public: | 69 public: |
| 76 static void toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{cpp
_type}}& impl, ExceptionState& exceptionState) | 70 static void toImpl(v8::Isolate* isolate, v8::Local<v8::Value> v8Value, {{cpp
_class}}& impl, ExceptionState& exceptionState) |
| 77 { | 71 { |
| 78 {# http://heycam.github.io/webidl/#es-union #} | 72 {# http://heycam.github.io/webidl/#es-union #} |
| 79 {# 1. null or undefined #} | 73 {# 1. null or undefined #} |
| 80 if (isUndefinedOrNull(v8Value)) | 74 if (isUndefinedOrNull(v8Value)) |
| 81 return; | 75 return; |
| 82 V8{{cpp_type}}::toImpl(isolate, v8Value, impl, exceptionState); | 76 {{v8_class}}::toImpl(isolate, v8Value, impl, exceptionState); |
| 83 } | 77 } |
| 84 }; | 78 }; |
| 85 | 79 |
| 86 {% endfor %} | 80 {% endif %} |
| 87 } // namespace blink | 81 } // namespace blink |
| 88 | 82 |
| 89 #endif // {{macro_guard}} | 83 #endif // {{cpp_class}}_h |
| OLD | NEW |