Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | List of all members
scripts.idlnode.IDLFile Class Reference
Inheritance diagram for scripts.idlnode.IDLFile:
scripts.idlnode.IDLNode

Public Member Functions

 __init__ (self, ast, filename=None)
 
- Public Member Functions inherited from scripts.idlnode.IDLNode
 __repr__ (self)
 
 __eq__ (self, other)
 
 __hash__ (self)
 
 reset_id (self, newId)
 
 all (self, type_filter=None)
 
 to_dict (self)
 
 to_hash (self)
 

Public Attributes

 filename
 
 typeDefs
 
 interfaces
 
 dictionaries
 
 implementsStatements
 
 enums
 
- Public Attributes inherited from scripts.idlnode.IDLNode
 id
 
 ext_attrs
 
 annotations
 
 members
 

Static Public Attributes

str DART_IDL = 'dart.idl'
 

Protected Member Functions

 _createImplementsStatement (self, implementor, implemented_name)
 
- Protected Member Functions inherited from scripts.idlnode.IDLNode
 _extra_repr (self)
 
 _all_subnodes (self)
 
 _to_hashable (self, obj)
 
 _find_all (self, ast, label, max_results=sys.maxsize)
 
 _find_first (self, ast, label)
 
 _has (self, ast, label)
 
 _convert_label_to_field (self, label)
 
 _convert_all (self, ast, label, idlnode_ctor)
 
 _convert_first (self, ast, label, idlnode_ctor)
 
 _convert_ext_attrs (self, ast)
 
 _convert_annotations (self, ast)
 
 _convert_constants (self, ast, js_name)
 

Detailed Description

IDLFile is the top-level node in each IDL file. It may contain interfaces.

Definition at line 413 of file idlnode.py.

Constructor & Destructor Documentation

◆ __init__()

scripts.idlnode.IDLFile.__init__ (   self,
  ast,
  id = None 
)
Initializes an IDLNode from a PegParser AST output.

Reimplemented from scripts.idlnode.IDLNode.

Definition at line 418 of file idlnode.py.

418 def __init__(self, ast, filename=None):
419 IDLNode.__init__(self, ast)
420 self.filename = filename
421
422 filename_basename = os.path.basename(filename)
423
424 # Report of union types mapped to any.
425
426 # Remember all the typedefs before we start walking the AST. Some
427 # IDLs now have typedefs before interfaces. So we need to remember
428 # to resolve the typedefs.
429 self.typeDefs = self._convert_all(ast, 'TypeDef', IDLTypeDef)
430 for typedefName in ast.typedefs:
431 typedef_type = ast.typedefs[typedefName]
432 # Ignore unions and dictionaries for now we just want normal typedefs to resolve our arguments/types.
433 if not (isinstance(typedef_type.idl_type, IdlUnionType)) and not (
434 typedef_type.idl_type.base_type == 'Dictionary'):
435 _addTypedef(IDLTypeDef(typedef_type))
436
437 self.interfaces = self._convert_all(ast, 'Interface', IDLInterface)
438 self.dictionaries = self._convert_all(ast, 'Dictionary', IDLDictionary)
439
440 if len(ast.callback_functions) > 0:
441 callback_functions = self._convert_all(ast, 'Callback_Function',
442 IDLCallbackFunction)
443 for callback_function in callback_functions:
444 for annotation in callback_function.annotations:
445 callback = callback_function.annotations[annotation]
446 cb_interface = IDLInterface(None, callback.name)
447 cb_interface.ext_attrs['Callback'] = len(callback.arguments)
448 op = IDLOperation(None, cb_interface.id, "handleEvent")
449 op.type = IDLType(callback.idl_type)
450 op.type = resolveTypedef(op.type)
451
452 if len(callback.arguments) > 0:
453 op.arguments = self._convert_all(
454 callback, 'Argument', IDLArgument)
455
456 cb_interface.operations = [op]
457 self.interfaces.append(cb_interface)
458
459 is_blink = not (isinstance(
460 ast, list)) and ast.__module__ == 'idl_definitions'
461
462 if is_blink:
463 # implements is handled by the interface merging step (see the function
464 # merge_interface_dependencies).
465 for interface in self.interfaces:
466 blink_interface = ast.interfaces.get(interface.id)
467 if filename_basename == self.DART_IDL:
468 # Special handling for dart.idl we need to remember the interface,
469 # since we could have many (not one interface / file). Then build up
470 # the IDLImplementsStatement for any implements in dart.idl.
471 interface_info = dependency.get_interfaces_info(
472 )['__dart_idl___']
473
474 self.implementsStatements = []
475
476 implement_pairs = interface_info['implement_pairs']
477 for implement_pair in implement_pairs:
478 interface_name = implement_pair[0]
479 implemented_name = implement_pair[1]
480
481 implementor = new_asts[interface_name].interfaces.get(
482 interface_name)
483 implement_statement = self._createImplementsStatement(
484 implementor, implemented_name)
485
486 self.implementsStatements.append(implement_statement)
487 elif interface.id in dependency.get_interfaces_info():
488 interface_info = dependency.get_interfaces_info()[interface.
489 id]
490
491 implements = []
492 if 'implements_interfaces' in interface_info:
493 implements = interface_info['implements_interfaces']
494 if not (blink_interface.is_partial) and len(implements) > 0:
495 implementor = new_asts[interface.id].interfaces.get(
496 interface.id)
497
498 self.implementsStatements = []
499
500 # TODO(terry): Need to handle more than one implements.
501 for implemented_name in implements:
502 implement_statement = self._createImplementsStatement(
503 implementor, implemented_name)
504 self.implementsStatements.append(
505 implement_statement)
506 else:
507 self.implementsStatements = []
508 else:
509 self.implementsStatements = self._convert_all(
510 ast, 'ImplStmt', IDLImplementsStatement)
511
512 # Record typedefs that are unions.
513 for typedefName in ast.typedefs:
514 typedef_type = ast.typedefs[typedefName]
515 if isinstance(typedef_type.idl_type, IdlUnionType):
516 self.typeDefs.append(IDLTypeDef(typedef_type))
517 elif typedef_type.idl_type.base_type == 'Dictionary':
518 dictionary = IDLDictionary(typedef_type, True)
519 self.dictionaries.append(dictionary)
520
521 self.enums = self._convert_all(ast, 'Enum', IDLEnum)
522
static void append(char **dst, size_t *count, const char *src, size_t n)
Definition editor.cpp:211
get_interfaces_info()
Definition dependency.py:9

Member Function Documentation

◆ _createImplementsStatement()

scripts.idlnode.IDLFile._createImplementsStatement (   self,
  implementor,
  implemented_name 
)
protected

Definition at line 523 of file idlnode.py.

523 def _createImplementsStatement(self, implementor, implemented_name):
524 implemented = new_asts[implemented_name].interfaces.get(
525 implemented_name)
526
527 implement_statement = IDLImplementsStatement(implemented)
528
529 implement_statement.implementor = IDLType(implementor)
530 implement_statement.implemented = IDLType(implemented)
531
532 return implement_statement
533
534

Member Data Documentation

◆ DART_IDL

str scripts.idlnode.IDLFile.DART_IDL = 'dart.idl'
static

Definition at line 416 of file idlnode.py.

◆ dictionaries

scripts.idlnode.IDLFile.dictionaries

Definition at line 438 of file idlnode.py.

◆ enums

scripts.idlnode.IDLFile.enums

Definition at line 521 of file idlnode.py.

◆ filename

scripts.idlnode.IDLFile.filename

Definition at line 420 of file idlnode.py.

◆ implementsStatements

scripts.idlnode.IDLFile.implementsStatements

Definition at line 474 of file idlnode.py.

◆ interfaces

scripts.idlnode.IDLFile.interfaces

Definition at line 437 of file idlnode.py.

◆ typeDefs

scripts.idlnode.IDLFile.typeDefs

Definition at line 429 of file idlnode.py.


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