Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
scripts.systemhtml.DartLibrary Class Reference

Public Member Functions

def __init__ (self, name, template_loader, library_type, output_dir, dart_js_interop)
 
def AddFile (self, path)
 
def AddTypeEntry (self, idl_name, dart_name)
 
def Emit (self, emitter, auxiliary_dir)
 

Detailed Description

Definition at line 2292 of file systemhtml.py.

Constructor & Destructor Documentation

◆ __init__()

def scripts.systemhtml.DartLibrary.__init__ (   self,
  name,
  template_loader,
  library_type,
  output_dir,
  dart_js_interop 
)

Definition at line 2294 of file systemhtml.py.

2295 dart_js_interop):
2296 self._template = template_loader.Load(
2297 '%s_%s.darttemplate' % (name, library_type))
2298 self._dart_path = os.path.join(output_dir,
2299 '%s_%s.dart' % (name, library_type))
2300 self._paths = []
2301 self._typeMap = {}
2302 self._dart_js_interop = dart_js_interop
2303

Member Function Documentation

◆ AddFile()

def scripts.systemhtml.DartLibrary.AddFile (   self,
  path 
)

Definition at line 2304 of file systemhtml.py.

2304 def AddFile(self, path):
2305 self._paths.append(path)
2306
static void append(char **dst, size_t *count, const char *src, size_t n)
Definition: editor.cpp:211

◆ AddTypeEntry()

def scripts.systemhtml.DartLibrary.AddTypeEntry (   self,
  idl_name,
  dart_name 
)

Definition at line 2307 of file systemhtml.py.

2307 def AddTypeEntry(self, idl_name, dart_name):
2308 self._typeMap[idl_name] = dart_name
2309

◆ Emit()

def scripts.systemhtml.DartLibrary.Emit (   self,
  emitter,
  auxiliary_dir 
)

Definition at line 2310 of file systemhtml.py.

2310 def Emit(self, emitter, auxiliary_dir):
2311
2312 def massage_path(path):
2313 # The most robust way to emit path separators is to use / always.
2314 return path.replace('\\', '/')
2315
2316 library_emitter = emitter.FileEmitter(self._dart_path)
2317 library_file_dir = os.path.dirname(self._dart_path)
2318 auxiliary_dir = os.path.relpath(auxiliary_dir, library_file_dir)
2319 emitters = library_emitter.Emit(
2320 self._template,
2321 AUXILIARY_DIR=massage_path(auxiliary_dir),
2322 NULLABLE='?')
2323 if isinstance(emitters, tuple):
2324 imports_emitter, map_emitter = emitters
2325 else:
2326 imports_emitter, map_emitter = emitters, None
2327
2328 for path in sorted(self._paths):
2329 relpath = os.path.relpath(path, library_file_dir)
2330 imports_emitter.Emit("part '$PATH';\n", PATH=massage_path(relpath))
2331
2332 # Emit the $!TYPE_MAP
2333 if map_emitter:
2334 items = list(self._typeMap.items())
2335 items.sort()
2336 for (idl_name, dart_name) in items:
2337 map_emitter.Emit(
2338 " '$IDL_NAME': () => $DART_NAME.instanceRuntimeType,\n",
2339 IDL_NAME=idl_name,
2340 DART_NAME=dart_name)
2341
2342
2343# ------------------------------------------------------------------------------
2344
2345

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