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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 {# Callback functions must be functions: | 121 {# Callback functions must be functions: |
122 http://www.w3.org/TR/WebIDL/#es-callback-function #} | 122 http://www.w3.org/TR/WebIDL/#es-callback-function #} |
123 {% if argument.is_optional %} | 123 {% if argument.is_optional %} |
124 if (!isUndefinedOrNull(info[{{argument.index}}])) { | 124 if (!isUndefinedOrNull(info[{{argument.index}}])) { |
125 if (!info[{{argument.index}}]->IsFunction()) { | 125 if (!info[{{argument.index}}]->IsFunction()) { |
126 {{throw_type_error(method, | 126 {{throw_type_error(method, |
127 '"The callback provided as parameter %s is not a function."' % | 127 '"The callback provided as parameter %s is not a function."' % |
128 (argument.index + 1)) | indent(8)}} | 128 (argument.index + 1)) | indent(8)}} |
129 return; | 129 return; |
130 } | 130 } |
131 {{argument.name}} = V8{{argument.idl_type}}::create(v8::Handle<v8::Function>
::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); | 131 {{argument.name}} = V8{{argument.idl_type}}::create(v8::Local<v8::Function>:
:Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); |
132 } else { | 132 } else { |
133 {{argument.name}} = nullptr; | 133 {{argument.name}} = nullptr; |
134 } | 134 } |
135 {% else %}{# argument.is_optional #} | 135 {% else %}{# argument.is_optional #} |
136 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %
}info[{{argument.index}}]->IsFunction(){% endif %}) { | 136 if (info.Length() <= {{argument.index}} || !{% if argument.is_nullable %}(info[{
{argument.index}}]->IsFunction() || info[{{argument.index}}]->IsNull()){% else %
}info[{{argument.index}}]->IsFunction(){% endif %}) { |
137 {{throw_type_error(method, | 137 {{throw_type_error(method, |
138 '"The callback provided as parameter %s is not a function."' % | 138 '"The callback provided as parameter %s is not a function."' % |
139 (argument.index + 1)) | indent }} | 139 (argument.index + 1)) | indent }} |
140 return; | 140 return; |
141 } | 141 } |
142 {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNul
l() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Handle<v8::Functi
on>::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); | 142 {{argument.name}} = {% if argument.is_nullable %}info[{{argument.index}}]->IsNul
l() ? nullptr : {% endif %}V8{{argument.idl_type}}::create(v8::Local<v8::Functio
n>::Cast(info[{{argument.index}}]), ScriptState::current(info.GetIsolate())); |
143 {% endif %}{# argument.is_optional #} | 143 {% endif %}{# argument.is_optional #} |
144 {% endif %}{# argument.idl_type == 'EventListener' #} | 144 {% endif %}{# argument.idl_type == 'EventListener' #} |
145 {% elif argument.is_variadic_wrapper_type %} | 145 {% elif argument.is_variadic_wrapper_type %} |
146 for (int i = {{argument.index}}; i < info.Length(); ++i) { | 146 for (int i = {{argument.index}}; i < info.Length(); ++i) { |
147 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { | 147 if (!V8{{argument.idl_type}}::hasInstance(info[i], info.GetIsolate())) { |
148 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % | 148 {{throw_type_error(method, '"parameter %s is not of type \'%s\'."' % |
149 (argument.index + 1, argument.idl_type)) | in
dent(8)}} | 149 (argument.index + 1, argument.idl_type)) | in
dent(8)}} |
150 return; | 150 return; |
151 } | 151 } |
152 {{argument.name}}.append(V8{{argument.idl_type}}::toImpl(v8::Handle<v8::Obje
ct>::Cast(info[i]))); | 152 {{argument.name}}.append(V8{{argument.idl_type}}::toImpl(v8::Local<v8::Objec
t>::Cast(info[i]))); |
153 } | 153 } |
154 {% elif argument.is_dictionary %} | 154 {% elif argument.is_dictionary %} |
155 {% if not argument.use_permissive_dictionary_conversion %} | 155 {% if not argument.use_permissive_dictionary_conversion %} |
156 {# Dictionaries must have type Undefined, Null or Object: | 156 {# Dictionaries must have type Undefined, Null or Object: |
157 http://heycam.github.io/webidl/#es-dictionary #} | 157 http://heycam.github.io/webidl/#es-dictionary #} |
158 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I
sObject()) { | 158 if (!isUndefinedOrNull(info[{{argument.index}}]) && !info[{{argument.index}}]->I
sObject()) { |
159 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % | 159 {{throw_type_error(method, '"parameter %s (\'%s\') is not an object."' % |
160 (argument.index + 1, argument.name)) | indent}} | 160 (argument.index + 1, argument.name)) | indent}} |
161 return; | 161 return; |
162 } | 162 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 {% endif %}{# not method.overloads #} | 443 {% endif %}{# not method.overloads #} |
444 {% if world_suffix in method.activity_logging_world_list %} | 444 {% if world_suffix in method.activity_logging_world_list %} |
445 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo
ntext()); | 445 ScriptState* scriptState = ScriptState::from(info.GetIsolate()->GetCurrentCo
ntext()); |
446 V8PerContextData* contextData = scriptState->perContextData(); | 446 V8PerContextData* contextData = scriptState->perContextData(); |
447 {% if method.activity_logging_world_check %} | 447 {% if method.activity_logging_world_check %} |
448 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac
tivityLogger()) | 448 if (scriptState->world().isIsolatedWorld() && contextData && contextData->ac
tivityLogger()) |
449 {% else %} | 449 {% else %} |
450 if (contextData && contextData->activityLogger()) { | 450 if (contextData && contextData->activityLogger()) { |
451 {% endif %} | 451 {% endif %} |
452 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{metho
d.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); | 452 ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{metho
d.name}}", "{{interface_name}}", info.Holder(), info.GetIsolate()); |
453 Vector<v8::Handle<v8::Value> > loggerArgs = toImplArguments<v8::Handle<v
8::Value> >(info, 0, exceptionState); | 453 Vector<v8::Local<v8::Value> > loggerArgs = toImplArguments<v8::Local<v8:
:Value> >(info, 0, exceptionState); |
454 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na
me}}", info.Length(), loggerArgs.data()); | 454 contextData->activityLogger()->logMethod("{{interface_name}}.{{method.na
me}}", info.Length(), loggerArgs.data()); |
455 } | 455 } |
456 {% endif %} | 456 {% endif %} |
457 {% if method.is_custom %} | 457 {% if method.is_custom %} |
458 {{v8_class}}::{{method.name}}MethodCustom(info); | 458 {{v8_class}}::{{method.name}}MethodCustom(info); |
459 {% else %} | 459 {% else %} |
460 {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(in
fo); | 460 {{cpp_class_or_partial}}V8Internal::{{method.name}}Method{{world_suffix}}(in
fo); |
461 {% endif %} | 461 {% endif %} |
462 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 462 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
463 } | 463 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 if method.overloads else | 652 if method.overloads else |
653 method.runtime_enabled_function) %} | 653 method.runtime_enabled_function) %} |
654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); | 654 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::Functio
nTemplate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}Metho
dCallback, v8Undefined(), defaultSignature, {{method.number_of_required_argument
s}})->GetFunction()); |
655 {% endfilter %}{# runtime_enabled() #} | 655 {% endfilter %}{# runtime_enabled() #} |
656 {% endfilter %}{# exposed() #} | 656 {% endfilter %}{# exposed() #} |
657 {% endfilter %}{# per_context_enabled() #} | 657 {% endfilter %}{# per_context_enabled() #} |
658 {% endfor %} | 658 {% endfor %} |
659 {% endif %} | 659 {% endif %} |
660 } | 660 } |
661 {%- endmacro %} | 661 {%- endmacro %} |
OLD | NEW |