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 provides shared functionality for the system to generate | 6 """This module provides shared functionality for the system to generate |
7 dart:html APIs from the IDL database.""" | 7 dart:html APIs from the IDL database.""" |
8 | 8 |
9 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 9 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ | 10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 FACTORY=factory_name, | 320 FACTORY=factory_name, |
321 CTOR_FACTORY_NAME=factory_constructor_name, | 321 CTOR_FACTORY_NAME=factory_constructor_name, |
322 PARAMS=constructor_info.ParametersDeclaration(self._DartType), | 322 PARAMS=constructor_info.ParametersDeclaration(self._DartType), |
323 FACTORY_PARAMS=factory_parameters) | 323 FACTORY_PARAMS=factory_parameters) |
324 | 324 |
325 for index, param_info in enumerate(constructor_info.param_infos): | 325 for index, param_info in enumerate(constructor_info.param_infos): |
326 if param_info.is_optional: | 326 if param_info.is_optional: |
327 inits.Emit(' if ($E != null) e.$E = $E;\n', E=param_info.name) | 327 inits.Emit(' if ($E != null) e.$E = $E;\n', E=param_info.name) |
328 | 328 |
329 if not constructor_info.pure_dart_constructor: | 329 if not constructor_info.pure_dart_constructor: |
330 template_file = ('factoryprovider_%s.darttemplate' % self._interface.doc_j
s_name) | 330 self.EmitStaticFactory(constructor_info) |
331 template = self._template_loader.TryLoad(template_file) | |
332 if template: | |
333 # There is a class specific factory. | |
334 # TODO(antonm): should move into the class template. | |
335 self._members_emitter.Emit(template) | |
336 else: | |
337 self.EmitStaticFactory(constructor_info) | |
338 | 331 |
339 def EmitHelpers(self, base_class): | 332 def EmitHelpers(self, base_class): |
340 pass | 333 pass |
341 | 334 |
342 def DeclareAttribute(self, attribute, type_name, attr_name, read_only): | 335 def DeclareAttribute(self, attribute, type_name, attr_name, read_only): |
343 """ Declares an attribute but does not include the code to invoke it. | 336 """ Declares an attribute but does not include the code to invoke it. |
344 """ | 337 """ |
345 self.EmitAttributeDocumentation(attribute) | 338 self.EmitAttributeDocumentation(attribute) |
346 if read_only: | 339 if read_only: |
347 template = '\n $TYPE get $NAME;\n' | 340 template = '\n $TYPE get $NAME;\n' |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 walk(interface.parents) | 432 walk(interface.parents) |
440 else: | 433 else: |
441 walk(interface.parents[1:]) | 434 walk(interface.parents[1:]) |
442 return result | 435 return result |
443 | 436 |
444 def _DartType(self, type_name): | 437 def _DartType(self, type_name): |
445 return self._type_registry.DartType(type_name) | 438 return self._type_registry.DartType(type_name) |
446 | 439 |
447 def _IsPrivate(self, name): | 440 def _IsPrivate(self, name): |
448 return name.startswith('_') | 441 return name.startswith('_') |
OLD | NEW |