OLD | NEW |
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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate
* isolate, const DOMWrapperWorld& world) { | 535 v8::Local<v8::FunctionTemplate> {{v8_class}}Constructor::domTemplate(v8::Isolate
* isolate, const DOMWrapperWorld& world) { |
536 static int domTemplateKey; // This address is used for a key to look up the do
m template. | 536 static int domTemplateKey; // This address is used for a key to look up the do
m template. |
537 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 537 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
538 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d
omTemplateKey); | 538 v8::Local<v8::FunctionTemplate> result = data->findInterfaceTemplate(world, &d
omTemplateKey); |
539 if (!result.IsEmpty()) | 539 if (!result.IsEmpty()) |
540 return result; | 540 return result; |
541 | 541 |
542 result = v8::FunctionTemplate::New(isolate, {{v8_class}}ConstructorCallback); | 542 result = v8::FunctionTemplate::New(isolate, {{v8_class}}ConstructorCallback); |
543 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); | 543 v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate(); |
544 instanceTemplate->SetInternalFieldCount({{v8_class}}::internalFieldCount); | 544 instanceTemplate->SetInternalFieldCount({{v8_class}}::internalFieldCount); |
545 result->SetClassName(v8AtomicString(isolate, "{{cpp_class}}")); | 545 result->SetClassName(v8AtomicString(isolate, "{{named_constructor.name}}")); |
546 result->Inherit({{v8_class}}::domTemplate(isolate, world)); | 546 result->Inherit({{v8_class}}::domTemplate(isolate, world)); |
547 data->setInterfaceTemplate(world, &domTemplateKey, result); | 547 data->setInterfaceTemplate(world, &domTemplateKey, result); |
548 return result; | 548 return result; |
549 } | 549 } |
550 | 550 |
| 551 void {{v8_class}}Constructor::NamedConstructorAttributeGetter( |
| 552 v8::Local<v8::Name> propertyName, |
| 553 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 554 v8::Local<v8::Context> creationContext = info.Holder()->CreationContext(); |
| 555 V8PerContextData* perContextData = V8PerContextData::from(creationContext); |
| 556 if (!perContextData) { |
| 557 // TODO(yukishiino): Return a valid named constructor even after the context
is detached |
| 558 return; |
| 559 } |
| 560 |
| 561 v8::Local<v8::Function> namedConstructor = perContextData->constructorForType(
&{{v8_class}}Constructor::wrapperTypeInfo); |
| 562 |
| 563 // Set the prototype of named constructors to the regular constructor. |
| 564 auto privateProperty = V8PrivateProperty::getNamedConstructorInitialized(info.
GetIsolate()); |
| 565 v8::Local<v8::Context> currentContext = info.GetIsolate()->GetCurrentContext()
; |
| 566 v8::Local<v8::Value> privateValue = privateProperty.get(currentContext, namedC
onstructor); |
| 567 |
| 568 if (privateValue.IsEmpty()) { |
| 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(); |
| 571 bool result = namedConstructor->Set(currentContext, v8AtomicString(info.GetI
solate(), "prototype"), interfacePrototype).ToChecked(); |
| 572 if (!result) |
| 573 return; |
| 574 privateProperty.set(currentContext, namedConstructor, v8::True(info.GetIsola
te())); |
| 575 } |
| 576 |
| 577 v8SetReturnValue(info, namedConstructor); |
| 578 } |
| 579 |
551 {% endif %} | 580 {% endif %} |
552 {% endblock %} | 581 {% endblock %} |
553 | 582 |
554 {##############################################################################} | 583 {##############################################################################} |
555 {% block overloaded_constructor %} | 584 {% block overloaded_constructor %} |
556 {% if constructor_overloads %} | 585 {% if constructor_overloads %} |
557 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { | 586 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) { |
558 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionC
ontext, "{{interface_name}}"); | 587 ExceptionState exceptionState(info.GetIsolate(), ExceptionState::ConstructionC
ontext, "{{interface_name}}"); |
559 {# 2. Initialize argcount to be min(maxarg, n). #} | 588 {# 2. Initialize argcount to be min(maxarg, n). #} |
560 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { | 589 switch (std::min({{constructor_overloads.maxarg}}, info.Length())) { |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 } | 922 } |
894 | 923 |
895 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} | 924 {% for method in methods if method.overloads and method.overloads.has_partial_ov
erloads %} |
896 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { | 925 void {{v8_class}}::register{{method.name | blink_capitalize}}MethodForPartialInt
erface(void (*method)(const v8::FunctionCallbackInfo<v8::Value>&)) { |
897 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; | 926 {{cpp_class}}V8Internal::{{method.name}}MethodForPartialInterface = method; |
898 } | 927 } |
899 | 928 |
900 {% endfor %} | 929 {% endfor %} |
901 {% endif %} | 930 {% endif %} |
902 {% endblock %} | 931 {% endblock %} |
OLD | NEW |