Flutter Engine
The Flutter Engine
Functions | Variables
scripts.generate_blink_file Namespace Reference

Functions

def generate_parameter_entries (param_infos)
 
def rename_constructor (name)
 
def Select_Stub (template, is_native)
 
def Generate_Blink (output_dir, database, type_registry)
 

Variables

string HEADER
 
string END_RESOLVER
 
string BLINK_UTILS
 
string CLASS_DEFINITION
 
string CLASS_DEFINITION_EXTENDS
 
list CONSTRUCTOR_0
 
list CONSTRUCTOR_ARGS
 
list ATTRIBUTE_GETTER
 
list ATTRIBUTE_SETTER
 
list OPERATION_0
 
list OPERATION_1
 
list OPERATION_2
 
list OPERATION_PQ
 
string ARGUMENT_NUM = "__arg_%s"
 
list OPERATION_ARGS
 
string CLASS_STATIC = 'Blink_JsNative_DomException.getProperty(js.context, "%s")'
 
list STATIC_ATTRIBUTE_GETTER
 
list STATIC_OPERATION_0
 
list STATIC_OPERATION_ARGS
 
string CLASS_DEFINITION_END
 
dictionary constructor_renames
 
dictionary suppressed_operations
 

Function Documentation

◆ Generate_Blink()

def scripts.generate_blink_file.Generate_Blink (   output_dir,
  database,
  type_registry 
)

Definition at line 432 of file generate_blink_file.py.

432def Generate_Blink(output_dir, database, type_registry):
433 blink_filename = os.path.join(output_dir, '_blink_dartium.dart')
434 blink_file = open(blink_filename, 'w')
435
436 blink_file.write(HEADER)
437
438 interfaces = database.GetInterfaces()
439 for interface in interfaces:
440 name = interface.id
441 resolver_entry = ' if (s == "%s") return Blink%s.instance;\n' % (name,
442 name)
443 blink_file.write(resolver_entry)
444
445 blink_file.write(END_RESOLVER)
446
447 for interface in interfaces:
448 name = interface.id
449
450 if interface.parents and len(
451 interface.parents) > 0 and interface.parents[0].id:
452 extends = interface.parents[0].id
453 class_def = CLASS_DEFINITION_EXTENDS % (name, extends, name)
454 else:
455 class_def = CLASS_DEFINITION % (name, name)
456 blink_file.write(class_def)
457
458 analyzed_constructors = AnalyzeConstructor(interface)
459 if analyzed_constructors:
460 _Emit_Blink_Constructors(blink_file, analyzed_constructors)
461 elif 'Constructor' in interface.ext_attrs:
462 # Zero parameter constructor.
463 blink_file.write(
464 Select_Stub(CONSTRUCTOR_0, _Is_Native(name, 'constructor')) %
465 rename_constructor(name))
466
467 _Process_Attributes(blink_file, interface, interface.attributes)
468 _Process_Operations(blink_file, interface, interface.operations, True)
469
470 _Emit_Extra_Operations(blink_file, name)
471
472 secondary_parents = database.TransitiveSecondaryParents(
473 interface, False)
474 for secondary in secondary_parents:
475 _Process_Attributes(blink_file, secondary, secondary.attributes)
476 _Process_Operations(blink_file, secondary, secondary.operations,
477 False)
478
479 blink_file.write(CLASS_DEFINITION_END)
480
481 blink_file.write(BLINK_UTILS)
482
483 blink_file.close()
484
485

◆ generate_parameter_entries()

def scripts.generate_blink_file.generate_parameter_entries (   param_infos)

Definition at line 387 of file generate_blink_file.py.

387def generate_parameter_entries(param_infos):
388 optional_default_args = 0
389 for argument in param_infos:
390 if argument.is_optional:
391 optional_default_args += 1
392
393 arg_count = len(param_infos)
394 min_arg_count = arg_count - optional_default_args
395 lb = min_arg_count - 2 if min_arg_count > 2 else 0
396 return (lb, arg_count + 1)
397
398

◆ rename_constructor()

def scripts.generate_blink_file.rename_constructor (   name)

Definition at line 405 of file generate_blink_file.py.

405def rename_constructor(name):
406 return constructor_renames[name] if name in constructor_renames else name
407
408

◆ Select_Stub()

def scripts.generate_blink_file.Select_Stub (   template,
  is_native 
)

Definition at line 425 of file generate_blink_file.py.

425def Select_Stub(template, is_native):
426 if is_native:
427 return template[0] + template[2]
428 else:
429 return template[0] + template[1]
430
431

Variable Documentation

◆ ARGUMENT_NUM

string scripts.generate_blink_file.ARGUMENT_NUM = "__arg_%s"

Definition at line 352 of file generate_blink_file.py.

◆ ATTRIBUTE_GETTER

list scripts.generate_blink_file.ATTRIBUTE_GETTER
Initial value:
1= [
2 ' %s_Getter_(mthis)',
3 ' => Blink_JsNative_DomException.getProperty(mthis /* %s */, "%s");\n\n',
4 ' native "Blink_Getter_%s_%s";\n\n'
5]

Definition at line 313 of file generate_blink_file.py.

◆ ATTRIBUTE_SETTER

list scripts.generate_blink_file.ATTRIBUTE_SETTER
Initial value:
1= [
2 ' %s_Setter_(mthis, __arg_0)',
3 ' => Blink_JsNative_DomException.setProperty(mthis /* %s */, "%s", __arg_0);\n\n',
4 ' native "Blink_Setter_%s_%s";\n\n'
5]

Definition at line 319 of file generate_blink_file.py.

◆ BLINK_UTILS

string scripts.generate_blink_file.BLINK_UTILS

Definition at line 121 of file generate_blink_file.py.

◆ CLASS_DEFINITION

string scripts.generate_blink_file.CLASS_DEFINITION
Initial value:
1= """class Blink%s {
2 static final instance = new Blink%s();
3
4"""
struct MyStruct s

Definition at line 286 of file generate_blink_file.py.

◆ CLASS_DEFINITION_END

string scripts.generate_blink_file.CLASS_DEFINITION_END
Initial value:
1= """}
2
3"""

Definition at line 383 of file generate_blink_file.py.

◆ CLASS_DEFINITION_EXTENDS

string scripts.generate_blink_file.CLASS_DEFINITION_EXTENDS
Initial value:
1= """class Blink%s extends Blink%s {
2 static final instance = new Blink%s();
3
4"""

Definition at line 291 of file generate_blink_file.py.

◆ CLASS_STATIC

string scripts.generate_blink_file.CLASS_STATIC = 'Blink_JsNative_DomException.getProperty(js.context, "%s")'

Definition at line 360 of file generate_blink_file.py.

◆ CONSTRUCTOR_0

list scripts.generate_blink_file.CONSTRUCTOR_0
Initial value:
1= [
2 ' constructorCallback_0_()',
3 ' => Blink_JsNative_DomException.callConstructor0("%s");\n\n',
4 ' native "Blink_Constructor_%s";\n\n'
5]

Definition at line 299 of file generate_blink_file.py.

◆ CONSTRUCTOR_ARGS

list scripts.generate_blink_file.CONSTRUCTOR_ARGS
Initial value:
1= [
2 ' constructorCallback_%s_(%s)',
3 ' => Blink_JsNative_DomException.callConstructor("%s", [%s]);\n\n',
4 ' native "Blink_Constructor_Args_%s" /* %s */;\n\n'
5]

Definition at line 306 of file generate_blink_file.py.

◆ constructor_renames

dictionary scripts.generate_blink_file.constructor_renames
Initial value:
1= {
2 'RTCPeerConnection': 'webkitRTCPeerConnection',
3 'SpeechRecognition': 'webkitSpeechRecognition',
4}

Definition at line 399 of file generate_blink_file.py.

◆ END_RESOLVER

string scripts.generate_blink_file.END_RESOLVER
Initial value:
1= """
2 // Failed to find it, check for custom renames
3 dynamic obj = resolverMap[s];
4 if (obj != null) return obj;
5 throw("No such interface exposed in blink: ${s}");
6}
7
8"""

Definition at line 112 of file generate_blink_file.py.

◆ HEADER

