1 {% include
'copyright_block.txt' %}
2 #ifndef {{macro_guard}}
3 #define {{macro_guard}}
5 {% for filename in header_includes
%}
6 #include "{{filename}}"
11 {% for decl in header_forward_decls
%}
15 {% for container in containers
%}
16 class {{exported
}}{{container
.cpp_class
}} final
{
17 ALLOW_ONLY_INLINE_ALLOCATION();
19 {{container
.cpp_class
}}();
20 bool isNull() const { return m_type
== SpecificTypeNone
; }
22 {% for member in container
.members
%}
23 bool is
{{member
.type_name
}}() const { return m_type
== {{member
.specific_type_enum
}}; }
24 {{member
.rvalue_cpp_type
}} getAs
{{member
.type_name
}}() const;
25 void set
{{member
.type_name
}}({{member
.rvalue_cpp_type
}});
26 static {{container
.cpp_class
}} from
{{member
.type_name
}}({{member
.rvalue_cpp_type
}});
29 {{container
.cpp_class
}}(const {{container
.cpp_class
}}&);
30 ~{{container
.cpp_class
}}();
31 {{container
.cpp_class
}}& operator=(const {{container
.cpp_class
}}&);
37 {% for member in container
.members
%}
38 {{member
.specific_type_enum
}},
43 {% for member in container
.members
%}
44 {{member
.cpp_type
}} m_
{{member
.cpp_name
}};
47 friend {{exported
}}v8::Local
<v8::Value
> toV8(const {{container
.cpp_class
}}&, v8::Local
<v8::Object
>, v8::Isolate
*);
50 class V8
{{container
.cpp_class
}} final
{
52 {{exported
}}static void toImpl(v8::Isolate
*, v8::Local
<v8::Value
>, {{container
.cpp_class
}}&, ExceptionState
&);
55 {{exported
}}v8::Local
<v8::Value
> toV8(const {{container
.cpp_class
}}&, v8::Local
<v8::Object
>, v8::Isolate
*);
57 template <class CallbackInfo
>
58 inline void v8SetReturnValue(const CallbackInfo
& callbackInfo
, {{container
.cpp_class
}}& impl
)
60 v8SetReturnValue(callbackInfo
, toV8(impl
, callbackInfo
.Holder(), callbackInfo
.GetIsolate()));
64 struct NativeValueTraits
<{{container
.cpp_class
}}> {
65 {{exported
}}static {{container
.cpp_class
}} nativeValue(v8::Isolate
*, v8::Local
<v8::Value
>, ExceptionState
&);
69 {% for cpp_type in nullable_cpp_types
%}
70 class V8
{{cpp_type
}}OrNull final
{
72 static void toImpl(v8::Isolate
* isolate
, v8::Local
<v8::Value
> v8Value
, {{cpp_type
}}& impl
, ExceptionState
& exceptionState
)
74 {# http://heycam.github.io/webidl/#es-union #}
75 {# 1. null or undefined #}
76 if (isUndefinedOrNull(v8Value
))
78 V8
{{cpp_type
}}::toImpl(isolate
, v8Value
, impl
, exceptionState
);
85 // We need to set canInitializeWithMemset=true because HeapVector supports
86 // items that can initialize with memset or have a vtable. It is safe to
87 // set canInitializeWithMemset=true for a union type object in practice.
88 // See https://codereview.chromium.org/1118993002/#msg5 for more details.
89 {% for container in containers
%}
90 WTF_ALLOW_MOVE_AND_INIT_WITH_MEM_FUNCTIONS(blink::{{container
.cpp_class
}});
93 #endif // {{macro_guard}}