Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
scripts.systemnative.DartiumBackend Class Reference
Inheritance diagram for scripts.systemnative.DartiumBackend:
scripts.htmldartgenerator.HtmlDartGenerator

Public Member Functions

 __init__ (self, interface, cpp_library_emitter, options, loggerParent)
 
 ImplementsMergedMembers (self)
 
 CustomJSMembers (self)
 
 GenerateCallback (self, info)
 
 ImplementationTemplate (self)
 
 RootClassName (self)
 
 DeriveNativeEntry (self, name, kind, count)
 
 DeriveNativeName (self, name, suffix="")
 
 DeriveQualifiedBlinkName (self, interface_name, name)
 
 NativeSpec (self)
 
 StartInterface (self, members_emitter)
 
 GenerateCustomFactory (self, constructor_info)
 
 IsConstructorArgumentOptional (self, argument)
 
 MakeFactoryCall (self, factory, method, arguments, constructor_info)
 
 EmitStaticFactoryOverload (self, constructor_info, name, arguments)
 
 HasSupportCheck (self)
 
 GetSupportCheck (self)
 
 FinishInterface (self)
 
 EmitAttribute (self, attribute, html_name, read_only)
 
 AddIndexer (self, element_type, nullable)
 
 AmendIndexer (self, element_type)
 
 EmitOperation (self, info, html_name, dart_js_interop=False)
 
 SecondaryContext (self, interface)
 
- Public Member Functions inherited from scripts.htmldartgenerator.HtmlDartGenerator
 EmitSupportCheck (self)
 
 EmitEventGetter (self, events_class_name)
 
 AddMembers (self, interface, declare_only=False, dart_js_interop=False)
 
 AddSecondaryMembers (self, interface)
 
 OmitOperationOverrides (self)
 
 AddConstant (self, constant)
 
 AddAttribute (self, attribute, declare_only=False)
 
 AddOperation (self, info, declare_only=False, dart_js_interop=False)
 
 AdditionalImplementedInterfaces (self)
 
 Mixins (self)
 
 AddConstructors (self, constructors, factory_name, factory_constructor_name, constructor_emitter)
 
 EmitHelpers (self, base_class, members_emitter)
 
 DeclareAttribute (self, attribute, attr_name, read_only)
 
 DeclareOperation (self, operation, return_type_name, method_name)
 
 EmitListMixin (self, element_name, nullable)
 
 SecureOutputType (self, type_name, is_dart_type=False, can_narrow_type=False, nullable=False)
 
 SecureBaseName (self, type_name)
 
 is_DOM_type (self, type_name)
 

Protected Member Functions

 _OutputConversion (self, idl_type, member)
 
 _InputConversion (self, idl_type, member)
 
 _EmitConstructorInfrastructure (self, constructor_info, cpp_prefix, cpp_suffix, factory_method_name, arguments=None, emit_to_native=False, is_custom=False)
 
 _GenerateCPPHeader (self)
 
 _GenerateAutoSetupScope (self, idl_name, native_suffix)
 
 _AddGetter (self, attr, html_name, read_only)
 
 _AddSetter (self, attr, html_name)
 
 _HasNativeIndexGetter (self)
 
 _EmitNativeIndexGetter (self, element_type)
 
 _HasExplicitIndexedGetter (self)
 
 _EmitExplicitIndexedGetter (self, dart_element_type)
 
 _HasNativeIndexSetter (self)
 
 _EmitNativeIndexSetter (self, element_type)
 
 _ChangePrivateOpMapArgToAny (self, operations)
 
 _GenerateDispatcher (self, info, operations, dart_declaration, html_name)
 
 _GenerateOperationNativeCallback (self, operation, arguments, cpp_callback_name, auto_scope_setup=True)
 
 _GenerateNativeBinding (self, idl_name, argument_count, dart_declaration, static, return_type, parameters, native_suffix, is_custom, auto_scope_setup=True, emit_metadata=True, emit_to_native=False, native_entry=None, wrap_unwrap_list=[], dictionary_return=False, output_conversion=None)
 
 _GenerateWebCoreReflectionAttributeName (self, attr)
 
 _IsStatic (self, attribute_name)
 
 _GenerateWebCoreFunctionExpression (self, function_name, idl_node, cpp_callback_name=None)
 
 _IsArgumentOptionalInWebCore (self, operation, argument)
 
 _GenerateCPPIncludes (self, includes)
 
 _ToWebKitName (self, name)
 
- Protected Member Functions inherited from scripts.htmldartgenerator.HtmlDartGenerator
 _RemoveShadowingOperationsWithSameSignature (self, operationsByName, interface)
 
 _AddRenamedOverloads (self, interface)
 
 _AddDesiredOverloadedOperations (self, potential_added_operations, interface, original_operations_by_name)
 
 _EnsureNoMultipleTypeSignatures (self, interface, operation, operations_by_name)
 
 _GetStringRepresentation (self, interface, operation)
 
 _OperationsByName (self, interface)
 
 _GenerateOverloadDispatcher (self, info, signatures, is_void, declaration, generate_call, is_optional, emitter, can_omit_type_check=lambda type, False pos)
 
 _GenerateDispatcherBody (self, info, operations, declaration, generate_call, is_optional, can_omit_type_check=lambda type, False pos)
 
 _AddConstructor (self, constructor_info, factory_name, factory_constructor_name, constructor_emitter)
 
 _AddFutureifiedOperation (self, info, html_name)
 
 _NarrowToImplementationType (self, type_name)
 
 _NarrowInputType (self, type_name)
 
 _DartType (self, type_name)
 
 _TypeInfo (self, type_name)
 
 _CallbackConvert (self, argType, info)
 
 _ConvertArgumentTypes (self, stmts_emitter, arguments, argument_count, info)
 
 _InputType (self, type_name, info)
 

Protected Attributes

 _interface
 
 _cpp_library_emitter
 
 _database
 
 _template_loader
 
 _type_registry
 
 _interface_type_info
 
 _metadata
 
 _cpp_header_emitter
 
 _cpp_impl_emitter
 
 _members_emitter
 
 _cpp_declarations_emitter
 
 _cpp_impl_includes
 
 _cpp_definitions_emitter
 
 _cpp_resolver_emitter
 
 _dart_js_interop
 
 _library_name
 
 _dart_use_blink
 
- Protected Attributes inherited from scripts.htmldartgenerator.HtmlDartGenerator
 _dart_use_blink
 
 _database
 
 _interface
 
 _type_registry
 
 _interface_type_info
 
 _renamer
 
 _metadata
 
 _library_name
 
 _mdn_reader
 
 _DartType
 
 _members_emitter
 
 _dart_js_interop
 

Detailed Description

Generates Dart implementation for one DOM IDL interface.

Definition at line 88 of file systemnative.py.

Constructor & Destructor Documentation

◆ __init__()

scripts.systemnative.DartiumBackend.__init__ (   self,
  interface,
  cpp_library_emitter,
  options,
  loggerParent 
)

Reimplemented from scripts.htmldartgenerator.HtmlDartGenerator.

Definition at line 91 of file systemnative.py.

91 def __init__(self, interface, cpp_library_emitter, options, loggerParent):
92 super(DartiumBackend, self).__init__(interface, options, True,
93 loggerParent)
94
95 self._interface = interface
96 self._cpp_library_emitter = cpp_library_emitter
97 self._database = options.database
98 self._template_loader = options.templates
99 self._type_registry = options.type_registry
100 self._interface_type_info = self._type_registry.TypeInfo(
101 self._interface.id)
102 self._metadata = options.metadata
103 # These get initialized by StartInterface
104 self._cpp_header_emitter = None
105 self._cpp_impl_emitter = None
106 self._members_emitter = None
107 self._cpp_declarations_emitter = None
108 self._cpp_impl_includes = None
109 self._cpp_definitions_emitter = None
110 self._cpp_resolver_emitter = None
111 self._dart_js_interop = options.dart_js_interop
112 _logger.setLevel(loggerParent.level)
113

Member Function Documentation

◆ _AddGetter()

scripts.systemnative.DartiumBackend._AddGetter (   self,
  attr,
  html_name,
  read_only 
)
protected

Definition at line 558 of file systemnative.py.

558 def _AddGetter(self, attr, html_name, read_only):
559 # Temporary hack to force dart:scalarlist clamped array for ImageData.data.
560 # TODO(antonm): solve in principled way.
561 if self._interface.id == 'ImageData' and html_name == 'data':
562 html_name = '_data'
563 type_info = self._TypeInfo(attr.type.id)
564
565 return_type = self.SecureOutputType(
566 attr.type.id, False, False if self._dart_use_blink else True)
567 dictionary_returned = False
568 # Return type for dictionary is any (untyped).
569 if attr.type.id == 'Dictionary':
570 return_type = ''
571 dictionary_returned = True
572
573 parameters = []
574 dart_declaration = '%s get %s' % (return_type, html_name)
575 is_custom = _IsCustom(attr) and (_IsCustomValue(attr, None) or
576 _IsCustomValue(attr, 'Getter'))
577
578 # Operation uses blink?
579 wrap_unwrap_list = []
580 return_wrap_jso = False
581 if self._dart_use_blink:
582 # Unwrap the type to get the JsObject if Type is:
583 #
584 # - known IDL type
585 # - type_id is None then it's probably a union type or overloaded
586 # it's a dynamic/any type
587 # - type is Object
588 #
589 # JsObject maybe stored in the Dart class.
590 return_wrap_jso = wrap_return_type_blink(return_type, attr.type.id,
591 self._type_registry)
592 wrap_unwrap_list.append(return_wrap_jso) # wrap_jso the returned object
593 wrap_unwrap_list.append(self._dart_use_blink)
594
595 # This seems to have been replaced with Custom=Getter (see above), but
596 # check to be sure we don't see the old syntax
597 assert (not ('CustomGetter' in attr.ext_attrs))
598 native_suffix = 'Getter'
599 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix)
600 native_entry = \
601 self.DeriveNativeEntry(attr.id, 'Getter', None)
602 output_conversion = self._OutputConversion(attr.type.id, attr.id)
603
604 cpp_callback_name = self._GenerateNativeBinding(
605 attr.id,
606 1,
607 dart_declaration,
608 attr.is_static,
609 return_type,
610 parameters,
611 native_suffix,
612 is_custom,
613 auto_scope_setup,
614 native_entry=native_entry,
615 wrap_unwrap_list=wrap_unwrap_list,
616 dictionary_return=dictionary_returned,
617 output_conversion=output_conversion)
618 if is_custom:
619 return
620
621 if 'Reflect' in attr.ext_attrs:
622 webcore_function_name = self._TypeInfo(
623 attr.type.id).webcore_getter_name()
624 if 'URL' in attr.ext_attrs:
625 if 'NonEmpty' in attr.ext_attrs:
626 webcore_function_name = 'getNonEmptyURLAttribute'
627 else:
628 webcore_function_name = 'getURLAttribute'
629 elif 'ImplementedAs' in attr.ext_attrs:
630 webcore_function_name = attr.ext_attrs['ImplementedAs']
631 else:
632 if attr.id == 'operator':
633 webcore_function_name = '_operator'
634 elif attr.id == 'target' and attr.type.id == 'SVGAnimatedString':
635 webcore_function_name = 'svgTarget'
636 elif attr.id == 'CSS':
637 webcore_function_name = 'css'
638 else:
639 webcore_function_name = self._ToWebKitName(attr.id)
640
641 function_expression = self._GenerateWebCoreFunctionExpression(
642 webcore_function_name, attr)
643 raises = ('RaisesException' in attr.ext_attrs and
644 attr.ext_attrs['RaisesException'] != 'Setter')
645

◆ _AddSetter()

scripts.systemnative.DartiumBackend._AddSetter (   self,
  attr,
  html_name 
)
protected

Definition at line 646 of file systemnative.py.

646 def _AddSetter(self, attr, html_name):
647 return_type = 'void'
648 ptype = self._DartType(attr.type.id)
649
650 type_info = self._TypeInfo(attr.type.id)
651
652 # Is the setter value a DartClass (that has a JsObject) or the type is
653 # None (it's a dynamic/any type) then unwrap_jso before passing to blink.
654 parameters = ['value']
655
656 dart_declaration = 'set %s(%s value)' % (html_name, ptype)
657 is_custom = _IsCustom(attr) and (_IsCustomValue(attr, None) or
658 _IsCustomValue(attr, 'Setter'))
659 # This seems to have been replaced with Custom=Setter (see above), but
660 # check to be sure we don't see the old syntax
661 assert (not ('CustomSetter' in attr.ext_attrs))
662 assert (not ('V8CustomSetter' in attr.ext_attrs))
663 native_suffix = 'Setter'
664 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix)
665 native_entry = \
666 self.DeriveNativeEntry(attr.id, 'Setter', None)
667
668 # setters return no object and if blink this must be unwrapped.?
669 wrap_unwrap_list = [False, self._dart_use_blink]
670
671 cpp_callback_name = self._GenerateNativeBinding(
672 attr.id,
673 2,
674 dart_declaration,
675 attr.is_static,
676 return_type,
677 parameters,
678 native_suffix,
679 is_custom,
680 auto_scope_setup,
681 native_entry=native_entry,
682 wrap_unwrap_list=wrap_unwrap_list)
683 if is_custom:
684 return
685
686 if 'Reflect' in attr.ext_attrs:
687 webcore_function_name = self._TypeInfo(
688 attr.type.id).webcore_setter_name()
689 else:
690 if 'ImplementedAs' in attr.ext_attrs:
691 attr_name = attr.ext_attrs['ImplementedAs']
692 else:
693 attr_name = attr.id
694 webcore_function_name = re.sub(r'^(xml|css|(?=[A-Z])|\w)',
695 lambda s: s.group(1).upper(),
696 attr_name)
697 webcore_function_name = 'set%s' % webcore_function_name
698
699 function_expression = self._GenerateWebCoreFunctionExpression(
700 webcore_function_name, attr)
701 raises = ('RaisesException' in attr.ext_attrs and
702 attr.ext_attrs['RaisesException'] != 'Getter')
703

◆ _ChangePrivateOpMapArgToAny()

scripts.systemnative.DartiumBackend._ChangePrivateOpMapArgToAny (   self,
  operations 
)
protected

Definition at line 834 of file systemnative.py.

834 def _ChangePrivateOpMapArgToAny(self, operations):
835 # TODO(terry): Hack to map any operations marked as private to not
836 # handle converting Map to native (JsObject) the public
837 # members that call the private method will have done
838 # conversions.
839 for operation in operations:
840 for arg in operation.arguments:
841 type = arg.type
842 if type.id == 'Dictionary':
843 type.id = 'any'
844

◆ _EmitConstructorInfrastructure()

scripts.systemnative.DartiumBackend._EmitConstructorInfrastructure (   self,
  constructor_info,
  cpp_prefix,
  cpp_suffix,
  factory_method_name,
  arguments = None,
  emit_to_native = False,
  is_custom = False 
)
protected