string scripts.generate_blink_file.HEADER
Initial value:
1= """/* Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 * for details. All rights reserved. Use of this source code is governed by a
3 * BSD-style license that can be found in the LICENSE file.
4 *
5 * DO NOT EDIT
6 * Auto-generated _blink library.
7 */
8library dart.dom._blink;
9
10import 'dart:async';
11import 'dart:js' as js;
12import 'dart:html' show DomException;
13import 'dart:_internal' as internal;
14// This is a place to put custom renames if we need them.
15final resolverMap = {
16};
17
18dynamic resolver(String s) {
19"""

Definition at line 92 of file generate_blink_file.py.

◆ OPERATION_0

list scripts.generate_blink_file.OPERATION_0
Initial value:
1= [
2 ' %s_Callback_0_(mthis)',
3 ' => Blink_JsNative_DomException.callMethod(mthis /* %s */, "%s", []);\n\n',
4 ' native "Blink_Operation_0_%s_%s";\n\n'
5]

Definition at line 326 of file generate_blink_file.py.

◆ OPERATION_1

list scripts.generate_blink_file.OPERATION_1
Initial value:
1= [
2 ' $%s_Callback_1_(mthis, __arg_0)',
3 ' => Blink_JsNative_DomException.callMethod(mthis /* %s */, "%s", [__arg_0]);\n\n',
4 ' native "Blink_Operation_1_%s_%s";\n\n'
5]

Definition at line 333 of file generate_blink_file.py.

◆ OPERATION_2

list scripts.generate_blink_file.OPERATION_2
Initial value:
1= [
2 ' $%s_Callback_2_(mthis, __arg_0, __arg_1)',
3 ' => Blink_JsNative_DomException.callMethod(mthis /* %s */, "%s", [__arg_0, __arg_1]);\n\n',
4 ' native "Blink_Operation_2_%s_%s";\n\n'
5]

Definition at line 339 of file generate_blink_file.py.

◆ OPERATION_ARGS

list scripts.generate_blink_file.OPERATION_ARGS
Initial value:
1= [
2 ' %s_Callback_%s_(mthis, %s)',
3 ' => Blink_JsNative_DomException.callMethod(mthis /* %s */, "%s", [%s]);\n\n',
4 ' native "Blink_Operation_%s_%s"; /* %s */\n\n'
5]

Definition at line 353 of file generate_blink_file.py.

◆ OPERATION_PQ

list scripts.generate_blink_file.OPERATION_PQ
Initial value:
1= [
2 ' $%s_Callback_1_(mthis, __arg_0)',
3 ' => Blink_JsNative_DomException.propertyQuery(mthis, __arg_0); /* %s */ \n\n',
4 ' native "Blink_Operation_PQ_%s";\n\n'
5]

Definition at line 345 of file generate_blink_file.py.

◆ STATIC_ATTRIBUTE_GETTER

list scripts.generate_blink_file.STATIC_ATTRIBUTE_GETTER
Initial value:
1= [
2 ' %s_Getter_()',
3 ' => Blink_JsNative_DomException.getProperty(%s /* %s */, "%s");\n\n',
4 ' /* %s */ native "Blink_Static_getter_%s_%s"'
5]

Definition at line 363 of file generate_blink_file.py.

◆ STATIC_OPERATION_0

list scripts.generate_blink_file.STATIC_OPERATION_0
Initial value:
1= [
2 ' %s_Callback_0_()',
3 ' => Blink_JsNative_DomException.callMethod(%s /* %s */, "%s", []);\n\n',
4 ' /* %s */ native "Blink_Static_Operation_0_%s_%s'
5]

Definition at line 370 of file generate_blink_file.py.

◆ STATIC_OPERATION_ARGS

list scripts.generate_blink_file.STATIC_OPERATION_ARGS
Initial value:
1= [
2 ' %s_Callback_%s_(%s)',
3 ' => Blink_JsNative_DomException.callMethod(%s /* %s */, "%s", [%s]);\n\n',
4 ' /* %s */ native "Blink_Static_Operations_%s_%s" /* %s */ \n\n'
5]

Definition at line 377 of file generate_blink_file.py.

◆ suppressed_operations

dictionary scripts.generate_blink_file.suppressed_operations
Initial value:
1= {
2 'WebGL2RenderingContextBase': ['readPixels2', 'texImage2D2'],
3}

Definition at line 568 of file generate_blink_file.py.