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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 idl_type = IdlType('double', is_nullable=idl_type.is_nullable) | 532 idl_type = IdlType('double', is_nullable=idl_type.is_nullable) |
| 533 cpp_value = 'static_cast<double>(%s)' % cpp_value | 533 cpp_value = 'static_cast<double>(%s)' % cpp_value |
| 534 # HTML5 says that unsigned reflected attributes should be in the range | 534 # HTML5 says that unsigned reflected attributes should be in the range |
| 535 # [0, 2^31). When a value isn't in this range, a default value (or 0) | 535 # [0, 2^31). When a value isn't in this range, a default value (or 0) |
| 536 # should be returned instead. | 536 # should be returned instead. |
| 537 extended_attributes = extended_attributes or {} | 537 extended_attributes = extended_attributes or {} |
| 538 if ('Reflect' in extended_attributes and | 538 if ('Reflect' in extended_attributes and |
| 539 idl_type.base_type in ['unsigned long', 'unsigned short']): | 539 idl_type.base_type in ['unsigned long', 'unsigned short']): |
| 540 cpp_value = cpp_value.replace('getUnsignedIntegralAttribute', | 540 cpp_value = cpp_value.replace('getUnsignedIntegralAttribute', |
| 541 'getIntegralAttribute') | 541 'getIntegralAttribute') |
| 542 cpp_value = 'std::max(0, %s)' % cpp_value | 542 cpp_value = 'std::max(0, int(%s))' % cpp_value |
|
abarth-chromium
2014/07/14 06:04:35
static_cast<int>(...)
haraken
2014/07/14 09:59:12
Done.
| |
| 543 return idl_type, cpp_value | 543 return idl_type, cpp_value |
| 544 | 544 |
| 545 | 545 |
| 546 def v8_conversion_type(idl_type, extended_attributes): | 546 def v8_conversion_type(idl_type, extended_attributes): |
| 547 """Returns V8 conversion type, adding any additional includes. | 547 """Returns V8 conversion type, adding any additional includes. |
| 548 | 548 |
| 549 The V8 conversion type is used to select the C++ -> V8 conversion function | 549 The V8 conversion type is used to select the C++ -> V8 conversion function |
| 550 or v8SetReturnValue* function; it can be an idl_type, a cpp_type, or a | 550 or v8SetReturnValue* function; it can be an idl_type, a cpp_type, or a |
| 551 separate name for the type of conversion (e.g., 'DOMWrapper'). | 551 separate name for the type of conversion (e.g., 'DOMWrapper'). |
| 552 """ | 552 """ |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 | 741 |
| 742 def is_explicit_nullable(idl_type): | 742 def is_explicit_nullable(idl_type): |
| 743 # Nullable type that isn't implicit nullable (see above.) For such types, | 743 # 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. | 744 # 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 | 745 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 746 | 746 |
| 747 IdlType.is_implicit_nullable = property(is_implicit_nullable) | 747 IdlType.is_implicit_nullable = property(is_implicit_nullable) |
| 748 IdlType.is_explicit_nullable = property(is_explicit_nullable) | 748 IdlType.is_explicit_nullable = property(is_explicit_nullable) |
| 749 IdlUnionType.is_implicit_nullable = False | 749 IdlUnionType.is_implicit_nullable = False |
| 750 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) | 750 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |