Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 {##############################################################################} | 1 {##############################################################################} |
| 2 {% macro generate_method(method, world_suffix) %} | 2 {% macro generate_method(method, world_suffix) %} |
| 3 {% filter conditional(method.conditional_string) %} | 3 {% filter conditional(method.conditional_string) %} |
| 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) | 4 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 5 { | 5 { |
| 6 {% if method.is_raises_exception or method.is_check_security_for_frame or | 6 {% if method.is_raises_exception or method.is_check_security_for_frame or |
| 7 method.name in ['addEventListener', 'removeEventListener'] %} | 7 method.name in ['addEventListener', 'removeEventListener'] %} |
| 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 8 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na me}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
| 9 {% endif %} | 9 {% endif %} |
| 10 {% if method.name in ['addEventListener', 'removeEventListener'] %} | 10 {% if method.name in ['addEventListener', 'removeEventListener'] %} |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 v8SetReturnValue(info, privateTemplate->GetFunction()); | 274 v8SetReturnValue(info, privateTemplate->GetFunction()); |
| 275 } | 275 } |
| 276 | 276 |
| 277 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) | 277 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 278 { | 278 { |
| 279 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); | 279 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); |
| 280 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info); | 280 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix }}(info); |
| 281 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); | 281 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); |
| 282 } | 282 } |
| 283 {% endmacro %} | 283 {% endmacro %} |
| 284 | |
| 285 | |
| 286 {##############################################################################} | |
| 287 {% macro constructor_callback(constructor) %} | |
| 288 static void constructor{{constructor.overload_index}}(const v8::FunctionCallback Info<v8::Value>& info) | |
| 289 { | |
| 290 {% if interface_length and not constructor.overload_index %} | |
| 291 {# FIXME: remove this UNLIKELY: constructors are heavy, so no difference. #} | |
| 292 if (UNLIKELY(info.Length() < {{interface_length}})) { | |
| 293 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "{{inte rface_name}}", ExceptionMessages::notEnoughArguments({{interface_length}}, info. Length())), info.GetIsolate()); | |
|
haraken
2013/12/13 10:23:31
You can use the throw_type_error macro here, or yo
Nils Barth (inactive)
2013/12/16 03:15:57
Fixed; used macro consistently.
| |
| 294 return; | |
| 295 } | |
| 296 {% endif %} | |
| 297 {% if is_constructor_raises_exception %} | |
| 298 ExceptionState exceptionState(ExceptionState::ConstructionContext, "{{interf ace_name}}", info.Holder(), info.GetIsolate()); | |
| 299 {% endif %} | |
| 300 {% for argument in constructor.arguments %} | |
| 301 {{generate_argument(constructor, argument) | indent}} | |
| 302 {% endfor %} | |
| 303 {% if is_constructor_call_with_execution_context %} | |
| 304 ExecutionContext* context = getExecutionContext(); | |
| 305 {% endif %} | |
| 306 {% if is_constructor_call_with_document %} | |
|
haraken
2013/12/13 10:23:31
I hope you replace [CallWith=Document] with [CallW
Nils Barth (inactive)
2013/12/16 03:15:57
Got it; will do after finish other constructors ([
| |
| 307 Document& document = *toDocument(getExecutionContext()); | |
| 308 {% endif %} | |
| 309 RefPtr<{{cpp_class}}> impl = {{cpp_class}}::create({{constructor.argument_li st | join(', ')}}); | |
| 310 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 311 {% if is_constructor_raises_exception %} | |
| 312 if (exceptionState.throwIfNeeded()) | |
| 313 return; | |
| 314 {% endif %} | |
| 315 | |
| 316 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{v8 _class}}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dep endent); | |
|
haraken
2013/12/13 10:23:31
Question: I wonder why we always specify 'Dependen
Nils Barth (inactive)
2013/12/16 03:15:57
Added a FIXME to that effect!
| |
| 317 v8SetReturnValue(info, wrapper); | |
| 318 } | |
| 319 {% endmacro %} | |
| OLD | NEW |