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

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

Issue 1383903002: wrap_jso should wrap JsArray as well, not always call wrap on its contents (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 if self.requires_named_arguments and param_info.is_optional: 508 if self.requires_named_arguments and param_info.is_optional:
509 return '%s : %s' % (param_info.name, param_info.name) 509 return '%s : %s' % (param_info.name, param_info.name)
510 else: 510 else:
511 return param_info.name 511 return param_info.name
512 512
513 if parameter_count is None: 513 if parameter_count is None:
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 and not type_id.endswith('[]'):
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, backend = None): 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'
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 def wrap_unwrap_type_blink(return_type, type_registry): 1439 def wrap_unwrap_type_blink(return_type, type_registry):
1440 """Returns True if the type is a blink type that requires wrap_jso or 1440 """Returns True if the type is a blink type that requires wrap_jso or
1441 unwrap_jso""" 1441 unwrap_jso"""
1442 if return_type and return_type.startswith('Html'): 1442 if return_type and return_type.startswith('Html'):
1443 return_type = return_type.replace('Html', 'HTML', 1) 1443 return_type = return_type.replace('Html', 'HTML', 1)
1444 return (type_registry.HasInterface(return_type) or not(return_type) or 1444 return (type_registry.HasInterface(return_type) or not(return_type) or
1445 return_type == 'Object' or 1445 return_type == 'Object' or
1446 return_type == 'Future' or 1446 return_type == 'Future' or
1447 return_type == 'SqlDatabase' or # renamed to Database 1447 return_type == 'SqlDatabase' or # renamed to Database
1448 return_type == 'HTMLElement' or 1448 return_type == 'HTMLElement' or
1449 return_type == 'MutationObserver') 1449 return_type == 'MutationObserver' or
1450 return_type.endswith('[]'))
1450 1451
1451 def wrap_type_blink(return_type, type_registry): 1452 def wrap_type_blink(return_type, type_registry):
1452 """Returns True if the type is a blink type that requires wrap_jso but 1453 """Returns True if the type is a blink type that requires wrap_jso but
1453 NOT unwrap_jso""" 1454 NOT unwrap_jso"""
1454 return (return_type == 'Map' or 1455 return (return_type == 'Map' or
1455 return_type == 'Rectangle') 1456 return_type == 'Rectangle')
1456 1457
1457 def wrap_return_type_blink(return_type, type_name, type_registry): 1458 def wrap_return_type_blink(return_type, type_name, type_registry):
1458 """Returns True if we should wrap the returned value. This checks 1459 """Returns True if we should wrap the returned value. This checks
1459 a number of different variations, calling the more basic functions 1460 a number of different variations, calling the more basic functions
1460 above.""" 1461 above."""
1461 return (wrap_unwrap_type_blink(return_type, type_registry) or 1462 return (wrap_unwrap_type_blink(return_type, type_registry) or
1462 wrap_unwrap_type_blink(type_name, type_registry) or 1463 wrap_unwrap_type_blink(type_name, type_registry) or
1463 wrap_type_blink(return_type, type_registry) or 1464 wrap_type_blink(return_type, type_registry) or
1464 wrap_unwrap_list_blink(return_type, type_registry)) 1465 wrap_unwrap_list_blink(return_type, type_registry))
OLDNEW
« no previous file with comments | « tests/html/wrapping_collections_test.dart ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698