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

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: 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
« lib/dom/scripts/generator.py ('K') | « 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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' 71 return_type = 'void'
72 return_prefix = '' 72 return_prefix = ''
73 error_return = ''
73 else: 74 else:
74 return_type = 'bool' 75 return_type = 'bool'
75 return_prefix = 'return ' 76 return_prefix = 'return '
77 error_return = ' false'
76 78
77 parameters = [] 79 parameters = []
78 arguments = [] 80 arguments = []
79 for argument in operation.arguments: 81 for argument in operation.arguments:
80 argument_type_info = GetIDLTypeInfo(argument.type.id) 82 argument_type_info = GetIDLTypeInfo(argument.type.id)
81 parameters.append('%s %s' % (argument_type_info.parameter_type(), 83 parameters.append('%s %s' % (argument_type_info.parameter_type(),
82 argument.id)) 84 argument.id))
83 arguments.append(argument.id) 85 arguments.append(argument_type_info.to_dart_conversion(argument.id))
84 cpp_impl_includes |= set(argument_type_info.conversion_includes()) 86 cpp_impl_includes |= set(argument_type_info.conversion_includes())
85 87
86 cpp_header_handlers_emitter.Emit( 88 cpp_header_handlers_emitter.Emit(
87 '\n' 89 '\n'
88 ' virtual $TYPE handleEvent($PARAMETERS);\n', 90 ' virtual $TYPE handleEvent($PARAMETERS);\n',
89 TYPE=return_type, PARAMETERS=', '.join(parameters)) 91 TYPE=return_type, PARAMETERS=', '.join(parameters))
90 92
91 cpp_impl_handlers_emitter.Emit( 93 cpp_impl_handlers_emitter.Emit(
92 '\n' 94 '\n'
93 '$TYPE $CLASS_NAME::handleEvent($PARAMETERS)\n' 95 '$TYPE $CLASS_NAME::handleEvent($PARAMETERS)\n'
94 '{\n' 96 '{\n'
97 ' if (!m_callback.isolate()->isAlive())\n'
98 ' return$ERROR_RETURN;\n'
99 ' DartIsolate::Scope scope(m_callback.isolate());\n'
100 ' DartApiScope apiScope;\n'
95 ' $(RETURN_PREFIX)m_callback.handleEvent($ARGUMENTS);\n' 101 ' $(RETURN_PREFIX)m_callback.handleEvent($ARGUMENTS);\n'
96 '}\n', 102 '}\n',
97 TYPE=return_type, 103 TYPE=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))
102 109
103 cpp_header_path = self._FilePathForCppHeader(self._interface.id) 110 cpp_header_path = self._FilePathForCppHeader(self._interface.id)
104 cpp_header_emitter = self._emitters.FileEmitter(cpp_header_path) 111 cpp_header_emitter = self._emitters.FileEmitter(cpp_header_path)
105 cpp_header_emitter.Emit( 112 cpp_header_emitter.Emit(
106 self._templates.Load('cpp_callback_header.template'), 113 self._templates.Load('cpp_callback_header.template'),
107 INTERFACE=self._interface.id, 114 INTERFACE=self._interface.id,
108 HANDLERS=cpp_header_handlers_emitter.Fragments()) 115 HANDLERS=cpp_header_handlers_emitter.Fragments())
109 116
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 def _InstanceOfNode(database, interface): 834 def _InstanceOfNode(database, interface):
828 if interface.id == 'Node': 835 if interface.id == 'Node':
829 return True 836 return True
830 for parent in interface.parents: 837 for parent in interface.parents:
831 if not database.HasInterface(parent.type.id): 838 if not database.HasInterface(parent.type.id):
832 continue 839 continue
833 parent_interface = database.GetInterface(parent.type.id) 840 parent_interface = database.GetInterface(parent.type.id)
834 if _InstanceOfNode(database, parent_interface): 841 if _InstanceOfNode(database, parent_interface):
835 return True 842 return True
836 return False 843 return False
OLDNEW
« lib/dom/scripts/generator.py ('K') | « lib/dom/scripts/generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698