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

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

Issue 10122011: Do not use overloaded toDartValue for primitive types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use capwords. Created 8 years, 8 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 | « lib/dom/scripts/generator.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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 if IsPureInterface(self._interface.id): 62 if IsPureInterface(self._interface.id):
63 return None 63 return None
64 64
65 cpp_impl_includes = set() 65 cpp_impl_includes = set()
66 cpp_header_handlers_emitter = emitter.Emitter() 66 cpp_header_handlers_emitter = emitter.Emitter()
67 cpp_impl_handlers_emitter = emitter.Emitter() 67 cpp_impl_handlers_emitter = emitter.Emitter()
68 class_name = 'Dart%s' % self._interface.id 68 class_name = 'Dart%s' % self._interface.id
69 for operation in interface.operations: 69 for operation in interface.operations:
70 if operation.type.id == 'void': 70 if operation.type.id == 'void':
71 return_type = 'void'
72 return_prefix = '' 71 return_prefix = ''
72 error_return = ''
73 else: 73 else:
74 return_type = 'bool'
75 return_prefix = 'return ' 74 return_prefix = 'return '
75 error_return = ' false'
76 76
77 parameters = [] 77 parameters = []
78 arguments = [] 78 arguments = []
79 for argument in operation.arguments: 79 for argument in operation.arguments:
80 argument_type_info = GetIDLTypeInfo(argument.type.id) 80 argument_type_info = GetIDLTypeInfo(argument.type.id)
81 parameters.append('%s %s' % (argument_type_info.parameter_type(), 81 parameters.append('%s %s' % (argument_type_info.parameter_type(),
82 argument.id)) 82 argument.id))
83 arguments.append(argument.id) 83 arguments.append(argument_type_info.to_dart_conversion(argument.id))
84 cpp_impl_includes |= set(argument_type_info.conversion_includes()) 84 cpp_impl_includes |= set(argument_type_info.conversion_includes())
85 85
86 native_return_type = GetIDLTypeInfo(operation.type.id).native_type()
86 cpp_header_handlers_emitter.Emit( 87 cpp_header_handlers_emitter.Emit(
87 '\n' 88 '\n'
88 ' virtual $TYPE handleEvent($PARAMETERS);\n', 89 ' virtual $TYPE handleEvent($PARAMETERS);\n',
89 TYPE=return_type, PARAMETERS=', '.join(parameters)) 90 TYPE=native_return_type, PARAMETERS=', '.join(parameters))
90 91
91 cpp_impl_handlers_emitter.Emit( 92 cpp_impl_handlers_emitter.Emit(
92 '\n' 93 '\n'
93 '$TYPE $CLASS_NAME::handleEvent($PARAMETERS)\n' 94 '$TYPE $CLASS_NAME::handleEvent($PARAMETERS)\n'
94 '{\n' 95 '{\n'
95 ' $(RETURN_PREFIX)m_callback.handleEvent($ARGUMENTS);\n' 96 ' if (!m_callback.isolate()->isAlive())\n'
97 ' return$ERROR_RETURN;\n'
98 ' DartIsolate::Scope scope(m_callback.isolate());\n'
99 ' DartApiScope apiScope;\n'
100 ' Dart_Handle arguments[] = { $ARGUMENTS };\n'
101 ' $(RETURN_PREFIX)m_callback.handleEvent($ARGUMENT_COUNT, arguments );\n'
96 '}\n', 102 '}\n',
97 TYPE=return_type, 103 TYPE=native_return_type,
98 CLASS_NAME=class_name, 104 CLASS_NAME=class_name,
99 PARAMETERS=', '.join(parameters), 105 PARAMETERS=', '.join(parameters),
106 ERROR_RETURN=error_return,
100 RETURN_PREFIX=return_prefix, 107 RETURN_PREFIX=return_prefix,
101 ARGUMENTS=', '.join(arguments)) 108 ARGUMENTS=', '.join(arguments),
109 ARGUMENT_COUNT=len(arguments))
102 110
103 cpp_header_path = self._FilePathForCppHeader(self._interface.id) 111 cpp_header_path = self._FilePathForCppHeader(self._interface.id)
104 cpp_header_emitter = self._emitters.FileEmitter(cpp_header_path) 112 cpp_header_emitter = self._emitters.FileEmitter(cpp_header_path)
105 cpp_header_emitter.Emit( 113 cpp_header_emitter.Emit(
106 self._templates.Load('cpp_callback_header.template'), 114 self._templates.Load('cpp_callback_header.template'),
107 INTERFACE=self._interface.id, 115 INTERFACE=self._interface.id,
108 HANDLERS=cpp_header_handlers_emitter.Fragments()) 116 HANDLERS=cpp_header_handlers_emitter.Fragments())
109 117
110 cpp_impl_path = self._FilePathForCppImplementation(self._interface.id) 118 cpp_impl_path = self._FilePathForCppImplementation(self._interface.id)
111 self._cpp_impl_files.append(cpp_impl_path) 119 self._cpp_impl_files.append(cpp_impl_path)
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 def _InstanceOfNode(database, interface): 835 def _InstanceOfNode(database, interface):
828 if interface.id == 'Node': 836 if interface.id == 'Node':
829 return True 837 return True
830 for parent in interface.parents: 838 for parent in interface.parents:
831 if not database.HasInterface(parent.type.id): 839 if not database.HasInterface(parent.type.id):
832 continue 840 continue
833 parent_interface = database.GetInterface(parent.type.id) 841 parent_interface = database.GetInterface(parent.type.id)
834 if _InstanceOfNode(database, parent_interface): 842 if _InstanceOfNode(database, parent_interface):
835 return True 843 return True
836 return False 844 return False
OLDNEW
« no previous file with comments | « lib/dom/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698