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

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

Issue 771813002: IDL: Null values should be converted for non-nullable dictionary members (re-land) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years 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_dictionary.py
diff --git a/Source/bindings/scripts/v8_dictionary.py b/Source/bindings/scripts/v8_dictionary.py
index 0cddb519b368e1d0248fea8db776634aafc7b52b..e45bd5d618453f8a6e52e7b801d6c168bf44feb8 100644
--- a/Source/bindings/scripts/v8_dictionary.py
+++ b/Source/bindings/scripts/v8_dictionary.py
@@ -28,6 +28,13 @@ def setter_name_for_dictionary_member(member):
return 'set%s' % v8_utilities.capitalize(name)
+def null_setter_name_for_dictionary_member(member):
+ if member.idl_type.is_nullable:
+ name = v8_utilities.cpp_name(member)
+ return 'set%sToNull' % v8_utilities.capitalize(name)
+ return None
+
+
def has_method_name_for_dictionary_member(member):
name = v8_utilities.cpp_name(member)
return 'has%s' % v8_utilities.capitalize(name)
@@ -68,7 +75,7 @@ def dictionary_context(dictionary, interfaces_info):
def member_context(member):
idl_type = member.idl_type
idl_type.add_includes_for_type()
- idl_type = unwrap_nullable_if_needed(idl_type)
+ unwrapped_idl_type = unwrap_nullable_if_needed(idl_type)
def default_values():
if not member.default_value:
@@ -76,7 +83,7 @@ def member_context(member):
if member.default_value.is_null:
return None, 'v8::Null(isolate)'
cpp_default_value = str(member.default_value)
- v8_default_value = idl_type.cpp_value_to_v8_value(
+ v8_default_value = unwrapped_idl_type.cpp_value_to_v8_value(
cpp_value=cpp_default_value, isolate='isolate',
creation_context='creationContext')
return cpp_default_value, v8_default_value
@@ -87,19 +94,21 @@ def member_context(member):
return {
'cpp_default_value': cpp_default_value,
'cpp_name': cpp_name,
- 'cpp_type': idl_type.cpp_type,
- 'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
+ 'cpp_type': unwrapped_idl_type.cpp_type,
+ 'cpp_value_to_v8_value': unwrapped_idl_type.cpp_value_to_v8_value(
cpp_value='impl.%s()' % cpp_name, isolate='isolate',
creation_context='creationContext',
extended_attributes=member.extended_attributes),
- 'enum_validation_expression': idl_type.enum_validation_expression,
+ 'enum_validation_expression': unwrapped_idl_type.enum_validation_expression,
'has_method_name': has_method_name_for_dictionary_member(member),
- 'is_object': idl_type.name == 'Object',
+ 'is_nullable': idl_type.is_nullable,
+ 'is_object': unwrapped_idl_type.name == 'Object',
'name': member.name,
'setter_name': setter_name_for_dictionary_member(member),
- 'use_output_parameter_for_result': idl_type.use_output_parameter_for_result,
+ 'null_setter_name': null_setter_name_for_dictionary_member(member),
+ 'use_output_parameter_for_result': unwrapped_idl_type.use_output_parameter_for_result,
'v8_default_value': v8_default_value,
- 'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
+ 'v8_value_to_local_cpp_value': unwrapped_idl_type.v8_value_to_local_cpp_value(
member.extended_attributes, member.name + 'Value',
member.name, isolate='isolate'),
}
@@ -165,6 +174,7 @@ def member_impl_context(member, interfaces_info, header_includes):
'is_object': is_object,
'is_traceable': idl_type.is_traceable,
'member_cpp_type': member_cpp_type(),
+ 'null_setter_name': null_setter_name_for_dictionary_member(member),
'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
'setter_name': setter_name_for_dictionary_member(member),
}
« no previous file with comments | « LayoutTests/fast/dom/idl-dictionary-unittest-expected.txt ('k') | Source/bindings/templates/dictionary_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698