| 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 native binding from the IDL database.""" | 7 native binding from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 import logging |
| 10 import os | 11 import os |
| 11 from generator import * | 12 from generator import * |
| 12 from htmldartgenerator import * | 13 from htmldartgenerator import * |
| 13 from idlnode import IDLArgument, IDLAttribute, IDLEnum, IDLMember | 14 from idlnode import IDLArgument, IDLAttribute, IDLEnum, IDLMember |
| 14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES | 15 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES |
| 15 | 16 |
| 17 _logger = logging.getLogger('systemnative') |
| 16 | 18 |
| 17 # TODO(vsm): This should be recoverable from IDL, but we appear to not | 19 # TODO(vsm): This should be recoverable from IDL, but we appear to not |
| 18 # track the necessary info. | 20 # track the necessary info. |
| 19 _url_utils = ['hash', 'host', 'hostname', 'origin', | 21 _url_utils = ['hash', 'host', 'hostname', 'origin', |
| 20 'password', 'pathname', 'port', 'protocol', | 22 'password', 'pathname', 'port', 'protocol', |
| 21 'search', 'username'] | 23 'search', 'username'] |
| 22 | 24 |
| 23 def array_type(data_type): | 25 def array_type(data_type): |
| 24 matched = re.match(r'([\w\d_\s]+)\[\]', data_type) | 26 matched = re.match(r'([\w\d_\s]+)\[\]', data_type) |
| 25 if not matched: | 27 if not matched: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 arr_match = array_type(t) | 71 arr_match = array_type(t) |
| 70 if arr_match is not None: | 72 if arr_match is not None: |
| 71 t = EncodeType(arr_match) | 73 t = EncodeType(arr_match) |
| 72 return "A_%s_A" % t | 74 return "A_%s_A" % t |
| 73 | 75 |
| 74 return _type_encoding_map.get(t) or t | 76 return _type_encoding_map.get(t) or t |
| 75 | 77 |
| 76 class DartiumBackend(HtmlDartGenerator): | 78 class DartiumBackend(HtmlDartGenerator): |
| 77 """Generates Dart implementation for one DOM IDL interface.""" | 79 """Generates Dart implementation for one DOM IDL interface.""" |
| 78 | 80 |
| 79 def __init__(self, interface, | 81 def __init__(self, interface, cpp_library_emitter, options, loggerParent): |
| 80 cpp_library_emitter, options): | 82 super(DartiumBackend, self).__init__(interface, options, True, loggerParent) |
| 81 super(DartiumBackend, self).__init__(interface, options, True) | |
| 82 | 83 |
| 83 self._interface = interface | 84 self._interface = interface |
| 84 self._cpp_library_emitter = cpp_library_emitter | 85 self._cpp_library_emitter = cpp_library_emitter |
| 85 self._database = options.database | 86 self._database = options.database |
| 86 self._template_loader = options.templates | 87 self._template_loader = options.templates |
| 87 self._type_registry = options.type_registry | 88 self._type_registry = options.type_registry |
| 88 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 89 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
| 89 self._metadata = options.metadata | 90 self._metadata = options.metadata |
| 90 # These get initialized by StartInterface | 91 # These get initialized by StartInterface |
| 91 self._cpp_header_emitter = None | 92 self._cpp_header_emitter = None |
| 92 self._cpp_impl_emitter = None | 93 self._cpp_impl_emitter = None |
| 93 self._members_emitter = None | 94 self._members_emitter = None |
| 94 self._cpp_declarations_emitter = None | 95 self._cpp_declarations_emitter = None |
| 95 self._cpp_impl_includes = None | 96 self._cpp_impl_includes = None |
| 96 self._cpp_definitions_emitter = None | 97 self._cpp_definitions_emitter = None |
| 97 self._cpp_resolver_emitter = None | 98 self._cpp_resolver_emitter = None |
| 98 self._dart_js_interop = options.dart_js_interop | 99 self._dart_js_interop = options.dart_js_interop |
| 100 _logger.setLevel(loggerParent.level) |
| 99 | 101 |
| 100 def ImplementsMergedMembers(self): | 102 def ImplementsMergedMembers(self): |
| 101 # We could not add merged functions to implementation class because | 103 # We could not add merged functions to implementation class because |
| 102 # underlying c++ object doesn't implement them. Merged functions are | 104 # underlying c++ object doesn't implement them. Merged functions are |
| 103 # generated on merged interface implementation instead. | 105 # generated on merged interface implementation instead. |
| 104 return False | 106 return False |
| 105 | 107 |
| 106 def CustomJSMembers(self): | 108 def CustomJSMembers(self): |
| 107 return {} | 109 return {} |
| 108 | 110 |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 | 1250 |
| 1249 def _IsCustom(op_or_attr): | 1251 def _IsCustom(op_or_attr): |
| 1250 assert(isinstance(op_or_attr, IDLMember)) | 1252 assert(isinstance(op_or_attr, IDLMember)) |
| 1251 return 'Custom' in op_or_attr.ext_attrs or 'DartCustom' in op_or_attr.ext_attr
s | 1253 return 'Custom' in op_or_attr.ext_attrs or 'DartCustom' in op_or_attr.ext_attr
s |
| 1252 | 1254 |
| 1253 def _IsCustomValue(op_or_attr, value): | 1255 def _IsCustomValue(op_or_attr, value): |
| 1254 if _IsCustom(op_or_attr): | 1256 if _IsCustom(op_or_attr): |
| 1255 return op_or_attr.ext_attrs.get('Custom') == value \ | 1257 return op_or_attr.ext_attrs.get('Custom') == value \ |
| 1256 or op_or_attr.ext_attrs.get('DartCustom') == value | 1258 or op_or_attr.ext_attrs.get('DartCustom') == value |
| 1257 return False | 1259 return False |
| OLD | NEW |