| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 ################################################################################ | 86 ################################################################################ |
| 87 # C++ types | 87 # C++ types |
| 88 ################################################################################ | 88 ################################################################################ |
| 89 | 89 |
| 90 CPP_TYPE_SAME_AS_IDL_TYPE = set([ | 90 CPP_TYPE_SAME_AS_IDL_TYPE = set([ |
| 91 'double', | 91 'double', |
| 92 'float', | 92 'float', |
| 93 'long long', | 93 'long long', |
| 94 'unsigned long long', | 94 'unsigned long long', |
| 95 'V8ObjectBuilder', |
| 95 ]) | 96 ]) |
| 96 CPP_INT_TYPES = set([ | 97 CPP_INT_TYPES = set([ |
| 97 'byte', | 98 'byte', |
| 98 'long', | 99 'long', |
| 99 'short', | 100 'short', |
| 100 ]) | 101 ]) |
| 101 CPP_UNSIGNED_TYPES = set([ | 102 CPP_UNSIGNED_TYPES = set([ |
| 102 'octet', | 103 'octet', |
| 103 'unsigned int', | 104 'unsigned int', |
| 104 'unsigned long', | 105 'unsigned long', |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 217 |
| 217 base_idl_type = idl_type.base_type | 218 base_idl_type = idl_type.base_type |
| 218 | 219 |
| 219 if idl_type.native_array_element_type: | 220 if idl_type.native_array_element_type: |
| 220 return '' | 221 return '' |
| 221 if idl_type.is_numeric_type: | 222 if idl_type.is_numeric_type: |
| 222 return ' = 0' | 223 return ' = 0' |
| 223 if base_idl_type == 'boolean': | 224 if base_idl_type == 'boolean': |
| 224 return ' = false' | 225 return ' = false' |
| 225 if (base_idl_type in NON_WRAPPER_TYPES or | 226 if (base_idl_type in NON_WRAPPER_TYPES or |
| 226 base_idl_type in CPP_SPECIAL_CONVERSION_RULES or | 227 base_idl_type in CPP_SPECIAL_CONVERSION_RULES or |
| 227 base_idl_type == 'any' or | 228 base_idl_type == 'any' or |
| 228 idl_type.is_string_type or | 229 idl_type.is_string_type or |
| 229 idl_type.is_enum): | 230 idl_type.is_enum or |
| 231 idl_type.is_dictionary or |
| 232 idl_type.is_union_type): |
| 230 return '' | 233 return '' |
| 234 if base_idl_type == 'V8ObjectBuilder': |
| 235 return '(info.GetIsolate())' |
| 231 return ' = nullptr' | 236 return ' = nullptr' |
| 232 | 237 |
| 233 | 238 |
| 234 # Allow access as idl_type.cpp_type if no arguments | 239 # Allow access as idl_type.cpp_type if no arguments |
| 235 IdlTypeBase.cpp_type = property(cpp_type) | 240 IdlTypeBase.cpp_type = property(cpp_type) |
| 236 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) | 241 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) |
| 237 IdlTypeBase.cpp_type_args = cpp_type | 242 IdlTypeBase.cpp_type_args = cpp_type |
| 238 IdlUnionType.cpp_type_initializer = '' | 243 IdlUnionType.cpp_type_initializer = '' |
| 239 | 244 |
| 240 | 245 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 'core/html/HTMLTableRowsCollection.h']), | 361 'core/html/HTMLTableRowsCollection.h']), |
| 357 'NodeList': set(['bindings/core/v8/V8NodeList.h', | 362 'NodeList': set(['bindings/core/v8/V8NodeList.h', |
| 358 'core/dom/NameNodeList.h', | 363 'core/dom/NameNodeList.h', |
| 359 'core/dom/NodeList.h', | 364 'core/dom/NodeList.h', |
| 360 'core/dom/StaticNodeList.h', | 365 'core/dom/StaticNodeList.h', |
| 361 'core/html/LabelsNodeList.h']), | 366 'core/html/LabelsNodeList.h']), |
| 362 'Promise': set(['bindings/core/v8/ScriptPromise.h']), | 367 'Promise': set(['bindings/core/v8/ScriptPromise.h']), |
| 363 'SerializedScriptValue': set(['bindings/core/v8/SerializedScriptValue.h', | 368 'SerializedScriptValue': set(['bindings/core/v8/SerializedScriptValue.h', |
| 364 'bindings/core/v8/SerializedScriptValueFactory
.h']), | 369 'bindings/core/v8/SerializedScriptValueFactory
.h']), |
| 365 'ScriptValue': set(['bindings/core/v8/ScriptValue.h']), | 370 'ScriptValue': set(['bindings/core/v8/ScriptValue.h']), |
| 371 'V8ObjectBuilder': set(['bindings/core/v8/V8ObjectBuilder.h']), |
| 366 } | 372 } |
| 367 | 373 |
| 368 | 374 |
| 369 def includes_for_type(idl_type): | 375 def includes_for_type(idl_type): |
| 370 idl_type = idl_type.preprocessed_type | 376 idl_type = idl_type.preprocessed_type |
| 371 | 377 |
| 372 # Simple types | 378 # Simple types |
| 373 base_idl_type = idl_type.base_type | 379 base_idl_type = idl_type.base_type |
| 374 if base_idl_type in INCLUDES_FOR_TYPE: | 380 if base_idl_type in INCLUDES_FOR_TYPE: |
| 375 return INCLUDES_FOR_TYPE[base_idl_type] | 381 return INCLUDES_FOR_TYPE[base_idl_type] |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 } | 660 } |
| 655 | 661 |
| 656 | 662 |
| 657 IdlTypeBase.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | 663 IdlTypeBase.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
| 658 | 664 |
| 659 | 665 |
| 660 def use_output_parameter_for_result(idl_type): | 666 def use_output_parameter_for_result(idl_type): |
| 661 """True when methods/getters which return the given idl_type should | 667 """True when methods/getters which return the given idl_type should |
| 662 take the output argument. | 668 take the output argument. |
| 663 """ | 669 """ |
| 664 return idl_type.is_dictionary or idl_type.is_union_type | 670 return idl_type.is_dictionary or idl_type.is_union_type or idl_type.base_typ
e == 'V8ObjectBuilder' |
| 665 | 671 |
| 666 IdlTypeBase.use_output_parameter_for_result = property(use_output_parameter_for_
result) | 672 IdlTypeBase.use_output_parameter_for_result = property(use_output_parameter_for_
result) |
| 667 | 673 |
| 668 | 674 |
| 669 ################################################################################ | 675 ################################################################################ |
| 670 # C++ -> V8 | 676 # C++ -> V8 |
| 671 ################################################################################ | 677 ################################################################################ |
| 672 | 678 |
| 673 def preprocess_idl_type(idl_type): | 679 def preprocess_idl_type(idl_type): |
| 674 if idl_type.is_nullable: | 680 if idl_type.is_nullable: |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 # DOMWrapper | 799 # DOMWrapper |
| 794 'DOMWrapperForMainWorld': 'v8SetReturnValueForMainWorld(info, WTF::getPtr({c
pp_value}))', | 800 'DOMWrapperForMainWorld': 'v8SetReturnValueForMainWorld(info, WTF::getPtr({c
pp_value}))', |
| 795 'DOMWrapperFast': 'v8SetReturnValueFast(info, WTF::getPtr({cpp_value}), {scr
ipt_wrappable})', | 801 'DOMWrapperFast': 'v8SetReturnValueFast(info, WTF::getPtr({cpp_value}), {scr
ipt_wrappable})', |
| 796 'DOMWrapperDefault': 'v8SetReturnValue(info, {cpp_value})', | 802 'DOMWrapperDefault': 'v8SetReturnValue(info, {cpp_value})', |
| 797 # Generic dictionary type | 803 # Generic dictionary type |
| 798 'Dictionary': 'v8SetReturnValue(info, {cpp_value})', | 804 'Dictionary': 'v8SetReturnValue(info, {cpp_value})', |
| 799 # Nullable dictionaries | 805 # Nullable dictionaries |
| 800 'NullableDictionary': 'v8SetReturnValue(info, result.get())', | 806 'NullableDictionary': 'v8SetReturnValue(info, result.get())', |
| 801 # Union types or dictionaries | 807 # Union types or dictionaries |
| 802 'DictionaryOrUnion': 'v8SetReturnValue(info, result)', | 808 'DictionaryOrUnion': 'v8SetReturnValue(info, result)', |
| 809 # Special container used for toJSON() resulting from serializer definitions. |
| 810 'V8ObjectBuilder': 'v8SetReturnValue(info, result.v8Value())', |
| 803 } | 811 } |
| 804 | 812 |
| 805 | 813 |
| 806 def v8_set_return_value(idl_type, cpp_value, extended_attributes=None, script_wr
appable='', release=False, for_main_world=False): | 814 def v8_set_return_value(idl_type, cpp_value, extended_attributes=None, script_wr
appable='', release=False, for_main_world=False): |
| 807 """Returns a statement that converts a C++ value to a V8 value and sets it a
s a return value. | 815 """Returns a statement that converts a C++ value to a V8 value and sets it a
s a return value. |
| 808 | 816 |
| 809 """ | 817 """ |
| 810 def dom_wrapper_conversion_type(): | 818 def dom_wrapper_conversion_type(): |
| 811 if not script_wrappable: | 819 if not script_wrappable: |
| 812 return 'DOMWrapperDefault' | 820 return 'DOMWrapperDefault' |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 number_of_nullable_member_types_union) | 977 number_of_nullable_member_types_union) |
| 970 | 978 |
| 971 | 979 |
| 972 def includes_nullable_type_union(idl_type): | 980 def includes_nullable_type_union(idl_type): |
| 973 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 981 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
| 974 return idl_type.number_of_nullable_member_types == 1 | 982 return idl_type.number_of_nullable_member_types == 1 |
| 975 | 983 |
| 976 IdlTypeBase.includes_nullable_type = False | 984 IdlTypeBase.includes_nullable_type = False |
| 977 IdlNullableType.includes_nullable_type = True | 985 IdlNullableType.includes_nullable_type = True |
| 978 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 986 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
| OLD | NEW |