Chromium Code Reviews| 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 import emitter | 9 import emitter |
| 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 'factory $CTOR($PARAMS) => ' | 367 'factory $CTOR($PARAMS) => ' |
| 368 '$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n', | 368 '$FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n', |
| 369 CTOR=constructor_info._ConstructorFullName(self._DartType), | 369 CTOR=constructor_info._ConstructorFullName(self._DartType), |
| 370 PARAMS=constructor_info.ParametersDeclaration(self._DartType), | 370 PARAMS=constructor_info.ParametersDeclaration(self._DartType), |
| 371 FACTORY=factory_name, | 371 FACTORY=factory_name, |
| 372 METADATA=metadata, | 372 METADATA=metadata, |
| 373 CTOR_FACTORY_NAME=factory_constructor_name, | 373 CTOR_FACTORY_NAME=factory_constructor_name, |
| 374 FACTORY_PARAMS=factory_parameters) | 374 FACTORY_PARAMS=factory_parameters) |
| 375 else: | 375 else: |
| 376 if has_factory_provider: | 376 if has_factory_provider: |
| 377 dispatcher_emitter = self._members_emitter.Emit( | 377 dispatcher_emitter = self._members_emitter.Emit( |
|
blois
2013/05/07 23:15:06
Is this being used either then?
Andrei Mouravski
2013/05/08 22:52:51
Done.
| |
| 378 '\n $(METADATA)' | 378 '\n $(METADATA)' |
| 379 'factory $CTOR($PARAMS) {\n' | 379 'factory $CTOR($PARAMS) {\n' |
| 380 '$!DISPATCHER' | 380 '$!DISPATCHER' |
| 381 ' return $FACTORY._create($FACTORY_PARAMS);\n' | 381 ' return $FACTORY._create($FACTORY_PARAMS);\n' |
| 382 ' }\n', | 382 ' }\n', |
| 383 CTOR=constructor_info._ConstructorFullName(self._DartType), | 383 CTOR=constructor_info._ConstructorFullName(self._DartType), |
| 384 PARAMS=constructor_info.ParametersDeclaration(self._DartType), | 384 PARAMS=constructor_info.ParametersDeclaration(self._DartType), |
| 385 FACTORY=factory_name, | 385 FACTORY=factory_name, |
| 386 METADATA=metadata, | 386 METADATA=metadata, |
| 387 FACTORY_PARAMS=constructor_info.ParametersAsArgumentList()) | 387 FACTORY_PARAMS=constructor_info.ParametersAsArgumentList()) |
| 388 | 388 |
| 389 for index, param_info in enumerate(constructor_info.param_infos): | |
| 390 if param_info.is_optional: | |
| 391 dispatcher_emitter.Emit( | |
| 392 ' if ($OPT_PARAM_NAME == null) {\n' | |
| 393 ' return $FACTORY._create($FACTORY_PARAMS);\n' | |
| 394 ' }\n', | |
| 395 OPT_PARAM_NAME=param_info.name, | |
| 396 FACTORY=factory_name, | |
| 397 FACTORY_PARAMS=constructor_info.ParametersAsArgumentList(index)) | |
| 398 else: | 389 else: |
| 399 inits = self._members_emitter.Emit( | 390 inits = self._members_emitter.Emit( |
| 400 '\n $(METADATA)' | 391 '\n $(METADATA)' |
| 401 'factory $CONSTRUCTOR($PARAMS) {\n' | 392 'factory $CONSTRUCTOR($PARAMS) {\n' |
| 402 ' var e = $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n' | 393 ' var e = $FACTORY.$CTOR_FACTORY_NAME($FACTORY_PARAMS);\n' |
| 403 '$!INITS' | 394 '$!INITS' |
| 404 ' return e;\n' | 395 ' return e;\n' |
| 405 ' }\n', | 396 ' }\n', |
| 406 CONSTRUCTOR=constructor_info._ConstructorFullName(self._DartType), | 397 CONSTRUCTOR=constructor_info._ConstructorFullName(self._DartType), |
| 407 METADATA=metadata, | 398 METADATA=metadata, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 590 if interface.parents: | 581 if interface.parents: |
| 591 parent = interface.parents[0] | 582 parent = interface.parents[0] |
| 592 if IsPureInterface(parent.type.id): | 583 if IsPureInterface(parent.type.id): |
| 593 walk(interface.parents) | 584 walk(interface.parents) |
| 594 else: | 585 else: |
| 595 walk(interface.parents[1:]) | 586 walk(interface.parents[1:]) |
| 596 return result | 587 return result |
| 597 | 588 |
| 598 def _DartType(self, type_name): | 589 def _DartType(self, type_name): |
| 599 return self._type_registry.DartType(type_name) | 590 return self._type_registry.DartType(type_name) |
| OLD | NEW |