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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 # generate the constants as part of the class. This will need to go away | 1922 # generate the constants as part of the class. This will need to go away |
1923 # if we revert back to generating interfaces. | 1923 # if we revert back to generating interfaces. |
1924 self._members_emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n', | 1924 self._members_emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n', |
1925 NAME=constant.id, | 1925 NAME=constant.id, |
1926 TYPE=constant.type.id, | 1926 TYPE=constant.type.id, |
1927 VALUE=constant.value) | 1927 VALUE=constant.value) |
1928 | 1928 |
1929 pass | 1929 pass |
1930 | 1930 |
1931 def AddGetter(self, attr): | 1931 def AddGetter(self, attr): |
1932 # Declare as a field in the native class. | 1932 # TODO(sra): Remove native body when Issue 829 fixed. |
1933 # TODO(vsm): Mark this as native somehow. | |
1934 self._members_emitter.Emit( | 1933 self._members_emitter.Emit( |
1935 '\n' | 1934 '\n $TYPE get $NAME() native "return this.$NAME;";\n', |
1936 ' $TYPE $NAME;\n', | 1935 NAME=attr.id, TYPE=attr.type.id) |
1937 NAME=attr.id, TYPE=attr.type.id, INTERFACE=self._interface.id) | |
1938 | 1936 |
1939 def AddSetter(self, attr): | 1937 def AddSetter(self, attr): |
1940 # TODO(vsm): Suppress for now. Should emit if there is no getter. | 1938 # TODO(sra): Remove native body when Issue 829 fixed. |
1941 pass | 1939 self._members_emitter.Emit( |
| 1940 '\n void set $NAME($TYPE value) native "this.$NAME = value;";\n', |
| 1941 NAME=attr.id, TYPE=attr.type.id) |
1942 | 1942 |
1943 def AddSecondaryGetter(self, interface, attr): | 1943 def AddSecondaryGetter(self, interface, attr): |
1944 self._SecondaryContext(interface) | 1944 self._SecondaryContext(interface) |
1945 self.AddGetter(attr) | 1945 self.AddGetter(attr) |
1946 | 1946 |
1947 def AddSecondarySetter(self, interface, attr): | 1947 def AddSecondarySetter(self, interface, attr): |
1948 self._SecondaryContext(interface) | 1948 self._SecondaryContext(interface) |
1949 self.AddSetter(attr) | 1949 self.AddSetter(attr) |
1950 | 1950 |
1951 def AddSecondaryOperation(self, interface, info): | 1951 def AddSecondaryOperation(self, interface, info): |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2014 Arguments: | 2014 Arguments: |
2015 info: An OperationInfo object. | 2015 info: An OperationInfo object. |
2016 """ | 2016 """ |
2017 # TODO(vsm): Handle overloads. | 2017 # TODO(vsm): Handle overloads. |
2018 self._members_emitter.Emit( | 2018 self._members_emitter.Emit( |
2019 '\n' | 2019 '\n' |
2020 ' $TYPE $NAME($ARGS) native;\n', | 2020 ' $TYPE $NAME($ARGS) native;\n', |
2021 TYPE=info.type_name, | 2021 TYPE=info.type_name, |
2022 NAME=info.name, | 2022 NAME=info.name, |
2023 ARGS=info.arg_implementation_declaration) | 2023 ARGS=info.arg_implementation_declaration) |
OLD | NEW |