| 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 add_includes_for_type(array_or_sequence_type) | 529 add_includes_for_type(array_or_sequence_type) |
| 530 return 'array' | 530 return 'array' |
| 531 | 531 |
| 532 # Simple types | 532 # Simple types |
| 533 base_idl_type = idl_type.base_type | 533 base_idl_type = idl_type.base_type |
| 534 # Basic types, without additional includes | 534 # Basic types, without additional includes |
| 535 if base_idl_type in CPP_INT_TYPES: | 535 if base_idl_type in CPP_INT_TYPES: |
| 536 return 'int' | 536 return 'int' |
| 537 if base_idl_type in CPP_UNSIGNED_TYPES: | 537 if base_idl_type in CPP_UNSIGNED_TYPES: |
| 538 return 'unsigned' | 538 return 'unsigned' |
| 539 if base_idl_type == 'DOMString': | 539 if base_idl_type in ('DOMString', 'ByteString'): |
| 540 if 'TreatReturnedNullStringAs' not in extended_attributes: | 540 if 'TreatReturnedNullStringAs' not in extended_attributes: |
| 541 return 'DOMString' | 541 return base_idl_type |
| 542 treat_returned_null_string_as = extended_attributes['TreatReturnedNullSt
ringAs'] | 542 treat_returned_null_string_as = extended_attributes['TreatReturnedNullSt
ringAs'] |
| 543 if treat_returned_null_string_as == 'Null': | 543 if treat_returned_null_string_as == 'Null': |
| 544 return 'StringOrNull' | 544 return 'StringOrNull' |
| 545 if treat_returned_null_string_as == 'Undefined': | 545 if treat_returned_null_string_as == 'Undefined': |
| 546 return 'StringOrUndefined' | 546 return 'StringOrUndefined' |
| 547 raise 'Unrecognized TreatReturnNullStringAs value: "%s"' % treat_returne
d_null_string_as | 547 raise 'Unrecognized TreatReturnNullStringAs value: "%s"' % treat_returne
d_null_string_as |
| 548 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': | 548 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': |
| 549 return base_idl_type | 549 return base_idl_type |
| 550 | 550 |
| 551 # Data type with potential additional includes | 551 # Data type with potential additional includes |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='info.Holder()', extended_attributes=None): | 666 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='info.Holder()', extended_attributes=None): |
| 667 """Returns an expression that converts a C++ value to a V8 value.""" | 667 """Returns an expression that converts a C++ value to a V8 value.""" |
| 668 # the isolate parameter is needed for callback interfaces | 668 # the isolate parameter is needed for callback interfaces |
| 669 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 669 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
| 670 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 670 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
| 671 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 671 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
| 672 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 672 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
| 673 return statement | 673 return statement |
| 674 | 674 |
| 675 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 675 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
| OLD | NEW |