Definition at line 249 of file systemnative.py.

256 is_custom=False):
257
258 constructor_callback_cpp_name = cpp_prefix + cpp_suffix
259
260 if arguments is None:
261 arguments = constructor_info.idl_args[0]
262 argument_count = len(arguments)
263 else:
264 argument_count = len(arguments)
265
266 typed_formals = constructor_info.ParametersAsArgumentList(
267 argument_count)
268 parameters = constructor_info.ParametersAsStringOfVariables(
269 argument_count)
270 interface_name = self._interface_type_info.interface_name()
271
272 dart_native_name, constructor_callback_id = \
273 self.DeriveNativeEntry(cpp_suffix, 'Constructor', argument_count)
274
275 # Then we emit the impedance matching wrapper to call out to the
276 # toplevel wrapper
277 if not emit_to_native:
278 toplevel_name = \
279 self.DeriveQualifiedBlinkName(self._interface.id,
280 dart_native_name)
281 self._members_emitter.Emit(
282 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => '
283 '$TOPLEVEL_NAME($OUTPARAMETERS);\n',
284 INTERFACE_NAME=self._interface_type_info.interface_name(),
285 FACTORY_METHOD_NAME=factory_method_name,
286 PARAMETERS=typed_formals,
287 TOPLEVEL_NAME=toplevel_name,
288 OUTPARAMETERS=parameters)
289
290 self._cpp_resolver_emitter.Emit(
291 ' if (name == "$ID")\n'
292 ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::$CPP_CALLBACK;\n',
293 ID=constructor_callback_id,
294 WEBKIT_INTERFACE_NAME=self._interface.id,
295 CPP_CALLBACK=constructor_callback_cpp_name)
296

◆ _EmitExplicitIndexedGetter()

scripts.systemnative.DartiumBackend._EmitExplicitIndexedGetter (   self,
  dart_element_type 
)
protected

Definition at line 808 of file systemnative.py.

808 def _EmitExplicitIndexedGetter(self, dart_element_type):
809 if any(op.id == 'getItem' for op in self._interface.operations):
810 indexed_getter = 'getItem'
811
812 self._members_emitter.Emit(
813 '\n'
814 ' $TYPE operator[](int index) {\n'
815 ' if (index < 0 || index >= length)\n'
816 ' throw new IndexError.withLength(index, length, indexable: this);\n'
817 ' return $INDEXED_GETTER(index);\n'
818 ' }\n',
819 TYPE=dart_element_type,
820 INDEXED_GETTER=indexed_getter)
821

◆ _EmitNativeIndexGetter()

scripts.systemnative.DartiumBackend._EmitNativeIndexGetter (   self,
  element_type 
)
protected

Definition at line 797 of file systemnative.py.

797 def _EmitNativeIndexGetter(self, element_type):
798 return_type = self.SecureOutputType(element_type, True)
799 parameters = ['index']
800 dart_declaration = '%s operator[](int index)' % return_type
801 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration,
802 False, return_type, parameters, 'Callback',
803 True, False)
804

◆ _EmitNativeIndexSetter()

scripts.systemnative.DartiumBackend._EmitNativeIndexSetter (   self,
  element_type 
)
protected

Definition at line 825 of file systemnative.py.

825 def _EmitNativeIndexSetter(self, element_type):
826 return_type = 'void'
827 formals = ', '.join(['int index', '%s value' % element_type])
828 parameters = ['index', 'value']
829 dart_declaration = 'void operator[]=(%s)' % formals
830 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration,
831 False, return_type, parameters, 'Callback',
832 True, False)
833

◆ _GenerateAutoSetupScope()

scripts.systemnative.DartiumBackend._GenerateAutoSetupScope (   self,
  idl_name,
  native_suffix 
)
protected

Definition at line 555 of file systemnative.py.

555 def _GenerateAutoSetupScope(self, idl_name, native_suffix):
556 return None
557

◆ _GenerateCPPHeader()

scripts.systemnative.DartiumBackend._GenerateCPPHeader (   self)
protected

Definition at line 394 of file systemnative.py.

