Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: third_party/WebKit/Source/bindings/templates/ConditionalFeaturesForModules.cpp.tmpl

Issue 2970003002: Add code generation for ConditionalFeatures bindings code (Closed)
Patch Set: Move awkward dependency into scripts.gni with its counterpart Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 {% include 'copyright_block.txt' %}
2
3 #include "bindings/modules/v8/ConditionalFeaturesForModules.h"
4
5 #include "bindings/core/v8/ConditionalFeaturesForCore.h"
6 {% for include in includes %}
7 #include "{{ include }}"
8 {% endfor %}
9
10 namespace blink {
11
12 namespace {
13 InstallConditionalFeaturesFunction
14 g_original_install_conditional_features_function = nullptr;
15 InstallPendingConditionalFeatureFunction
16 g_original_install_pending_conditional_feature_function = nullptr;
17 }
18
19 void InstallConditionalFeaturesForModules(
20 const WrapperTypeInfo* wrapper_type_info,
21 const ScriptState* script_state,
22 v8::Local<v8::Object> prototype_object,
23 v8::Local<v8::Function> interface_object) {
24 (*g_original_install_conditional_features_function)(
25 wrapper_type_info, script_state, prototype_object, interface_object);
26
27 {% if installers_by_interface %}
28 ExecutionContext* execution_context = ExecutionContext::From(script_state);
29 if (!execution_context)
30 return;
31 v8::Isolate* isolate = script_state->GetIsolate();
32 const DOMWrapperWorld& world = script_state->World();
33 // TODO(iclelland): Extract this common code out of ConditionalFeaturesForCore
34 // and ConditionalFeaturesForModules into a block.
35 {% for interface in installers_by_interface %}
36 if (wrapper_type_info == &{{ interface.class }}::wrapperTypeInfo) {
37 {% if interface.is_global %}
38 v8::Local<v8::Object> instance_object =
39 script_state->GetContext()->Global();
40 {% endif %}
41 {% for installer in interface.installers %}
42 if ({{ installer.condition }}(execution_context)) {
43 {{ installer.class_or_partial }}::{{ installer.install_method }}(
44 isolate, world, {% if interface.is_global %}instance_object{% else %}v 8::Local<v8::Object>(){% endif %}, prototype_object,
45 interface_object);
46 }
47 {% endfor %}
48 }
49 {% endfor %}
50 {% endif %}
51 }
52
53 void InstallPendingConditionalFeatureForModules(
54 const String& feature,
55 const ScriptState* script_state) {
56 (*g_original_install_pending_conditional_feature_function)(feature,
57 script_state);
58
59 // TODO(iclelland): Extract this common code out of ConditionalFeaturesForCore
60 // and ConditionalFeaturesForModules into a block.
61 {% if installers_by_feature %}
62 v8::Local<v8::Object> prototype_object;
63 v8::Local<v8::Function> interface_object;
64 v8::Isolate* isolate = script_state->GetIsolate();
65 const DOMWrapperWorld& world = script_state->World();
66 V8PerContextData* context_data = script_state->PerContextData();
67 {% for feature in installers_by_feature %}
68 if (feature == "{{ feature.name }}") {
69 {% for installer in feature.installers %}
70 if (context_data->GetExistingConstructorAndPrototypeForType(
71 &{{ installer.class }}::wrapperTypeInfo, &prototype_object,
72 &interface_object)) {
73 {{ installer.class_or_partial }}::{{ installer.install_method }}(
74 isolate, world, v8::Local<v8::Object>(), prototype_object,
75 interface_object);
76 }
77 {% endfor %}
78 return;
79 }
80 {% endfor %}
81 {% endif %}
82 }
83
84 void RegisterInstallConditionalFeaturesForModules() {
85 RegisterInstallConditionalFeaturesForCore();
86 g_original_install_conditional_features_function =
87 SetInstallConditionalFeaturesFunction(
88 &InstallConditionalFeaturesForModules);
89 g_original_install_pending_conditional_feature_function =
90 SetInstallPendingConditionalFeatureFunction(
91 &InstallPendingConditionalFeatureForModules);
92 }
93
94 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698