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

Side by Side Diff: lib/html/scripts/systemnative.py

Issue 11191026: Unify formatting of parameters in interfaces and implementing classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 template_file = 'factoryprovider_%s.darttemplate' % self._html_interface_nam e 220 template_file = 'factoryprovider_%s.darttemplate' % self._html_interface_nam e
221 template = self._template_loader.TryLoad(template_file) 221 template = self._template_loader.TryLoad(template_file)
222 if not template: 222 if not template:
223 template = self._template_loader.Load('factoryprovider.darttemplate') 223 template = self._template_loader.Load('factoryprovider.darttemplate')
224 224
225 native_binding = '%s_constructor_Callback' % self._interface.id 225 native_binding = '%s_constructor_Callback' % self._interface.id
226 emitter.Emit( 226 emitter.Emit(
227 template, 227 template,
228 FACTORYPROVIDER=factory_provider, 228 FACTORYPROVIDER=factory_provider,
229 INTERFACE=self._html_interface_name, 229 INTERFACE=self._html_interface_name,
230 PARAMETERS=constructor_info.ParametersImplementationDeclaration(self._Da rtType), 230 PARAMETERS=constructor_info.ParametersDeclaration(self._DartType),
231 ARGUMENTS=constructor_info.ParametersAsArgumentList(), 231 ARGUMENTS=constructor_info.ParametersAsArgumentList(),
232 NATIVE_NAME=native_binding) 232 NATIVE_NAME=native_binding)
233 233
234 def FinishInterface(self): 234 def FinishInterface(self):
235 self._GenerateCPPHeader() 235 self._GenerateCPPHeader()
236 236
237 self._cpp_impl_emitter.Emit( 237 self._cpp_impl_emitter.Emit(
238 self._template_loader.Load('cpp_implementation.template'), 238 self._template_loader.Load('cpp_implementation.template'),
239 INTERFACE=self._interface.id, 239 INTERFACE=self._interface.id,
240 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes), 240 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes),
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 return 469 return
470 470
471 is_custom = 'Custom' in operation.ext_attrs 471 is_custom = 'Custom' in operation.ext_attrs
472 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments) 472 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments)
473 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments) 473 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments)
474 474
475 dart_declaration = '%s%s %s(%s)' % ( 475 dart_declaration = '%s%s %s(%s)' % (
476 'static ' if info.IsStatic() else '', 476 'static ' if info.IsStatic() else '',
477 SecureOutputType(self, info.type_name), 477 SecureOutputType(self, info.type_name),
478 html_name, 478 html_name,
479 info.ParametersImplementationDeclaration( 479 info.ParametersDeclaration(
480 (lambda x: 'Dynamic') if needs_dispatcher else self._DartType)) 480 (lambda x: 'Dynamic') if needs_dispatcher else self._DartType))
481 481
482 if not needs_dispatcher: 482 if not needs_dispatcher:
483 # Bind directly to native implementation 483 # Bind directly to native implementation
484 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) 484 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos)
485 cpp_callback_name = self._GenerateNativeBinding( 485 cpp_callback_name = self._GenerateNativeBinding(
486 info.name, argument_count, dart_declaration, 'Callback', is_custom) 486 info.name, argument_count, dart_declaration, 'Callback', is_custom)
487 if not is_custom: 487 if not is_custom:
488 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name) 488 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name)
489 else: 489 else:
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 def EmitResolver(self, template, output_dir): 883 def EmitResolver(self, template, output_dir):
884 file_path = os.path.join(output_dir, 'DartResolver.cpp') 884 file_path = os.path.join(output_dir, 'DartResolver.cpp')
885 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template) 885 includes_emitter, body_emitter = self._emitters.FileEmitter(file_path).Emit( template)
886 for header_file in self._headers_list: 886 for header_file in self._headers_list:
887 path = os.path.relpath(header_file, output_dir) 887 path = os.path.relpath(header_file, output_dir)
888 includes_emitter.Emit('#include "$PATH"\n', PATH=path) 888 includes_emitter.Emit('#include "$PATH"\n', PATH=path)
889 body_emitter.Emit( 889 body_emitter.Emit(
890 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n' 890 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argume ntCount))\n'
891 ' return func;\n', 891 ' return func;\n',
892 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 892 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
OLDNEW
« lib/html/scripts/generator.py ('K') | « lib/html/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698