| 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 21 matching lines...) Expand all Loading... |
| 32 class methods. | 32 class methods. |
| 33 | 33 |
| 34 Spec: | 34 Spec: |
| 35 http://www.w3.org/TR/WebIDL/#es-type-mapping | 35 http://www.w3.org/TR/WebIDL/#es-type-mapping |
| 36 | 36 |
| 37 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 37 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
| 38 """ | 38 """ |
| 39 | 39 |
| 40 import posixpath | 40 import posixpath |
| 41 | 41 |
| 42 from idl_types import IdlType, IdlUnionType | 42 from idl_types import IdlTypeBase, IdlType, IdlUnionType |
| 43 import v8_attributes # for IdlType.constructor_type_name | 43 import v8_attributes # for IdlType.constructor_type_name |
| 44 from v8_globals import includes | 44 from v8_globals import includes |
| 45 | 45 |
| 46 | 46 |
| 47 ################################################################################ | 47 ################################################################################ |
| 48 # V8-specific handling of IDL types | 48 # V8-specific handling of IDL types |
| 49 ################################################################################ | 49 ################################################################################ |
| 50 | 50 |
| 51 NON_WRAPPER_TYPES = frozenset([ | 51 NON_WRAPPER_TYPES = frozenset([ |
| 52 'CompareHow', | 52 'CompareHow', |
| (...skipping 12 matching lines...) Expand all Loading... |
| 65 'Float64Array': ('double', 'v8::kExternalDoubleArray'), | 65 'Float64Array': ('double', 'v8::kExternalDoubleArray'), |
| 66 'Int8Array': ('signed char', 'v8::kExternalByteArray'), | 66 'Int8Array': ('signed char', 'v8::kExternalByteArray'), |
| 67 'Int16Array': ('short', 'v8::kExternalShortArray'), | 67 'Int16Array': ('short', 'v8::kExternalShortArray'), |
| 68 'Int32Array': ('int', 'v8::kExternalIntArray'), | 68 'Int32Array': ('int', 'v8::kExternalIntArray'), |
| 69 'Uint8Array': ('unsigned char', 'v8::kExternalUnsignedByteArray'), | 69 'Uint8Array': ('unsigned char', 'v8::kExternalUnsignedByteArray'), |
| 70 'Uint8ClampedArray': ('unsigned char', 'v8::kExternalPixelArray'), | 70 'Uint8ClampedArray': ('unsigned char', 'v8::kExternalPixelArray'), |
| 71 'Uint16Array': ('unsigned short', 'v8::kExternalUnsignedShortArray'), | 71 'Uint16Array': ('unsigned short', 'v8::kExternalUnsignedShortArray'), |
| 72 'Uint32Array': ('unsigned int', 'v8::kExternalUnsignedIntArray'), | 72 'Uint32Array': ('unsigned int', 'v8::kExternalUnsignedIntArray'), |
| 73 } | 73 } |
| 74 | 74 |
| 75 IdlTypeBase.is_typed_array_element_type = False |
| 75 IdlType.is_typed_array_element_type = property( | 76 IdlType.is_typed_array_element_type = property( |
| 76 lambda self: self.base_type in TYPED_ARRAYS) | 77 lambda self: self.base_type in TYPED_ARRAYS) |
| 77 IdlUnionType.is_typed_array_element_type = False | |
| 78 | 78 |
| 79 | 79 |
| 80 IdlTypeBase.is_wrapper_type = False |
| 80 IdlType.is_wrapper_type = property( | 81 IdlType.is_wrapper_type = property( |
| 81 lambda self: (self.is_interface_type and | 82 lambda self: (self.is_interface_type and |
| 82 self.base_type not in NON_WRAPPER_TYPES)) | 83 self.base_type not in NON_WRAPPER_TYPES)) |
| 83 | 84 |
| 84 | 85 |
| 85 ################################################################################ | 86 ################################################################################ |
| 86 # C++ types | 87 # C++ types |
| 87 ################################################################################ | 88 ################################################################################ |
| 88 | 89 |
| 89 CPP_TYPE_SAME_AS_IDL_TYPE = set([ | 90 CPP_TYPE_SAME_AS_IDL_TYPE = set([ |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 212 |
| 212 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False): | 213 def cpp_type_union(idl_type, extended_attributes=None, raw_type=False): |
| 213 return (member_type.cpp_type for member_type in idl_type.member_types) | 214 return (member_type.cpp_type for member_type in idl_type.member_types) |
| 214 | 215 |
| 215 | 216 |
| 216 def cpp_type_initializer_union(idl_type): | 217 def cpp_type_initializer_union(idl_type): |
| 217 return (member_type.cpp_type_initializer for member_type in idl_type.member_
types) | 218 return (member_type.cpp_type_initializer for member_type in idl_type.member_
types) |
| 218 | 219 |
| 219 | 220 |
| 220 # Allow access as idl_type.cpp_type if no arguments | 221 # Allow access as idl_type.cpp_type if no arguments |
| 221 IdlType.cpp_type = property(cpp_type) | 222 IdlTypeBase.cpp_type = property(cpp_type) |
| 222 IdlType.cpp_type_initializer = property(cpp_type_initializer) | 223 IdlTypeBase.cpp_type_initializer = property(cpp_type_initializer) |
| 224 IdlTypeBase.cpp_type_args = cpp_type |
| 223 IdlUnionType.cpp_type = property(cpp_type_union) | 225 IdlUnionType.cpp_type = property(cpp_type_union) |
| 224 IdlUnionType.cpp_type_initializer = property(cpp_type_initializer_union) | 226 IdlUnionType.cpp_type_initializer = property(cpp_type_initializer_union) |
| 225 IdlType.cpp_type_args = cpp_type | |
| 226 IdlUnionType.cpp_type_args = cpp_type_union | 227 IdlUnionType.cpp_type_args = cpp_type_union |
| 227 | 228 |
| 228 | 229 |
| 229 def cpp_template_type(template, inner_type): | 230 def cpp_template_type(template, inner_type): |
| 230 """Returns C++ template specialized to type, with space added if needed.""" | 231 """Returns C++ template specialized to type, with space added if needed.""" |
| 231 if inner_type.endswith('>'): | 232 if inner_type.endswith('>'): |
| 232 format_string = '{template}<{inner_type} >' | 233 format_string = '{template}<{inner_type} >' |
| 233 else: | 234 else: |
| 234 format_string = '{template}<{inner_type}>' | 235 format_string = '{template}<{inner_type}>' |
| 235 return format_string.format(template=template, inner_type=inner_type) | 236 return format_string.format(template=template, inner_type=inner_type) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 IdlType.implemented_as = property(implemented_as) | 271 IdlType.implemented_as = property(implemented_as) |
| 271 | 272 |
| 272 IdlType.set_implemented_as_interfaces = classmethod( | 273 IdlType.set_implemented_as_interfaces = classmethod( |
| 273 lambda cls, new_implemented_as_interfaces: | 274 lambda cls, new_implemented_as_interfaces: |
| 274 cls.implemented_as_interfaces.update(new_implemented_as_interfaces)) | 275 cls.implemented_as_interfaces.update(new_implemented_as_interfaces)) |
| 275 | 276 |
| 276 | 277 |
| 277 # [GarbageCollected] | 278 # [GarbageCollected] |
| 278 IdlType.garbage_collected_types = set() | 279 IdlType.garbage_collected_types = set() |
| 279 | 280 |
| 281 IdlTypeBase.is_garbage_collected = False |
| 280 IdlType.is_garbage_collected = property( | 282 IdlType.is_garbage_collected = property( |
| 281 lambda self: self.base_type in IdlType.garbage_collected_types) | 283 lambda self: self.base_type in IdlType.garbage_collected_types) |
| 282 | 284 |
| 283 IdlType.set_garbage_collected_types = classmethod( | 285 IdlType.set_garbage_collected_types = classmethod( |
| 284 lambda cls, new_garbage_collected_types: | 286 lambda cls, new_garbage_collected_types: |
| 285 cls.garbage_collected_types.update(new_garbage_collected_types)) | 287 cls.garbage_collected_types.update(new_garbage_collected_types)) |
| 286 | 288 |
| 287 | 289 |
| 288 # [WillBeGarbageCollected] | 290 # [WillBeGarbageCollected] |
| 289 IdlType.will_be_garbage_collected_types = set() | 291 IdlType.will_be_garbage_collected_types = set() |
| 290 | 292 |
| 293 IdlTypeBase.is_will_be_garbage_collected = False |
| 291 IdlType.is_will_be_garbage_collected = property( | 294 IdlType.is_will_be_garbage_collected = property( |
| 292 lambda self: self.base_type in IdlType.will_be_garbage_collected_types) | 295 lambda self: self.base_type in IdlType.will_be_garbage_collected_types) |
| 293 | 296 |
| 294 IdlType.set_will_be_garbage_collected_types = classmethod( | 297 IdlType.set_will_be_garbage_collected_types = classmethod( |
| 295 lambda cls, new_will_be_garbage_collected_types: | 298 lambda cls, new_will_be_garbage_collected_types: |
| 296 cls.will_be_garbage_collected_types.update(new_will_be_garbage_collected
_types)) | 299 cls.will_be_garbage_collected_types.update(new_will_be_garbage_collected
_types)) |
| 297 | 300 |
| 298 | 301 |
| 299 def gc_type(idl_type): | 302 def gc_type(idl_type): |
| 300 if idl_type.is_garbage_collected: | 303 if idl_type.is_garbage_collected: |
| 301 return 'GarbageCollectedObject' | 304 return 'GarbageCollectedObject' |
| 302 if idl_type.is_will_be_garbage_collected: | 305 if idl_type.is_will_be_garbage_collected: |
| 303 return 'WillBeGarbageCollectedObject' | 306 return 'WillBeGarbageCollectedObject' |
| 304 return 'RefCountedObject' | 307 return 'RefCountedObject' |
| 305 | 308 |
| 306 IdlType.gc_type = property(gc_type) | 309 IdlTypeBase.gc_type = property(gc_type) |
| 307 | 310 |
| 308 | 311 |
| 309 ################################################################################ | 312 ################################################################################ |
| 310 # Includes | 313 # Includes |
| 311 ################################################################################ | 314 ################################################################################ |
| 312 | 315 |
| 313 def includes_for_cpp_class(class_name, relative_dir_posix): | 316 def includes_for_cpp_class(class_name, relative_dir_posix): |
| 314 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h'
)]) | 317 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h'
)]) |
| 315 | 318 |
| 316 | 319 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 | 377 |
| 375 IdlType.includes_for_type = property(includes_for_type) | 378 IdlType.includes_for_type = property(includes_for_type) |
| 376 IdlUnionType.includes_for_type = property( | 379 IdlUnionType.includes_for_type = property( |
| 377 lambda self: set.union(*[includes_for_type(member_type) | 380 lambda self: set.union(*[includes_for_type(member_type) |
| 378 for member_type in self.member_types])) | 381 for member_type in self.member_types])) |
| 379 | 382 |
| 380 | 383 |
| 381 def add_includes_for_type(idl_type): | 384 def add_includes_for_type(idl_type): |
| 382 includes.update(idl_type.includes_for_type) | 385 includes.update(idl_type.includes_for_type) |
| 383 | 386 |
| 384 IdlType.add_includes_for_type = add_includes_for_type | 387 IdlTypeBase.add_includes_for_type = add_includes_for_type |
| 385 IdlUnionType.add_includes_for_type = add_includes_for_type | |
| 386 | 388 |
| 387 | 389 |
| 388 def includes_for_interface(interface_name): | 390 def includes_for_interface(interface_name): |
| 389 return IdlType(interface_name).includes_for_type | 391 return IdlType(interface_name).includes_for_type |
| 390 | 392 |
| 391 | 393 |
| 392 def add_includes_for_interface(interface_name): | 394 def add_includes_for_interface(interface_name): |
| 393 includes.update(includes_for_interface(interface_name)) | 395 includes.update(includes_for_interface(interface_name)) |
| 394 | 396 |
| 395 | 397 |
| 396 def impl_should_use_nullable_container(idl_type): | 398 def impl_should_use_nullable_container(idl_type): |
| 397 return idl_type.native_array_element_type or idl_type.is_primitive_type | 399 return idl_type.native_array_element_type or idl_type.is_primitive_type |
| 398 | 400 |
| 399 IdlType.impl_should_use_nullable_container = property( | 401 IdlTypeBase.impl_should_use_nullable_container = property( |
| 400 impl_should_use_nullable_container) | 402 impl_should_use_nullable_container) |
| 401 | 403 |
| 402 | 404 |
| 403 def impl_includes_for_type(idl_type, interfaces_info): | 405 def impl_includes_for_type(idl_type, interfaces_info): |
| 404 includes_for_type = set() | 406 includes_for_type = set() |
| 405 if idl_type.impl_should_use_nullable_container: | 407 if idl_type.impl_should_use_nullable_container: |
| 406 includes_for_type.add('bindings/core/v8/Nullable.h') | 408 includes_for_type.add('bindings/core/v8/Nullable.h') |
| 407 | 409 |
| 408 idl_type = idl_type.preprocessed_type | 410 idl_type = idl_type.preprocessed_type |
| 409 native_array_element_type = idl_type.native_array_element_type | 411 native_array_element_type = idl_type.native_array_element_type |
| 410 if native_array_element_type: | 412 if native_array_element_type: |
| 411 includes_for_type.update(impl_includes_for_type( | 413 includes_for_type.update(impl_includes_for_type( |
| 412 native_array_element_type, interfaces_info)) | 414 native_array_element_type, interfaces_info)) |
| 413 includes_for_type.add('wtf/Vector.h') | 415 includes_for_type.add('wtf/Vector.h') |
| 414 | 416 |
| 415 if idl_type.is_string_type: | 417 if idl_type.is_string_type: |
| 416 includes_for_type.add('wtf/text/WTFString.h') | 418 includes_for_type.add('wtf/text/WTFString.h') |
| 417 if idl_type.name in interfaces_info: | 419 if idl_type.name in interfaces_info: |
| 418 interface_info = interfaces_info[idl_type.name] | 420 interface_info = interfaces_info[idl_type.name] |
| 419 includes_for_type.add(interface_info['include_path']) | 421 includes_for_type.add(interface_info['include_path']) |
| 420 return includes_for_type | 422 return includes_for_type |
| 421 | 423 |
| 422 IdlType.impl_includes_for_type = impl_includes_for_type | 424 IdlTypeBase.impl_includes_for_type = impl_includes_for_type |
| 423 | 425 |
| 424 | 426 |
| 425 component_dir = {} | 427 component_dir = {} |
| 426 | 428 |
| 427 | 429 |
| 428 def set_component_dirs(new_component_dirs): | 430 def set_component_dirs(new_component_dirs): |
| 429 component_dir.update(new_component_dirs) | 431 component_dir.update(new_component_dirs) |
| 430 | 432 |
| 431 | 433 |
| 432 ################################################################################ | 434 ################################################################################ |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 if macro == 'TONATIVE_VOID_EXCEPTIONSTATE': | 558 if macro == 'TONATIVE_VOID_EXCEPTIONSTATE': |
| 557 args.append('ScriptState::current(%s)' % isolate) | 559 args.append('ScriptState::current(%s)' % isolate) |
| 558 | 560 |
| 559 if declare_variable: | 561 if declare_variable: |
| 560 args.insert(0, this_cpp_type) | 562 args.insert(0, this_cpp_type) |
| 561 else: | 563 else: |
| 562 suffix += '_INTERNAL' | 564 suffix += '_INTERNAL' |
| 563 | 565 |
| 564 return '%s(%s)' % (macro + suffix, ', '.join(args)) | 566 return '%s(%s)' % (macro + suffix, ', '.join(args)) |
| 565 | 567 |
| 566 | 568 IdlTypeBase.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value |
| 567 IdlType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | |
| 568 IdlUnionType.v8_value_to_local_cpp_value = v8_value_to_local_cpp_value | |
| 569 | 569 |
| 570 | 570 |
| 571 ################################################################################ | 571 ################################################################################ |
| 572 # C++ -> V8 | 572 # C++ -> V8 |
| 573 ################################################################################ | 573 ################################################################################ |
| 574 | 574 |
| 575 def preprocess_idl_type(idl_type): | 575 def preprocess_idl_type(idl_type): |
| 576 if idl_type.is_enum: | 576 if idl_type.is_enum: |
| 577 # Enumerations are internally DOMStrings | 577 # Enumerations are internally DOMStrings |
| 578 return IdlType('DOMString') | 578 return IdlType('DOMString') |
| 579 if (idl_type.name == 'Any' or idl_type.is_callback_function): | 579 if (idl_type.name == 'Any' or idl_type.is_callback_function): |
| 580 return IdlType('ScriptValue') | 580 return IdlType('ScriptValue') |
| 581 return idl_type | 581 return idl_type |
| 582 | 582 |
| 583 IdlType.preprocessed_type = property(preprocess_idl_type) | 583 IdlTypeBase.preprocessed_type = property(preprocess_idl_type) |
| 584 IdlUnionType.preprocessed_type = property(preprocess_idl_type) | |
| 585 | 584 |
| 586 | 585 |
| 587 def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): | 586 def preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes): |
| 588 """Returns IDL type and value, with preliminary type conversions applied.""" | 587 """Returns IDL type and value, with preliminary type conversions applied.""" |
| 589 idl_type = idl_type.preprocessed_type | 588 idl_type = idl_type.preprocessed_type |
| 590 if idl_type.name == 'Promise': | 589 if idl_type.name == 'Promise': |
| 591 idl_type = IdlType('ScriptValue') | 590 idl_type = IdlType('ScriptValue') |
| 592 if idl_type.base_type in ['long long', 'unsigned long long']: | 591 if idl_type.base_type in ['long long', 'unsigned long long']: |
| 593 # long long and unsigned long long are not representable in ECMAScript; | 592 # long long and unsigned long long are not representable in ECMAScript; |
| 594 # we represent them as doubles. | 593 # we represent them as doubles. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 return base_idl_type | 643 return base_idl_type |
| 645 | 644 |
| 646 # Data type with potential additional includes | 645 # Data type with potential additional includes |
| 647 add_includes_for_type(idl_type) | 646 add_includes_for_type(idl_type) |
| 648 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt | 647 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt |
| 649 return base_idl_type | 648 return base_idl_type |
| 650 | 649 |
| 651 # Pointer type | 650 # Pointer type |
| 652 return 'DOMWrapper' | 651 return 'DOMWrapper' |
| 653 | 652 |
| 654 IdlType.v8_conversion_type = v8_conversion_type | 653 IdlTypeBase.v8_conversion_type = v8_conversion_type |
| 655 | 654 |
| 656 | 655 |
| 657 V8_SET_RETURN_VALUE = { | 656 V8_SET_RETURN_VALUE = { |
| 658 'boolean': 'v8SetReturnValueBool(info, {cpp_value})', | 657 'boolean': 'v8SetReturnValueBool(info, {cpp_value})', |
| 659 'int': 'v8SetReturnValueInt(info, {cpp_value})', | 658 'int': 'v8SetReturnValueInt(info, {cpp_value})', |
| 660 'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', | 659 'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', |
| 661 'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 660 'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
| 662 'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
, | 661 'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
, |
| 663 'ScalarValueString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsol
ate())', | 662 'ScalarValueString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsol
ate())', |
| 664 # [TreatReturnedNullStringAs] | 663 # [TreatReturnedNullStringAs] |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 | 719 |
| 721 return [ | 720 return [ |
| 722 member_type.v8_set_return_value(cpp_value + str(i), | 721 member_type.v8_set_return_value(cpp_value + str(i), |
| 723 extended_attributes, | 722 extended_attributes, |
| 724 script_wrappable, | 723 script_wrappable, |
| 725 release and release[i], | 724 release and release[i], |
| 726 for_main_world) | 725 for_main_world) |
| 727 for i, member_type in | 726 for i, member_type in |
| 728 enumerate(idl_type.member_types)] | 727 enumerate(idl_type.member_types)] |
| 729 | 728 |
| 730 IdlType.v8_set_return_value = v8_set_return_value | 729 IdlTypeBase.v8_set_return_value = v8_set_return_value |
| 731 IdlUnionType.v8_set_return_value = v8_set_return_value_union | 730 IdlUnionType.v8_set_return_value = v8_set_return_value_union |
| 732 | 731 |
| 733 IdlType.release = property(lambda self: self.is_interface_type) | 732 IdlType.release = property(lambda self: self.is_interface_type) |
| 734 IdlUnionType.release = property( | 733 IdlUnionType.release = property( |
| 735 lambda self: [member_type.is_interface_type | 734 lambda self: [member_type.is_interface_type |
| 736 for member_type in self.member_types]) | 735 for member_type in self.member_types]) |
| 737 | 736 |
| 738 | 737 |
| 739 CPP_VALUE_TO_V8_VALUE = { | 738 CPP_VALUE_TO_V8_VALUE = { |
| 740 # Built-in types | 739 # Built-in types |
| (...skipping 24 matching lines...) Expand all Loading... |
| 765 | 764 |
| 766 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='info.Holder()', extended_attributes=None): | 765 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea
tion_context='info.Holder()', extended_attributes=None): |
| 767 """Returns an expression that converts a C++ value to a V8 value.""" | 766 """Returns an expression that converts a C++ value to a V8 value.""" |
| 768 # the isolate parameter is needed for callback interfaces | 767 # the isolate parameter is needed for callback interfaces |
| 769 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) | 768 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext
ended_attributes) |
| 770 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) | 769 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) |
| 771 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] | 770 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] |
| 772 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) | 771 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat
ion_context=creation_context) |
| 773 return statement | 772 return statement |
| 774 | 773 |
| 775 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value | 774 IdlTypeBase.cpp_value_to_v8_value = cpp_value_to_v8_value |
| 776 | 775 |
| 777 | 776 |
| 778 def literal_cpp_value(idl_type, idl_literal): | 777 def literal_cpp_value(idl_type, idl_literal): |
| 779 """Converts an expression that is a valid C++ literal for this type.""" | 778 """Converts an expression that is a valid C++ literal for this type.""" |
| 780 # FIXME: add validation that idl_type and idl_literal are compatible | 779 # FIXME: add validation that idl_type and idl_literal are compatible |
| 781 literal_value = str(idl_literal) | 780 literal_value = str(idl_literal) |
| 782 if idl_type.base_type in CPP_UNSIGNED_TYPES: | 781 if idl_type.base_type in CPP_UNSIGNED_TYPES: |
| 783 return literal_value + 'u' | 782 return literal_value + 'u' |
| 784 return literal_value | 783 return literal_value |
| 785 | 784 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 800 return idl_type.is_nullable and ( | 799 return idl_type.is_nullable and ( |
| 801 (idl_type.is_string_type or idl_type.is_wrapper_type) and | 800 (idl_type.is_string_type or idl_type.is_wrapper_type) and |
| 802 not idl_type.native_array_element_type) | 801 not idl_type.native_array_element_type) |
| 803 | 802 |
| 804 | 803 |
| 805 def is_explicit_nullable(idl_type): | 804 def is_explicit_nullable(idl_type): |
| 806 # Nullable type that isn't implicit nullable (see above.) For such types, | 805 # Nullable type that isn't implicit nullable (see above.) For such types, |
| 807 # we use Nullable<T> or similar explicit ways to represent a null value. | 806 # we use Nullable<T> or similar explicit ways to represent a null value. |
| 808 return idl_type.is_nullable and not idl_type.is_implicit_nullable | 807 return idl_type.is_nullable and not idl_type.is_implicit_nullable |
| 809 | 808 |
| 810 IdlType.is_implicit_nullable = property(is_implicit_nullable) | 809 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |
| 811 IdlType.is_explicit_nullable = property(is_explicit_nullable) | |
| 812 IdlUnionType.is_implicit_nullable = False | 810 IdlUnionType.is_implicit_nullable = False |
| 813 IdlUnionType.is_explicit_nullable = property(is_explicit_nullable) | 811 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |
| OLD | NEW |