394 def _GenerateCPPHeader(self):
395 to_native_emitter = emitter.Emitter()
396 if self._interface_type_info.custom_to_native():
397 return_type = 'PassRefPtr<NativeType>'
398 to_native_body = ';'
399 to_native_arg_body = ';'
400 else:
401 return_type = 'NativeType*'
402 to_native_body = emitter.Format(
403 '\n'
404 ' {\n'
405 ' DartDOMData* domData = DartDOMData::current();\n'
406 ' return DartDOMWrapper::unwrapDartWrapper<Dart$INTERFACE>(domData, handle, exception);\n'
407 ' }',
408 INTERFACE=self._interface.id)
409 to_native_arg_body = emitter.Format(
410 '\n'
411 ' {\n'
412 ' return DartDOMWrapper::unwrapDartWrapper<Dart$INTERFACE>(args, index, exception);\n'
413 ' }',
414 INTERFACE=self._interface.id)
415
416 to_native_emitter.Emit(
417 ' static $RETURN_TYPE toNative(Dart_Handle handle, Dart_Handle& exception)$TO_NATIVE_BODY\n'
418 '\n'
419 ' static $RETURN_TYPE toNativeWithNullCheck(Dart_Handle handle, Dart_Handle& exception)\n'
420 ' {\n'
421 ' return Dart_IsNull(handle) ? 0 : toNative(handle, exception);\n'
422 ' }\n'
423 '\n'
424 ' static $RETURN_TYPE toNative(Dart_NativeArguments args, int index, Dart_Handle& exception)$TO_NATIVE_ARG_BODY\n'
425 '\n'
426 ' static $RETURN_TYPE toNativeWithNullCheck(Dart_NativeArguments args, int index, Dart_Handle& exception)\n'
427 ' {\n'
428 ' // toNative accounts for Null objects also.\n'
429 ' return toNative(args, index, exception);\n'
430 ' }\n',
431 RETURN_TYPE=return_type,
432 TO_NATIVE_BODY=to_native_body,
433 TO_NATIVE_ARG_BODY=to_native_arg_body,
434 INTERFACE=self._interface.id)
435
436 to_dart_emitter = emitter.Emitter()
437
438 ext_attrs = self._interface.ext_attrs
439
440 to_dart_emitter.Emit(
441 ' static Dart_Handle toDart(NativeType* value)\n'
442 ' {\n'
443 ' if (!value)\n'
444 ' return Dart_Null();\n'
445 ' DartDOMData* domData = DartDOMData::current();\n'
446 ' Dart_WeakPersistentHandle result =\n'
447 ' DartDOMWrapper::lookupWrapper<Dart$(INTERFACE)>(domData, value);\n'
448 ' if (result)\n'
449 ' return Dart_HandleFromWeakPersistent(result);\n'
450 ' return createWrapper(domData, value);\n'
451 ' }\n'
452 ' static void returnToDart(Dart_NativeArguments args,\n'
453 ' NativeType* value,\n'
454 ' bool autoDartScope = true)\n'
455 ' {\n'
456 ' if (value) {\n'
457 ' DartDOMData* domData = static_cast<DartDOMData*>(\n'
458 ' Dart_GetNativeIsolateData(args));\n'
459 ' Dart_WeakPersistentHandle result =\n'
460 ' DartDOMWrapper::lookupWrapper<Dart$(INTERFACE)>(domData, value);\n'
461 ' if (result)\n'
462 ' Dart_SetWeakHandleReturnValue(args, result);\n'
463 ' else {\n'
464 ' if (autoDartScope) {\n'
465 ' Dart_SetReturnValue(args, createWrapper(domData, value));\n'
466 ' } else {\n'
467 ' DartApiScope apiScope;\n'
468 ' Dart_SetReturnValue(args, createWrapper(domData, value));\n'
469 ' }\n'
470 ' }\n'
471 ' }\n'
472 ' }\n',
473 INTERFACE=self._interface.id)
474
475 if ('CustomToV8' in ext_attrs or 'PureInterface' in ext_attrs or
476 'CPPPureInterface' in ext_attrs or
477 'SpecialWrapFor' in ext_attrs or
478 ('Custom' in ext_attrs and ext_attrs['Custom'] == 'Wrap') or
479 ('Custom' in ext_attrs and ext_attrs['Custom'] == 'ToV8') or
480 self._interface_type_info.custom_to_dart()):
481 to_dart_emitter.Emit(
482 ' static Dart_Handle createWrapper(DartDOMData* domData, NativeType* value);\n'
483 )
484 else:
485 to_dart_emitter.Emit(
486 ' static Dart_Handle createWrapper(DartDOMData* domData, NativeType* value)\n'
487 ' {\n'
488 ' return DartDOMWrapper::createWrapper<Dart$(INTERFACE)>(domData, value, Dart$(INTERFACE)::dartClassId);\n'
489 ' }\n',
490 INTERFACE=self._interface.id)
491
492 webcore_includes = self._GenerateCPPIncludes(
493 self._interface_type_info.webcore_includes())
494
495 is_node_test = lambda interface: interface.id == 'Node'
496 is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs
497 is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attrs
498
499 def TypeCheckHelper(test):
500 return 'true' if any(
501 map(test, self._database.Hierarchy(
502 self._interface))) else 'false'
503
504 to_active_emitter = emitter.Emitter()
505 to_node_emitter = emitter.Emitter()
506 to_event_target_emitter = emitter.Emitter()
507
508 if (any(map(is_active_test,
509 self._database.Hierarchy(self._interface)))):
510 to_active_emitter.Emit('return toNative(value);')
511 else:
512 to_active_emitter.Emit('return 0;')
513
514 if (any(map(is_node_test, self._database.Hierarchy(self._interface)))):
515 to_node_emitter.Emit('return toNative(value);')
516 else:
517 to_node_emitter.Emit('return 0;')
518
519 if (any(
520 map(is_event_target_test,
521 self._database.Hierarchy(self._interface)))):
522 to_event_target_emitter.Emit('return toNative(value);')
523 else:
524 to_event_target_emitter.Emit('return 0;')
525
526 v8_interface_include = ''
527 # V8AbstractWorker.h does not exist so we have to hard code this case.
528 if self._interface.id != 'AbstractWorker':
529 # FIXME: We need this to access the WrapperTypeInfo.
530 v8_interface_include = '#include "V8%s.h"' % (self._interface.id)
531
532 self._cpp_header_emitter.Emit(
533 self._template_loader.Load('cpp_header.template'),
534 INTERFACE=self._interface.id,
535 WEBCORE_INCLUDES=webcore_includes,
536 V8_INTERFACE_INCLUDE=v8_interface_include,
537 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
538 WEBCORE_CLASS_NAME_ESCAPED=self._interface_type_info.native_type().
539 replace('<', '_').replace('>', '_'),
540 DECLARATIONS=self._cpp_declarations_emitter.Fragments(),
541 IS_NODE=TypeCheckHelper(is_node_test),
542 IS_ACTIVE=TypeCheckHelper(is_active_test),
543 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test),
544 TO_NODE=to_node_emitter.Fragments(),
545 TO_ACTIVE=to_active_emitter.Fragments(),
546 TO_EVENT_TARGET=to_event_target_emitter.Fragments(),
547 TO_NATIVE=to_native_emitter.Fragments(),
548 TO_DART=to_dart_emitter.Fragments())
549

◆ _GenerateCPPIncludes()

scripts.systemnative.DartiumBackend._GenerateCPPIncludes (   self,
  includes 
)
protected

Definition at line 1151 of file systemnative.py.

1151 def _GenerateCPPIncludes(self, includes):
1152 return None
1153

◆ _GenerateDispatcher()

scripts.systemnative.DartiumBackend._GenerateDispatcher (   self,
  info,
  operations,
  dart_declaration,
  html_name 
)
protected

Definition at line 936 of file systemnative.py.

937 html_name):
938
939 def GenerateCall(stmts_emitter, call_emitter, version, operation,
940 argument_count):
941 native_suffix = 'Callback'
942 actuals = info.ParametersAsListOfVariables(
943 argument_count,
944 self._type_registry if self._dart_use_blink else None,
945 self._dart_js_interop, self)
946 actuals_s = ", ".join(actuals)
947 formals = actuals
948 return_type = self.SecureOutputType(operation.type.id)
949
950 return_wrap_jso = False
951 if self._dart_use_blink:
952 return_wrap_jso = wrap_return_type_blink(
953 return_type, info.type_name, self._type_registry)
954
955 native_suffix = 'Callback'
956 is_custom = _IsCustom(operation)
957 base_name = '_%s_%s' % (operation.id, version)
958 static = True
959 if not operation.is_static:
960 actuals = ['this'] + actuals
961 formals = ['mthis'] + formals
962 actuals_s = ", ".join(actuals)
963 formals_s = ", ".join(formals)
964 dart_declaration = '%s(%s)' % (base_name, formals_s)
965 native_entry = \
966 self.DeriveNativeEntry(operation.id, 'Method', argument_count)
967 overload_base_name = native_entry[0]
968 overload_name = \
969 self.DeriveQualifiedBlinkName(self._interface.id,
970 overload_base_name)
971 call_emitter.Emit(
972 '$NAME($ARGS)', NAME=overload_name, ARGS=actuals_s)
973 auto_scope_setup = \
974 self._GenerateAutoSetupScope(base_name, native_suffix)
975 cpp_callback_name = self._GenerateNativeBinding(
976 base_name, (0 if static else 1) + argument_count,
977 dart_declaration,
978 static,
979 return_type,
980 formals,
981 native_suffix,
982 is_custom,
983 auto_scope_setup,
984 emit_metadata=False,
985 emit_to_native=True,
986 native_entry=native_entry)
987 if not is_custom:
988 self._GenerateOperationNativeCallback(
989 operation, operation.arguments[:argument_count],
990 cpp_callback_name, auto_scope_setup)
991
992 self._GenerateDispatcherBody(info, operations, dart_declaration,
993 GenerateCall, IsOptional)
994

◆ _GenerateNativeBinding()

scripts.systemnative.DartiumBackend._GenerateNativeBinding (   self,
  idl_name,
  argument_count,
  dart_declaration,
  static,
  return_type,
  parameters,
  native_suffix,
  is_custom,
  auto_scope_setup = True,
  emit_metadata = True,
  emit_to_native = False,
  native_entry = None,
  wrap_unwrap_list = [],
  dictionary_return = False,
  output_conversion = None 
)
protected

Definition at line 1009 of file systemnative.py.

