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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 | 392 |
| 393 def includes_for_interface(interface_name): | 393 def includes_for_interface(interface_name): |
| 394 return IdlType(interface_name).includes_for_type | 394 return IdlType(interface_name).includes_for_type |
| 395 | 395 |
| 396 | 396 |
| 397 def add_includes_for_interface(interface_name): | 397 def add_includes_for_interface(interface_name): |
| 398 includes.update(includes_for_interface(interface_name)) | 398 includes.update(includes_for_interface(interface_name)) |
| 399 | 399 |
| 400 | 400 |
| 401 def impl_should_use_nullable_container(idl_type): | 401 def impl_should_use_nullable_container(idl_type): |
| 402 if idl_type.name == 'Object': | |
| 403 # We use ScriptValue for Objects in dictionary impls. | |
| 404 return False | |
| 402 return not(idl_type.cpp_type_has_null_value) | 405 return not(idl_type.cpp_type_has_null_value) |
|
haraken
2014/09/24 04:08:56
Can't we make idl_type.cpp_type_has_null_value ret
bashi
2014/09/24 05:28:55
Done.
| |
| 403 | 406 |
| 404 IdlTypeBase.impl_should_use_nullable_container = property( | 407 IdlTypeBase.impl_should_use_nullable_container = property( |
| 405 impl_should_use_nullable_container) | 408 impl_should_use_nullable_container) |
| 406 | 409 |
| 407 | 410 |
| 408 def impl_includes_for_type(idl_type, interfaces_info): | 411 def impl_includes_for_type(idl_type, interfaces_info): |
| 409 includes_for_type = set() | 412 includes_for_type = set() |
| 410 if idl_type.impl_should_use_nullable_container: | 413 if idl_type.impl_should_use_nullable_container: |
| 411 includes_for_type.add('bindings/core/v8/Nullable.h') | 414 includes_for_type.add('bindings/core/v8/Nullable.h') |
| 412 | 415 |
| 413 idl_type = idl_type.preprocessed_type | 416 idl_type = idl_type.preprocessed_type |
| 414 native_array_element_type = idl_type.native_array_element_type | 417 native_array_element_type = idl_type.native_array_element_type |
| 415 if native_array_element_type: | 418 if native_array_element_type: |
| 416 includes_for_type.update(impl_includes_for_type( | 419 includes_for_type.update(impl_includes_for_type( |
| 417 native_array_element_type, interfaces_info)) | 420 native_array_element_type, interfaces_info)) |
| 418 includes_for_type.add('wtf/Vector.h') | 421 includes_for_type.add('wtf/Vector.h') |
| 419 | 422 |
| 423 base_idl_type = idl_type.base_type | |
| 420 if idl_type.is_string_type: | 424 if idl_type.is_string_type: |
| 421 includes_for_type.add('wtf/text/WTFString.h') | 425 includes_for_type.add('wtf/text/WTFString.h') |
| 422 if idl_type.base_type in interfaces_info: | 426 if base_idl_type in interfaces_info: |
| 423 interface_info = interfaces_info[idl_type.base_type] | 427 interface_info = interfaces_info[idl_type.base_type] |
| 424 includes_for_type.add(interface_info['include_path']) | 428 includes_for_type.add(interface_info['include_path']) |
| 429 if base_idl_type in INCLUDES_FOR_TYPE: | |
| 430 includes_for_type.update(INCLUDES_FOR_TYPE[base_idl_type]) | |
| 425 return includes_for_type | 431 return includes_for_type |
| 426 | 432 |
| 427 IdlTypeBase.impl_includes_for_type = impl_includes_for_type | 433 IdlTypeBase.impl_includes_for_type = impl_includes_for_type |
| 428 | 434 |
| 429 | 435 |
| 430 component_dir = {} | 436 component_dir = {} |
| 431 | 437 |
| 432 | 438 |
| 433 def set_component_dirs(new_component_dirs): | 439 def set_component_dirs(new_component_dirs): |
| 434 component_dir.update(new_component_dirs) | 440 component_dir.update(new_component_dirs) |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 | 601 |
| 596 | 602 |
| 597 ################################################################################ | 603 ################################################################################ |
| 598 # C++ -> V8 | 604 # C++ -> V8 |
| 599 ################################################################################ | 605 ################################################################################ |
| 600 | 606 |
| 601 def preprocess_idl_type(idl_type): | 607 def preprocess_idl_type(idl_type): |
| 602 if idl_type.is_enum: | 608 if idl_type.is_enum: |
| 603 # Enumerations are internally DOMStrings | 609 # Enumerations are internally DOMStrings |
| 604 return IdlType('DOMString') | 610 return IdlType('DOMString') |
| 605 if (idl_type.name == 'Any' or idl_type.is_callback_function): | 611 if (idl_type.name in ['Any', 'Object'] or idl_type.is_callback_function): |
| 606 return IdlType('ScriptValue') | 612 return IdlType('ScriptValue') |
| 607 return idl_type | 613 return idl_type |
| 608 | 614 |
| 609 IdlTypeBase.preprocessed_type = property(preprocess_idl_type) | 615 IdlTypeBase.preprocessed_type = property(preprocess_idl_type) |
| 610 | 616 |
| 611 | 617 |
| 612 def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): | 618 def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): |
| 613 """Returns IDL type and value, with preliminary type conversions applied.""" | 619 """Returns IDL type and value, with preliminary type conversions applied.""" |
| 614 idl_type = idl_type.preprocessed_type | 620 idl_type = idl_type.preprocessed_type |
| 615 if idl_type.name == 'Promise': | 621 if idl_type.name == 'Promise': |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 | 840 |
| 835 | 841 |
| 836 def is_explicit_nullable(idl_type): | 842 def is_explicit_nullable(idl_type): |
| 837 # Nullable type that isn't implicit nullable (see above.) For such types, | 843 # 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. | 844 # 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 | 845 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 840 | 846 |
| 841 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 847 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
| 842 IdlUnionType.is_implicit_nullable = False | 848 IdlUnionType.is_implicit_nullable = False |
| 843 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 849 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |