summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/bindings/templates/external_reference_table.cc.tmpl
blob: dcd1bee8fa437f63cb10099d158a41ca5fb1c1df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{% filter format_blink_cpp_source_code %}

{% include 'copyright_block.txt' %}

#include "{{this_include_header_path}}"

#include <cstdint>

{% for include_file in include_files %}
#include "{{include_file}}"
{% endfor %}

namespace blink {

// We use forward declaration instead of include for faster compile time here.
{% for interface in interfaces %}
{% if interface.has_constructor_callback %}
namespace {{interface.internal_namespace}} {
{{interface.component|upper}}_EXPORT void ConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
}  // namespace {{interface.internal_namespace}}

{% endif %}
{% endfor %}

const intptr_t* {{class}}::GetTable() {
  static const intptr_t kReferenceTable[] = {
#if defined(USE_V8_CONTEXT_SNAPSHOT)
    // Android is sensitive on its APK size, and this table improves it.
    // So we drop the table entries until the V8 context snapshot feature
    // is released on Android.
    {% for interface in interfaces %}
    {%   set v8_class = interface.v8_class %}
    {# Attributes #}
    {%-  for attribute in interface.attributes %}
    {%-    for world_suffix in attribute.world_suffixes %}
    {%       if not attribute.constructor_type %}
    reinterpret_cast<intptr_t>({{v8_class}}::{{attribute.camel_case_name}}AttributeGetterCallback{{world_suffix}}),
    {%       else %}
    reinterpret_cast<intptr_t>({{v8_class}}::{{attribute.camel_case_name}}ConstructorGetterCallback{{world_suffix}}),
    {%       endif %}
    {%       if attribute.has_setter %}
    reinterpret_cast<intptr_t>({{v8_class}}::{{attribute.camel_case_name}}AttributeSetterCallback{{world_suffix}}),
    {%       endif %}
    {%-    endfor %}{# world_suffix #}
    {%-  endfor %}{# attributes #}
    {# Methods / Operations #}
    {%   for method in interface.methods %}
    {%-    for world_suffix in method.world_suffixes %}
    {%       if not method.overload_index or method.overloads %}
    {%         if (method.overloads and method.overloads.visible and
                   (not method.overloads.has_partial_overloads or not interface.is_partial)) or
                  (not method.overloads and method.visible) %}
    reinterpret_cast<intptr_t>({{v8_class}}::{{method.camel_case_name}}MethodCallback{{world_suffix}}),
    {%         endif %}
    {%       endif %}
    {%       if method.is_cross_origin and method.visible and not method.overloads %}
    reinterpret_cast<intptr_t>({{v8_class}}::{{method.camel_case_name}}OriginSafeMethodGetterCallback{{world_suffix}}),
    {%       endif%}
    {%     endfor %}
    {%   endfor %}{# method #}
    {%   if interface.has_origin_safe_method_setter %}
    reinterpret_cast<intptr_t>({{v8_class}}::{{interface.name}}OriginSafeMethodSetterCallback),
    {%   endif %}
    {%   if interface.has_cross_origin_named_getter %}
    reinterpret_cast<intptr_t>({{v8_class}}::CrossOriginNamedGetter),
    {%   endif %}
    {%   if interface.has_cross_origin_named_setter %}
    reinterpret_cast<intptr_t>({{v8_class}}::CrossOriginNamedSetter),
    {%   endif %}
    {%   if interface.has_cross_origin_named_enumerator %}
    reinterpret_cast<intptr_t>({{v8_class}}::CrossOriginNamedEnumerator),
    {%   endif %}
    {%   if interface.has_cross_origin_indexed_getter %}
    reinterpret_cast<intptr_t>({{v8_class}}::CrossOriginIndexedGetter),
    {%   endif %}
    {%   if interface.has_security_check %}
    reinterpret_cast<intptr_t>({{v8_class}}::SecurityCheck),
    reinterpret_cast<intptr_t>(&{{v8_class}}::wrapper_type_info),
    {%  endif %}
    {# Other properties #}
    {%   if interface.has_constructor_callback %}
    reinterpret_cast<intptr_t>({{interface.internal_namespace}}::ConstructorCallback),
    {%   endif %}
    {%   if interface.named_property_getter %}
    reinterpret_cast<intptr_t>({{v8_class}}::NamedPropertyGetterCallback),
    {%   endif %}
    {%   if interface.named_property_setter %}
    reinterpret_cast<intptr_t>({{v8_class}}::NamedPropertySetterCallback),
    {%   endif %}
    {%   if interface.named_property_deleter %}
    reinterpret_cast<intptr_t>({{v8_class}}::NamedPropertyDeleterCallback),
    {%   endif %}
    {%   if interface.named_property_getter and interface.named_property_getter.is_enumerable %}
    reinterpret_cast<intptr_t>({{v8_class}}::NamedPropertyQueryCallback),
    reinterpret_cast<intptr_t>({{v8_class}}::NamedPropertyEnumeratorCallback),
    {%   endif %}
    {%   if interface.indexed_property_getter %}
    reinterpret_cast<intptr_t>({{v8_class}}::IndexedPropertyGetterCallback),
    reinterpret_cast<intptr_t>({{v8_class}}::IndexedPropertyDefinerCallback),
    reinterpret_cast<intptr_t>({{v8_class}}::IndexedPropertyDescriptorCallback),
    {%   endif %}
    {%   if interface.indexed_property_getter or interface.named_property_setter %}
    reinterpret_cast<intptr_t>({{v8_class}}::IndexedPropertySetterCallback),
    {%   endif %}
    {%   if interface.indexed_property_deleter %}
    reinterpret_cast<intptr_t>({{v8_class}}::IndexedPropertyDeleterCallback),
    {%   endif %}
    {%   if interface.has_security_check_function %}
    reinterpret_cast<intptr_t>({{v8_class}}::SecurityCheck),
    {%   endif %}
    {% endfor %}{# interfaces #}
    reinterpret_cast<intptr_t>(V8ObjectConstructor::IsValidConstructorMode),
#endif  // USE_V8_CONTEXT_SNAPSHOT
    0  // terminate with a null
  };

  return kReferenceTable;
}

}  // namespace blink

{% endfilter %}{# format_blink_cpp_source_code #}