| 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 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 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1864 # is useful not only for browser compat, but to allow code that links | 1864 # is useful not only for browser compat, but to allow code that links |
| 1865 # against dart:dom to load in a worker isolate. | 1865 # against dart:dom to load in a worker isolate. |
| 1866 native_spec = '*' + interface_name | 1866 native_spec = '*' + interface_name |
| 1867 | 1867 |
| 1868 if base: | 1868 if base: |
| 1869 extends = ' extends ' + base | 1869 extends = ' extends ' + base |
| 1870 elif native_spec[0] == '=': | 1870 elif native_spec[0] == '=': |
| 1871 # The implementation is a singleton with no prototype. | 1871 # The implementation is a singleton with no prototype. |
| 1872 extends = '' | 1872 extends = '' |
| 1873 else: | 1873 else: |
| 1874 extends = ' extends DOMTypeJs' | 1874 extends = ' extends _DOMTypeJs' |
| 1875 | 1875 |
| 1876 # TODO: Include all implemented interfaces, including other Lists. | 1876 # TODO: Include all implemented interfaces, including other Lists. |
| 1877 implements = [interface_name] | 1877 implements = [interface_name] |
| 1878 element_type = MaybeTypedArrayElementType(self._interface) | 1878 element_type = MaybeTypedArrayElementType(self._interface) |
| 1879 if element_type: | 1879 if element_type: |
| 1880 implements.append('List<' + element_type + '>') | 1880 implements.append('List<' + element_type + '>') |
| 1881 | 1881 |
| 1882 self._members_emitter = self._dart_code.Emit( | 1882 self._members_emitter = self._dart_code.Emit( |
| 1883 self._template, | 1883 self._template, |
| 1884 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 1884 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1898 element_type = MaybeTypedArrayElementType(interface) | 1898 element_type = MaybeTypedArrayElementType(interface) |
| 1899 if element_type: | 1899 if element_type: |
| 1900 self.AddTypedArrayConstructors(element_type) | 1900 self.AddTypedArrayConstructors(element_type) |
| 1901 | 1901 |
| 1902 | 1902 |
| 1903 def FinishInterface(self): | 1903 def FinishInterface(self): |
| 1904 """.""" | 1904 """.""" |
| 1905 pass | 1905 pass |
| 1906 | 1906 |
| 1907 def _ImplClassName(self, type_name): | 1907 def _ImplClassName(self, type_name): |
| 1908 return type_name + 'Js' | 1908 return '_' + type_name + 'Js' |
| 1909 | 1909 |
| 1910 def _NarrowToImplementationType(self, type_name): | 1910 def _NarrowToImplementationType(self, type_name): |
| 1911 # TODO(sra): Move into the 'system' and cache the result. | 1911 # TODO(sra): Move into the 'system' and cache the result. |
| 1912 if type_name == 'EventListener': | 1912 if type_name == 'EventListener': |
| 1913 # Callbacks are typedef functions so don't have a class. | 1913 # Callbacks are typedef functions so don't have a class. |
| 1914 return type_name | 1914 return type_name |
| 1915 if self._system._database.HasInterface(type_name): | 1915 if self._system._database.HasInterface(type_name): |
| 1916 interface = self._system._database.GetInterface(type_name) | 1916 interface = self._system._database.GetInterface(type_name) |
| 1917 if _RecognizeCallback(interface): | 1917 if _RecognizeCallback(interface): |
| 1918 # Callbacks are typedef functions so don't have a class. | 1918 # Callbacks are typedef functions so don't have a class. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 info: An OperationInfo object. | 2031 info: An OperationInfo object. |
| 2032 """ | 2032 """ |
| 2033 # TODO(vsm): Handle overloads. | 2033 # TODO(vsm): Handle overloads. |
| 2034 self._members_emitter.Emit( | 2034 self._members_emitter.Emit( |
| 2035 '\n' | 2035 '\n' |
| 2036 ' $TYPE $NAME($PARAMS) native;\n', | 2036 ' $TYPE $NAME($PARAMS) native;\n', |
| 2037 TYPE=self._NarrowOutputType(info.type_name), | 2037 TYPE=self._NarrowOutputType(info.type_name), |
| 2038 NAME=info.name, | 2038 NAME=info.name, |
| 2039 PARAMS=info.ParametersImplementationDeclaration( | 2039 PARAMS=info.ParametersImplementationDeclaration( |
| 2040 lambda type_name: self._NarrowInputType(type_name))) | 2040 lambda type_name: self._NarrowInputType(type_name))) |
| OLD | NEW |