blob: abcfeefa5af5f15fc527753e462f9ff4cdf35318 [file] [log] [blame]
{% filter format_blink_cpp_source_code %}
{% include 'copyright_block.txt' %}
#ifndef {{v8_class}}_h
#define {{v8_class}}_h
{% for filename in header_includes %}
#include "{{filename}}"
{% endfor %}
namespace blink {
{% if optional_features %}
class ScriptState;
{% endif %}
{% if named_constructor %}
class {{v8_class}}Constructor {
STATIC_ONLY({{v8_class}}Constructor);
public:
static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
{{exported}}static void NamedConstructorAttributeGetter(v8::Local<v8::Name> propertyName, const v8::PropertyCallbackInfo<v8::Value>& info);
{{exported}}static const WrapperTypeInfo wrapperTypeInfo;
};
{% endif %}
class {{v8_class}} {
STATIC_ONLY({{v8_class}});
public:
{% if is_array_buffer_or_view %}
{{exported}}static {{cpp_class}}* toImpl(v8::Local<v8::Object> object);
{% else %}
{{exported}}static bool hasInstance(v8::Local<v8::Value>, v8::Isolate*);
static v8::Local<v8::Object> findInstanceInPrototypeChain(v8::Local<v8::Value>, v8::Isolate*);
{{exported}}static v8::Local<v8::FunctionTemplate> domTemplate(v8::Isolate*, const DOMWrapperWorld&);
{% if has_named_properties_object %}
{{exported}}static v8::Local<v8::FunctionTemplate> domTemplateForNamedPropertiesObject(v8::Isolate*, const DOMWrapperWorld&);
{% endif %}
static {{cpp_class}}* toImpl(v8::Local<v8::Object> object) {
return ToScriptWrappable(object)->ToImpl<{{cpp_class}}>();
}
{% endif %}
{{exported}}static {{cpp_class}}* toImplWithTypeCheck(v8::Isolate*, v8::Local<v8::Value>);
{% if has_partial_interface %}
{{exported}}static WrapperTypeInfo wrapperTypeInfo;
{% else %}
{{exported}}static const WrapperTypeInfo wrapperTypeInfo;
{% endif %}
static void Trace(Visitor* visitor, ScriptWrappable* scriptWrappable) {
visitor->Trace(scriptWrappable->ToImpl<{{cpp_class}}>());
}
static void TraceWrappers(WrapperVisitor* visitor, ScriptWrappable* scriptWrappable) {
visitor->TraceWrappers(scriptWrappable->ToImpl<{{cpp_class}}>());
}
{% for method in methods %}
{% if method.is_custom %}
static void {{method.name}}MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% if method.is_custom_call_prologue %}
static void {{method.name}}MethodPrologueCustom(const v8::FunctionCallbackInfo<v8::Value>&, {{cpp_class}}*);
{% endif %}
{% if method.is_custom_call_epilogue %}
static void {{method.name}}MethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>&, {{cpp_class}}*);
{% endif %}
{% endfor %}
{% if has_custom_constructor %}
static void constructorCustom(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% for attribute in attributes %}
{% if attribute.has_custom_getter %}{# FIXME: and not attribute.implemented_by #}
{% if attribute.is_data_type_property %}
static void {{attribute.name}}AttributeGetterCustom(const v8::PropertyCallbackInfo<v8::Value>&);
{% else %}
static void {{attribute.name}}AttributeGetterCustom(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% endif %}
{% if attribute.has_custom_setter %}{# FIXME: and not attribute.implemented_by #}
{% if attribute.is_data_type_property %}
static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
{% else %}
static void {{attribute.name}}AttributeSetterCustom(v8::Local<v8::Value>, const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% endif %}
{% endfor %}
{# Custom special operations #}
{% if indexed_property_getter and indexed_property_getter.is_custom %}
static void indexedPropertyGetterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if indexed_property_setter and indexed_property_setter.is_custom %}
static void indexedPropertySetterCustom(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if indexed_property_deleter and indexed_property_deleter.is_custom %}
static void indexedPropertyDeleterCustom(uint32_t, const v8::PropertyCallbackInfo<v8::Boolean>&);
{% endif %}
{% if named_property_getter and named_property_getter.is_custom %}
static void namedPropertyGetterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if named_property_setter and named_property_setter.is_custom %}
static void namedPropertySetterCustom(const AtomicString&, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if named_property_getter and named_property_getter.is_custom_property_query %}
static void namedPropertyQueryCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Integer>&);
{% endif %}
{% if named_property_deleter and named_property_deleter.is_custom %}
static void namedPropertyDeleterCustom(const AtomicString&, const v8::PropertyCallbackInfo<v8::Boolean>&);
{% endif %}
{% if named_property_getter and named_property_getter.is_custom_property_enumerator %}
static void namedPropertyEnumeratorCustom(const v8::PropertyCallbackInfo<v8::Array>&);
{% endif %}
{# END custom special operations #}
{% if has_custom_legacy_call_as_function %}
static void legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{# Custom internal fields #}
{% set custom_internal_field_counter = 0 %}
{% if is_event_target and not is_node %}
{# Event listeners on DOM nodes are explicitly supported in the GC controller. #}
static const int eventListenerCacheIndex = kV8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
{% set custom_internal_field_counter = custom_internal_field_counter + 1 %}
{% endif %}
{# persistentHandleIndex must be the last field, if it is present.
Detailed explanation: https://codereview.chromium.org/139173012
FIXME: Remove this internal field, and share one field for either:
* a persistent handle (if the object is in oilpan) or
* a C++ pointer to the DOM object (if the object is not in oilpan) #}
static const int internalFieldCount = kV8DefaultWrapperInternalFieldCount + {{custom_internal_field_counter}};
{# End custom internal fields #}
{% if prepare_prototype_and_interface_object_func %}
{{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate);
{% elif has_partial_interface %}
{{exported}}static void preparePrototypeAndInterfaceObject(v8::Local<v8::Context>, const DOMWrapperWorld&, v8::Local<v8::Object> prototypeObject, v8::Local<v8::Function> interfaceObject, v8::Local<v8::FunctionTemplate> interfaceTemplate) {}
{% endif %}
{% if has_partial_interface %}
{{exported}}static void updateWrapperTypeInfo(InstallTemplateFunction, InstallRuntimeEnabledFunction, PreparePrototypeAndInterfaceObjectFunction);
{{exported}}static void install{{v8_class}}Template(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::FunctionTemplate> interfaceTemplate);
{% for method in methods if method.overloads and method.overloads.has_partial_overloads %}
{{exported}}static void register{{method.name | blink_capitalize}}MethodForPartialInterface(void (*)(const v8::FunctionCallbackInfo<v8::Value>&));
{% endfor %}
{% endif %}
{% for feature in optional_features %}
static void install{{feature.name}}(v8::Isolate*, const DOMWrapperWorld&, v8::Local<v8::Object> instance, v8::Local<v8::Object> prototype, v8::Local<v8::Function> interface);
static void install{{feature.name}}(ScriptState*, v8::Local<v8::Object> instance);
{% if not feature.needs_instance %}
static void install{{feature.name}}(ScriptState*);
{% endif %}
{% endfor %}
// Callback functions
{% if constructors or has_custom_constructor or has_html_constructor %}
{{exported}}static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% for constant in constants | has_special_getter %}
{{exported}}static void {{constant.name}}ConstantGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endfor %}
{% for attribute in attributes %}
{% if attribute.is_cached_accessor %}
{{exported}}static v8::Local<v8::Private> {{attribute.name}}CachedPropertyKey(v8::Isolate*);
{% endif %}
{% for world_suffix in attribute.world_suffixes %}
{% if not attribute.constructor_type %}
{{exported}}static void {{attribute.name}}AttributeGetterCallback{{world_suffix}}(
{%- if attribute.is_data_type_property -%}
v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&
{%- else -%}
const v8::FunctionCallbackInfo<v8::Value>&
{%- endif -%});
{% elif attribute.needs_constructor_getter_callback %}
{{exported}}static void {{attribute.name}}ConstructorGetterCallback{{world_suffix}}(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if attribute.has_setter %}
{{exported}}static void {{attribute.name}}AttributeSetterCallback{{world_suffix}}(
{%- if attribute.is_data_type_property -%}
v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&
{%- else -%}
const v8::FunctionCallbackInfo<v8::Value>&
{%- endif -%});
{% endif %}
{% endfor %}
{% endfor %}
{% for method in methods %}
{% for world_suffix in method.world_suffixes %}
{% if not method.overload_index or method.overloads %}
{# Document about the following condition: #}
{# https://docs.google.com/document/d/1qBC7Therp437Jbt_QYAtNYMZs6zQ_7_tnMkNUG_ACqs/edit?usp=sharing #}
{% if (method.overloads and method.overloads.visible and
(not method.overloads.has_partial_overloads or not is_partial)) or
(not method.overloads and method.visible) %}
{# A single callback is generated for overloaded methods #}
{# with considering partial overloads #}
{{exported}}static void {{method.name}}MethodCallback{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% endif %}
{% if method.is_cross_origin and method.visible %}
{{exported}}static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% endfor %}
{% endfor %}
{% if iterator_method %}
{{exported}}static void {{iterator_method.name}}MethodCallback(const v8::FunctionCallbackInfo<v8::Value>&);
{% endif %}
{% if has_origin_safe_method_setter %}
{{exported}}static void {{cpp_class}}OriginSafeMethodSetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<void>&);
{% endif %}
{% if has_access_check_callbacks and not is_partial %}
{{exported}}static bool securityCheck(v8::Local<v8::Context>, v8::Local<v8::Object>, v8::Local<v8::Value>);
{% if has_cross_origin_named_getter %}
{{exported}}static void crossOriginNamedGetter(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if has_cross_origin_named_setter %}
{{exported}}static void crossOriginNamedSetter(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if has_cross_origin_named_enumerator %}
{{exported}}static void crossOriginNamedEnumerator(const v8::PropertyCallbackInfo<v8::Array>&);
{% endif %}
{% if has_cross_origin_indexed_getter %}
{{exported}}static void crossOriginIndexedGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% endif %}
{% if named_property_getter %}
{{exported}}static void namedPropertyGetterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if named_property_setter %}
{{exported}}static void namedPropertySetterCallback(v8::Local<v8::Name>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if named_property_deleter %}
{{exported}}static void namedPropertyDeleterCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Boolean>&);
{% endif %}
{% if named_property_getter and named_property_getter.is_enumerable %}
{{exported}}static void namedPropertyQueryCallback(v8::Local<v8::Name>, const v8::PropertyCallbackInfo<v8::Integer>&);
{% endif %}
{% if named_property_getter and named_property_getter.is_enumerable %}
{{exported}}static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>&);
{% endif %}
{% if indexed_property_getter or named_property_getter %}
{{exported}}static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if indexed_property_setter or named_property_setter %}
{{exported}}static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
{% endif %}
{% if indexed_property_deleter or named_property_deleter %}
{{exported}}static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCallbackInfo<v8::Boolean>&);
{% endif %}
{% if needs_runtime_enabled_installer %}
{{exported}}static void installRuntimeEnabledFeatures(
v8::Isolate* isolate,
const DOMWrapperWorld& world,
v8::Local<v8::Object> instance,
v8::Local<v8::Object> prototype,
v8::Local<v8::Function> interface);
{% if has_partial_interface %}
static InstallRuntimeEnabledFunction install{{v8_class}}RuntimeEnabledFunction;
{% endif %}
{% endif %}
{% if has_partial_interface %}
private:
static InstallTemplateFunction install{{v8_class}}TemplateFunction;
{% endif %}
};
template <>
struct NativeValueTraits<{{cpp_class}}> : public NativeValueTraitsBase<{{cpp_class}}> {
{{exported}}static {{cpp_class}}* NativeValue(v8::Isolate*, v8::Local<v8::Value>, ExceptionState&);
};
template <>
struct V8TypeOf<{{cpp_class}}> {
typedef {{v8_class}} Type;
};
} // namespace blink
#endif // {{v8_class}}_h
{% endfilter %}{# format_blink_cpp_source_code #}