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

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

Issue 21555003: Exposing native doubles as doubles when they are read-only or method return values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « tools/dom/scripts/systemhtml.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 WEBCORE_CLASS_NAME_ESCAPED= 369 WEBCORE_CLASS_NAME_ESCAPED=
370 self._interface_type_info.native_type().replace('<', '_').replace('>', ' _'), 370 self._interface_type_info.native_type().replace('<', '_').replace('>', ' _'),
371 DECLARATIONS=self._cpp_declarations_emitter.Fragments(), 371 DECLARATIONS=self._cpp_declarations_emitter.Fragments(),
372 IS_NODE=TypeCheckHelper(is_node_test), 372 IS_NODE=TypeCheckHelper(is_node_test),
373 IS_ACTIVE=TypeCheckHelper(is_active_test), 373 IS_ACTIVE=TypeCheckHelper(is_active_test),
374 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test), 374 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test),
375 TO_NATIVE=to_native_emitter.Fragments(), 375 TO_NATIVE=to_native_emitter.Fragments(),
376 TO_DART=to_dart_emitter.Fragments()) 376 TO_DART=to_dart_emitter.Fragments())
377 377
378 def EmitAttribute(self, attribute, html_name, read_only): 378 def EmitAttribute(self, attribute, html_name, read_only):
379 self._AddGetter(attribute, html_name) 379 self._AddGetter(attribute, html_name, read_only)
380 if not read_only: 380 if not read_only:
381 self._AddSetter(attribute, html_name) 381 self._AddSetter(attribute, html_name)
382 382
383 def _AddGetter(self, attr, html_name): 383 def _AddGetter(self, attr, html_name, read_only):
384 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. 384 # Temporary hack to force dart:scalarlist clamped array for ImageData.data.
385 # TODO(antonm): solve in principled way. 385 # TODO(antonm): solve in principled way.
386 if self._interface.id == 'ImageData' and html_name == 'data': 386 if self._interface.id == 'ImageData' and html_name == 'data':
387 html_name = '_data' 387 html_name = '_data'
388 type_info = self._TypeInfo(attr.type.id) 388 type_info = self._TypeInfo(attr.type.id)
389 dart_declaration = '%s get %s' % ( 389 dart_declaration = '%s get %s' % (
390 self.SecureOutputType(attr.type.id), html_name) 390 self.SecureOutputType(attr.type.id, False, read_only), html_name)
391 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs 391 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs
392 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, 392 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1,
393 dart_declaration, 'Getter', is_custom) 393 dart_declaration, 'Getter', is_custom)
394 if is_custom: 394 if is_custom:
395 return 395 return
396 396
397 if 'Reflect' in attr.ext_attrs: 397 if 'Reflect' in attr.ext_attrs:
398 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() 398 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name()
399 if 'URL' in attr.ext_attrs: 399 if 'URL' in attr.ext_attrs:
400 if 'NonEmpty' in attr.ext_attrs: 400 if 'NonEmpty' in attr.ext_attrs:
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 'Callback', True) 554 'Callback', True)
555 555
556 def EmitOperation(self, info, html_name): 556 def EmitOperation(self, info, html_name):
557 """ 557 """
558 Arguments: 558 Arguments:
559 info: An OperationInfo object. 559 info: An OperationInfo object.
560 """ 560 """
561 561
562 dart_declaration = '%s%s %s(%s)' % ( 562 dart_declaration = '%s%s %s(%s)' % (
563 'static ' if info.IsStatic() else '', 563 'static ' if info.IsStatic() else '',
564 self.SecureOutputType(info.type_name), 564 self.SecureOutputType(info.type_name, False, True),
565 html_name, 565 html_name,
566 info.ParametersDeclaration(self._DartType)) 566 info.ParametersDeclaration(self._DartType))
567 567
568 operation = info.operations[0] 568 operation = info.operations[0]
569 is_custom = 'Custom' in operation.ext_attrs 569 is_custom = 'Custom' in operation.ext_attrs
570 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments) 570 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments)
571 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments) 571 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments)
572 572
573 if info.callback_args: 573 if info.callback_args:
574 self._AddFutureifiedOperation(info, html_name) 574 self._AddFutureifiedOperation(info, html_name)
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 return ''.join(['#include %s\n' % include for include in sorted(includes)]) 1007 return ''.join(['#include %s\n' % include for include in sorted(includes)])
1008 1008
1009 def _ToWebKitName(self, name): 1009 def _ToWebKitName(self, name):
1010 name = name[0].lower() + name[1:] 1010 name = name[0].lower() + name[1:]
1011 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), 1011 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(),
1012 name) 1012 name)
1013 return re.sub(r'^(create|exclusive)', 1013 return re.sub(r'^(create|exclusive)',
1014 lambda s: 'is' + s.group(1).capitalize(), 1014 lambda s: 'is' + s.group(1).capitalize(),
1015 name) 1015 name)
1016 1016
1017 def _TypeInfo(self, type_name):
1018 return self._type_registry.TypeInfo(type_name)
1019
1020 def _DartType(self, type_name):
1021 return self._type_registry.DartType(type_name)
1022
1023
1024 class CPPLibraryEmitter(): 1017 class CPPLibraryEmitter():
1025 def __init__(self, emitters, cpp_sources_dir): 1018 def __init__(self, emitters, cpp_sources_dir):
1026 self._emitters = emitters 1019 self._emitters = emitters
1027 self._cpp_sources_dir = cpp_sources_dir 1020 self._cpp_sources_dir = cpp_sources_dir
1028 self._library_headers = dict((lib, []) for lib in HTML_LIBRARY_NAMES) 1021 self._library_headers = dict((lib, []) for lib in HTML_LIBRARY_NAMES)
1029 self._sources_list = [] 1022 self._sources_list = []
1030 1023
1031 def CreateHeaderEmitter(self, interface_name, library_name, is_callback=False) : 1024 def CreateHeaderEmitter(self, interface_name, library_name, is_callback=False) :
1032 path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name) 1025 path = os.path.join(self._cpp_sources_dir, 'Dart%s.h' % interface_name)
1033 if not is_callback: 1026 if not is_callback:
(...skipping 30 matching lines...) Expand all
1064 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 1057 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
1065 ' return func;\n', 1058 ' return func;\n',
1066 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 1059 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
1067 1060
1068 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1061 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1069 return ( 1062 return (
1070 interface.id.endswith('Event') and 1063 interface.id.endswith('Event') and
1071 operation.id.startswith('init') and 1064 operation.id.startswith('init') and
1072 argument.ext_attrs.get('Default') == 'Undefined' and 1065 argument.ext_attrs.get('Default') == 'Undefined' and
1073 argument.type.id == 'DOMString') 1066 argument.type.id == 'DOMString')
OLDNEW
« no previous file with comments | « tools/dom/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698