| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, 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 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 ' }\n' | 1633 ' }\n' |
| 1634 '}\n', | 1634 '}\n', |
| 1635 CLASS=self._class_name, | 1635 CLASS=self._class_name, |
| 1636 NAME=info.name, | 1636 NAME=info.name, |
| 1637 JSNAME1=js_name_1, | 1637 JSNAME1=js_name_1, |
| 1638 JSNAME2=js_name_2, | 1638 JSNAME2=js_name_2, |
| 1639 NATIVENAME=native_name, | 1639 NATIVENAME=native_name, |
| 1640 PARAMS=', '.join(['_this'] + arg_names), | 1640 PARAMS=', '.join(['_this'] + arg_names), |
| 1641 ARGS=', '.join(['_this.$dom'] + unwrap_args)) | 1641 ARGS=', '.join(['_this.$dom'] + unwrap_args)) |
| 1642 else: | 1642 else: |
| 1643 if info.js_name in ['delete', 'continue']: |
| 1644 access = "['%s']" % info.js_name |
| 1645 else: |
| 1646 access = ".%s" % info.js_name |
| 1643 self._js_code.Emit( | 1647 self._js_code.Emit( |
| 1644 '\n' | 1648 '\n' |
| 1645 'function native_$(CLASS)_$(NATIVENAME)($PARAMS) {\n' | 1649 'function native_$(CLASS)_$(NATIVENAME)($PARAMS) {\n' |
| 1646 ' try {\n' | 1650 ' try {\n' |
| 1647 ' return __dom_wrap(_this.$dom.$JSNAME($ARGS));\n' | 1651 ' return __dom_wrap(_this.$dom$ACCESS($ARGS));\n' |
| 1648 ' } catch (e) {\n' | 1652 ' } catch (e) {\n' |
| 1649 ' throw __dom_wrap_exception(e);\n' | 1653 ' throw __dom_wrap_exception(e);\n' |
| 1650 ' }\n' | 1654 ' }\n' |
| 1651 '}\n', | 1655 '}\n', |
| 1652 CLASS=self._class_name, | 1656 CLASS=self._class_name, |
| 1653 NAME=info.name, | 1657 NAME=info.name, |
| 1654 JSNAME=info.js_name, | 1658 ACCESS=access, |
| 1655 NATIVENAME=native_name, | 1659 NATIVENAME=native_name, |
| 1656 PARAMS=', '.join(['_this'] + arg_names), | 1660 PARAMS=', '.join(['_this'] + arg_names), |
| 1657 ARGS=', '.join(unwrap_args)) | 1661 ARGS=', '.join(unwrap_args)) |
| 1658 | 1662 |
| 1659 | 1663 |
| 1660 def GenerateDispatch(self, emitter, info, indent, position, overloads): | 1664 def GenerateDispatch(self, emitter, info, indent, position, overloads): |
| 1661 """Generates a dispatch to one of the overloads. | 1665 """Generates a dispatch to one of the overloads. |
| 1662 | 1666 |
| 1663 Arguments: | 1667 Arguments: |
| 1664 emitter: an Emitter for the body of a block of code. | 1668 emitter: an Emitter for the body of a block of code. |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 Arguments: | 1968 Arguments: |
| 1965 info: An OperationInfo object. | 1969 info: An OperationInfo object. |
| 1966 """ | 1970 """ |
| 1967 # TODO(vsm): Handle overloads. | 1971 # TODO(vsm): Handle overloads. |
| 1968 self._members_emitter.Emit( | 1972 self._members_emitter.Emit( |
| 1969 '\n' | 1973 '\n' |
| 1970 ' $TYPE $NAME($ARGS) native;\n', | 1974 ' $TYPE $NAME($ARGS) native;\n', |
| 1971 TYPE=info.type_name, | 1975 TYPE=info.type_name, |
| 1972 NAME=info.name, | 1976 NAME=info.name, |
| 1973 ARGS=info.arg_implementation_declaration) | 1977 ARGS=info.arg_implementation_declaration) |
| OLD | NEW |