Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
| 2 | 2 |
| 3 | 3 |
| 4 {##############################################################################} | 4 {##############################################################################} |
| 5 {% block indexed_property_getter %} | 5 {% block indexed_property_getter %} |
| 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} | 6 {% if indexed_property_getter and not indexed_property_getter.is_custom %} |
| 7 {% set getter = indexed_property_getter %} | 7 {% set getter = indexed_property_getter %} |
| 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) | 8 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) |
| 9 { | 9 { |
| 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); | 10 {{cpp_class}}* impl = {{v8_class}}::toImpl(info.Holder()); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 {% endif %} | 467 {% endif %} |
| 468 {% endblock %} | 468 {% endblock %} |
| 469 | 469 |
| 470 | 470 |
| 471 {##############################################################################} | 471 {##############################################################################} |
| 472 {% block named_constructor %} | 472 {% block named_constructor %} |
| 473 {% from 'methods.cpp' import generate_constructor with context %} | 473 {% from 'methods.cpp' import generate_constructor with context %} |
| 474 {% if named_constructor %} | 474 {% if named_constructor %} |
| 475 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class | 475 {% set to_active_dom_object = '%s::toActiveDOMObject' % v8_class |
| 476 if is_active_dom_object else '0' %} | 476 if is_active_dom_object else '0' %} |
| 477 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, 0, {{v8_class}} ::installConditionallyEnabledMethods, {{v8_class}}::installConditionallyEnabledP roperties, "{{interface_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::{{wrapper_class_id}}, WrapperTypeInfo::{{event_target_inherita nce}}, WrapperTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; | 477 const WrapperTypeInfo {{v8_class}}Constructor::wrapperTypeInfo = { gin::kEmbedde rBlink, {{v8_class}}Constructor::domTemplate, {{v8_class}}::refObject, {{v8_clas s}}::derefObject, {{v8_class}}::trace, {{to_active_dom_object}}, 0, {{v8_class}} ::preparePrototypeObject, {{v8_class}}::installConditionallyEnabledProperties, " {{interface_name}}", 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperType Info::{{wrapper_class_id}}, WrapperTypeInfo::{{event_target_inheritance}}, Wrapp erTypeInfo::{{lifetime}}, WrapperTypeInfo::{{gc_type}} }; |
| 478 | 478 |
| 479 {{generate_constructor(named_constructor)}} | 479 {{generate_constructor(named_constructor)}} |
| 480 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate * isolate) | 480 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate * isolate) |
| 481 { | 481 { |
| 482 static int domTemplateKey; // This address is used for a key to look up the dom template. | 482 static int domTemplateKey; // This address is used for a key to look up the dom template. |
| 483 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 483 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 484 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl ateKey); | 484 v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTempl ateKey); |
| 485 if (!result.IsEmpty()) | 485 if (!result.IsEmpty()) |
| 486 return result; | 486 return result; |
| 487 | 487 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 {% endfilter %} | 919 {% endfilter %} |
| 920 {% endfilter %} | 920 {% endfilter %} |
| 921 {% endfor %} | 921 {% endfor %} |
| 922 } | 922 } |
| 923 | 923 |
| 924 {% endif %} | 924 {% endif %} |
| 925 {% endblock %} | 925 {% endblock %} |
| 926 | 926 |
| 927 | 927 |
| 928 {##############################################################################} | 928 {##############################################################################} |
| 929 {% block prepare_prototype_object %} | |
| 930 {% from 'methods.cpp' import install_conditionally_enabled_methods with context %} | |
|
haraken
2015/04/22 10:54:51
install_conditionally_enabled_methods => prepare_p
Jens Widell
2015/04/22 13:04:51
My thinking here is that the macro imported from m
haraken
2015/04/22 13:10:32
Makes sense, let's keep it. (Alternately I want to
Jens Widell
2015/04/22 14:22:10
Yes, it would certainly be great to eliminate [Per
| |
| 931 {% if unscopeables or conditionally_enabled_methods %} | |
| 932 void {{v8_class}}::preparePrototypeObject(v8::Isolate* isolate, v8::Local<v8::Ob ject> prototypeObject) | |
| 933 { | |
| 934 {% if unscopeables %} | |
| 935 {{install_unscopeables() | indent}} | |
| 936 {% endif %} | |
| 937 {% if conditionally_enabled_methods %} | |
|
haraken
2015/04/22 10:54:51
Once we remove [PerContextEnabled], can we remove
Jens Widell
2015/04/22 13:04:51
Yes, I imagine we could do that then.
| |
| 938 {{install_conditionally_enabled_methods() | indent}} | |
| 939 {% endif %} | |
| 940 } | |
| 941 | |
| 942 {% endif %} | |
| 943 {% endblock %} | |
| 944 | |
| 945 | |
| 946 {##############################################################################} | |
| 947 {% macro install_unscopeables() %} | |
| 948 v8::Local<v8::Context> v8Context(prototypeObject->CreationContext()); | |
| 949 v8::Local<v8::Name> unscopablesSymbol(v8::Symbol::GetUnscopables(isolate)); | |
| 950 {% if is_partial %} | |
|
haraken
2015/04/22 10:54:51
Why do we need a different logic between partial a
Jens Widell
2015/04/22 13:04:52
We don't; the partial variant works for both, but
haraken
2015/04/22 13:10:32
Just to confirm: If we have X and PartialX, is it
Jens Widell
2015/04/22 14:22:10
Yes. V8FooPartial::preparePrototypeObject() calls
haraken
2015/04/22 15:36:10
ok, understood.
I still prefer not introducing di
Jens Widell
2015/04/22 16:37:07
We need to make sure to only read an own @@unscopa
haraken
2015/04/22 17:02:26
Makes sense. Then shall we use the current is_part
Jens Widell
2015/04/22 17:08:04
Sure, I'll make that change.
Jens Widell
2015/04/22 17:15:13
Done.
| |
| 951 bool hasUnscopables = v8CallBoolean(prototypeObject->HasOwnProperty(v8Context, u nscopablesSymbol)); | |
| 952 v8::Local<v8::Object> unscopeables; | |
| 953 if (hasUnscopables) | |
|
haraken
2015/04/22 10:54:51
if (!v8CallBoolean(...))
?
Jens Widell
2015/04/22 13:04:51
We can inline the HasOwnProperty() call here, yes.
Jens Widell
2015/04/22 17:15:13
Done.
| |
| 954 unscopeables = prototypeObject->Get(v8Context, unscopablesSymbol).ToLocalChe cked(); | |
| 955 else | |
| 956 unscopeables = v8::Object::New(isolate); | |
| 957 {% else %} | |
| 958 v8::Local<v8::Object> unscopeables(v8::Object::New(isolate)); | |
| 959 {% endif %} | |
| 960 {% for name in unscopeables %} | |
| 961 unscopeables->ForceSet(v8Context, v8AtomicString(isolate, "{{name}}"), v8::True( isolate)).FromJust(); | |
| 962 {% endfor %} | |
| 963 prototypeObject->ForceSet(v8Context, v8::Symbol::GetUnscopables(isolate), unscop eables).FromJust(); | |
| 964 {% endmacro %} | |
| 965 | |
| 966 | |
| 967 {##############################################################################} | |
| 929 {% block to_active_dom_object %} | 968 {% block to_active_dom_object %} |
| 930 {% if is_active_dom_object %} | 969 {% if is_active_dom_object %} |
| 931 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Local<v8::Object> wrapper) | 970 ActiveDOMObject* {{v8_class}}::toActiveDOMObject(v8::Local<v8::Object> wrapper) |
| 932 { | 971 { |
| 933 return toImpl(wrapper); | 972 return toImpl(wrapper); |
| 934 } | 973 } |
| 935 | 974 |
| 936 {% endif %} | 975 {% endif %} |
| 937 {% endblock %} | 976 {% endblock %} |
| 938 | 977 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 993 {% endif %} | 1032 {% endif %} |
| 994 } | 1033 } |
| 995 | 1034 |
| 996 {% endblock %} | 1035 {% endblock %} |
| 997 | 1036 |
| 998 {##############################################################################} | 1037 {##############################################################################} |
| 999 {% block partial_interface %} | 1038 {% block partial_interface %} |
| 1000 {% if has_partial_interface %} | 1039 {% if has_partial_interface %} |
| 1001 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template; | 1040 InstallTemplateFunction {{v8_class}}::install{{v8_class}}TemplateFunction = (Ins tallTemplateFunction)&{{v8_class}}::install{{v8_class}}Template; |
| 1002 | 1041 |
| 1003 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, InstallConditionallyEnabledMethodsFunction installConditionallyEnabled MethodsFunction) | 1042 void {{v8_class}}::updateWrapperTypeInfo(InstallTemplateFunction installTemplate Function, PreparePrototypeObjectFunction preparePrototypeObjectFunction) |
| 1004 { | 1043 { |
| 1005 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; | 1044 {{v8_class}}::install{{v8_class}}TemplateFunction = installTemplateFunction; |
| 1006 if (installConditionallyEnabledMethodsFunction) | 1045 if (preparePrototypeObjectFunction) |
| 1007 {{v8_class}}::wrapperTypeInfo.installConditionallyEnabledMethodsFunction = installConditionallyEnabledMethodsFunction; | 1046 {{v8_class}}::wrapperTypeInfo.preparePrototypeObjectFunction = preparePr ototypeObjectFunction; |
| 1008 } | 1047 } |
| 1009 | 1048 |
| 1010 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} | 1049 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} |
| 1011 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) | 1050 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) |
| 1012 { | 1051 { |
| 1013 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 1052 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
| 1014 } | 1053 } |
| 1015 {% endfor %} | 1054 {% endfor %} |
| 1016 {% endif %} | 1055 {% endif %} |
| 1017 {% endblock %} | 1056 {% endblock %} |
| OLD | NEW |