OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 """This module generates Dart APIs from the IDL database.""" | 6 """This module generates Dart APIs from the IDL database.""" |
7 | 7 |
8 import emitter | 8 import emitter |
9 import idlnode | 9 import idlnode |
10 import logging | 10 import logging |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 ast = [('Annotation', [('Id', 'WebKit')]), | 280 ast = [('Annotation', [('Id', 'WebKit')]), |
281 ('InterfaceType', ('ScopedName', 'EventTarget'))] | 281 ('InterfaceType', ('ScopedName', 'EventTarget'))] |
282 interface.parents.append(idlnode.IDLParentInterface(ast)) | 282 interface.parents.append(idlnode.IDLParentInterface(ast)) |
283 | 283 |
284 def AddMissingArguments(self, database): | 284 def AddMissingArguments(self, database): |
285 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'Object')), ('Id', 'arg')
]) | 285 ARG = idlnode.IDLArgument([('Type', ('ScopedName', 'Object')), ('Id', 'arg')
]) |
286 for interface in database.GetInterfaces(): | 286 for interface in database.GetInterfaces(): |
287 for operation in interface.operations: | 287 for operation in interface.operations: |
288 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|CallStack': | 288 if operation.ext_attrs.get('CallWith') == 'ScriptArguments|CallStack': |
289 operation.arguments.append(ARG) | 289 operation.arguments.append(ARG) |
290 | |
291 # ------------------------------------------------------------------------------ | |
292 | |
293 class DummyImplementationSystem(systembase.System): | |
294 """Generates a dummy implementation for use by the editor analysis. | |
295 | |
296 All the code comes from hand-written library files. | |
297 """ | |
298 | |
299 def __init__(self, options): | |
300 super(DummyImplementationSystem, self).__init__(options) | |
301 factory_providers_file = os.path.join(self._output_dir, 'src', 'dummy', | |
302 'RegularFactoryProviders.dart') | |
303 self._factory_providers_emitter = self._emitters.FileEmitter( | |
304 factory_providers_file) | |
305 self._impl_file_paths = [factory_providers_file] | |
306 | |
307 def ProcessInterface(self, interface): | |
308 DummyInterfaceGenerator(self, interface).Generate() | |
309 | |
310 def ProcessCallback(self, interface, info): | |
311 pass | |
312 | |
313 def GenerateLibraries(self): | |
314 # Library generated for implementation. | |
315 self._GenerateLibFile( | |
316 'dom_dummy.darttemplate', | |
317 os.path.join(self._output_dir, 'dom_dummy.dart'), | |
318 (self._interface_system._dart_interface_file_paths + | |
319 self._impl_file_paths)) | |
320 | |
321 | |
322 # ------------------------------------------------------------------------------ | |
323 | |
324 class DummyInterfaceGenerator(systembase.BaseGenerator): | |
325 """Generates dummy implementation.""" | |
326 | |
327 def __init__(self, system, interface): | |
328 super(DummyInterfaceGenerator, self).__init__(system._database, interface) | |
329 self._system = system | |
330 | |
331 def StartInterface(self): | |
332 # There is no implementation to match the interface, but there might be a | |
333 # factory constructor for the Dart interface. | |
334 constructor_info = AnalyzeConstructor(self._interface) | |
335 if constructor_info: | |
336 dart_interface_name = self._interface.id | |
337 self._EmitFactoryProvider(dart_interface_name, constructor_info) | |
338 | |
339 def _EmitFactoryProvider(self, interface_name, constructor_info): | |
340 factory_provider = '_' + interface_name + 'FactoryProvider' | |
341 self._system._factory_providers_emitter.Emit( | |
342 self._system._templates.Load('factoryprovider.darttemplate'), | |
343 FACTORYPROVIDER=factory_provider, | |
344 CONSTRUCTOR=interface_name, | |
345 PARAMETERS=constructor_info.ParametersImplementationDeclaration(DartType
)) | |
346 | |
347 def FinishInterface(self): | |
348 pass | |
349 | |
350 def AddTypedArrayConstructors(self, element_type): | |
351 pass | |
352 | |
353 def AddEventAttributes(self, event_attrs): | |
354 pass | |
OLD | NEW |