Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Functions | Variables
scripts.idlnode Namespace Reference

Classes

class  IDLAnnotation
 
class  IDLAnnotations
 
class  IDLArgument
 
class  IDLAttribute
 
class  IDLCallbackFunction
 
class  IDLConstant
 
class  IDLDictionary
 
class  IDLDictionaryMember
 
class  IDLDictionaryMembers
 
class  IDLDictNode
 
class  IDLEnum
 
class  IDLExtAttrFunctionValue
 
class  IDLExtAttrs
 
class  IDLFile
 
class  IDLImplementsStatement
 
class  IDLInterface
 
class  IDLMember
 
class  IDLModule
 
class  IDLNode
 
class  IDLOperation
 
class  IDLParentInterface
 
class  IDLType
 
class  IDLTypeDef
 

Functions

 report_unions_to_any ()
 
 _addTypedef (typedef)
 
 resolveTypedef (type)
 
 generate_callback (interface_name, result_type, arguments)
 
 generate_operation (interface_name, result_type_name, oper_name, arguments, result_nullable=False)
 
 generate_setLike_operations_properties (interface, set_like)
 

Variables

dict new_asts = {}
 
list _unions_to_any = []
 
list _typeDefsFixup = []
 
dict _operation_suffix_map
 

Function Documentation

◆ _addTypedef()

scripts.idlnode._addTypedef (   typedef)
protected

Definition at line 35 of file idlnode.py.

35def _addTypedef(typedef):
36 _typeDefsFixup.append(typedef)
37
38

◆ generate_callback()

scripts.idlnode.generate_callback (   interface_name,
  result_type,
  arguments 
)

Definition at line 826 of file idlnode.py.

826def generate_callback(interface_name, result_type, arguments):
827 syn_op = IDLOperation(None, interface_name, 'callback')
828
829 syn_op.type = resolveTypedef(result_type)
830 syn_op.arguments = arguments
831
832 return syn_op
833
834

◆ generate_operation()

scripts.idlnode.generate_operation (   interface_name,
  result_type_name,
  oper_name,
  arguments,
  result_nullable = False 
)
 Synthesize an IDLOperation with no AST used for support of setlike.
 Arguments is a list of argument where each argument is:
      [IDLType, argument_name, optional_boolean] 

Definition at line 835 of file idlnode.py.

839 result_nullable=False):
840 """ Synthesize an IDLOperation with no AST used for support of setlike."""
841 """ Arguments is a list of argument where each argument is:
842 [IDLType, argument_name, optional_boolean] """
843
844 syn_op = IDLOperation(None, interface_name, oper_name)
845
846 syn_op.type = IDLType(None, result_type_name)
847 syn_op.type = resolveTypedef(syn_op.type)
848 syn_op.type.nullable = result_nullable
849
850 for argument in arguments:
851 arg = IDLArgument(None, argument[1])
852 arg.type = argument[0]
853 arg.optional = argument[2] if len(argument) > 2 else False
854 syn_op.arguments.append(arg)
855
856 return syn_op
857
858

◆ generate_setLike_operations_properties()

scripts.idlnode.generate_setLike_operations_properties (   interface,
  set_like 
)
Need to create (in our database) a number of operations.  This is a new IDL
syntax, the implied operations for a set now use setlike<T> where T is a known
type e.g., setlike<FontFace> setlike implies these operations are generated:

   void forEach(any callback, optional any thisArg);
   boolean has(FontFace fontFace);
   boolean has(FontFace fontFace);

if setlike is not read-only these operations are generated:

       FontFaceSet add(FontFace value);
       boolean delete(FontFace value);
       void clear();

Definition at line 859 of file idlnode.py.

