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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 | 714 |
715 def literal_cpp_value(idl_type, idl_literal): | 715 def literal_cpp_value(idl_type, idl_literal): |
716 """Converts an expression that is a valid C++ literal for this type.""" | 716 """Converts an expression that is a valid C++ literal for this type.""" |
717 # FIXME: add validation that idl_type and idl_literal are compatible | 717 # FIXME: add validation that idl_type and idl_literal are compatible |
718 literal_value = str(idl_literal) | 718 literal_value = str(idl_literal) |
719 if idl_type.base_type in CPP_UNSIGNED_TYPES: | 719 if idl_type.base_type in CPP_UNSIGNED_TYPES: |
720 return literal_value + 'u' | 720 return literal_value + 'u' |
721 return literal_value | 721 return literal_value |
722 | 722 |
723 IdlType.literal_cpp_value = literal_cpp_value | 723 IdlType.literal_cpp_value = literal_cpp_value |
| 724 |
| 725 |
| 726 def is_nullable_simple(idl_type): |
| 727 # Nullable type where the corresponding C++ type supports a null value. |
| 728 # - String types (String/AtomicString) represent null as a null string, |
| 729 # i.e. one for which String::isNull() returns true. |
| 730 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as |
| 731 # a null pointer. |
| 732 return idl_type.is_nullable and ( |
| 733 (idl_type.is_string_type or idl_type.is_wrapper_type) and |
| 734 not idl_type.native_array_element_type) |
| 735 |
| 736 IdlType.is_nullable_simple = property(is_nullable_simple) |
| 737 IdlUnionType.is_nullable_simple = False |
OLD | NEW |