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

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

Issue 937773002: IDL: Support default values for dictionary members of union types (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « Source/bindings/scripts/v8_dictionary.py ('k') | Source/bindings/templates/union.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_types.py
diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
index 8759fb7c948963e4ba0e45a2b0a9b2c0f1b3329a..6b76eadd2ed7dc13771662500cd2f0ec0926d251 100644
--- a/Source/bindings/scripts/v8_types.py
+++ b/Source/bindings/scripts/v8_types.py
@@ -896,7 +896,24 @@ def literal_cpp_value(idl_type, idl_literal):
return literal_value + 'u'
return literal_value
+
+def union_literal_cpp_value(idl_type, idl_literal):
haraken 2015/02/18 15:09:04 Can we merge literal_cpp_value and union_literal_c
Jens Widell 2015/02/18 15:14:39 We can implement a single function that handles bo
+ if idl_literal.is_null:
+ return idl_type.name + '()'
+ elif idl_literal.idl_type == 'DOMString':
+ member_type = idl_type.string_member_type
+ elif idl_literal.idl_type in ('integer', 'float'):
+ member_type = idl_type.numeric_member_type
+ elif idl_literal.idl_type == 'boolean':
+ member_type = idl_type.boolean_member_type
+ else:
+ raise ValueError('Unsupported literal type: ' + idl_literal.idl_type)
+
+ return '%s::from%s(%s)' % (idl_type.name, member_type.name,
+ member_type.literal_cpp_value(idl_literal))
+
IdlType.literal_cpp_value = literal_cpp_value
+IdlUnionType.literal_cpp_value = union_literal_cpp_value
################################################################################
« no previous file with comments | « Source/bindings/scripts/v8_dictionary.py ('k') | Source/bindings/templates/union.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698