1024 output_conversion=None):
1025 metadata = []
1026 if emit_metadata:
1027 metadata = self._metadata.GetFormattedMetadata(
1028 self._renamer.GetLibraryName(self._interface), self._interface,
1029 idl_name, ' ')
1030
1031 if (native_entry):
1032 dart_native_name, native_binding = native_entry
1033 else:
1034 dart_native_name = \
1035 self.DeriveNativeName(idl_name, native_suffix)
1036 native_binding_id = self._interface.id
1037 native_binding_id = TypeIdToBlinkName(native_binding_id,
1038 self._database)
1039 native_binding = \
1040 '%s_%s_%s' % (native_binding_id, idl_name, native_suffix)
1041
1042 if not static:
1043 formals = ", ".join(['mthis'] + parameters)
1044 actuals = ", ".join(['this'] + parameters)
1045 else:
1046 formals = ", ".join(parameters)
1047 actuals = ", ".join(parameters)
1048
1049 if not emit_to_native:
1050 caller_emitter = self._members_emitter
1051 full_dart_name = \
1052 self.DeriveQualifiedBlinkName(self._interface.id,
1053 dart_native_name)
1054 if IsPureInterface(self._interface.id, self._database):
1055 caller_emitter.Emit('\n'
1056 ' $METADATA$DART_DECLARATION;\n',
1057 METADATA=metadata,
1058 DART_DECLARATION=dart_declaration)
1059 else:
1060 emit_template = '''
1061 $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);
1062 '''
1063 if output_conversion and not dictionary_return:
1064 conversion_template = '''
1065 $METADATA$DART_DECLARATION => %s($DART_NAME($ACTUALS));
1066 '''
1067 emit_template = conversion_template % output_conversion.function_name
1068
1069 elif wrap_unwrap_list and wrap_unwrap_list[0]:
1070 if return_type == 'Rectangle':
1071 jso_util_method = 'make_dart_rectangle'
1072 elif wrap_unwrap_list[0]:
1073 jso_util_method = ''
1074
1075 if dictionary_return:
1076 emit_jso_template = '''
1077 $METADATA$DART_DECLARATION => convertNativeDictionaryToDartDictionary(%s($DART_NAME($ACTUALS)));
1078 '''
1079 else:
1080 emit_jso_template = '''
1081 $METADATA$DART_DECLARATION => %s($DART_NAME($ACTUALS));
1082 '''
1083 emit_template = emit_jso_template % jso_util_method
1084
1085 if caller_emitter:
1086 caller_emitter.Emit(
1087 emit_template,
1088 METADATA=metadata,
1089 DART_DECLARATION=dart_declaration,
1090 DART_NAME=full_dart_name,
1091 ACTUALS=actuals)
1092 cpp_callback_name = '%s%s' % (idl_name, native_suffix)
1093
1094 self._cpp_resolver_emitter.Emit(
1095 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n'
1096 ' *autoSetupScope = $AUTO_SCOPE_SETUP;\n'
1097 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n'
1098 ' }\n',
1099 ARGC=argument_count,
1100 NATIVE_BINDING=native_binding,
1101 INTERFACE_NAME=self._interface.id,
1102 AUTO_SCOPE_SETUP='true' if auto_scope_setup else 'false',
1103 CPP_CALLBACK_NAME=cpp_callback_name)
1104
1105 if is_custom:
1106 self._cpp_declarations_emitter.Emit(
1107 '\n'
1108 'void $CPP_CALLBACK_NAME(Dart_NativeArguments);\n',
1109 CPP_CALLBACK_NAME=cpp_callback_name)
1110
1111 return cpp_callback_name
1112

◆ _GenerateOperationNativeCallback()

scripts.systemnative.DartiumBackend._GenerateOperationNativeCallback (   self,
  operation,
  arguments,
  cpp_callback_name,
  auto_scope_setup = True 
)
protected

Definition at line 998 of file systemnative.py.

1002 auto_scope_setup=True):
1003 webcore_function_name = operation.ext_attrs.get('ImplementedAs',
1004 operation.id)
1005
1006 function_expression = self._GenerateWebCoreFunctionExpression(
1007 webcore_function_name, operation, cpp_callback_name)
1008

◆ _GenerateWebCoreFunctionExpression()

scripts.systemnative.DartiumBackend._GenerateWebCoreFunctionExpression (   self,
  function_name,
  idl_node,
  cpp_callback_name = None 
)
protected

Definition at line 1131 of file systemnative.py.

1134 cpp_callback_name=None):
1135 return None
1136

◆ _GenerateWebCoreReflectionAttributeName()

scripts.systemnative.DartiumBackend._GenerateWebCoreReflectionAttributeName (   self,
  attr 
)
protected

Definition at line 1113 of file systemnative.py.

1113 def _GenerateWebCoreReflectionAttributeName(self, attr):
1114 namespace = 'HTMLNames'
1115 svg_exceptions = [
1116 'class', 'id', 'onabort', 'onclick', 'onerror', 'onload',
1117 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover',
1118 'onmouseup', 'onresize', 'onscroll', 'onunload'
1119 ]
1120 if self._interface.id.startswith(
1121 'SVG') and not attr.id in svg_exceptions:
1122 namespace = 'SVGNames'
1123 self._cpp_impl_includes.add('"%s.h"' % namespace)
1124
1125 attribute_name = attr.ext_attrs['Reflect'] or attr.id.lower()
1126 return 'WebCore::%s::%sAttr' % (namespace, attribute_name)
1127

◆ _HasExplicitIndexedGetter()

scripts.systemnative.DartiumBackend._HasExplicitIndexedGetter (   self)
protected

Definition at line 805 of file systemnative.py.

805 def _HasExplicitIndexedGetter(self):
806 return any(op.id == 'getItem' for op in self._interface.operations)
807

◆ _HasNativeIndexGetter()

scripts.systemnative.DartiumBackend._HasNativeIndexGetter (   self)
protected

Definition at line 794 of file systemnative.py.

794 def _HasNativeIndexGetter(self):
795 return 'CustomIndexedGetter' in self._interface.ext_attrs
796

◆ _HasNativeIndexSetter()

scripts.systemnative.DartiumBackend._HasNativeIndexSetter (   self)
protected

Definition at line 822 of file systemnative.py.

822 def _HasNativeIndexSetter(self):
823 return 'CustomIndexedSetter' in self._interface.ext_attrs
824

◆ _InputConversion()

scripts.systemnative.DartiumBackend._InputConversion (   self,
  idl_type,
  member 
)
protected

Definition at line 134 of file systemnative.py.

134 def _InputConversion(self, idl_type, member):
135 return FindConversion(idl_type, 'set', self._interface.id, member)
136

◆ _IsArgumentOptionalInWebCore()

scripts.systemnative.DartiumBackend._IsArgumentOptionalInWebCore (   self,
  operation,
  argument 
)
protected

Definition at line 1137 of file systemnative.py.

1137 def _IsArgumentOptionalInWebCore(self, operation, argument):
1138 if not IsOptional(argument):
1139 return False
1140 if 'Callback' in argument.ext_attrs:
1141 return False
1142 if operation.id in ['addEventListener', 'removeEventListener'
1143 ] and argument.id == 'useCapture':
1144 return False
1145 if 'DartForceOptional' in argument.ext_attrs:
1146 return False
1147 if argument.type.id == 'Dictionary':
1148 return False
1149 return True
1150

◆ _IsStatic()

scripts.systemnative.DartiumBackend._IsStatic (   self,
  attribute_name 
)
protected

Definition at line 1128 of file systemnative.py.

1128 def _IsStatic(self, attribute_name):
1129 return False
1130

◆ _OutputConversion()

scripts.systemnative.DartiumBackend._OutputConversion (   self,
  idl_type,
  member 
)
protected

Definition at line 123 of file systemnative.py.

