| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 'Int16Array': ('short', 'v8::kExternalShortArray'), | 67 'Int16Array': ('short', 'v8::kExternalShortArray'), |
| 68 'Int32Array': ('int', 'v8::kExternalIntArray'), | 68 'Int32Array': ('int', 'v8::kExternalIntArray'), |
| 69 'Uint8Array': ('unsigned char', 'v8::kExternalUnsignedByteArray'), | 69 'Uint8Array': ('unsigned char', 'v8::kExternalUnsignedByteArray'), |
| 70 'Uint8ClampedArray': ('unsigned char', 'v8::kExternalPixelArray'), | 70 'Uint8ClampedArray': ('unsigned char', 'v8::kExternalPixelArray'), |
| 71 'Uint16Array': ('unsigned short', 'v8::kExternalUnsignedShortArray'), | 71 'Uint16Array': ('unsigned short', 'v8::kExternalUnsignedShortArray'), |
| 72 'Uint32Array': ('unsigned int', 'v8::kExternalUnsignedIntArray'), | 72 'Uint32Array': ('unsigned int', 'v8::kExternalUnsignedIntArray'), |
| 73 } | 73 } |
| 74 | 74 |
| 75 IdlType.is_typed_array_type = property( | 75 IdlType.is_typed_array_type = property( |
| 76 lambda self: self.base_type in TYPED_ARRAYS) | 76 lambda self: self.base_type in TYPED_ARRAYS) |
| 77 IdlUnionType.is_typed_array_type = False |
| 77 | 78 |
| 78 | 79 |
| 79 IdlType.is_wrapper_type = property( | 80 IdlType.is_wrapper_type = property( |
| 80 lambda self: (self.is_interface_type and | 81 lambda self: (self.is_interface_type and |
| 81 self.base_type not in NON_WRAPPER_TYPES)) | 82 self.base_type not in NON_WRAPPER_TYPES)) |
| 82 | 83 |
| 83 | 84 |
| 84 ################################################################################ | 85 ################################################################################ |
| 85 # C++ types | 86 # C++ types |
| 86 ################################################################################ | 87 ################################################################################ |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 implemented_as_class = idl_type.implemented_as | 185 implemented_as_class = idl_type.implemented_as |
| 185 if raw_type: | 186 if raw_type: |
| 186 return implemented_as_class + '*' | 187 return implemented_as_class + '*' |
| 187 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr' | 188 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr' |
| 188 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_argument else 'RefPtr')
, new_type, idl_type.gc_type) | 189 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_argument else 'RefPtr')
, new_type, idl_type.gc_type) |
| 189 return cpp_template_type(ptr_type, implemented_as_class) | 190 return cpp_template_type(ptr_type, implemented_as_class) |
| 190 # Default, assume native type is a pointer with same type name as idl type | 191 # Default, assume native type is a pointer with same type name as idl type |
| 191 return base_idl_type + '*' | 192 return base_idl_type + '*' |
| 192 | 193 |
| 193 | 194 |
| 194 def cpp_type_union(idl_type, extended_attributes=None): | 195 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False): |
| 195 return (member_type.cpp_type for member_type in idl_type.member_types) | 196 return (member_type.cpp_type for member_type in idl_type.member_types) |
| 196 | 197 |
| 197 | 198 |
| 198 # Allow access as idl_type.cpp_type if no arguments | 199 # Allow access as idl_type.cpp_type if no arguments |
| 199 IdlType.cpp_type = property(cpp_type) | 200 IdlType.cpp_type = property(cpp_type) |
| 200 IdlUnionType.cpp_type = property(cpp_type_union) | 201 IdlUnionType.cpp_type = property(cpp_type_union) |
| 201 IdlType.cpp_type_args = cpp_type | 202 IdlType.cpp_type_args = cpp_type |
| 202 IdlUnionType.cpp_type_args = cpp_type_union | 203 IdlUnionType.cpp_type_args = cpp_type_union |
| 203 | 204 |
| 204 | 205 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 | 701 |
| 701 def literal_cpp_value(idl_type, idl_literal): | 702 def literal_cpp_value(idl_type, idl_literal): |
| 702 """Converts an expression that is a valid C++ literal for this type.""" | 703 """Converts an expression that is a valid C++ literal for this type.""" |
| 703 # FIXME: add validation that idl_type and idl_literal are compatible | 704 # FIXME: add validation that idl_type and idl_literal are compatible |
| 704 literal_value = str(idl_literal) | 705 literal_value = str(idl_literal) |
| 705 if idl_type.base_type in CPP_UNSIGNED_TYPES: | 706 if idl_type.base_type in CPP_UNSIGNED_TYPES: |
| 706 return literal_value + 'u' | 707 return literal_value + 'u' |
| 707 return literal_value | 708 return literal_value |
| 708 | 709 |
| 709 IdlType.literal_cpp_value = literal_cpp_value | 710 IdlType.literal_cpp_value = literal_cpp_value |
| OLD | NEW |