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

Unified Diff: Source/bindings/scripts/v8_types.py

Issue 357413003: IDL: Drop redundant null check for string and wrapper type attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/scripts/v8_types.py
diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
index 95bb3adbfe46dd09d1d8e196e61aa930739d3882..e357766d4b3099fca64a9a940c86cf0c31833ddd 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -558,6 +558,8 @@ def v8_conversion_type(idl_type, extended_attributes):
if base_idl_type in CPP_UNSIGNED_TYPES:
return 'unsigned'
if idl_type.is_string_type:
+ if idl_type.is_nullable:
+ return 'StringOrNull'
if 'TreatReturnedNullStringAs' not in extended_attributes:
return base_idl_type
treat_returned_null_string_as = extended_attributes['TreatReturnedNullStringAs']
@@ -676,6 +678,9 @@ CPP_VALUE_TO_V8_VALUE = {
'double': 'v8::Number::New({isolate}, {cpp_value})',
'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})',
'void': 'v8Undefined()',
+ # [TreatNullReturnValueAs]
+ 'StringOrNull': '!{cpp_value}.isNull() ? v8String({isolate}, {cpp_value}) : v8::Handle<v8::Value>(v8::Null({isolate}))',
haraken 2014/07/01 00:57:33 Flip the order and avoid a negation. {cpp_value}.
Jens Widell 2014/07/01 06:43:22 Done.
+ 'StringOrUndefined': '!{cpp_value}.isNull() ? v8String({isolate}, {cpp_value}) : v8Undefined()',
haraken 2014/07/01 00:57:33 Ditto. BTW, who needs StringOrUndefined? The beha
Jens Widell 2014/07/01 06:43:22 A bit strange, yes. Kicks in with [TreatReturnedNu
# Special cases
'EventHandler': '{cpp_value} ? v8::Handle<v8::Value>(V8AbstractEventListener::cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Handle<v8::Value>(v8::Null({isolate}))',
'ScriptValue': '{cpp_value}.v8Value()',

Powered by Google App Engine
This is Rietveld 408576698