123 def _OutputConversion(self, idl_type, member):
124 conversion = FindConversion(idl_type, 'get', self._interface.id, member)
125 # TODO(jacobr) handle promise consistently in dart2js and dartium.
126 if idl_type == 'Promise':
127 return _promise_to_future
128 if conversion:
129 if conversion.function_name in ('convertNativeToDart_DateTime',
130 'convertNativeToDart_ImageData'):
131 return None
132 return conversion
133

◆ _ToWebKitName()

scripts.systemnative.DartiumBackend._ToWebKitName (   self,
  name 
)
protected

Definition at line 1154 of file systemnative.py.

1154 def _ToWebKitName(self, name):
1155 name = name[0].lower() + name[1:]
1156 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
1157 name)
1158 return re.sub(r'^(create|exclusive)',
1159 lambda s: 'is' + s.group(1).capitalize(), name)
1160
1161

◆ AddIndexer()

scripts.systemnative.DartiumBackend.AddIndexer (   self,
  element_type,
  nullable 
)
Adds all the methods required to complete implementation of List.

Definition at line 704 of file systemnative.py.

704 def AddIndexer(self, element_type, nullable):
705 """Adds all the methods required to complete implementation of List."""
706 # We would like to simply inherit the implementation of everything except
707 # length, [], and maybe []=. It is possible to extend from a base
708 # array implementation class only when there is no other implementation
709 # inheritance. There might be no implementation inheritance other than
710 # DOMBaseWrapper for many classes, but there might be some where the
711 # array-ness is introduced by a non-root interface:
712 #
713 # interface Y extends X, List<T> ...
714 #
715 # In the non-root case we have to choose between:
716 #
717 # class YImpl extends XImpl { add List<T> methods; }
718 #
719 # and
720 #
721 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; }
722 #
723 dart_element_type = self._DartType(element_type)
724 if self._HasNativeIndexGetter():
725 self._EmitNativeIndexGetter(dart_element_type)
726 elif self._HasExplicitIndexedGetter():
727 self._EmitExplicitIndexedGetter(dart_element_type)
728 else:
729 is_custom = any((op.id == 'item' and _IsCustom(op))
730 for op in self._interface.operations)
731
732 output_conversion = self._OutputConversion(element_type, 'item')
733 conversion_name = ''
734 if output_conversion:
735 conversion_name = output_conversion.function_name
736
737 # First emit a toplevel function to do the native call
738 # Calls to this are emitted elsewhere,
739 dart_native_name, resolver_string = \
740 self.DeriveNativeEntry("item", 'Method', 1)
741
742 # Emit the method which calls the toplevel function, along with
743 # the [] operator.
744 dart_qualified_name = \
745 self.DeriveQualifiedBlinkName(self._interface.id,
746 dart_native_name)
747
748 type_info = self._TypeInfo(element_type)
749 blinkNativeIndexed = """
750 $TYPE operator[](int index) {
751 if (index < 0 || index >= length)
752 throw new IndexError.withLength(index, length, indexable: this);
753 return _nativeIndexedGetter(index);
754 }
755
756 $TYPE _nativeIndexedGetter(int index) => $(CONVERSION_NAME)($(DART_NATIVE_NAME)(this, index));
757"""
758 blinkNativeIndexedGetter = \
759 ' $(DART_NATIVE_NAME)(this, index);\n'
760 self._members_emitter.Emit(
761 blinkNativeIndexed,
762 DART_NATIVE_NAME=dart_qualified_name,
763 TYPE=self.SecureOutputType(element_type),
764 INTERFACE=self._interface.id,
765 CONVERSION_NAME=conversion_name)
766
767 if self._HasNativeIndexSetter():
768 self._EmitNativeIndexSetter(dart_element_type)
769 else:
770 self._members_emitter.Emit(
771 '\n'
772 ' void operator[]=(int index, $TYPE value) {\n'
773 ' throw new UnsupportedError("Cannot assign element of immutable List.");\n'
774 ' }\n',
775 TYPE=dart_element_type)
776
777 self.EmitListMixin(dart_element_type, nullable)
778

◆ AmendIndexer()

scripts.systemnative.DartiumBackend.AmendIndexer (   self,
  element_type 
)

Definition at line 779 of file systemnative.py.

779 def AmendIndexer(self, element_type):
780 # If interface is marked as having native indexed
781 # getter or setter, we must emit overrides as it's not
782 # guaranteed that the corresponding methods in C++ would be
783 # virtual. For example, as of time of writing, even though
784 # Uint8ClampedArray inherits from Uint8Array, ::set method
785 # is not virtual and accessing it through Uint8Array pointer
786 # would lead to wrong semantics (modulo vs. clamping.)
787 dart_element_type = self._DartType(element_type)
788
789 if self._HasNativeIndexGetter():
790 self._EmitNativeIndexGetter(dart_element_type)
791 if self._HasNativeIndexSetter():
792 self._EmitNativeIndexSetter(dart_element_type)
793

◆ CustomJSMembers()

scripts.systemnative.DartiumBackend.CustomJSMembers (   self)

Definition at line 120 of file systemnative.py.

120 def CustomJSMembers(self):
121 return {}
122

◆ DeriveNativeEntry()

scripts.systemnative.DartiumBackend.DeriveNativeEntry (   self,
  name,
  kind,
  count 
)

Definition at line 158 of file systemnative.py.

158 def DeriveNativeEntry(self, name, kind, count):
159 interface_id = self._interface.id
160 database = self._database
161 tag = ""
162 if kind == 'Getter':
163 tag = "%s_Getter" % name
164 blink_entry = tag
165 elif kind == 'Setter':
166 tag = "%s_Setter" % name
167 blink_entry = tag
168 elif kind == 'Constructor':
169 tag = "constructorCallback"
170 blink_entry = tag
171 elif kind == 'Method':
172 tag = "%s_Callback" % name
173 blink_entry = tag
174
175 interface_id = TypeIdToBlinkName(interface_id, database)
176
177 def mkPublic(s):
178 if s.startswith("_") or s.startswith("$"):
179 return "$" + s
180 return s
181
182 if count is not None:
183 arity = str(count)
184 dart_name = mkPublic("_".join([tag, arity]))
185 else:
186 dart_name = mkPublic(tag)
187 resolver_string = "_".join([interface_id, tag])
188
189 return (dart_name, resolver_string)
190

◆ DeriveNativeName()

scripts.systemnative.DartiumBackend.DeriveNativeName (   self,
  name,
  suffix = "" 
)

Definition at line 191 of file systemnative.py.

191 def DeriveNativeName(self, name, suffix=""):
192 fields = ['$' + name]
193 if suffix != "":
194 fields.append(suffix)
195 return "_".join(fields)
196

◆ DeriveQualifiedBlinkName()

scripts.systemnative.DartiumBackend.DeriveQualifiedBlinkName (   self,
  interface_name,
  name 
)

Definition at line 197 of file systemnative.py.

197 def DeriveQualifiedBlinkName(self, interface_name, name):
198 blinkClass = DeriveQualifiedName("_blink",
199 DeriveBlinkClassName(interface_name))
200 blinkInstance = DeriveQualifiedName(blinkClass, "instance")
201 return DeriveQualifiedName(blinkInstance, name + "_")
202

◆ EmitAttribute()

scripts.systemnative.DartiumBackend.EmitAttribute (   self,
  attribute,
  html_name,
  read_only 
)

Definition at line 550 of file systemnative.py.

