5"""This module provides shared functionality for the system to generate
6dart:html APIs from the IDL database."""
9from generator
import AnalyzeOperation, ConstantOutputOrder, \
10 DartDomNameOfAttribute, FindMatchingAttribute, IsPureInterface, \
11 TypeOrNothing, ConvertToFuture, GetCallbackInfo
12from copy
import deepcopy
13from htmlrenamer
import convert_to_future_members, custom_html_constructors, \
14 GetDDC_Extension, keep_overloaded_members, overloaded_and_renamed,\
15 private_html_members, renamed_html_members, renamed_overloads, \
17from generator
import TypeOrVar
19from mdnreader
import MDNReader
23_logger = logging.getLogger(
'htmldartgenerator')
30 'Window':
'WindowBase',
31 'Location':
'LocationBase',
32 'History':
'HistoryBase',
42 def __init__(self, interface, options, dart_use_blink, logger):
53 _logger.setLevel(logger.level)
56 if self.HasSupportCheck():
57 check = self.GetSupportCheck()
58 if type(check) != tuple:
59 signature =
'get supported'
65 ' /// Checks if this type is supported on the current platform.\n'
66 ' static bool $SIGNATURE => $SUPPORT_CHECK;\n',
72 "EventTarget.removeEventListener, EventTarget.dispatchEvent')"
74 "\n $TYPE get on =>\n new $TYPE(this);\n",
75 TYPE=events_class_name)
77 def AddMembers(self, interface, declare_only=False, dart_js_interop=False):
78 if self.
_interface.id ==
'WebGLRenderingContextBase' or self.
_interface.id ==
'WebGL2RenderingContextBase' or \
82 self._gl_constants.extend(interface.constants)
84 for const
in sorted(interface.constants, key=ConstantOutputOrder):
87 for attr
in sorted(interface.attributes, key=ConstantOutputOrder):
88 if attr.type.id !=
'EventHandler' and attr.type.id !=
'EventListener':
94 requires_indexer =
False
103 if parent_type_info.list_item_type():
104 self.AmendIndexer(parent_type_info.list_item_type())
112 operationsByName, interface)
115 for id
in sorted(operationsByName.keys()):
116 operations = operationsByName[id]
117 info = AnalyzeOperation(interface, operations)
119 if (
'%s.%s' % (interface.id,
120 info.declared_name)
in convert_to_future_members):
124 secondary_parents = self.
_database.TransitiveSecondaryParents(
126 remove_duplicate_parents = list(set(secondary_parents))
127 if len(secondary_parents) != len(remove_duplicate_parents):
128 secondary_parents = remove_duplicate_parents
129 parent_list =
", ".join(
130 [
" %s" % (parent.id)
for parent
in secondary_parents])
131 _logger.warn(
'Interface %s has duplicate parent interfaces %s - ' \
132 'ignoring duplicates. Please file a bug with the dart:html team.' % (interface.id, parent_list))
134 for parent_interface
in sorted(secondary_parents,
135 key=ConstantOutputOrder):
136 if isinstance(parent_interface, str):
139 for attr
in sorted(parent_interface.attributes,
140 key=ConstantOutputOrder):
141 if not FindMatchingAttribute(interface, attr):
142 if attr.type.id !=
'EventHandler':
143 self.SecondaryContext(parent_interface)
151 operationsByName, interface)
154 for id
in sorted(operationsByName.keys()):
155 if not any(op.id == id
for op
in interface.operations):
156 operations = operationsByName[id]
157 info = AnalyzeOperation(interface, operations)
158 self.SecondaryContext(parent_interface)
163 if not interface.parents:
166 parent_name = interface.parents[0].type.id
167 parent = self.
_database.GetInterface(parent_name)
168 if parent == self.
_interface or parent == interface:
173 if (IsPureInterface(parent_name, self.
_database)):
175 for operation
in parent.operations:
176 if operation.id
in operationsByName:
177 operations = operationsByName[operation.id]
178 for existing_operation
in operations:
179 if existing_operation.SameSignatureAs(operation):
180 del operationsByName[operation.id]
183 """The IDL has a number of functions with the same name but that accept
184 different types. This is fine for JavaScript, but results in vague type
185 signatures for Dart. We rename some of these (by adding a new identical
186 operation with a different DartName), but leave the original version as
187 well in some cases."""
188 potential_added_operations = set()
191 operation.ext_attrs[
'DartName']
192 if 'DartName' in operation.ext_attrs
else ''
193 for operation
in interface.operations
196 added_operations = []
197 for operation
in interface.operations:
199 interface, operation)
200 if (full_operation_str
in renamed_overloads
and
201 renamed_overloads[full_operation_str]
not in already_renamed
203 if '%s.%s' % (interface.id,
204 operation.id)
in overloaded_and_renamed:
205 cloned_operation = deepcopy(operation)
206 cloned_operation.ext_attrs[
'DartName'] = renamed_overloads[
208 added_operations.append(cloned_operation)
210 dart_name = renamed_overloads[full_operation_str]
214 operation.ext_attrs[
'DartName'] = dart_name
215 potential_added_operations.add(operation.id)
218 interface.operations += added_operations
220 interface, operations_by_name)
223 interface, original_operations_by_name):
224 """For some cases we desire to keep the overloaded version in dart, for
225 simplicity of API, and explain the parameters accepted in documentation."""
227 for operation_id
in potential_added_operations:
228 if (operation_id
not in updated_operations_by_name
and '%s.%s' %
229 (interface.id, operation_id)
in keep_overloaded_members):
230 for operation
in original_operations_by_name[operation_id]:
231 cloned_operation = deepcopy(operation)
232 cloned_operation.ext_attrs[
'DartName'] = operation_id
233 interface.operations.append(cloned_operation)
237 """Make sure that there is now at most one operation with a particular
238 operation.id. If not, stop library generation, and throw an error, requiring
239 programmer input about the best name change before proceeding."""
240 operation_str =
'%s.%s' % (interface.id, operation.id)
242 if (operation.id
in operations_by_name
and
243 len(operations_by_name[operation.id]) > 1
and len(
246 lambda overload: overload.startswith(operation_str),
247 renamed_overloads.keys()))) == 0
and
248 operation_str
not in keep_overloaded_members
and
249 operation_str
not in overloaded_and_renamed
and
250 operation_str
not in renamed_html_members
and
251 operation_str
not in private_html_members
and
252 operation_str
not in removed_html_members
and
253 operation.id !=
'__getter__' and
254 operation.id !=
'__setter__' and operation.id !=
'__delete__'):
256 'Multiple type signatures for %s.%s. Please file a bug with'
257 ' the dart:html team to determine if one of these functions should be'
258 ' renamed.' % (interface.id, operation.id))
261 """Given an IDLOperation, return a object-independent representation of the
262 operations's signature."""
263 return '%s.%s(%s)' % (interface.id, operation.id,
', '.join(
264 [
'%s %s' % (arg.type.id, arg.id)
for arg
in operation.arguments]))
267 operationsByName = {}
268 for operation
in interface.operations:
269 name = operation.ext_attrs.get(
'DartName', operation.id)
270 operationsByName.setdefault(name, []).
append(operation)
271 return operationsByName
277 const_name = self.
_renamer.RenameMember(
286 annotations = self.
_metadata.GetFormattedMetadata(
291 '\n $(ANNOTATIONS)static const $TYPE$NAME = $VALUE;\n',
292 ANNOTATIONS=annotations,
295 VALUE=constant.value)
298 """ Adds an attribute to the generated class.
300 attribute - The attribute which is to be added.
301 declare_only- True if the attribute should be declared as an abstract
302 member and not include invocation code.
304 dom_name = DartDomNameOfAttribute(attribute)
310 html_setter_name = self.
_renamer.RenameMember(
311 self.
_interface.id, attribute, dom_name,
'set:')
312 read_only = (attribute.is_read_only
or
313 'Replaceable' in attribute.ext_attrs
or
314 not html_setter_name)
317 assert (
not html_setter_name
or attr_name == html_setter_name)
320 if attribute.type.id ==
'any':
321 attribute.type.nullable =
True
326 self.EmitAttribute(attribute, attr_name, read_only)
328 def AddOperation(self, info, declare_only=False, dart_js_interop=False):
331 if self.
_interface.id ==
"Window" and info.name ==
'__getter__':
332 info.operations[1].type = info.operations[0].type
333 """ Adds an operation to the generated class.
335 info - The operation info of the operation to be added.
336 declare_only- True if the operation should be declared as an abstract
337 member and not include invocation code.
343 method_name = self.
_renamer.RenameMember(
344 self.
_interface.id, info.operations[0], info.name,
'call:')
346 if info.name ==
'item':
348 self.EmitOperation(info,
'_item')
354 nullable=info.type_nullable),
357 self.EmitOperation(info, method_name, dart_js_interop)
368 can_omit_type_check=lambda type, pos:
False):
370 parameter_names = [p.name
for p
in info.param_infos]
371 number_of_required_in_dart = info.NumberOfRequiredInDart()
373 body_emitter = emitter.Emit(
'\n'
377 DECLARATION=declaration)
381 def GenerateCall(signature_index, argument_count, checks):
383 (stmts_emitter, call_emitter) = body_emitter.Emit(
384 ' if ($CHECKS) {\n$!STMTS$!CALL }\n',
386 CHECKS=
' && '.join(checks))
388 (stmts_emitter, call_emitter) = body_emitter.Emit(
389 '$!STMTS$!CALL', INDENT=
' ')
392 call_emitter = call_emitter.Emit(
393 '$(INDENT)$!CALL;\n$(INDENT)return;\n')
395 call_emitter = call_emitter.Emit(
'$(INDENT)return $!CALL;\n')
398 generate_call(stmts_emitter, call_emitter, version[0],
399 signature_index, argument_count)
401 def IsTypeChecking(interface_argument):
402 return 'LegacyInterfaceTypeChecking' in interface_argument.ext_attrs
or \
403 self.
_database.HasInterface(interface_argument.id)
405 def GenerateChecksAndCall(signature_index, argument_count):
407 typechecked_interface = IsTypeChecking(self.
_interface)
409 for i
in reversed(range(0, argument_count)):
410 argument = signatures[signature_index][i]
411 parameter_name = parameter_names[i]
415 if test_type
in [
'dynamic',
'Object']:
416 checks.append(
'%s != null' % parameter_name)
417 elif not can_omit_type_check(test_type, i):
418 typechecked = typechecked_interface
or IsTypeChecking(
421 (
'TreatNullAs' in argument.ext_attrs)
or \
422 (argument.default_value
is not None)
or \
423 (argument.default_value_is_null)
424 if argument.type.nullable
or converts_null
or not typechecked:
426 '(%s is %s || %s == null)' %
427 (parameter_name, test_type, parameter_name))
430 '(%s is %s)' % (parameter_name, test_type))
431 elif i >= number_of_required_in_dart
and not argument.type.nullable:
432 checks.append(
'%s != null' % parameter_name)
437 '%s == null' % name
for name
in parameter_names[argument_count:]
440 GenerateCall(signature_index, argument_count, checks)
443 if len(signatures) > 1:
445 for signature_index, signature
in enumerate(signatures):
446 for argument_position, argument
in enumerate(signature):
447 if argument.type.id !=
'ArrayBuffer':
449 candidates = enumerate(signatures[signature_index + 1:],
451 for candidate_index, candidate
in candidates:
452 if len(candidate) <= argument_position:
455 argument_position].type.id !=
'ArrayBufferView':
459 'Cannot deal with more than a single swap')
460 index_swaps[candidate_index] = signature_index
461 index_swaps[signature_index] = candidate_index
463 for signature_index
in range(len(signatures)):
464 signature_index = index_swaps.get(signature_index,
466 signature = signatures[signature_index]
467 for argument_position, argument
in enumerate(signature):
468 if is_optional(signature_index, argument):
469 GenerateChecksAndCall(signature_index,
471 GenerateChecksAndCall(signature_index, len(signature))
473 ' throw new ArgumentError("Incorrect number or type of arguments");'
476 signature = signatures[0]
477 argument_count = len(signature)
478 for argument_position, argument
in list(enumerate(signature))[::-1]:
479 if is_optional(0, argument):
480 check =
'%s != null' % parameter_names[argument_position]
488 GenerateCall(0, argument_count, [check])
489 argument_count = argument_position
490 GenerateCall(0, argument_count, [])
498 can_omit_type_check=lambda type, pos:
False):
500 def GenerateCall(stmts_emitter, call_emitter, version, signature_index,
502 generate_call(stmts_emitter, call_emitter, version,
503 operations[signature_index], argument_count)
505 def IsOptional(signature_index, argument):
506 return is_optional(argument)
511 info, [operation.arguments
for operation
in operations],
512 operations[0].type.id ==
'void', declaration, GenerateCall,
513 IsOptional, emitter, can_omit_type_check)
523 implements.append(
'List<%s>' % item_type)
533 mixins.append(
'ListMixin<%s>' % item_type)
534 mixins.append(
'ImmutableListMixin<%s>' % item_type)
539 factory_constructor_name, constructor_emitter):
540 """ Adds all of the constructors.
542 constructors - List of the constructors to be added.
543 factory_name - Name of the factory for this class.
544 factory_constructor_name - The name of the constructor on the
545 factory_name to call (calls an autogenerated FactoryProvider
547 constructor_emitter - Emitter used to emit constructors when generating
548 classes using the static extension pattern.
550 for constructor_info
in constructors:
552 factory_constructor_name, constructor_emitter)
555 factory_constructor_name, constructor_emitter):
557 if ((self.
_interface.id ==
'HTMLImageElement' or
560 not constructor_info.pure_dart_constructor):
563 if self.GenerateCustomFactory(constructor_info):
566 metadata = self.
_metadata.GetFormattedMetadata(
569 target_emitter = constructor_emitter
if constructor_emitter
else \
572 if not factory_constructor_name:
573 factory_constructor_name =
'_create'
574 factory_parameters = constructor_info.ParametersAsArgumentList()
576 factory_parameters =
', '.join(constructor_info.factory_parameters)
578 def InputType(type_name):
579 conversion = self._InputConversion(type_name,
580 constructor_info.declared_name)
582 return conversion.input_type
585 type_name)
if type_name
else 'dynamic'
587 if constructor_info.pure_dart_constructor:
589 has_optional = any(param_info.is_optional
590 for param_info
in constructor_info.param_infos)
591 factory_call = self.MakeFactoryCall(
592 factory_name, factory_constructor_name, factory_parameters,
597 'factory $CTOR($PARAMS) => '
600 PARAMS=constructor_info.ParametersAsDeclaration(InputType),
601 FACTORY_CALL=factory_call,
604 inits = target_emitter.Emit(
606 'factory $CONSTRUCTOR($PARAMS) {\n'
607 ' $CONSTRUCTOR e = $FACTORY_CALL;\n'
611 CONSTRUCTOR=constructor_info._ConstructorFullName(
614 FACTORY_CALL=factory_call,
615 PARAMS=constructor_info.ParametersAsDeclaration(InputType))
617 for index, param_info
in enumerate(
618 constructor_info.param_infos):
619 if param_info.is_optional:
621 ' if ($E != null) e.$E = $E;\n',
624 custom_factory_ctr = self.
_interface.id
in _custom_factories
626 constructor_full_name = constructor_info._ConstructorFullName(
633 factory_name = constructor_full_name
635 def GenerateCall(stmts_emitter, call_emitter, version,
636 signature_index, argument_count):
637 name = emitter.Format(
'_create_$VERSION', VERSION=version)
638 arguments = constructor_info.idl_args[
639 signature_index][:argument_count]
643 type_ids = [p.type.id
for p
in arguments]
645 self.DeriveNativeEntry(
"constructorCallback",
'Constructor', argument_count)
647 self.DeriveQualifiedBlinkName(self.
_interface.id,
649 args = constructor_info.ParametersAsArgumentList(
653 (factory_params, converted_arguments,
655 stmts_emitter, arguments, argument_count,
657 args =
', '.join(converted_arguments)
658 call_template =
'$FACTORY_NAME($FACTORY_PARAMS)'
660 qualified_name = emitter.Format(
661 '$FACTORY.$NAME', FACTORY=factory_name, NAME=name)
662 (factory_params, converted_arguments,
664 stmts_emitter, arguments, argument_count,
666 args =
', '.join(converted_arguments)
667 call_template =
'$FACTORY_NAME($FACTORY_PARAMS)'
670 FACTORY_NAME=qualified_name,
672 self.EmitStaticFactoryOverload(constructor_info, name,
673 arguments, constructor_emitter)
675 def IsOptional(signature_index, argument):
676 return self.IsConstructorArgumentOptional(argument)
678 entry_declaration = emitter.Format(
679 '$(METADATA)$FACTORY_KEYWORD $CTOR($PARAMS)',
680 FACTORY_KEYWORD=(
'factory' if not custom_factory_ctr
else
681 'static %s' % constructor_full_name),
682 CTOR=((
'' if not custom_factory_ctr
else '_factory') +
683 constructor_full_name),
685 PARAMS=constructor_info.ParametersAsDeclaration(InputType))
687 overload_declaration = entry_declaration
690 constructor_info.idl_args,
False,
691 overload_declaration, GenerateCall,
692 IsOptional, target_emitter)
695 """Given a API function that uses callbacks, convert it to using Futures.
697 This conversion assumes the success callback is always provided before the
698 error callback (and so far in the DOM API, this is the case)."""
699 callback_info = GetCallbackInfo(
700 self.
_database.GetInterface(info.callback_args[0].type_id))
703 ignore_named_parameters =
True if html_name.startswith(
'_')
else False
709 if len(info.callback_args) > 1:
710 error_callback_info = GetCallbackInfo(
711 self.
_database.GetInterface(info.callback_args[1].type_id))
712 error_callbackNames = []
713 for paramInfo
in error_callback_info.param_infos:
714 error_callbackNames.append(paramInfo.name)
715 errorCallbackVariables =
", ".join(error_callbackNames)
716 errorName = error_callback_info.param_infos[-1].name
718 ',\n %s(%s) { completer.completeError(%s); }' % (
719 (
'%s : ' % info.callback_args[1].name
720 if info.requires_named_arguments
and
721 info.callback_args[1].is_optional
and
722 not (ignore_named_parameters)
else ''),
723 errorCallbackVariables, errorName))
725 extensions = GetDDC_Extension(self.
_interface, info.declared_name)
727 ddc_extensions =
"\n".join(extensions)
735 callbackArgsLen = len(callback_info.param_infos)
737 callbackVariables =
''
738 completerVariable =
''
739 if callbackArgsLen == 1:
740 callbackVariables =
'value'
741 completerVariable = callbackVariables
742 if callback_info.param_infos[0].type_id:
744 callback_info.param_infos[0].type_id)
745 elif callbackArgsLen > 1:
747 for paramInfo
in callback_info.param_infos:
748 callbackNames.append(paramInfo.name)
749 callbackVariables =
",".join(callbackNames)
750 completerVariable = callbackNames[-1]
752 callback_info.param_infos[-1].type_id)
754 param_list = info.ParametersAsArgumentList(
None,
755 ignore_named_parameters)
756 dictionary_argument = info.dictionaryArgumentName()
759 if dictionary_argument
is not None:
760 mapArg = dictionary_argument[0]
761 tempVariable =
'%s_dict' % mapArg
762 mapArgOptional = dictionary_argument[1]
765 if not (param_list.endswith(
', mapArg')
or
766 param_list.endswith(
', options')
or
767 param_list == mapArg):
769 "ERROR: %s.%s - Last parameter or only parameter %s is not of type Map"
771 param_list =
'%s_dict' % param_list
774 convert_map =
' var %s = null;\n'\
775 ' if (%s != null) {\n'\
776 ' %s = convertDartToNative_Dictionary(%s);\n'\
777 ' }\n' % (tempVariable, mapArg, tempVariable, mapArg)
779 convert_map =
' var %s = convertDartToNative_Dictionary(%s);\n' % (
780 tempVariable, mapArg)
783 if '_RenamingAnnotation' in dir(self):
785 self._RenamingAnnotation(info.declared_name, html_name) +
786 self._Metadata(info.type_name, info.declared_name,
None,
790 ' $METADATA$MODIFIERS$TYPE$FUTURE_GENERIC $NAME($PARAMS) {\n'
791 ' $CONVERT_DICTIONARY'
792 ' var completer = new Completer$(FUTURE_GENERIC)();\n'
793 ' $ORIGINAL_FUNCTION($PARAMS_LIST\n'
794 ' $NAMED_PARAM($VARIABLE_NAME) { '
796 'completer.complete($COMPLETER_NAME); }'
797 '$ERROR_CALLBACK);\n'
798 ' return completer.future;\n'
801 MODIFIERS=
'static ' if info.IsStatic()
else '',
803 nullable=info.type_nullable),
808 CONVERT_DICTIONARY=convert_map,
809 PARAMS_LIST=
'' if param_list ==
'' else param_list +
',',
810 NAMED_PARAM=(
'%s : ' % info.callback_args[0].name
811 if info.requires_named_arguments
and
812 info.callback_args[0].is_optional
and
813 not (ignore_named_parameters)
else ''),
814 VARIABLE_NAME=callbackVariables,
815 COMPLETER_NAME=completerVariable,
816 DDC_EXTENSION=ddc_extensions,
817 ERROR_CALLBACK=error_callback,
818 FUTURE_GENERIC=future_generic,
819 ORIGINAL_FUNCTION=html_name)
825 if self.
_interface.id
not in custom_html_constructors:
826 target_emitter = members_emitter
if members_emitter
else \
829 ' // To suppress missing implicit constructor warnings.\n'
830 ' factory $CLASSNAME._() { '
831 'throw new UnsupportedError("Not supported"); }\n',
835 """ Declares an attribute but does not include the code to invoke it.
844 template =
'\n $TYPE get $NAME;\n'
846 template =
'\n $TYPE get $NAME native;\n' \
847 '\n set $NAME($TYPE value) native;\n'
851 nullable = attribute.type.nullable
or not is_compat
856 attribute.type.id, nullable=nullable))
859 """ Declares an operation but does not include the code to invoke it.
861 operation - The operation to be declared.
862 return_type_name - The name of the return type.
863 method_name - The name of the method.
867 if (self.
_interface.id ==
'Element' and method_name ==
'click' and
871 template =
'\n $TYPE $NAME($PARAMS);\n'
875 TYPE=return_type_name,
882 template_file =
'immutable_list_mixin.darttemplate'
884 has_length_setter =
False
886 def _HasExplicitIndexedGetter(self):
887 return any(op.id ==
'getItem' for op
in self.
_interface.operations)
889 def _HasCustomIndexedGetter(self):
890 return 'CustomIndexedGetter' in self.
_interface.ext_attrs
892 def _HasNativeIndexedGetter(self):
893 return not (_HasCustomIndexedGetter(self)
or
894 _HasExplicitIndexedGetter(self))
896 if _HasExplicitIndexedGetter(self):
897 getter_name =
'getItem'
899 getter_name =
'_nativeIndexedGetter'
902 if attr.id ==
'length':
904 has_length_setter =
not attr.is_read_only
907 attr.id ==
'numberOfItems' for attr
in self.
_interface.attributes)
909 template = self._template_loader.Load(
911 'DEFINE_LENGTH_AS_NUM_ITEMS':
912 not has_length
and has_num_items,
913 'DEFINE_LENGTH_SETTER':
914 not has_length_setter,
915 'USE_NATIVE_INDEXED_GETTER':
916 _HasNativeIndexedGetter(self)
or
917 _HasExplicitIndexedGetter(self),
920 element_js = element_name +
"|Null"
923 element_js = element_name
925 template, E=element_name, EJS=element_js, GETTER=getter_name)
930 can_narrow_type=False,
932 """ Converts the type name to the secure type name for return types.
934 can_narrow_type - True if the output type can be narrowed further than
935 what would be accepted for input, used to narrow num APIs down to double
939 dart_name = type_name
942 dart_name = type_info.dart_type()
943 if can_narrow_type
and dart_name ==
'num':
944 dart_name = type_info.native_type()
948 assert (dart_name !=
'HistoryBase' and dart_name !=
'LocationBase')
949 if dart_name ==
'Window':
950 dart_name = _secure_base_types[dart_name]
951 if type_name ==
'any':
953 if nullable
and dart_name !=
'dynamic':
954 dart_name = dart_name +
'?'
958 if type_name
in _secure_base_types:
959 return _secure_base_types[type_name]
982 interface = self.
_database.GetInterface(argType)
983 if "Callback" in interface.ext_attrs:
984 return interface.ext_attrs[
'Callback']
990 converted_arguments = []
991 target_parameters = []
992 calling_parameters = []
993 for position, arg
in enumerate(arguments[:argument_count]):
996 if callBackInfo
is None:
997 conversion = self._InputConversion(arg.type.id,
1000 conversion = self._InputConversion(
'Callback',
1003 param_name = arguments[position].id
1005 temp_version[0] += 1
1006 temp_name =
'%s_%s' % (param_name, temp_version[0])
1007 temp_type = conversion.output_type
1008 null_assert_needed = info.param_infos[position].is_nullable \
1009 and not conversion.nullable_input
1011 '$(INDENT)$TYPE $NAME = $CONVERT($ARG$NULLASSERT);\n'
1012 if callBackInfo
is None else
1013 '$(INDENT)$TYPE $NAME = $CONVERT($ARG$NULLASSERT, $ARITY);\n',
1014 TYPE=TypeOrVar(temp_type),
1016 CONVERT=conversion.function_name,
1017 ARG=info.param_infos[position].name,
1018 NULLASSERT=
'!' if null_assert_needed
else '',
1020 converted_arguments.append(temp_name)
1021 param_type = temp_type
1022 verified_type = temp_type
1024 converted_arguments.append(info.param_infos[position].name)
1025 if self.
_database.HasTypeDef(arg.type.id):
1026 param_type =
'dynamic'
1032 info.param_infos[position].type_id, info)
1036 if param_type == verified_type:
1038 'String',
'num',
'int',
'double',
'bool',
1041 param_type =
'dynamic'
1042 arg_is_nullable = arg.type.nullable
1045 if (info.param_infos[position].is_optional
and
1046 (info.param_infos[position].default_value_is_null ==
True or
1047 info.param_infos[position].default_value ==
None)
1048 )
or info.param_infos[position].is_nullable:
1049 arg_is_nullable =
True
1050 target_parameters.append(
1051 '%s%s' % (TypeOrNothing(param_type, nullable=arg_is_nullable),
1053 calling_parameters.append(
',%s ' % param_name)
1055 return target_parameters, converted_arguments, calling_parameters
1058 conversion = self._InputConversion(type_name, info.declared_name)
1060 return conversion.input_type
1063 if self.
_database.HasTypeDef(type_name):
1067 type_name)
if type_name
else 'dynamic'
static bool is_compatible(const GrSurfaceCharacterization &gsc, const GrBackendTexture &backendTex)
_NarrowInputType(self, type_name)
AddSecondaryMembers(self, interface)
_GenerateDispatcherBody(self, info, operations, declaration, generate_call, is_optional, can_omit_type_check=lambda type, False pos)
DeclareOperation(self, operation, return_type_name, method_name)
AdditionalImplementedInterfaces(self)
_EnsureNoMultipleTypeSignatures(self, interface, operation, operations_by_name)
AddOperation(self, info, declare_only=False, dart_js_interop=False)
AddConstructors(self, constructors, factory_name, factory_constructor_name, constructor_emitter)
SecureOutputType(self, type_name, is_dart_type=False, can_narrow_type=False, nullable=False)
AddAttribute(self, attribute, declare_only=False)
_CallbackConvert(self, argType, info)
_AddDesiredOverloadedOperations(self, potential_added_operations, interface, original_operations_by_name)
AddConstant(self, constant)
_ConvertArgumentTypes(self, stmts_emitter, arguments, argument_count, info)
_RemoveShadowingOperationsWithSameSignature(self, operationsByName, interface)
_InputType(self, type_name, info)
OmitOperationOverrides(self)
SecureBaseName(self, type_name)
_TypeInfo(self, type_name)
_AddRenamedOverloads(self, interface)
_DartType(self, type_name)
_AddFutureifiedOperation(self, info, html_name)
EmitListMixin(self, element_name, nullable)
is_DOM_type(self, type_name)
AddMembers(self, interface, declare_only=False, dart_js_interop=False)
_AddConstructor(self, constructor_info, factory_name, factory_constructor_name, constructor_emitter)
_GetStringRepresentation(self, interface, operation)
_OperationsByName(self, interface)
EmitEventGetter(self, events_class_name)
_GenerateOverloadDispatcher(self, info, signatures, is_void, declaration, generate_call, is_optional, emitter, can_omit_type_check=lambda type, False pos)
DeclareAttribute(self, attribute, attr_name, read_only)
__init__(self, interface, options, dart_use_blink, logger)
_NarrowToImplementationType(self, type_name)
EmitHelpers(self, base_class, members_emitter)
static void append(char **dst, size_t *count, const char *src, size_t n)