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

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: Clean up 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 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
chasej 2017/07/11 20:12:32 Ditto about copyright include.
iclelland 2017/07/12 17:23:20 Done.
4
5 #include "bindings/modules/v8/ConditionalFeaturesForModules.h"
6
7 #include "bindings/core/v8/ConditionalFeaturesForCore.h"
8 {% for include in includes %}
9 #include "{{ include }}"
10 {% endfor %}
11
12 namespace blink {
13
14 namespace {
15 InstallConditionalFeaturesFunction
16 g_original_install_conditional_features_function = nullptr;
17 InstallPendingConditionalFeatureFunction
18 g_original_install_pending_conditional_feature_function = nullptr;
19 }
20
21 void InstallConditionalFeaturesForModules(
chasej 2017/07/11 20:12:32 This method seems very similar to the Core version
iclelland 2017/07/12 17:23:20 I've made them identical now, except that the Core
chasej 2017/07/12 19:53:41 Is that newly-added todo in this CL? I'm not seein
iclelland 2017/07/13 15:32:59 Oops -- missed it, thanks for catching.
22 const WrapperTypeInfo* wrapper_type_info,
23 const ScriptState* script_state,
24 v8::Local<v8::Object> prototype_object,
25 v8::Local<v8::Function> interface_object) {
26 (*g_original_install_conditional_features_function)(
27 wrapper_type_info, script_state, prototype_object, interface_object);
28
29 {% if installers_by_interface %}
30 ExecutionContext* execution_context = ExecutionContext::From(script_state);
31 if (!execution_context)
32 return;
33 v8::Isolate* isolate = script_state->GetIsolate();
34 const DOMWrapperWorld& world = script_state->World();
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 {% if installers_by_feature %}
60 v8::Local<v8::Object> prototype_object;
61 v8::Local<v8::Function> interface_object;
62 v8::Isolate* isolate = script_state->GetIsolate();
63 const DOMWrapperWorld& world = script_state->World();
64 V8PerContextData* context_data = script_state->PerContextData();
65 {% for feature in installers_by_feature %}
66 if (feature == "{{ feature.name }}") {
67 {% for installer in feature.installers %}
68 if (context_data->GetExistingConstructorAndPrototypeForType(
69 &{{ installer.class }}::wrapperTypeInfo, &prototype_object,
70 &interface_object)) {
71 {{ installer.class_or_partial }}::{{ installer.install_method }}(
72 isolate, world, v8::Local<v8::Object>(), prototype_object,
73 interface_object);
74 }
75 {% endfor %}
76 return;
77 }
78 {% endfor %}
79 {% endif %}
80 }
81
82 void RegisterInstallConditionalFeaturesForModules() {
83 RegisterInstallConditionalFeaturesForCore();
84 g_original_install_conditional_features_function =
85 SetInstallConditionalFeaturesFunction(
86 &InstallConditionalFeaturesForModules);
87 g_original_install_pending_conditional_feature_function =
88 SetInstallPendingConditionalFeatureFunction(
89 &InstallPendingConditionalFeatureForModules);
90 }
91
92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698