550 def EmitAttribute(self, attribute, html_name, read_only):
551 self._AddGetter(attribute, html_name, read_only)
552 if not read_only:
553 self._AddSetter(attribute, html_name)
554

◆ EmitOperation()

scripts.systemnative.DartiumBackend.EmitOperation (   self,
  info,
  html_name,
  dart_js_interop = False 
)
Arguments:
info: An OperationInfo object.

Definition at line 845 of file systemnative.py.

845 def EmitOperation(self, info, html_name, dart_js_interop=False):
846 """
847 Arguments:
848 info: An OperationInfo object.
849 """
850 if self._renamer.isPrivate(self._interface, info.operations[0].id):
851 # Any private operations with Maps parameters changed to any type.
852 # The public method that delegates to this private operation has already
853 # converted from Map to native (JsObject) e.g., Element.animate.
854 self._ChangePrivateOpMapArgToAny(info.operations)
855
856 return_type = self.SecureOutputType(info.type_name, False,
857 False if dart_js_interop else True)
858
859 formals = info.ParametersAsDeclaration(self._DartType)
860
861 parameters = info.ParametersAsListOfVariables(
862 None, self._type_registry if self._dart_use_blink else None,
863 dart_js_interop, self)
864
865 operation = info.operations[0]
866
867 output_conversion = self._OutputConversion(operation.type.id,
868 operation.id)
869
870 dictionary_returned = False
871 # Return type for dictionary is any (untyped).
872 if operation.type.id == 'Dictionary':
873 return_type = ''
874 dictionary_returned = True
875
876 dart_declaration = '%s%s %s(%s)' % ('static ' if info.IsStatic() else
877 '', return_type, html_name, formals)
878
879 is_custom = _IsCustom(operation)
880 has_optional_arguments = any(
881 IsOptional(argument) for argument in operation.arguments)
882 needs_dispatcher = not is_custom and (len(info.operations) > 1 or
883 has_optional_arguments)
884
885 # Operation uses blink?
886 wrap_unwrap_list = []
887 return_wrap_jso = False
888 # return type wrapped?
889 if self._dart_use_blink:
890 # Wrap the type to store the JsObject if Type is:
891 #
892 # it's a dynamic/any type
893 # - type is Object
894 #
895 # JsObject maybe stored in the Dart class.
896 return_wrap_jso = wrap_return_type_blink(
897 return_type, info.type_name, self._type_registry)
898 return_type_info = self._type_registry.TypeInfo(info.type_name)
899 # wrap_jso the returned object
900 wrap_unwrap_list.append(return_wrap_jso)
901 wrap_unwrap_list.append(self._dart_use_blink)
902
903 if info.callback_args:
904 self._AddFutureifiedOperation(info, html_name)
905 elif not needs_dispatcher:
906 # Bind directly to native implementation
907 argument_count = (0 if info.IsStatic() else 1) + len(
908 info.param_infos)
909 native_suffix = 'Callback'
910 auto_scope_setup = self._GenerateAutoSetupScope(
911 info.name, native_suffix)
912 native_entry = \
913 self.DeriveNativeEntry(operation.id, 'Method', len(info.param_infos))
914 cpp_callback_name = self._GenerateNativeBinding(
915 info.name,
916 argument_count,
917 dart_declaration,
918 info.IsStatic(),
919 return_type,
920 parameters,
921 native_suffix,
922 is_custom,
923 auto_scope_setup,
924 native_entry=native_entry,
925 wrap_unwrap_list=wrap_unwrap_list,
926 dictionary_return=dictionary_returned,
927 output_conversion=output_conversion)
928 if not is_custom:
929 self._GenerateOperationNativeCallback(
930 operation, operation.arguments, cpp_callback_name,
931 auto_scope_setup)
932 else:
933 self._GenerateDispatcher(info, info.operations, dart_declaration,
934 html_name)
935

◆ EmitStaticFactoryOverload()

scripts.systemnative.DartiumBackend.EmitStaticFactoryOverload (   self,
  constructor_info,
  name,
  arguments 
)

Definition at line 339 of file systemnative.py.

339 def EmitStaticFactoryOverload(self, constructor_info, name, arguments):
340 constructor_callback_cpp_name = name + 'constructorCallback'
341 self._EmitConstructorInfrastructure(
342 constructor_info,
343 name,
344 'constructorCallback',
345 name,
346 arguments,
347 emit_to_native=True,
348 is_custom=False)
349
350 ext_attrs = self._interface.ext_attrs
351
352 create_function = 'create'
353 if 'NamedConstructor' in ext_attrs:
354 create_function = 'createForJSConstructor'
355 function_expression = '%s::%s' % (
356 self._interface_type_info.native_type(), create_function)
357

◆ FinishInterface()

scripts.systemnative.DartiumBackend.FinishInterface (   self)

Definition at line 370 of file systemnative.py.

370 def FinishInterface(self):
371 interface = self._interface
372 if interface.parents:
373 supertype = '%sClassId' % interface.parents[0].type.id
374 else:
375 supertype = '-1'
376
377 self._GenerateCPPHeader()
378
379 self._cpp_impl_emitter.Emit(
380 self._template_loader.Load('cpp_implementation.template'),
381 INTERFACE=self._interface.id,
382 SUPER_INTERFACE=supertype,
383 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes),
384 CALLBACKS=self._cpp_definitions_emitter.Fragments(),
385 RESOLVER=self._cpp_resolver_emitter.Fragments(),
386 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
387 WEBCORE_CLASS_NAME_ESCAPED=self._interface_type_info.native_type().
388 replace('<', '_').replace('>', '_'),
389 DART_IMPLEMENTATION_CLASS=self._interface_type_info.
390 implementation_name(),
391 DART_IMPLEMENTATION_LIBRARY_ID='Dart%sLibraryId' %
392 self._renamer.GetLibraryId(self._interface))
393

◆ GenerateCallback()

scripts.systemnative.DartiumBackend.GenerateCallback (   self,
  info 
)

Definition at line 137 of file systemnative.py.

137 def GenerateCallback(self, info):
138 return None
139

◆ GenerateCustomFactory()

scripts.systemnative.DartiumBackend.GenerateCustomFactory (   self,
  constructor_info 
)

Definition at line 297 of file systemnative.py.

297 def GenerateCustomFactory(self, constructor_info):
298 if 'CustomConstructor' not in self._interface.ext_attrs:
299 return False
300
301 annotations = self._metadata.GetFormattedMetadata(
302 self._library_name, self._interface, self._interface.id, ' ')
303
304 self._members_emitter.Emit(
305 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n',
306 ANNOTATIONS=annotations,
307 CTOR=constructor_info._ConstructorFullName(self._DartType),
308 PARAMS=constructor_info.ParametersAsDeclaration(self._DartType),
309 FACTORY_PARAMS= \
310 constructor_info.ParametersAsArgumentList())
311
312 # MutationObserver has custom _create. TODO(terry): Consider table but this is only one.
313 if self._interface.id != 'MutationObserver':
314 constructor_callback_cpp_name = 'constructorCallback'
315 self._EmitConstructorInfrastructure(
316 constructor_info,
317 "",
318 constructor_callback_cpp_name,
319 '_create',
320 is_custom=True)
321
322 self._cpp_declarations_emitter.Emit(
323 '\n'
324 'void $CPP_CALLBACK(Dart_NativeArguments);\n',
325 CPP_CALLBACK=constructor_callback_cpp_name)
326
327 return True
328

◆ GetSupportCheck()

scripts.systemnative.DartiumBackend.GetSupportCheck (   self)

Definition at line 362 of file systemnative.py.

