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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 if idl_type.impl_should_use_nullable_container: | 410 if idl_type.impl_should_use_nullable_container: |
| 411 includes_for_type.add('bindings/core/v8/Nullable.h') | 411 includes_for_type.add('bindings/core/v8/Nullable.h') |
| 412 | 412 |
| 413 idl_type = idl_type.preprocessed_type | 413 idl_type = idl_type.preprocessed_type |
| 414 native_array_element_type = idl_type.native_array_element_type | 414 native_array_element_type = idl_type.native_array_element_type |
| 415 if native_array_element_type: | 415 if native_array_element_type: |
| 416 includes_for_type.update(impl_includes_for_type( | 416 includes_for_type.update(impl_includes_for_type( |
| 417 native_array_element_type, interfaces_info)) | 417 native_array_element_type, interfaces_info)) |
| 418 includes_for_type.add('wtf/Vector.h') | 418 includes_for_type.add('wtf/Vector.h') |
| 419 | 419 |
| 420 base_idl_type = idl_type.base_type | |
| 420 if idl_type.is_string_type: | 421 if idl_type.is_string_type: |
| 421 includes_for_type.add('wtf/text/WTFString.h') | 422 includes_for_type.add('wtf/text/WTFString.h') |
| 422 if idl_type.base_type in interfaces_info: | 423 if base_idl_type in interfaces_info: |
| 423 interface_info = interfaces_info[idl_type.base_type] | 424 interface_info = interfaces_info[idl_type.base_type] |
| 424 includes_for_type.add(interface_info['include_path']) | 425 includes_for_type.add(interface_info['include_path']) |
| 426 if base_idl_type in INCLUDES_FOR_TYPE: | |
| 427 includes_for_type.update(INCLUDES_FOR_TYPE[base_idl_type]) | |
| 425 return includes_for_type | 428 return includes_for_type |
| 426 | 429 |
| 427 IdlTypeBase.impl_includes_for_type = impl_includes_for_type | 430 IdlTypeBase.impl_includes_for_type = impl_includes_for_type |
| 428 | 431 |
| 429 | 432 |
| 430 component_dir = {} | 433 component_dir = {} |
| 431 | 434 |
| 432 | 435 |
| 433 def set_component_dirs(new_component_dirs): | 436 def set_component_dirs(new_component_dirs): |
| 434 component_dir.update(new_component_dirs) | 437 component_dir.update(new_component_dirs) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 | 598 |
| 596 | 599 |
| 597 ################################################################################ | 600 ################################################################################ |
| 598 # C++ -> V8 | 601 # C++ -> V8 |
| 599 ################################################################################ | 602 ################################################################################ |
| 600 | 603 |
| 601 def preprocess_idl_type(idl_type): | 604 def preprocess_idl_type(idl_type): |
| 602 if idl_type.is_enum: | 605 if idl_type.is_enum: |
| 603 # Enumerations are internally DOMStrings | 606 # Enumerations are internally DOMStrings |
| 604 return IdlType('DOMString') | 607 return IdlType('DOMString') |
| 605 if (idl_type.name == 'Any' or idl_type.is_callback_function): | 608 if (idl_type.name in ['Any', 'Object'] or idl_type.is_callback_function): |
| 606 return IdlType('ScriptValue') | 609 return IdlType('ScriptValue') |
| 607 return idl_type | 610 return idl_type |
| 608 | 611 |
| 609 IdlTypeBase.preprocessed_type = property(preprocess_idl_type) | 612 IdlTypeBase.preprocessed_type = property(preprocess_idl_type) |
| 610 | 613 |
| 611 | 614 |
| 612 def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): | 615 def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): |
| 613 """Returns IDL type and value, with preliminary type conversions applied.""" | 616 """Returns IDL type and value, with preliminary type conversions applied.""" |
| 614 idl_type = idl_type.preprocessed_type | 617 idl_type = idl_type.preprocessed_type |
| 615 if idl_type.name == 'Promise': | 618 if idl_type.name == 'Promise': |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 | 818 |
| 816 | 819 |
| 817 def cpp_type_has_null_value(idl_type): | 820 def cpp_type_has_null_value(idl_type): |
| 818 # - String types (String/AtomicString) represent null as a null string, | 821 # - String types (String/AtomicString) represent null as a null string, |
| 819 # i.e. one for which String::isNull() returns true. | 822 # i.e. one for which String::isNull() returns true. |
| 820 # - Enum types, as they are implemented as Strings. | 823 # - Enum types, as they are implemented as Strings. |
| 821 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as | 824 # - Wrapper types (raw pointer or RefPtr/PassRefPtr) represent null as |
| 822 # a null pointer. | 825 # a null pointer. |
| 823 # - Dictionary types represent null as a null pointer. They are garbage | 826 # - Dictionary types represent null as a null pointer. They are garbage |
| 824 # collected so their type is raw pointer. | 827 # collected so their type is raw pointer. |
| 828 # - 'Object' type. We use ScriptValue for object type. | |
| 825 return (idl_type.is_string_type or idl_type.is_wrapper_type or | 829 return (idl_type.is_string_type or idl_type.is_wrapper_type or |
| 826 idl_type.is_enum or idl_type.is_dictionary) | 830 idl_type.is_enum or idl_type.is_dictionary or idl_type.name == 'Obje ct') |
|
Jens Widell
2014/09/24 05:48:58
For a nullable type, |idl_type.name| has a "OrNull
bashi
2014/09/24 07:19:30
Done. Thank you for pointing this out!
| |
| 827 | 831 |
| 828 IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value) | 832 IdlTypeBase.cpp_type_has_null_value = property(cpp_type_has_null_value) |
| 829 | 833 |
| 830 | 834 |
| 831 def is_implicit_nullable(idl_type): | 835 def is_implicit_nullable(idl_type): |
| 832 # Nullable type where the corresponding C++ type supports a null value. | 836 # Nullable type where the corresponding C++ type supports a null value. |
| 833 return idl_type.is_nullable and idl_type.cpp_type_has_null_value | 837 return idl_type.is_nullable and idl_type.cpp_type_has_null_value |
| 834 | 838 |
| 835 | 839 |
| 836 def is_explicit_nullable(idl_type): | 840 def is_explicit_nullable(idl_type): |
| 837 # Nullable type that isn't implicit nullable (see above.) For such types, | 841 # Nullable type that isn't implicit nullable (see above.) For such types, |
| 838 # we use Nullable<T> or similar explicit ways to represent a null value. | 842 # we use Nullable<T> or similar explicit ways to represent a null value. |
| 839 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 843 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 840 | 844 |
| 841 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 845 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
| 842 IdlUnionType.is_implicit_nullable = False | 846 IdlUnionType.is_implicit_nullable = False |
| 843 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 847 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |