Flutter Engine
The Flutter Engine
Classes | Functions | Variables
code_generator_dart Namespace Reference

Classes

class  CodeGeneratorDart
 

Functions

def initialize_jinja_env (cache_dir)
 
def conditional_if_endif (code, conditional_string)
 
def runtime_enabled_if (code, runtime_enabled_function_name)
 
def main (argv)
 

Variables

 module_path
 
 module_filename
 
 third_party_dir
 
 templates_dir = os.path.normpath(os.path.join(module_path, 'templates'))
 
string module_pyname = os.path.splitext(module_filename)[0] + '.py'
 
 dart_script_path = os.path.dirname(os.path.abspath(__file__))
 
 script_path
 
 INTERFACES_WITHOUT_RESOLVERS
 

Function Documentation

◆ conditional_if_endif()

def code_generator_dart.conditional_if_endif (   code,
  conditional_string 
)

Definition at line 273 of file code_generator_dart.py.

273def conditional_if_endif(code, conditional_string):
274 # Jinja2 filter to generate if/endif directive blocks
275 if not conditional_string:
276 return code
277 return ('#if %s\n' % conditional_string + code +
278 '#endif // %s\n' % conditional_string)
279
280
281# [RuntimeEnabled]
def conditional_if_endif(code, conditional_string)

◆ initialize_jinja_env()

def code_generator_dart.initialize_jinja_env (   cache_dir)

Definition at line 255 of file code_generator_dart.py.

255def initialize_jinja_env(cache_dir):
256 jinja_env = jinja2.Environment(
257 loader=jinja2.FileSystemLoader(templates_dir),
258 # Bytecode cache is not concurrency-safe unless pre-cached:
259 # if pre-cached this is read-only, but writing creates a race condition.
260 bytecode_cache=jinja2.FileSystemBytecodeCache(cache_dir),
261 keep_trailing_newline=True, # newline-terminate generated files
262 lstrip_blocks=True, # so can indent control flow tags
263 trim_blocks=True)
264 jinja_env.filters.update({
265 'blink_capitalize': DartUtilities.capitalize,
266 'conditional': conditional_if_endif,
267 'runtime_enabled': runtime_enabled_if,
268 })
269 return jinja_env
270
271
272# [Conditional]
def initialize_jinja_env(cache_dir)

◆ main()

def code_generator_dart.main (   argv)

Definition at line 294 of file code_generator_dart.py.

294def main(argv):
295 # If file itself executed, cache templates
296 try:
297 cache_dir = argv[1]
298 dummy_filename = argv[2]
299 except IndexError as err:
300 print('Usage: %s OUTPUT_DIR DUMMY_FILENAME' % argv[0])
301 return 1
302
303 # Cache templates
304 jinja_env = initialize_jinja_env(cache_dir)
305 template_filenames = [
306 filename for filename in os.listdir(templates_dir)
307 # Skip .svn, directories, etc.
308 if filename.endswith(('.cpp', '.h', '.template'))
309 ]
310 for template_filename in template_filenames:
311 jinja_env.get_template(template_filename)
312
313 # Create a dummy file as output for the build system,
314 # since filenames of individual cache files are unpredictable and opaque
315 # (they are hashes of the template path, which varies based on environment)
316 with open(dummy_filename, 'w') as dummy_file:
317 pass # |open| creates or touches the file
318
319
def print(*args, **kwargs)
Definition: run_tests.py:49

◆ runtime_enabled_if()

def code_generator_dart.runtime_enabled_if (   code,
  runtime_enabled_function_name 
)

Definition at line 282 of file code_generator_dart.py.

282def runtime_enabled_if(code, runtime_enabled_function_name):
283 if not runtime_enabled_function_name:
284 return code
285 # Indent if statement to level of original code
286 indent = re.match(' *', code).group(0)
287 return ('%sif (%s())\n' % (indent, runtime_enabled_function_name) +
288 ' %s' % code)
289
290
def runtime_enabled_if(code, runtime_enabled_function_name)

Variable Documentation

◆ dart_script_path

code_generator_dart.dart_script_path = os.path.dirname(os.path.abspath(__file__))

Definition at line 73 of file code_generator_dart.py.

◆ INTERFACES_WITHOUT_RESOLVERS

code_generator_dart.INTERFACES_WITHOUT_RESOLVERS
Initial value:
1= frozenset([
2 'TypeConversions', 'GCObservation', 'InternalProfilers',
3 'InternalRuntimeFlags', 'InternalSettings', 'InternalSettingsGenerated',
4 'Internals', 'LayerRect', 'LayerRectList', 'MallocStatistics',
5 'TypeConversions'
6])

Definition at line 87 of file code_generator_dart.py.

◆ module_filename

code_generator_dart.module_filename

Definition at line 58 of file code_generator_dart.py.

◆ module_path

code_generator_dart.module_path

Definition at line 58 of file code_generator_dart.py.

◆ module_pyname

string code_generator_dart.module_pyname = os.path.splitext(module_filename)[0] + '.py'

Definition at line 65 of file code_generator_dart.py.

◆ script_path

code_generator_dart.script_path
Initial value:
1= os.path.join(
2 os.path.dirname(os.path.dirname(dart_script_path)), 'scripts')

Definition at line 74 of file code_generator_dart.py.

◆ templates_dir

code_generator_dart.templates_dir = os.path.normpath(os.path.join(module_path, 'templates'))

Definition at line 62 of file code_generator_dart.py.

◆ third_party_dir

code_generator_dart.third_party_dir
Initial value:
1= os.path.normpath(
2 os.path.join(module_path, os.pardir, os.pardir, os.pardir, os.pardir,
3 os.pardir))

Definition at line 59 of file code_generator_dart.py.