Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: Source/bindings/scripts/v8_types.py

Issue 606653006: bindings: Adds DOMArrayBuffer, etc. as thin wrappers for ArrayBuffer, etc. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Synced. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 'Dictionary', 52 'Dictionary',
53 'EventHandler', 53 'EventHandler',
54 'EventListener', 54 'EventListener',
55 'NodeFilter', 55 'NodeFilter',
56 'SerializedScriptValue', 56 'SerializedScriptValue',
57 ]) 57 ])
58 TYPED_ARRAYS = { 58 TYPED_ARRAY_TYPES = frozenset([
59 # (cpp_type, v8_type), used by constructor templates 59 'Float32Array',
60 'ArrayBuffer': None, 60 'Float64Array',
61 'ArrayBufferView': None, 61 'Int8Array',
62 'Float32Array': ('float', 'v8::kExternalFloatArray'), 62 'Int16Array',
63 'Float64Array': ('double', 'v8::kExternalDoubleArray'), 63 'Int32Array',
64 'Int8Array': ('signed char', 'v8::kExternalByteArray'), 64 'Uint8Array',
65 'Int16Array': ('short', 'v8::kExternalShortArray'), 65 'Uint8ClampedArray',
66 'Int32Array': ('int', 'v8::kExternalIntArray'), 66 'Uint16Array',
67 'Uint8Array': ('unsigned char', 'v8::kExternalUnsignedByteArray'), 67 'Uint32Array',
68 'Uint8ClampedArray': ('unsigned char', 'v8::kExternalPixelArray'), 68 ])
69 'Uint16Array': ('unsigned short', 'v8::kExternalUnsignedShortArray'), 69 ARRAY_BUFFER_AND_VIEW_TYPES = TYPED_ARRAY_TYPES.union(frozenset([
70 'Uint32Array': ('unsigned int', 'v8::kExternalUnsignedIntArray'), 70 'ArrayBuffer',
71 } 71 'ArrayBufferView',
72 'DataView',
73 ]))
72 74
73 IdlType.is_typed_array_element_type = property( 75 IdlType.is_array_buffer_or_view = property(
74 lambda self: self.base_type in TYPED_ARRAYS) 76 lambda self: self.base_type in ARRAY_BUFFER_AND_VIEW_TYPES)
77
78 IdlType.is_typed_array = property(
79 lambda self: self.base_type in TYPED_ARRAY_TYPES)
75 80
76 IdlType.is_wrapper_type = property( 81 IdlType.is_wrapper_type = property(
77 lambda self: (self.is_interface_type and 82 lambda self: (self.is_interface_type and
78 self.base_type not in NON_WRAPPER_TYPES)) 83 self.base_type not in NON_WRAPPER_TYPES))
79 84
80 85
81 ################################################################################ 86 ################################################################################
82 # C++ types 87 # C++ types
83 ################################################################################ 88 ################################################################################
84 89
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if base_idl_type in CPP_SPECIAL_CONVERSION_RULES: 174 if base_idl_type in CPP_SPECIAL_CONVERSION_RULES:
170 return CPP_SPECIAL_CONVERSION_RULES[base_idl_type] 175 return CPP_SPECIAL_CONVERSION_RULES[base_idl_type]
171 176
172 if base_idl_type in NON_WRAPPER_TYPES: 177 if base_idl_type in NON_WRAPPER_TYPES:
173 return ('PassRefPtr<%s>' if used_as_rvalue_type else 'RefPtr<%s>') % bas e_idl_type 178 return ('PassRefPtr<%s>' if used_as_rvalue_type else 'RefPtr<%s>') % bas e_idl_type
174 if idl_type.is_string_type: 179 if idl_type.is_string_type:
175 if not raw_type: 180 if not raw_type:
176 return 'String' 181 return 'String'
177 return 'V8StringResource<%s>' % string_mode() 182 return 'V8StringResource<%s>' % string_mode()
178 183
179 if idl_type.is_typed_array_element_type and raw_type: 184 if idl_type.is_array_buffer_or_view and raw_type:
180 return base_idl_type + '*' 185 return idl_type.implemented_as + '*'
181 if idl_type.is_interface_type: 186 if idl_type.is_interface_type:
182 implemented_as_class = idl_type.implemented_as 187 implemented_as_class = idl_type.implemented_as
183 if raw_type: 188 if raw_type:
184 return implemented_as_class + '*' 189 return implemented_as_class + '*'
185 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr' 190 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr'
186 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_rvalue_type else 'RefPt r'), new_type, idl_type.gc_type) 191 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_rvalue_type else 'RefPt r'), new_type, idl_type.gc_type)
187 return cpp_template_type(ptr_type, implemented_as_class) 192 return cpp_template_type(ptr_type, implemented_as_class)
188 if idl_type.is_dictionary: 193 if idl_type.is_dictionary:
189 return base_idl_type 194 return base_idl_type
190 # Default, assume native type is a pointer with same type name as idl type 195 # Default, assume native type is a pointer with same type name as idl type
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 359
355 def includes_for_type(idl_type): 360 def includes_for_type(idl_type):
356 idl_type = idl_type.preprocessed_type 361 idl_type = idl_type.preprocessed_type
357 362
358 # Simple types 363 # Simple types
359 base_idl_type = idl_type.base_type 364 base_idl_type = idl_type.base_type
360 if base_idl_type in INCLUDES_FOR_TYPE: 365 if base_idl_type in INCLUDES_FOR_TYPE:
361 return INCLUDES_FOR_TYPE[base_idl_type] 366 return INCLUDES_FOR_TYPE[base_idl_type]
362 if idl_type.is_basic_type: 367 if idl_type.is_basic_type:
363 return set() 368 return set()
364 if idl_type.is_typed_array_element_type:
365 return set(['bindings/core/v8/custom/V8%sCustom.h' % base_idl_type])
366 if base_idl_type.endswith('ConstructorConstructor'): 369 if base_idl_type.endswith('ConstructorConstructor'):
367 # FIXME: rename to NamedConstructor 370 # FIXME: rename to NamedConstructor
368 # FIXME: replace with a [NamedConstructorAttribute] extended attribute 371 # FIXME: replace with a [NamedConstructorAttribute] extended attribute
369 # Ending with 'ConstructorConstructor' indicates a named constructor, 372 # Ending with 'ConstructorConstructor' indicates a named constructor,
370 # and these do not have header files, as they are part of the generated 373 # and these do not have header files, as they are part of the generated
371 # bindings for the interface 374 # bindings for the interface
372 return set() 375 return set()
373 if base_idl_type.endswith('Constructor'): 376 if base_idl_type.endswith('Constructor'):
374 # FIXME: replace with a [ConstructorAttribute] extended attribute 377 # FIXME: replace with a [ConstructorAttribute] extended attribute
375 base_idl_type = idl_type.constructor_type_name 378 base_idl_type = idl_type.constructor_type_name
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) 524 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState'])
522 elif 'Clamp' in extended_attributes: 525 elif 'Clamp' in extended_attributes:
523 arguments = ', '.join([v8_value, 'Clamp', 'exceptionState']) 526 arguments = ', '.join([v8_value, 'Clamp', 'exceptionState'])
524 elif idl_type.v8_conversion_needs_exception_state: 527 elif idl_type.v8_conversion_needs_exception_state:
525 arguments = ', '.join([v8_value, 'exceptionState']) 528 arguments = ', '.join([v8_value, 'exceptionState'])
526 else: 529 else:
527 arguments = v8_value 530 arguments = v8_value
528 531
529 if base_idl_type in V8_VALUE_TO_CPP_VALUE: 532 if base_idl_type in V8_VALUE_TO_CPP_VALUE:
530 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] 533 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type]
531 elif idl_type.is_typed_array_element_type: 534 elif idl_type.is_array_buffer_or_view:
532 cpp_expression_format = ( 535 cpp_expression_format = (
533 '{v8_value}->Is{idl_type}() ? ' 536 '{v8_value}->Is{idl_type}() ? '
534 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value})) : 0') 537 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value})) : 0')
535 elif idl_type.is_dictionary: 538 elif idl_type.is_dictionary:
536 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va riable_name}, exceptionState)' 539 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va riable_name}, exceptionState)'
537 elif needs_type_check: 540 elif needs_type_check:
538 cpp_expression_format = ( 541 cpp_expression_format = (
539 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})') 542 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})')
540 else: 543 else:
541 cpp_expression_format = ( 544 cpp_expression_format = (
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 879
877 880
878 def is_explicit_nullable(idl_type): 881 def is_explicit_nullable(idl_type):
879 # Nullable type that isn't implicit nullable (see above.) For such types, 882 # Nullable type that isn't implicit nullable (see above.) For such types,
880 # we use Nullable<T> or similar explicit ways to represent a null value. 883 # we use Nullable<T> or similar explicit ways to represent a null value.
881 return idl_type.is_nullable and not idl_type.is_implicit_nullable 884 return idl_type.is_nullable and not idl_type.is_implicit_nullable
882 885
883 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) 886 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable)
884 IdlUnionType.is_implicit_nullable = False 887 IdlUnionType.is_implicit_nullable = False
885 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) 888 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698