| 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 systems to generate | 6 """This module provides shared functionality for the systems to generate |
| 7 wrapping binding from the IDL database.""" | 7 wrapping binding from the IDL database.""" |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 from generator import * | 10 from generator import * |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 369 |
| 370 # Process in order of ascending number of arguments to ensure missing | 370 # Process in order of ascending number of arguments to ensure missing |
| 371 # optional arguments are processed early. | 371 # optional arguments are processed early. |
| 372 overloads = sorted(info.overloads, | 372 overloads = sorted(info.overloads, |
| 373 key=lambda overload: len(overload.arguments)) | 373 key=lambda overload: len(overload.arguments)) |
| 374 self._native_version = 0 | 374 self._native_version = 0 |
| 375 fallthrough = self.GenerateDispatch(body, info, ' ', 0, overloads) | 375 fallthrough = self.GenerateDispatch(body, info, ' ', 0, overloads) |
| 376 if fallthrough: | 376 if fallthrough: |
| 377 body.Emit(' throw "Incorrect number or type of arguments";\n'); | 377 body.Emit(' throw "Incorrect number or type of arguments";\n'); |
| 378 | 378 |
| 379 def GenerateSingleOperation(self, emitter, info, indent, operation): | 379 def AddStaticOperation(self, info): |
| 380 pass |
| 381 |
| 382 def GenerateSingleOperation(self, emitter, info, indent, operation): |
| 380 """Generates a call to a single operation. | 383 """Generates a call to a single operation. |
| 381 | 384 |
| 382 Arguments: | 385 Arguments: |
| 383 emitter: an Emitter for the body of a block of code. | 386 emitter: an Emitter for the body of a block of code. |
| 384 info: the compound information about the operation and its overloads. | 387 info: the compound information about the operation and its overloads. |
| 385 indent: an indentation string for generated code. | 388 indent: an indentation string for generated code. |
| 386 operation: the IDLOperation to call. | 389 operation: the IDLOperation to call. |
| 387 """ | 390 """ |
| 388 # TODO(sra): Do we need to distinguish calling with missing optional | 391 # TODO(sra): Do we need to distinguish calling with missing optional |
| 389 # arguments from passing 'null' which is represented as 'undefined'? | 392 # arguments from passing 'null' which is represented as 'undefined'? |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee | 537 # dispatch has removed f(X), leaving only f(Y), but there is no guarantee |
| 535 # that Y = Z-X, so we need to check for Y. | 538 # that Y = Z-X, so we need to check for Y. |
| 536 true_code = emitter.Emit( | 539 true_code = emitter.Emit( |
| 537 '$(INDENT)if ($COND) {\n' | 540 '$(INDENT)if ($COND) {\n' |
| 538 '$!TRUE' | 541 '$!TRUE' |
| 539 '$(INDENT)}\n', | 542 '$(INDENT)}\n', |
| 540 COND=test, INDENT=indent) | 543 COND=test, INDENT=indent) |
| 541 self.GenerateDispatch( | 544 self.GenerateDispatch( |
| 542 true_code, info, indent + ' ', position + 1, positive) | 545 true_code, info, indent + ' ', position + 1, positive) |
| 543 return True | 546 return True |
| OLD | NEW |