Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {% extends 'interface_base.cpp' %} | 1 {% extends 'interface_base.cpp' %} |
| 2 | 2 |
| 3 | 3 |
| 4 {##############################################################################} | 4 {##############################################################################} |
| 5 {% macro attribute_configuration(attribute) %} | 5 {% macro attribute_configuration(attribute) %} |
| 6 {% set getter_callback = | 6 {% set getter_callback = |
| 7 '%sV8Internal::%sAttributeGetterCallback' % | 7 '%sV8Internal::%sAttributeGetterCallback' % |
| 8 (cpp_class, attribute.name) | 8 (cpp_class, attribute.name) |
| 9 if not attribute.constructor_type else | 9 if not attribute.constructor_type else |
| 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} | 10 '{0}V8Internal::{0}ConstructorGetter'.format(interface_name) %} |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); | 122 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); |
| 123 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, jsValue, info); | 123 {{cpp_class}}V8Internal::{{cpp_class}}OriginSafeMethodSetter(name, jsValue, info); |
| 124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 124 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 125 } | 125 } |
| 126 | 126 |
| 127 {% endif %} | 127 {% endif %} |
| 128 {% endblock %} | 128 {% endblock %} |
| 129 | 129 |
| 130 | 130 |
| 131 {##############################################################################} | 131 {##############################################################################} |
| 132 {% from 'methods.cpp' import generate_argument with context %} | 132 {% block overloaded_constructor_callback %} |
|
Nils Barth (inactive)
2013/12/13 07:04:16
Diff looks weird; just look at new code.
This is
| |
| 133 {% block constructor %} | 133 {% if constructors|length > 1 %} |
| 134 {% if has_constructor %} | |
| 135 {# FIXME: support overloading #} | |
| 136 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 134 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 137 { | 135 { |
| 138 {% if constructor_arguments %} | 136 {% for constructor in constructors %} |
| 139 {# FIXME: remove this UNLIKELY: constructors are heavy, so no difference. #} | 137 if ({{constructor.overload_resolution_expression}}) { |
| 140 if (UNLIKELY(info.Length() < {{interface_length}})) { | 138 {{cpp_class}}V8Internal::constructor{{constructor.overload_index}}(info) ; |
| 141 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "{{inte rface_name}}", ExceptionMessages::notEnoughArguments({{interface_length}}, info. Length())), info.GetIsolate()); | |
| 142 return; | 139 return; |
| 143 } | 140 } |
| 141 {% endfor %} | |
| 142 {% if interface_length %} | |
| 143 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), info.GetIsolate()); | |
| 144 if (UNLIKELY(info.Length() < {{interface_length}})) { | |
| 145 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{in terface_length}}, info.Length())); | |
| 146 exceptionState.throwIfNeeded(); | |
| 147 return; | |
| 148 } | |
| 149 exceptionState.throwTypeError("No matching constructor signature."); | |
| 150 exceptionState.throwIfNeeded(); | |
| 151 {% else %} | |
| 152 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}", "N o matching constructor signature."), info.GetIsolate()); | |
| 144 {% endif %} | 153 {% endif %} |
| 145 {% if is_constructor_raises_exception %} | |
| 146 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), info.GetIsolate()); | |
| 147 {% endif %} | |
| 148 {% for argument in constructor_arguments %} | |
| 149 {{generate_argument(constructor_method, argument) | indent}} | |
| 150 {% endfor %} | |
| 151 {% if is_constructor_call_with_execution_context %} | |
| 152 ExecutionContext* context = getExecutionContext(); | |
| 153 {% endif %} | |
| 154 {% if is_constructor_call_with_document %} | |
| 155 Document& document = *toDocument(getExecutionContext()); | |
| 156 {% endif %} | |
| 157 RefPtr<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor_argument_li st | join(', ')}}); | |
| 158 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 159 {% if is_constructor_raises_exception %} | |
| 160 if (exceptionState.throwIfNeeded()) | |
| 161 return; | |
| 162 {% endif %} | |
| 163 | |
| 164 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent); | |
| 165 v8SetReturnValue(info, wrapper); | |
| 166 } | 154 } |
| 167 | 155 |
| 168 {% endif %} | 156 {% endif %} |
| 169 {% endblock %} | 157 {% endblock %} |
| 170 | 158 |
| 171 | 159 |
| 172 {##############################################################################} | 160 {##############################################################################} |
| 173 {% block event_constructor %} | 161 {% block event_constructor %} |
| 174 {% if has_event_constructor %} | 162 {% if has_event_constructor %} |
| 175 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 163 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 {% endfor %} | 318 {% endfor %} |
| 331 return true; | 319 return true; |
| 332 } | 320 } |
| 333 | 321 |
| 334 {% endif %} | 322 {% endif %} |
| 335 {% endblock %} | 323 {% endblock %} |
| 336 | 324 |
| 337 | 325 |
| 338 {##############################################################################} | 326 {##############################################################################} |
| 339 {% block constructor_callback %} | 327 {% block constructor_callback %} |
| 340 {% if has_constructor or has_event_constructor %} | 328 {% if constructors or has_event_constructor %} |
| 341 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) | 329 void {{v8_class}}::constructorCallback(const v8::FunctionCallbackInfo<v8::Value> & info) |
| 342 { | 330 { |
| 343 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | 331 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); |
| 344 {% if measure_as %} | 332 {% if measure_as %} |
| 345 UseCounter::count(activeDOMWindow(), UseCounter::{{measure_as}}); | 333 UseCounter::count(activeDOMWindow(), UseCounter::{{measure_as}}); |
| 346 {% endif %} | 334 {% endif %} |
| 347 if (!info.IsConstructCall()) { | 335 if (!info.IsConstructCall()) { |
| 348 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "Please use the 'new' operator, this DOM object constructor cannot be called a s a function."), info.GetIsolate()); | 336 throwTypeError(ExceptionMessages::failedToConstruct("{{interface_name}}" , "Please use the 'new' operator, this DOM object constructor cannot be called a s a function."), info.GetIsolate()); |
| 349 return; | 337 return; |
| 350 } | 338 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 {% set methods_name, methods_length = | 380 {% set methods_name, methods_length = |
| 393 ('%sMethods' % v8_class, | 381 ('%sMethods' % v8_class, |
| 394 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) | 382 'WTF_ARRAY_LENGTH(%sMethods)' % v8_class) |
| 395 if has_method_configuration else (0, 0) %} | 383 if has_method_configuration else (0, 0) %} |
| 396 {{attributes_name}}, {{attributes_length}}, | 384 {{attributes_name}}, {{attributes_length}}, |
| 397 {{accessors_name}}, {{accessors_length}}, | 385 {{accessors_name}}, {{accessors_length}}, |
| 398 {{methods_name}}, {{methods_length}}, | 386 {{methods_name}}, {{methods_length}}, |
| 399 isolate, currentWorldType); | 387 isolate, currentWorldType); |
| 400 {% endfilter %} | 388 {% endfilter %} |
| 401 | 389 |
| 402 {% if has_constructor or has_event_constructor %} | 390 {% if constructors or has_event_constructor %} |
| 403 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); | 391 functionTemplate->SetCallHandler({{v8_class}}::constructorCallback); |
| 404 functionTemplate->SetLength({{interface_length}}); | 392 functionTemplate->SetLength({{interface_length}}); |
| 405 {% endif %} | 393 {% endif %} |
| 406 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate(); | 394 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate(); |
| 407 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate(); | 395 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate(); |
| 408 {% if is_check_security and interface_name != 'Window' %} | 396 {% if is_check_security and interface_name != 'Window' %} |
| 409 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); | 397 instanceTemplate->SetAccessCheckCallbacks({{cpp_class}}V8Internal::namedSecu rityCheck, {{cpp_class}}V8Internal::indexedSecurityCheck, v8::External::New(isol ate, const_cast<WrapperTypeInfo*>(&{{v8_class}}::wrapperTypeInfo))); |
| 410 {% endif %} | 398 {% endif %} |
| 411 {% for attribute in attributes if attribute.runtime_enabled_function %} | 399 {% for attribute in attributes if attribute.runtime_enabled_function %} |
| 412 {% filter conditional(attribute.conditional_string) %} | 400 {% filter conditional(attribute.conditional_string) %} |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 fromInternalPointer(object)->deref(); | 675 fromInternalPointer(object)->deref(); |
| 688 } | 676 } |
| 689 | 677 |
| 690 template<> | 678 template<> |
| 691 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) | 679 v8::Handle<v8::Value> toV8NoInline({{cpp_class}}* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) |
| 692 { | 680 { |
| 693 return toV8(impl, creationContext, isolate); | 681 return toV8(impl, creationContext, isolate); |
| 694 } | 682 } |
| 695 | 683 |
| 696 {% endblock %} | 684 {% endblock %} |
| OLD | NEW |