Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Side by Side Diff: Source/bindings/templates/methods.cpp

Issue 1100223003: bindings: Add empty checks for toV8() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %} 1 {% from 'conversions.cpp' import declare_enum_validation_variable, v8_value_to_l ocal_cpp_value %}
2 2
3 3
4 {##############################################################################} 4 {##############################################################################}
5 {% macro generate_method(method, world_suffix) %} 5 {% macro generate_method(method, world_suffix) %}
6 {% filter conditional(method.conditional_string) %} 6 {% filter conditional(method.conditional_string) %}
7 {% if method.returns_promise and method.has_exception_state %} 7 {% if method.returns_promise and method.has_exception_state %}
8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e) 8 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}Promis e(const v8::FunctionCallbackInfo<v8::Value>& info, ExceptionState& exceptionStat e)
9 {% else %} 9 {% else %}
10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info) 10 static void {{method.name}}{{method.overload_index}}Method{{world_suffix}}(const v8::FunctionCallbackInfo<v8::Value>& info)
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld()); 523 v8::Local<v8::Context> contextInPrivateScript = toV8Context(frame, DOMWrappe rWorld::privateScriptIsolatedWorld());
524 if (contextInPrivateScript.IsEmpty()) 524 if (contextInPrivateScript.IsEmpty())
525 return false; 525 return false;
526 ScriptState* scriptState = ScriptState::from(contextInPrivateScript); 526 ScriptState* scriptState = ScriptState::from(contextInPrivateScript);
527 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame); 527 ScriptState* scriptStateInUserScript = ScriptState::forMainWorld(frame);
528 if (!scriptState->executionContext()) 528 if (!scriptState->executionContext())
529 return false; 529 return false;
530 530
531 ScriptState::Scope scope(scriptState); 531 ScriptState::Scope scope(scriptState);
532 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate()); 532 v8::Local<v8::Value> holder = toV8(holderImpl, scriptState->context()->Globa l(), scriptState->isolate());
533 if (holder.IsEmpty())
534 return false;
533 535
534 {% for argument in method.arguments %} 536 {% for argument in method.arguments %}
535 v8::Local<v8::Value> {{argument.handle}} = {{argument.private_script_cpp_val ue_to_v8_value}}; 537 v8::Local<v8::Value> {{argument.handle}} = {{argument.private_script_cpp_val ue_to_v8_value}};
536 {% endfor %} 538 {% endfor %}
537 {% if method.arguments %} 539 {% if method.arguments %}
538 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} }; 540 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
539 {% else %} 541 {% else %}
540 {# Empty array initializers are illegal, and don\t compile in MSVC. #} 542 {# Empty array initializers are illegal, and don\t compile in MSVC. #}
541 v8::Local<v8::Value> *argv = 0; 543 v8::Local<v8::Value> *argv = 0;
542 {% endif %} 544 {% endif %}
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 method.exposed_test) %} 643 method.exposed_test) %}
642 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all 644 {% filter runtime_enabled(method.overloads.runtime_enabled_function_all
643 if method.overloads else 645 if method.overloads else
644 method.runtime_enabled_function) %} 646 method.runtime_enabled_function) %}
645 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::FunctionTem plate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCal lback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}}) ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()); 647 prototypeObject->Set(v8AtomicString(isolate, "{{method.name}}"), v8::FunctionTem plate::New(isolate, {{cpp_class_or_partial}}V8Internal::{{method.name}}MethodCal lback, v8Undefined(), defaultSignature, {{method.number_of_required_arguments}}) ->GetFunction(isolate->GetCurrentContext()).ToLocalChecked());
646 {% endfilter %}{# runtime_enabled() #} 648 {% endfilter %}{# runtime_enabled() #}
647 {% endfilter %}{# exposed() #} 649 {% endfilter %}{# exposed() #}
648 {% endfor %} 650 {% endfor %}
649 {% endif %} 651 {% endif %}
650 {%- endmacro %} 652 {%- endmacro %}
OLDNEW
« no previous file with comments | « Source/bindings/templates/attributes.cpp ('k') | Source/bindings/tests/results/core/V8TestInterface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698