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

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

Issue 2785943002: [Bindings] Simplify V8PrivateProperty::Symbol methods (Closed)
Patch Set: NOLINT comment hack Created 3 years, 8 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
1 {% extends 'interface_base.cpp.tmpl' %} 1 {% extends 'interface_base.cpp.tmpl' %}
2 2
3 {##############################################################################} 3 {##############################################################################}
4 {% block indexed_property_getter %} 4 {% block indexed_property_getter %}
5 {% if indexed_property_getter and not indexed_property_getter.is_custom %} 5 {% if indexed_property_getter and not indexed_property_getter.is_custom %}
6 {% set getter = indexed_property_getter %} 6 {% set getter = indexed_property_getter %}
7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) { 7 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo <v8::Value>& info) {
8 {% if getter.is_raises_exception %} 8 {% if getter.is_raises_exception %}
9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}"); 9 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::IndexedGetter Context, "{{interface_name}}");
10 {% endif %} 10 {% endif %}
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (!perContextData) { 556 if (!perContextData) {
557 // TODO(yukishiino): Return a valid named constructor even after the context is detached 557 // TODO(yukishiino): Return a valid named constructor even after the context is detached
558 return; 558 return;
559 } 559 }
560 560
561 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType( &{{v8_class}}Constructor::wrapperTypeInfo); 561 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType( &{{v8_class}}Constructor::wrapperTypeInfo);
562 562
563 // Set the prototype of named constructors to the regular constructor. 563 // Set the prototype of named constructors to the regular constructor.
564 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info. GetIsolate()); 564 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info. GetIsolate());
565 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext() ; 565 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext() ;
566 v8::Local<v8::Value> privateValue = privateProperty.get(currentContext, namedC onstructor); 566 v8::Local<v8::Value> privateValue = privateProperty.getOrEmpty(namedConstructo r);
567 567
568 if (privateValue.IsEmpty()) { 568 if (privateValue.IsEmpty()) {
569 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo); 569 v8::Local<v8::Function> interface = perContextData->constructorForType(&{{v8 _class}}::wrapperTypeInfo);
570 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, v8A tomicString(info.GetIsolate(), "prototype")).ToLocalChecked(); 570 v8::Local<v8::Value> interfacePrototype = interface->Get(currentContext, v8A tomicString(info.GetIsolate(), "prototype")).ToLocalChecked();
571 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI solate(), "prototype"), interfacePrototype).ToChecked(); 571 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI solate(), "prototype"), interfacePrototype).ToChecked();
572 if (!result) 572 if (!result)
573 return; 573 return;
574 privateProperty.set(currentContext, namedConstructor, v8::True(info.GetIsola te())); 574 privateProperty.set(namedConstructor, v8::True(info.GetIsolate()));
575 } 575 }
576 576
577 v8SetReturnValue(info, namedConstructor); 577 v8SetReturnValue(info, namedConstructor);
578 } 578 }
579 579
580 {% endif %} 580 {% endif %}
581 {% endblock %} 581 {% endblock %}
582 582
583 {##############################################################################} 583 {##############################################################################}
584 {% block overloaded_constructor %} 584 {% block overloaded_constructor %}
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 923 }
924 924
925 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %} 925 {% for method in methods if method.overloads and method.overloads.has_partial_ov erloads %}
926 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { 926 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) {
927 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; 927 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method;
928 } 928 }
929 929
930 {% endfor %} 930 {% endfor %}
931 {% endif %} 931 {% endif %}
932 {% endblock %} 932 {% endblock %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698