Chromium Code Reviews| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 'Promise': 'ScriptPromise', | 113 'Promise': 'ScriptPromise', |
| 114 'ScriptValue': 'ScriptValue', | 114 'ScriptValue': 'ScriptValue', |
| 115 # FIXME: Eliminate custom bindings for XPathNSResolver http://crbug.com/345 529 | 115 # FIXME: Eliminate custom bindings for XPathNSResolver http://crbug.com/345 529 |
| 116 'XPathNSResolver': 'RefPtrWillBeRawPtr<XPathNSResolver>', | 116 'XPathNSResolver': 'RefPtrWillBeRawPtr<XPathNSResolver>', |
| 117 'boolean': 'bool', | 117 'boolean': 'bool', |
| 118 'unrestricted double': 'double', | 118 'unrestricted double': 'double', |
| 119 'unrestricted float': 'float', | 119 'unrestricted float': 'float', |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 def cpp_type_initializer(idl_type): | |
| 124 """Returns a string containing a C++ initialization statement for the | |
| 125 corresponding type. | |
| 126 | |
| 127 |idl_type| argument is of type IdlType. | |
| 128 """ | |
| 129 | |
| 130 cpp_type = str(idl_type.cpp_type) | |
| 131 | |
| 132 if (idl_type.base_type in (CPP_TYPE_SAME_AS_IDL_TYPE | CPP_INT_TYPES | CPP_U NSIGNED_TYPES) or | |
| 133 cpp_type in ('float', 'double') or | |
|
haraken
2014/07/16 00:54:02
Can't we use idl_type.is_numeric_type() ?
Mostyn Bramley-Moore
2014/07/16 07:15:20
Done.
| |
| 134 cpp_type.endswith('*')): | |
|
haraken
2014/07/16 00:54:02
Can this happen?
Actually we don't want to mix id
Jens Widell
2014/07/16 07:00:53
This is copied from my patch (which is unpolished)
Mostyn Bramley-Moore
2014/07/16 07:15:20
Done.
| |
| 135 return ' = 0' | |
| 136 if cpp_type == 'bool': | |
|
haraken
2014/07/16 00:54:02
idl_type.base_type == 'boolean'
Mostyn Bramley-Moore
2014/07/16 07:15:20
Done.
| |
| 137 return ' = false' | |
| 138 if cpp_type == 'String': | |
| 139 return ' = ""' | |
|
haraken
2014/07/16 00:54:02
We shouldn't add this. A String should be initiali
Mostyn Bramley-Moore
2014/07/16 07:15:20
Done.
| |
| 140 return '' | |
| 141 | |
| 123 def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argumen t=False, used_as_variadic_argument=False, used_in_cpp_sequence=False): | 142 def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argumen t=False, used_as_variadic_argument=False, used_in_cpp_sequence=False): |
| 124 """Returns C++ type corresponding to IDL type. | 143 """Returns C++ type corresponding to IDL type. |
| 125 | 144 |
| 126 |idl_type| argument is of type IdlType, while return value is a string | 145 |idl_type| argument is of type IdlType, while return value is a string |
| 127 | 146 |
| 128 Args: | 147 Args: |
| 129 idl_type: | 148 idl_type: |
| 130 IdlType | 149 IdlType |
| 131 raw_type: | 150 raw_type: |
| 132 bool, True if idl_type's raw/primitive C++ type should be returned. | 151 bool, True if idl_type's raw/primitive C++ type should be returned. |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 | 760 |
| 742 def is_explicit_nullable(idl_type): | 761 def is_explicit_nullable(idl_type): |
| 743 # Nullable type that isn't implicit nullable (see above.) For such types, | 762 # Nullable type that isn't implicit nullable (see above.) For such types, |
| 744 # we use Nullable<T> or similar explicit ways to represent a null value. | 763 # we use Nullable<T> or similar explicit ways to represent a null value. |
| 745 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 764 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 746 | 765 |
| 747 IdlType.is_implicit_nullable = property(is_implicit_nullable) | 766 IdlType.is_implicit_nullable = property(is_implicit_nullable) |
| 748 IdlType.is_explicit_nullable = property(is_explicit_nullable) | 767 IdlType.is_explicit_nullable = property(is_explicit_nullable) |
| 749 IdlUnionType.is_implicit_nullable = False | 768 IdlUnionType.is_implicit_nullable = False |
| 750 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) | 769 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |