Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/dom/scripts/systemnative.py

Issue 23819035: Give generatored bindings classes a field remembering an index into a cache of handles on the corre… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 os 10 import os
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 cpp_type_name = _cpp_callback_map[cpp_tuple] 122 cpp_type_name = _cpp_callback_map[cpp_tuple]
123 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: 123 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map:
124 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] 124 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)]
125 else: 125 else:
126 cpp_type_name = interface_name 126 cpp_type_name = interface_name
127 return cpp_type_name 127 return cpp_type_name
128 128
129 class DartiumBackend(HtmlDartGenerator): 129 class DartiumBackend(HtmlDartGenerator):
130 """Generates Dart implementation for one DOM IDL interface.""" 130 """Generates Dart implementation for one DOM IDL interface."""
131 131
132 def __init__(self, interface, cpp_library_emitter, options): 132 def __init__(self, interface, cid, cpp_library_emitter, options):
133 super(DartiumBackend, self).__init__(interface, options) 133 super(DartiumBackend, self).__init__(interface, options)
134 134
135 self._interface = interface 135 self._interface = interface
136 self._cid = cid;
136 self._cpp_library_emitter = cpp_library_emitter 137 self._cpp_library_emitter = cpp_library_emitter
137 self._database = options.database 138 self._database = options.database
138 self._template_loader = options.templates 139 self._template_loader = options.templates
139 self._type_registry = options.type_registry 140 self._type_registry = options.type_registry
140 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) 141 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id)
141 self._metadata = options.metadata 142 self._metadata = options.metadata
142 143
143 def ImplementsMergedMembers(self): 144 def ImplementsMergedMembers(self):
144 # We could not add merged functions to implementation class because 145 # We could not add merged functions to implementation class because
145 # underlying c++ object doesn't implement them. Merged functions are 146 # underlying c++ object doesn't implement them. Merged functions are
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return (value[0], 'true') 351 return (value[0], 'true')
351 else: 352 else:
352 return 'true' 353 return 'true'
353 354
354 def FinishInterface(self): 355 def FinishInterface(self):
355 self._GenerateCPPHeader() 356 self._GenerateCPPHeader()
356 357
357 self._cpp_impl_emitter.Emit( 358 self._cpp_impl_emitter.Emit(
358 self._template_loader.Load('cpp_implementation.template'), 359 self._template_loader.Load('cpp_implementation.template'),
359 INTERFACE=self._interface.id, 360 INTERFACE=self._interface.id,
361 CID=str(self._cid),
360 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes), 362 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes),
361 CALLBACKS=self._cpp_definitions_emitter.Fragments(), 363 CALLBACKS=self._cpp_definitions_emitter.Fragments(),
362 RESOLVER=self._cpp_resolver_emitter.Fragments(), 364 RESOLVER=self._cpp_resolver_emitter.Fragments(),
363 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), 365 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(),
364 WEBCORE_CLASS_NAME_ESCAPED= 366 WEBCORE_CLASS_NAME_ESCAPED=
365 self._interface_type_info.native_type().replace('<', '_').replace('>', ' _'), 367 self._interface_type_info.native_type().replace('<', '_').replace('>', ' _'),
366 DART_IMPLEMENTATION_CLASS=self._interface_type_info.implementation_name( ), 368 DART_IMPLEMENTATION_CLASS=self._interface_type_info.implementation_name( ),
367 DART_IMPLEMENTATION_LIBRARY='dart:%s' % self._renamer.GetLibraryName(sel f._interface)) 369 DART_IMPLEMENTATION_LIBRARY='dart:%s' % self._renamer.GetLibraryName(sel f._interface))
368 370
369 def _GenerateCPPHeader(self): 371 def _GenerateCPPHeader(self):
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 1140 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
1139 ' return func;\n', 1141 ' return func;\n',
1140 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 1142 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
1141 1143
1142 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1144 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1143 return ( 1145 return (
1144 interface.id.endswith('Event') and 1146 interface.id.endswith('Event') and
1145 operation.id.startswith('init') and 1147 operation.id.startswith('init') and
1146 argument.ext_attrs.get('Default') == 'Undefined' and 1148 argument.ext_attrs.get('Default') == 'Undefined' and
1147 argument.type.id == 'DOMString') 1149 argument.type.id == 'DOMString')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698