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 {# Local variables #} | 6 {# Local variables #} |
7 {% if method.has_exception_state %} | 7 {% if method.has_exception_state %} |
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 {# Overloaded methods have length checked during overload resolution #} | 10 {# Overloaded methods have length checked during overload resolution #} |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 {% endif %} | 231 {% endif %} |
232 {% if method.is_call_with_execution_context %} | 232 {% if method.is_call_with_execution_context %} |
233 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); | 233 ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate()); |
234 {% endif %} | 234 {% endif %} |
235 {% if method.is_call_with_script_arguments %} | 235 {% if method.is_call_with_script_arguments %} |
236 RefPtrWillBeRawPtr<ScriptArguments> scriptArguments(createScriptArguments(script
State, info, {{method.number_of_arguments}})); | 236 RefPtrWillBeRawPtr<ScriptArguments> scriptArguments(createScriptArguments(script
State, info, {{method.number_of_arguments}})); |
237 {% endif %} | 237 {% endif %} |
238 {# Call #} | 238 {# Call #} |
239 {% if method.idl_type == 'void' %} | 239 {% if method.idl_type == 'void' %} |
240 {{cpp_value}}; | 240 {{cpp_value}}; |
| 241 {% elif method.is_implemented_in_private_script %} |
| 242 {{method.cpp_type}} result; |
| 243 if (!{{method.cpp_value}}) |
| 244 return; |
241 {% elif method.is_constructor %} | 245 {% elif method.is_constructor %} |
242 {{method.cpp_type}} impl = {{cpp_value}}; | 246 {{method.cpp_type}} impl = {{cpp_value}}; |
243 {% elif method.is_call_with_script_state or method.is_raises_exception %} | 247 {% elif method.is_call_with_script_state or method.is_raises_exception %} |
244 {# FIXME: consider always using a local variable #} | 248 {# FIXME: consider always using a local variable #} |
245 {{method.cpp_type}} result = {{cpp_value}}; | 249 {{method.cpp_type}} result = {{cpp_value}}; |
246 {% endif %} | 250 {% endif %} |
247 {# Post-call #} | 251 {# Post-call #} |
248 {% if method.is_raises_exception %} | 252 {% if method.is_raises_exception %} |
249 if (exceptionState.hadException()) { | 253 if (exceptionState.hadException()) { |
250 {{throw_from_exception_state(method)}}; | 254 {{throw_from_exception_state(method)}}; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo
cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) | 480 static void {{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}(v8::Lo
cal<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) |
477 { | 481 { |
478 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); | 482 TRACE_EVENT_SET_SAMPLING_STATE("blink", "DOMGetter"); |
479 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix
}}(info); | 483 {{cpp_class}}V8Internal::{{method.name}}OriginSafeMethodGetter{{world_suffix
}}(info); |
480 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 484 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
481 } | 485 } |
482 {% endmacro %} | 486 {% endmacro %} |
483 | 487 |
484 | 488 |
485 {##############################################################################} | 489 {##############################################################################} |
| 490 {% macro method_implemented_in_private_script(method) %} |
| 491 static bool {{method.name}}MethodImplementedInPrivateScript({{method.argument_de
clarations_for_private_script | join(', ')}}) |
| 492 { |
| 493 if (!frame) |
| 494 return false; |
| 495 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::privat
eScriptIsolatedWorld()); |
| 496 if (context.IsEmpty()) |
| 497 return false; |
| 498 ScriptState* scriptState = ScriptState::from(context); |
| 499 if (!scriptState->executionContext()) |
| 500 return false; |
| 501 |
| 502 ScriptState::Scope scope(scriptState); |
| 503 v8::Handle<v8::Value> holder = toV8(holderImpl, scriptState->context()->Glob
al(), scriptState->isolate()); |
| 504 |
| 505 {% for argument in method.arguments %} |
| 506 v8::Handle<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value
}}; |
| 507 {% endfor %} |
| 508 {% if method.arguments %} |
| 509 v8::Handle<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}}
}; |
| 510 {% else %} |
| 511 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} |
| 512 v8::Handle<v8::Value> *argv = 0; |
| 513 {% endif %} |
| 514 // FIXME: Support exceptions thrown from Blink-in-JS. |
| 515 v8::TryCatch block; |
| 516 {% if method.returned_v8_value_to_local_cpp_value %} |
| 517 v8::Handle<v8::Value> v8Value = PrivateScriptRunner::runDOMMethod(scriptStat
e, "{{cpp_class}}", "{{method.name}}", holder, {{method.arguments | length}}, ar
gv); |
| 518 if (block.HasCaught()) |
| 519 return false; |
| 520 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.na
me}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate()
); |
| 521 {{method.raw_cpp_type}} cppValue = {{method.returned_v8_value_to_local_cpp_v
alue}}; |
| 522 if (block.HasCaught()) |
| 523 return false; |
| 524 *result = cppValue; |
| 525 {% else %}{# void return type #} |
| 526 PrivateScriptRunner::runDOMMethod(scriptState, "{{cpp_class}}", "{{method.na
me}}", holder, {{method.arguments | length}}, argv); |
| 527 if (block.HasCaught()) |
| 528 return false; |
| 529 {% endif %} |
| 530 return true; |
| 531 } |
| 532 {% endmacro %} |
| 533 |
| 534 |
| 535 {##############################################################################} |
486 {% macro generate_constructor(constructor) %} | 536 {% macro generate_constructor(constructor) %} |
487 {% set name = '%sConstructorCallback' % v8_class | 537 {% set name = '%sConstructorCallback' % v8_class |
488 if constructor.is_named_constructor else | 538 if constructor.is_named_constructor else |
489 'constructor%s' % (constructor.overload_index or '') %} | 539 'constructor%s' % (constructor.overload_index or '') %} |
490 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) | 540 static void {{name}}(const v8::FunctionCallbackInfo<v8::Value>& info) |
491 { | 541 { |
492 v8::Isolate* isolate = info.GetIsolate(); | 542 v8::Isolate* isolate = info.GetIsolate(); |
493 {% if constructor.is_named_constructor %} | 543 {% if constructor.is_named_constructor %} |
494 if (!info.IsConstructCall()) { | 544 if (!info.IsConstructCall()) { |
495 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co
nstructor.name}}"), isolate); | 545 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("{{co
nstructor.name}}"), isolate); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); | 588 v8::Handle<v8::Object> wrapper = wrap(impl.get(), info.Holder(), isolate); |
539 {% else %} | 589 {% else %} |
540 {% set constructor_class = v8_class + ('Constructor' | 590 {% set constructor_class = v8_class + ('Constructor' |
541 if constructor.is_named_constructor else | 591 if constructor.is_named_constructor else |
542 '') %} | 592 '') %} |
543 v8::Handle<v8::Object> wrapper = info.Holder(); | 593 v8::Handle<v8::Object> wrapper = info.Holder(); |
544 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr
uctor_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); | 594 V8DOMWrapper::associateObjectWithWrapper<{{v8_class}}>(impl.release(), &{{constr
uctor_class}}::wrapperTypeInfo, wrapper, isolate, {{wrapper_configuration}}); |
545 {% endif %} | 595 {% endif %} |
546 v8SetReturnValue(info, wrapper); | 596 v8SetReturnValue(info, wrapper); |
547 {% endmacro %} | 597 {% endmacro %} |
OLD | NEW |