859def generate_setLike_operations_properties(interface, set_like):
860 """
861 Need to create (in our database) a number of operations. This is a new IDL
862 syntax, the implied operations for a set now use setlike<T> where T is a known
863 type e.g., setlike<FontFace> setlike implies these operations are generated:
864
865 void forEach(any callback, optional any thisArg);
866 boolean has(FontFace fontFace);
867 boolean has(FontFace fontFace);
868
869 if setlike is not read-only these operations are generated:
870
871 FontFaceSet add(FontFace value);
872 boolean delete(FontFace value);
873 void clear();
874 """
875 setlike_ops = []
876 """
877 Need to create a typedef for a function callback e.g.,
878 a setlike will need a callback that has the proper args in FontFaceSet that is
879 three arguments, etc.
880
881 typedef void FontFaceSetForEachCallback(
882 FontFace fontFace, FontFace fontFaceAgain, FontFaceSet set);
883
884 void forEach(FontFaceSetForEachCallback callback, [Object thisArg]);
885 """
886 callback_name = '%sForEachCallback' % interface.id
887 set_op = generate_operation(interface.id, 'void', 'forEach',
888 [[IDLType(None, callback_name), 'callback'],
889 [IDLType(None, 'any'), 'thisArg', True]])
890 setlike_ops.append(set_op)
891
892 set_op = generate_operation(
893 interface.id, 'boolean', 'has',
894 [[IDLType(None, set_like.value_type.base_type), 'arg']])
895 setlike_ops.append(set_op)
896
897 if not set_like.is_read_only:
898 # Issue #45676: `add` can return null on Firefox, so this should be
899 # typed nullable.
900 add_result_nullable = True
901 set_op = generate_operation(
902 interface.id, interface.id, 'add',
903 [[IDLType(None, set_like.value_type.base_type), 'arg']],
904 add_result_nullable)
905 setlike_ops.append(set_op)
906 set_op = generate_operation(
907 interface.id, 'boolean', 'delete',
908 [[IDLType(None, set_like.value_type.base_type), 'arg']])
909 setlike_ops.append(set_op)
910 set_op = generate_operation(interface.id, 'void', 'clear', [])
911 setlike_ops.append(set_op)
912
913 return setlike_ops
914
915

◆ report_unions_to_any()

scripts.idlnode.report_unions_to_any ( )

Definition at line 20 of file idlnode.py.

20def report_unions_to_any():
21 global _unions_to_any
22
23 warnings = []
24 for union_id in sorted(_unions_to_any):
25 warnings.append('Union type %s is mapped to \'any\'' % union_id)
26
27 return warnings
28
29
30# Ugly but Chrome IDLs can reference typedefs in any IDL w/o an include. So we
31# need to remember any typedef seen then alias any reference to a typedef.

◆ resolveTypedef()

scripts.idlnode.resolveTypedef (   type)
 Given a type if it's a known typedef (only typedef's that aren't union)
  are remembered for fixup.  typedefs that are union type are mapped to
  any so those we don't need to alias.  typedefs referenced in the file
  where the typedef was defined are automatically aliased to the real type.
  This resolves typedef where the declaration is in another IDL file.

Definition at line 39 of file idlnode.py.

39def resolveTypedef(type):
40 """ Given a type if it's a known typedef (only typedef's that aren't union)
41 are remembered for fixup. typedefs that are union type are mapped to
42 any so those we don't need to alias. typedefs referenced in the file
43 where the typedef was defined are automatically aliased to the real type.
44 This resolves typedef where the declaration is in another IDL file.
45 """
46 for typedef in _typeDefsFixup:
47 if typedef.id == type.id:
48 return typedef.type
49
50 return type
51
52

Variable Documentation

◆ _operation_suffix_map

dict scripts.idlnode._operation_suffix_map
protected
Initial value:
1= {
2 '__getter__': "Getter",
3 '__setter__': "Setter",
4 '__delete__': "Deleter",
5}

Definition at line 53 of file idlnode.py.

◆ _typeDefsFixup

list scripts.idlnode._typeDefsFixup = []
protected

Definition at line 32 of file idlnode.py.

◆ _unions_to_any

list scripts.idlnode._unions_to_any = []
protected

Definition at line 17 of file idlnode.py.

◆ new_asts

dict scripts.idlnode.new_asts = {}

Definition at line 14 of file idlnode.py.