Chromium Code Reviews| 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 |
| ################################################################################ |