OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 882 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
883 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 883 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
884 return statement | 884 return statement |
885 | 885 |
886 IdlTypeBase.cpp_value_to_v8_value = cpp_value_to_v8_value | 886 IdlTypeBase.cpp_value_to_v8_value = cpp_value_to_v8_value |
887 | 887 |
888 | 888 |
889 def literal_cpp_value(idl_type, idl_literal): | 889 def literal_cpp_value(idl_type, idl_literal): |
890 """Converts an expression that is a valid C++ literal for this type.""" | 890 """Converts an expression that is a valid C++ literal for this type.""" |
891 # FIXME: add validation that idl_type and idl_literal are compatible | 891 # FIXME: add validation that idl_type and idl_literal are compatible |
| 892 if idl_type.base_type in ('any', 'object') and idl_literal.is_null: |
| 893 return 'ScriptValue()' |
892 literal_value = str(idl_literal) | 894 literal_value = str(idl_literal) |
893 if idl_type.base_type in CPP_UNSIGNED_TYPES: | 895 if idl_type.base_type in CPP_UNSIGNED_TYPES: |
894 return literal_value + 'u' | 896 return literal_value + 'u' |
895 return literal_value | 897 return literal_value |
896 | 898 |
897 | 899 |
898 def union_literal_cpp_value(idl_type, idl_literal): | 900 def union_literal_cpp_value(idl_type, idl_literal): |
899 if idl_literal.is_null: | 901 if idl_literal.is_null: |
900 return idl_type.name + '()' | 902 return idl_type.name + '()' |
901 elif idl_literal.idl_type == 'DOMString': | 903 elif idl_literal.idl_type == 'DOMString': |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 number_of_nullable_member_types_union) | 967 number_of_nullable_member_types_union) |
966 | 968 |
967 | 969 |
968 def includes_nullable_type_union(idl_type): | 970 def includes_nullable_type_union(idl_type): |
969 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 971 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
970 return idl_type.number_of_nullable_member_types == 1 | 972 return idl_type.number_of_nullable_member_types == 1 |
971 | 973 |
972 IdlTypeBase.includes_nullable_type = False | 974 IdlTypeBase.includes_nullable_type = False |
973 IdlNullableType.includes_nullable_type = True | 975 IdlNullableType.includes_nullable_type = True |
974 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 976 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
OLD | NEW |