100 generate_prototype_events=False):
101 print(
'\n ----- Accessing DOM using %s -----\n' %
102 ('dart:js' if dart_js_interop else 'C++'))
103
104 start_time = time.time()
105
106 current_dir = os.path.dirname(__file__)
107 auxiliary_dir = os.path.join(current_dir, '..', 'src')
108 template_dir = os.path.join(current_dir, '..', 'templates')
109
110 _logger.setLevel(logging_level)
111
112 generator = dartgenerator.DartGenerator(logging_level)
113 generator.LoadAuxiliary(auxiliary_dir)
114
115 generator.FilterMembersWithUnidentifiedTypes(common_database)
116 webkit_database = common_database.Clone()
117
118
119 generator.FilterInterfaces(
120 database=webkit_database,
121 or_annotations=['WebKit', 'Dart'],
122 exclude_displaced=['WebKit'],
123 exclude_suppressed=['WebKit', 'Dart'])
124 generator.FixEventTargets(webkit_database)
125 generator.AddMissingArguments(webkit_database)
126 generator.CleanupOperationArguments(webkit_database)
127
128 emitters = multiemitter.MultiEmitter(logging_level)
129 metadata = DartMetadata(os.path.join(current_dir, '..', 'dom.json'),
130 os.path.join(current_dir, '..', 'docs.json'),
131 logging_level)
132 renamer = HtmlRenamer(webkit_database, metadata)
133 type_registry = TypeRegistry(webkit_database, renamer)
134
135 print(
'GenerateFromDatabase %s seconds' %
round(
136 (time.time() - start_time), 2))
137
138 def RunGenerator(dart_libraries, dart_output_dir, template_loader,
139 backend_factory, dart_js_interop):
140 options = GeneratorOptions(template_loader, webkit_database,
141 type_registry, renamer, metadata,
142 dart_js_interop)
143 dart_library_emitter = DartLibraryEmitter(emitters, dart_output_dir,
144 dart_libraries)
145 event_generator = HtmlEventGenerator(webkit_database, renamer, metadata,
146 template_loader)
147 prototype_event_generator = Prototype_HtmlEventGenerator(
148 webkit_database, renamer, metadata, event_generator)
149
150 def generate_interface(interface, gl_constants=None):
151 backend = backend_factory(interface)
152 interface_generator = HtmlDartInterfaceGenerator(
153 options, dart_library_emitter, event_generator,
154 prototype_event_generator, interface, backend)
155 interface_generator.Generate()
156 if len(backend._gl_constants) > 0
and not (gl_constants
is None):
157 gl_constants.extend(backend._gl_constants)
158
159 generator.Generate(webkit_database, common_database, generate_interface)
160 if generate_prototype_events:
162 prototype_event_generator.WriteFile(dart_bin)
163
164 dart_library_emitter.EmitLibraries(auxiliary_dir, dart_js_interop)
165
166 if dart2js_output_dir:
167 template_paths = ['html/dart2js', 'html/impl', 'html/interface', '']
168 template_loader = TemplateLoader(template_dir, template_paths, {
169 'DARTIUM': False,
170 'DART2JS': True,
171 'JSINTEROP': False,
172 'NNBD': True,
173 })
174 backend_options = GeneratorOptions(template_loader, webkit_database,
175 type_registry, renamer, metadata,
176 dart_js_interop)
177
178 backend_factory = lambda interface:\
179 Dart2JSBackend(interface, backend_options, logging_level, generate_static_extensions)
180
181 dart_output_dir = os.path.join(dart2js_output_dir, 'dart')
182 dart_libraries = DartLibraries(HTML_LIBRARY_NAMES, template_loader,
183 'dart2js', dart2js_output_dir,
184 dart_js_interop)
185 for file in generator._auxiliary_files.values():
186 if file.endswith('darttemplate'):
187 dart_libraries._libraries['html'].AddFile(file)
188
189 print(
'\nGenerating dart2js:\n')
190 start_time = time.time()
191
192 RunGenerator(dart_libraries, dart_output_dir, template_loader,
193 backend_factory, dart_js_interop)
194
195 print(
'Generated dart2js in %s seconds' %
196 round(time.time() - start_time, 2))
197
198 emitters.Flush()
199
200 if update_dom_metadata:
201 metadata.Flush()
202
203 monitored.FinishMonitoring(dart2js_output_dir, _logger)
204
205
static void round(SkPoint *p)
def print(*args, **kwargs)