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

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

Issue 1349293006: Start using the dart2js type conversions in Dartium as well. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged Created 5 years, 3 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
« no previous file with comments | « sdk/lib/indexed_db/dartium/indexed_db_dartium.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | 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 systems to generate 6 """This module provides shared functionality for systems to generate
7 Dart APIs from the IDL database.""" 7 Dart APIs from the IDL database."""
8 8
9 import copy 9 import copy
10 import json 10 import json
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 parameter_count = len(self.param_infos) 514 parameter_count = len(self.param_infos)
515 return ', '.join(map(param_name, self.param_infos[:parameter_count])) 515 return ', '.join(map(param_name, self.param_infos[:parameter_count]))
516 516
517 def isCallback(self, type_registry, type_id): 517 def isCallback(self, type_registry, type_id):
518 if type_id: 518 if type_id:
519 callback_type = type_registry._database._all_interfaces[type_id] 519 callback_type = type_registry._database._all_interfaces[type_id]
520 return callback_type.operations[0].id == 'handleEvent' if len(callback_typ e.operations) > 0 else False 520 return callback_type.operations[0].id == 'handleEvent' if len(callback_typ e.operations) > 0 else False
521 else: 521 else:
522 return False 522 return False
523 523
524 def ParametersAsListOfVariables(self, parameter_count=None, type_registry=None , dart_js_interop=False): 524 def ParametersAsListOfVariables(self, parameter_count=None, type_registry=None , dart_js_interop=False, backend = None):
525 """Returns a list of the first parameter_count parameter names 525 """Returns a list of the first parameter_count parameter names
526 as raw variables. 526 as raw variables.
527 """ 527 """
528 isRemoveOperation = self.name == 'removeEventListener' or self.name == 'remo veListener' 528 isRemoveOperation = self.name == 'removeEventListener' or self.name == 'remo veListener'
529 529
530 if parameter_count is None: 530 if parameter_count is None:
531 parameter_count = len(self.param_infos) 531 parameter_count = len(self.param_infos)
532 if not type_registry: 532 if not type_registry:
533 return [p.name for p in self.param_infos[:parameter_count]] 533 return [p.name for p in self.param_infos[:parameter_count]]
534 else: 534 else:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 else: 581 else:
582 callback_args_call.append(callback_arg.id) 582 callback_args_call.append(callback_arg.id)
583 parameters.append('unwrap_jso((%s) => %s(%s))' % 583 parameters.append('unwrap_jso((%s) => %s(%s))' %
584 (", ".join(callback_args_decl), 584 (", ".join(callback_args_decl),
585 p.name, 585 p.name,
586 ", ".join(callback_args_call))) 586 ", ".join(callback_args_call)))
587 else: 587 else:
588 parameters.append('unwrap_jso(%s)' % p.name) 588 parameters.append('unwrap_jso(%s)' % p.name)
589 else: 589 else:
590 if dart_js_interop: 590 if dart_js_interop:
591 conversion = backend._InputConversion(p.type_id, self.declared_name)
591 passParam = p.name 592 passParam = p.name
592 if type_id == 'Dictionary': 593 if conversion:
593 # Need to pass the IDL Dictionary from Dart Map to JavaScript obje ct. 594 # Need to pass the IDL Dictionary from Dart Map to JavaScript obje ct.
594 passParam = '{0} != null ? new js.JsObject.jsify({0}) : {0}'.forma t(p.name) 595 passParam = '{0}({1})'.format(conversion.function_name, p.name)
595 else: 596 else:
596 passParam = p.name 597 passParam = p.name
597 parameters.append(passParam) 598 parameters.append(passParam)
598 599
599 return parameters 600 return parameters
600 601
601 def ParametersAsStringOfVariables(self, parameter_count=None): 602 def ParametersAsStringOfVariables(self, parameter_count=None):
602 """Returns a string containing the first parameter_count parameter names 603 """Returns a string containing the first parameter_count parameter names
603 as raw variables, comma separated. 604 as raw variables, comma separated.
604 """ 605 """
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 return_type == 'Rectangle') 1455 return_type == 'Rectangle')
1455 1456
1456 def wrap_return_type_blink(return_type, type_name, type_registry): 1457 def wrap_return_type_blink(return_type, type_name, type_registry):
1457 """Returns True if we should wrap the returned value. This checks 1458 """Returns True if we should wrap the returned value. This checks
1458 a number of different variations, calling the more basic functions 1459 a number of different variations, calling the more basic functions
1459 above.""" 1460 above."""
1460 return (wrap_unwrap_type_blink(return_type, type_registry) or 1461 return (wrap_unwrap_type_blink(return_type, type_registry) or
1461 wrap_unwrap_type_blink(type_name, type_registry) or 1462 wrap_unwrap_type_blink(type_name, type_registry) or
1462 wrap_type_blink(return_type, type_registry) or 1463 wrap_type_blink(return_type, type_registry) or
1463 wrap_unwrap_list_blink(return_type, type_registry)) 1464 wrap_unwrap_list_blink(return_type, type_registry))
OLDNEW
« no previous file with comments | « sdk/lib/indexed_db/dartium/indexed_db_dartium.dart ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698