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

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

Issue 14455007: Refactoring DOM annotations and comment generation, adding DOM API triage list (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
11 from generator import * 11 from generator import *
12 from htmldartgenerator import * 12 from htmldartgenerator import *
13 from idlnode import IDLArgument 13 from idlnode import IDLArgument
14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES 14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES
15 15
16 class DartiumBackend(HtmlDartGenerator): 16 class DartiumBackend(HtmlDartGenerator):
17 """Generates Dart implementation for one DOM IDL interface.""" 17 """Generates Dart implementation for one DOM IDL interface."""
18 18
19 def __init__(self, interface, cpp_library_emitter, options): 19 def __init__(self, interface, cpp_library_emitter, options):
20 super(DartiumBackend, self).__init__(interface, options) 20 super(DartiumBackend, self).__init__(interface, options)
21 21
22 self._interface = interface 22 self._interface = interface
23 self._cpp_library_emitter = cpp_library_emitter 23 self._cpp_library_emitter = cpp_library_emitter
24 self._database = options.database 24 self._database = options.database
25 self._template_loader = options.templates 25 self._template_loader = options.templates
26 self._type_registry = options.type_registry 26 self._type_registry = options.type_registry
27 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) 27 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id)
28 self._metadata = options.metadata
28 29
29 def ImplementsMergedMembers(self): 30 def ImplementsMergedMembers(self):
30 # We could not add merged functions to implementation class because 31 # We could not add merged functions to implementation class because
31 # underlying c++ object doesn't implement them. Merged functions are 32 # underlying c++ object doesn't implement them. Merged functions are
32 # generated on merged interface implementation instead. 33 # generated on merged interface implementation instead.
33 return False 34 return False
34 35
35 def CustomJSMembers(self): 36 def CustomJSMembers(self):
36 return {} 37 return {}
37 38
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 overload_name = '_%s_%s' % (operation.id, version) 514 overload_name = '_%s_%s' % (operation.id, version)
514 argument_list = ', '.join(parameter_names[:argument_count]) 515 argument_list = ', '.join(parameter_names[:argument_count])
515 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list) 516 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list)
516 517
517 dart_declaration = '%s%s %s(%s)' % ( 518 dart_declaration = '%s%s %s(%s)' % (
518 'static ' if operation.is_static else '', 519 'static ' if operation.is_static else '',
519 self.SecureOutputType(operation.type.id), 520 self.SecureOutputType(operation.type.id),
520 overload_name, argument_list) 521 overload_name, argument_list)
521 cpp_callback_name = self._GenerateNativeBinding( 522 cpp_callback_name = self._GenerateNativeBinding(
522 overload_name, (0 if operation.is_static else 1) + argument_count, 523 overload_name, (0 if operation.is_static else 1) + argument_count,
523 dart_declaration, 'Callback', False) 524 dart_declaration, 'Callback', False, False)
524 self._GenerateOperationNativeCallback(operation, operation.arguments[:argu ment_count], cpp_callback_name) 525 self._GenerateOperationNativeCallback(operation, operation.arguments[:argu ment_count], cpp_callback_name)
525 526
526 self._GenerateDispatcherBody( 527 self._GenerateDispatcherBody(
527 operations, 528 operations,
528 parameter_names, 529 parameter_names,
529 dart_declaration, 530 dart_declaration,
530 GenerateCall, 531 GenerateCall,
531 self._IsArgumentOptionalInWebCore) 532 self._IsArgumentOptionalInWebCore)
532 533
533 def SecondaryContext(self, interface): 534 def SecondaryContext(self, interface):
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 799
799 # Generate to Dart conversion of C++ value. 800 # Generate to Dart conversion of C++ value.
800 to_dart_conversion = return_type_info.to_dart_conversion(value_expression, self._interface.id, ext_attrs) 801 to_dart_conversion = return_type_info.to_dart_conversion(value_expression, self._interface.id, ext_attrs)
801 invocation_emitter.Emit( 802 invocation_emitter.Emit(
802 ' Dart_Handle returnValue = $TO_DART_CONVERSION;\n' 803 ' Dart_Handle returnValue = $TO_DART_CONVERSION;\n'
803 ' if (returnValue)\n' 804 ' if (returnValue)\n'
804 ' Dart_SetReturnValue(args, returnValue);\n', 805 ' Dart_SetReturnValue(args, returnValue);\n',
805 TO_DART_CONVERSION=to_dart_conversion) 806 TO_DART_CONVERSION=to_dart_conversion)
806 807
807 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, 808 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration,
808 native_suffix, is_custom): 809 native_suffix, is_custom, emit_metadata=True):
809 annotations = FormatAnnotationsAndComments( 810 metadata = []
810 GetAnnotationsAndComments(self._renamer.GetLibraryName(self._interface), 811 if emit_metadata:
811 self._interface.id, idl_name), 812 metadata = self._metadata.GetFormattedMetadata(
812 ' ') 813 self._renamer.GetLibraryName(self._interface),
814 self._interface.id, idl_name, ' ')
813 815
814 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) 816 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix)
815 self._members_emitter.Emit( 817 self._members_emitter.Emit(
816 '\n' 818 '\n'
817 ' $ANNOTATIONS$DART_DECLARATION native "$NATIVE_BINDING";\n', 819 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n',
818 DOMINTERFACE=self._interface.id, 820 DOMINTERFACE=self._interface.id,
819 ANNOTATIONS=annotations, 821 METADATA=metadata,
820 DART_DECLARATION=dart_declaration, 822 DART_DECLARATION=dart_declaration,
821 NATIVE_BINDING=native_binding) 823 NATIVE_BINDING=native_binding)
822 824
823 cpp_callback_name = '%s%s' % (idl_name, native_suffix) 825 cpp_callback_name = '%s%s' % (idl_name, native_suffix)
824 self._cpp_resolver_emitter.Emit( 826 self._cpp_resolver_emitter.Emit(
825 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING")\n' 827 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING")\n'
826 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n', 828 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n',
827 ARGC=argument_count, 829 ARGC=argument_count,
828 NATIVE_BINDING=native_binding, 830 NATIVE_BINDING=native_binding,
829 INTERFACE_NAME=self._interface.id, 831 INTERFACE_NAME=self._interface.id,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 932 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
931 ' return func;\n', 933 ' return func;\n',
932 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 934 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
933 935
934 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 936 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
935 return ( 937 return (
936 interface.id.endswith('Event') and 938 interface.id.endswith('Event') and
937 operation.id.startswith('init') and 939 operation.id.startswith('init') and
938 argument.ext_attrs.get('Default') == 'Undefined' and 940 argument.ext_attrs.get('Default') == 'Undefined' and
939 argument.type.id == 'DOMString') 941 argument.type.id == 'DOMString')
OLDNEW
« tools/dom/scripts/dartmetadata.py ('K') | « tools/dom/scripts/systemhtml.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698