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

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

Issue 289113003: Make custom constructors use uniform resolvers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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
« no previous file with comments | « sdk/lib/_blink/dartium/_blink_dartium.dart ('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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 def DeriveQualifiedName(library_name, name): 317 def DeriveQualifiedName(library_name, name):
318 return library_name + "." + name 318 return library_name + "." + name
319 319
320 def DeriveNativeName(interface_name, name, suffix): 320 def DeriveNativeName(interface_name, name, suffix):
321 fields = ["Native", interface_name, name] 321 fields = ["Native", interface_name, name]
322 if suffix != "": 322 if suffix != "":
323 fields.append(suffix) 323 fields.append(suffix)
324 return "_".join(fields) 324 return "_".join(fields)
325 325
326 def DeriveResolverString(interface_id, operation_id, native_suffix, type_ids, 326 def DeriveResolverString(interface_id, operation_id, native_suffix, type_ids):
327 is_custom):
328 type_string = \ 327 type_string = \
329 "_".join(type_ids) 328 "_".join(type_ids)
330 if native_suffix: 329 if native_suffix:
331 operation_id = "%s_%s" % (operation_id, native_suffix) 330 operation_id = "%s_%s" % (operation_id, native_suffix)
332 if is_custom: 331 components = \
333 components = \ 332 [interface_id, operation_id,
334 [interface_id, operation_id, 333 "RESOLVER_STRING", str(len(type_ids)), type_string]
335 "RESOLVER_STRING"]
336 else:
337 components = \
338 [interface_id, operation_id,
339 "RESOLVER_STRING", str(len(type_ids)), type_string]
340 return "_".join(components) 334 return "_".join(components)
341 335
342 # FIXME(leafp) This should really go elsewhere. I think the right thing 336 # FIXME(leafp) This should really go elsewhere. I think the right thing
343 # to do is to add support in the DartLibraries objects in systemhtml 337 # to do is to add support in the DartLibraries objects in systemhtml
344 # for emitting top level code in libraries. This can then just be a 338 # for emitting top level code in libraries. This can then just be a
345 # normal use of that kind of object 339 # normal use of that kind of object
346 def GetNativeLibraryEmitter(emitters, template_loader, 340 def GetNativeLibraryEmitter(emitters, template_loader,
347 dartium_output_dir, dart_output_dir, 341 dartium_output_dir, dart_output_dir,
348 auxiliary_dir): 342 auxiliary_dir):
349 def massage_path(path): 343 def massage_path(path):
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 else: 572 else:
579 argument_count = len(arguments) 573 argument_count = len(arguments)
580 574
581 typed_formals = constructor_info.ParametersAsArgumentList(argument_count) 575 typed_formals = constructor_info.ParametersAsArgumentList(argument_count)
582 parameters = constructor_info.ParametersAsStringOfVariables(argument_count) 576 parameters = constructor_info.ParametersAsStringOfVariables(argument_count)
583 interface_name = self._interface_type_info.interface_name() 577 interface_name = self._interface_type_info.interface_name()
584 578
585 if self._dart_use_blink: 579 if self._dart_use_blink:
586 type_ids = [p.type.id for p in arguments[:argument_count]] 580 type_ids = [p.type.id for p in arguments[:argument_count]]
587 constructor_callback_id = \ 581 constructor_callback_id = \
588 DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids, 582 DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids)
589 is_custom)
590 else: 583 else:
591 constructor_callback_id = self._interface.id + '_' + constructor_callbac k_cpp_name 584 constructor_callback_id = self._interface.id + '_' + constructor_callbac k_cpp_name
592 585
593 if self._dart_use_blink: 586 if self._dart_use_blink:
594 # First we emit the toplevel function 587 # First we emit the toplevel function
595 dart_native_name = \ 588 dart_native_name = \
596 DeriveNativeName(self._interface.id, constructor_callback_cpp_name, "") 589 DeriveNativeName(self._interface.id, constructor_callback_cpp_name, "")
597 self._native_library_emitter.Emit( 590 self._native_library_emitter.Emit(
598 '\n' 591 '\n'
599 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', 592 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n',
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 elif self._HasExplicitIndexedGetter(): 1000 elif self._HasExplicitIndexedGetter():
1008 self._EmitExplicitIndexedGetter(dart_element_type) 1001 self._EmitExplicitIndexedGetter(dart_element_type)
1009 else: 1002 else:
1010 if self._dart_use_blink: 1003 if self._dart_use_blink:
1011 dart_native_name = \ 1004 dart_native_name = \
1012 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter") 1005 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter")
1013 # First emit a toplevel function to do the native call 1006 # First emit a toplevel function to do the native call
1014 # Calls to this are emitted elsewhere, 1007 # Calls to this are emitted elsewhere,
1015 resolver_string = \ 1008 resolver_string = \
1016 DeriveResolverString(self._interface.id, "item", "Callback", 1009 DeriveResolverString(self._interface.id, "item", "Callback",
1017 ["unsigned long"], False) 1010 ["unsigned long"])
1018 self._native_library_emitter.Emit( 1011 self._native_library_emitter.Emit(
1019 '\n' 1012 '\n'
1020 '$(DART_NATIVE_NAME)(mthis, index) ' 1013 '$(DART_NATIVE_NAME)(mthis, index) '
1021 'native "$(RESOLVER_STRING)";\n', 1014 'native "$(RESOLVER_STRING)";\n',
1022 DART_NATIVE_NAME = dart_native_name, 1015 DART_NATIVE_NAME = dart_native_name,
1023 RESOLVER_STRING=resolver_string) 1016 RESOLVER_STRING=resolver_string)
1024 1017
1025 # Emit the method which calls the toplevel function, along with 1018 # Emit the method which calls the toplevel function, along with
1026 # the [] operator. 1019 # the [] operator.
1027 self._members_emitter.Emit( 1020 self._members_emitter.Emit(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 elif not needs_dispatcher: 1136 elif not needs_dispatcher:
1144 # Bind directly to native implementation 1137 # Bind directly to native implementation
1145 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) 1138 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos)
1146 native_suffix = 'Callback' 1139 native_suffix = 'Callback'
1147 auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix) 1140 auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix)
1148 if self._dart_use_blink: 1141 if self._dart_use_blink:
1149 type_ids = [argument.type.id 1142 type_ids = [argument.type.id
1150 for argument in operation.arguments[:argument_count]] 1143 for argument in operation.arguments[:argument_count]]
1151 resolver_string = \ 1144 resolver_string = \
1152 DeriveResolverString(self._interface.id, operation.id, 1145 DeriveResolverString(self._interface.id, operation.id,
1153 native_suffix, type_ids, is_custom) 1146 native_suffix, type_ids)
1154 else: 1147 else:
1155 resolver_string = None 1148 resolver_string = None
1156 cpp_callback_name = self._GenerateNativeBinding( 1149 cpp_callback_name = self._GenerateNativeBinding(
1157 info.name, argument_count, dart_declaration, 1150 info.name, argument_count, dart_declaration,
1158 info.IsStatic(), return_type, parameters, 1151 info.IsStatic(), return_type, parameters,
1159 native_suffix, is_custom, auto_scope_setup, 1152 native_suffix, is_custom, auto_scope_setup,
1160 resolver_string=resolver_string) 1153 resolver_string=resolver_string)
1161 if not is_custom: 1154 if not is_custom:
1162 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name, auto_scope_setup) 1155 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name, auto_scope_setup)
1163 else: 1156 else:
(...skipping 15 matching lines...) Expand all
1179 static = True 1172 static = True
1180 if not operation.is_static: 1173 if not operation.is_static:
1181 actuals = ['mthis'] + actuals 1174 actuals = ['mthis'] + actuals
1182 actuals_s = ", ".join(actuals) 1175 actuals_s = ", ".join(actuals)
1183 dart_declaration = '%s(%s)' % ( 1176 dart_declaration = '%s(%s)' % (
1184 base_name, actuals_s) 1177 base_name, actuals_s)
1185 type_ids = [argument.type.id 1178 type_ids = [argument.type.id
1186 for argument in operation.arguments[:argument_count]] 1179 for argument in operation.arguments[:argument_count]]
1187 resolver_string = \ 1180 resolver_string = \
1188 DeriveResolverString(self._interface.id, operation.id, 1181 DeriveResolverString(self._interface.id, operation.id,
1189 native_suffix, type_ids, is_custom) 1182 native_suffix, type_ids)
1190 else: 1183 else:
1191 base_name = '_%s_%s' % (operation.id, version) 1184 base_name = '_%s_%s' % (operation.id, version)
1192 overload_name = base_name 1185 overload_name = base_name
1193 static = operation.is_static 1186 static = operation.is_static
1194 actuals_s = ", ".join(actuals) 1187 actuals_s = ", ".join(actuals)
1195 dart_declaration = '%s%s %s(%s)' % ( 1188 dart_declaration = '%s%s %s(%s)' % (
1196 'static ' if static else '', 1189 'static ' if static else '',
1197 return_type, 1190 return_type,
1198 overload_name, actuals_s) 1191 overload_name, actuals_s)
1199 resolver_string = None 1192 resolver_string = None
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 e.Emit("};\n"); 1936 e.Emit("};\n");
1944 e.Emit('\n'); 1937 e.Emit('\n');
1945 e.Emit('} // namespace WebCore\n'); 1938 e.Emit('} // namespace WebCore\n');
1946 1939
1947 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 1940 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
1948 return ( 1941 return (
1949 interface.id.endswith('Event') and 1942 interface.id.endswith('Event') and
1950 operation.id.startswith('init') and 1943 operation.id.startswith('init') and
1951 argument.ext_attrs.get('Default') == 'Undefined' and 1944 argument.ext_attrs.get('Default') == 'Undefined' and
1952 argument.type.id == 'DOMString') 1945 argument.type.id == 'DOMString')
OLDNEW
« no previous file with comments | « sdk/lib/_blink/dartium/_blink_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698