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 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='info.Holder()', extended_attributes=None): | 687 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='info.Holder()', extended_attributes=None): |
688 """Returns an expression that converts a C++ value to a V8 value.""" | 688 """Returns an expression that converts a C++ value to a V8 value.""" |
689 # the isolate parameter is needed for callback interfaces | 689 # the isolate parameter is needed for callback interfaces |
690 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 690 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
691 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 691 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
692 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 692 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
693 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 693 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
694 return statement | 694 return statement |
695 | 695 |
696 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 696 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value |
| 697 |
| 698 |
| 699 def literal_cpp_value(idl_type, idl_literal): |
| 700 """Converts an expression that is a valid C++ literal for this type.""" |
| 701 # FIXME: add validation that idl_type and idl_literal are compatible |
| 702 literal_value = str(idl_literal) |
| 703 if idl_type.base_type in CPP_UNSIGNED_TYPES: |
| 704 return literal_value + 'u' |
| 705 return literal_value |
| 706 |
| 707 IdlType.literal_cpp_value = literal_cpp_value |
OLD | NEW |