362 def GetSupportCheck(self):
363 # Assume that everything is supported on Dartium.
364 value = js_support_checks.get(self._interface.doc_js_name)
365 if type(value) == tuple:
366 return (value[0], 'true')
367 else:
368 return 'true'
369

◆ HasSupportCheck()

scripts.systemnative.DartiumBackend.HasSupportCheck (   self)

Definition at line 358 of file systemnative.py.

358 def HasSupportCheck(self):
359 # Need to omit a support check if it is conditional in JS.
360 return self._interface.doc_js_name in js_support_checks
361

◆ ImplementationTemplate()

scripts.systemnative.DartiumBackend.ImplementationTemplate (   self)

Definition at line 140 of file systemnative.py.

140 def ImplementationTemplate(self):
141 template = None
142 interface_name = self._interface.doc_js_name
143 if interface_name == self._interface.id or not self._database.HasInterface(
144 interface_name):
145 template_file = 'impl_%s.darttemplate' % interface_name
146 template = self._template_loader.TryLoad(template_file)
147 if not template:
148 template = self._template_loader.Load(
149 'dart_implementation.darttemplate')
150 return template
151

◆ ImplementsMergedMembers()

scripts.systemnative.DartiumBackend.ImplementsMergedMembers (   self)

Definition at line 114 of file systemnative.py.

114 def ImplementsMergedMembers(self):
115 # We could not add merged functions to implementation class because
116 # underlying c++ object doesn't implement them. Merged functions are
117 # generated on merged interface implementation instead.
118 return False
119

◆ IsConstructorArgumentOptional()

scripts.systemnative.DartiumBackend.IsConstructorArgumentOptional (   self,
  argument 
)

Definition at line 329 of file systemnative.py.

329 def IsConstructorArgumentOptional(self, argument):
330 return IsOptional(argument)
331

◆ MakeFactoryCall()

scripts.systemnative.DartiumBackend.MakeFactoryCall (   self,
  factory,
  method,
  arguments,
  constructor_info 
)

Definition at line 332 of file systemnative.py.

332 def MakeFactoryCall(self, factory, method, arguments, constructor_info):
333 return emitter.Format(
334 '$FACTORY.$METHOD($ARGUMENTS)',
335 FACTORY=factory,
336 METHOD=method,
337 ARGUMENTS=arguments)
338

◆ NativeSpec()

scripts.systemnative.DartiumBackend.NativeSpec (   self)

Definition at line 203 of file systemnative.py.

203 def NativeSpec(self):
204 return ''
205

◆ RootClassName()

scripts.systemnative.DartiumBackend.RootClassName (   self)

Definition at line 152 of file systemnative.py.

152 def RootClassName(self):
153 return 'DartHtmlDomObject'
154

◆ SecondaryContext()

scripts.systemnative.DartiumBackend.SecondaryContext (   self,
  interface 
)

Definition at line 995 of file systemnative.py.

995 def SecondaryContext(self, interface):
996 pass
997

◆ StartInterface()

scripts.systemnative.DartiumBackend.StartInterface (   self,
  members_emitter 
)

Definition at line 206 of file systemnative.py.

206 def StartInterface(self, members_emitter):
207 # Create emitters for c++ implementation.
208 if not IsPureInterface(self._interface.id, self._database) and \
209 not IsCustomType(self._interface.id):
210 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter(
211 self._interface.id,
212 self._renamer.GetLibraryName(self._interface))
213 self._cpp_impl_emitter = \
214 self._cpp_library_emitter.CreateSourceEmitter(self._interface.id)
215 else:
216 self._cpp_header_emitter = emitter.Emitter()
217 self._cpp_impl_emitter = emitter.Emitter()
218
219 self._interface_type_info = self._TypeInfo(self._interface.id)
220 self._members_emitter = members_emitter
221
222 self._cpp_declarations_emitter = emitter.Emitter()
223
224 # This is a hack to work around a strange C++ compile error that we weren't
225 # able to track down the true cause of.
226 if self._interface.id == 'Timing':
227 self._cpp_impl_includes.add('"core/animation/TimedItem.h"')
228
229 self._cpp_definitions_emitter = emitter.Emitter()
230 self._cpp_resolver_emitter = emitter.Emitter()
231
232 # We need to revisit our treatment of typed arrays, right now
233 # it is full of hacks.
234 if self._interface.ext_attrs.get('ConstructorTemplate') == 'TypedArray':
235 self._cpp_resolver_emitter.Emit(
236 ' if (name == "$(INTERFACE_NAME)_constructor_Callback")\n'
237 ' return Dart$(INTERFACE_NAME)Internal::constructorCallback;\n',
238 INTERFACE_NAME=self._interface.id)
239
240 self._cpp_impl_includes.add('"DartArrayBufferViewCustom.h"')
241 self._cpp_definitions_emitter.Emit(
242 '\n'
243 'static void constructorCallback(Dart_NativeArguments args)\n'
244 '{\n'
245 ' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INTERFACE_NAME)>(args);\n'
246 '}\n',
247 INTERFACE_NAME=self._interface.id)
248

Member Data Documentation

◆ _cpp_declarations_emitter

scripts.systemnative.DartiumBackend._cpp_declarations_emitter
protected

Definition at line 107 of file systemnative.py.

◆ _cpp_definitions_emitter

scripts.systemnative.DartiumBackend._cpp_definitions_emitter
protected

Definition at line 109 of file systemnative.py.

◆ _cpp_header_emitter

scripts.systemnative.DartiumBackend._cpp_header_emitter
protected

Definition at line 104 of file systemnative.py.

◆ _cpp_impl_emitter

scripts.systemnative.DartiumBackend._cpp_impl_emitter
protected

Definition at line 105 of file systemnative.py.

◆ _cpp_impl_includes

scripts.systemnative.DartiumBackend._cpp_impl_includes
protected

Definition at line 108 of file systemnative.py.

◆ _cpp_library_emitter

scripts.systemnative.DartiumBackend._cpp_library_emitter
protected

Definition at line 96 of file systemnative.py.

◆ _cpp_resolver_emitter

scripts.systemnative.DartiumBackend._cpp_resolver_emitter
protected

Definition at line 110 of file systemnative.py.

◆ _dart_js_interop

scripts.systemnative.DartiumBackend._dart_js_interop
protected

Definition at line 111 of file systemnative.py.

◆ _dart_use_blink

scripts.systemnative.DartiumBackend._dart_use_blink
protected

Definition at line 593 of file systemnative.py.

◆ _database

scripts.systemnative.DartiumBackend._database
protected

Definition at line 97 of file systemnative.py.

◆ _interface

scripts.systemnative.DartiumBackend._interface
protected

Definition at line 95 of file systemnative.py.

◆ _interface_type_info

scripts.systemnative.DartiumBackend._interface_type_info
protected

Definition at line 100 of file systemnative.py.

◆ _library_name

scripts.systemnative.DartiumBackend._library_name
protected

Definition at line 302 of file systemnative.py.

◆ _members_emitter

scripts.systemnative.DartiumBackend._members_emitter
protected

Definition at line 106 of file systemnative.py.

◆ _metadata

scripts.systemnative.DartiumBackend._metadata
protected

Definition at line 102 of file systemnative.py.

◆ _template_loader

scripts.systemnative.DartiumBackend._template_loader
protected

Definition at line 98 of file systemnative.py.

◆ _type_registry

scripts.systemnative.DartiumBackend._type_registry
protected

Definition at line 99 of file systemnative.py.


The documentation for this class was generated from the following file: