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

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

Issue 12378043: Support DateTime conversions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « no previous file | 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 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 1193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 # sequence<float> should map to Vector<float> 1204 # sequence<float> should map to Vector<float>
1205 if self.idl_type() == 'float': return 'float' 1205 if self.idl_type() == 'float': return 'float'
1206 return self.native_type() 1206 return self.native_type()
1207 1207
1208 def to_native_info(self, idl_node, interface_name): 1208 def to_native_info(self, idl_node, interface_name):
1209 type = self.native_type() 1209 type = self.native_type()
1210 if type == 'SerializedScriptValue': 1210 if type == 'SerializedScriptValue':
1211 type = 'RefPtr<%s>' % type 1211 type = 'RefPtr<%s>' % type
1212 if type == 'String': 1212 if type == 'String':
1213 type = 'DartStringAdapter' 1213 type = 'DartStringAdapter'
1214 return '%s', type, 'DartUtilities', 'dartTo%s' % self._capitalized_native_ty pe() 1214 target_type = self._capitalized_native_type()
1215 if self.idl_type() == 'Date':
1216 target_type = 'Date'
1217 return '%s', type, 'DartUtilities', 'dartTo%s' % target_type
1215 1218
1216 def parameter_type(self): 1219 def parameter_type(self):
1217 if self.native_type() == 'String': 1220 if self.native_type() == 'String':
1218 return 'const String&' 1221 return 'const String&'
1219 return self.native_type() 1222 return self.native_type()
1220 1223
1221 def conversion_includes(self): 1224 def conversion_includes(self):
1222 return [] 1225 return []
1223 1226
1224 def to_dart_conversion(self, value, interface_name=None, attributes=None): 1227 def to_dart_conversion(self, value, interface_name=None, attributes=None):
1225 function_name = self._capitalized_native_type() 1228 # TODO(antonm): if there are more instances of the case
1226 function_name = function_name[0].lower() + function_name[1:] 1229 # when conversion depends on both Dart type and C++ type,
1230 # consider introducing a corresponding argument/class.
1231 if self.idl_type() == 'Date':
1232 function_name = 'date'
1233 else:
1234 function_name = self._capitalized_native_type()
1235 function_name = function_name[0].lower() + function_name[1:]
1227 function_name = 'DartUtilities::%sToDart' % function_name 1236 function_name = 'DartUtilities::%sToDart' % function_name
1228 if attributes and 'TreatReturnedNullStringAs' in attributes: 1237 if attributes and 'TreatReturnedNullStringAs' in attributes:
1229 function_name += 'WithNullCheck' 1238 function_name += 'WithNullCheck'
1230 return '%s(%s)' % (function_name, value) 1239 return '%s(%s)' % (function_name, value)
1231 1240
1232 def webcore_getter_name(self): 1241 def webcore_getter_name(self):
1233 return self._data.webcore_getter_name 1242 return self._data.webcore_getter_name
1234 1243
1235 def webcore_setter_name(self): 1244 def webcore_setter_name(self):
1236 return self._data.webcore_setter_name 1245 return self._data.webcore_setter_name
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 webcore_getter_name='getUnsignedIntegralAttribute' , 1334 webcore_getter_name='getUnsignedIntegralAttribute' ,
1326 webcore_setter_name='setUnsignedIntegralAttribute' ), 1335 webcore_setter_name='setUnsignedIntegralAttribute' ),
1327 'long long': TypeData(clazz='Primitive', dart_type='int'), 1336 'long long': TypeData(clazz='Primitive', dart_type='int'),
1328 'unsigned long long': TypeData(clazz='Primitive', dart_type='int'), 1337 'unsigned long long': TypeData(clazz='Primitive', dart_type='int'),
1329 'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'), 1338 'float': TypeData(clazz='Primitive', dart_type='num', native_type='double'),
1330 'double': TypeData(clazz='Primitive', dart_type='num'), 1339 'double': TypeData(clazz='Primitive', dart_type='num'),
1331 1340
1332 'any': TypeData(clazz='Primitive', dart_type='Object', native_type='ScriptVa lue'), 1341 'any': TypeData(clazz='Primitive', dart_type='Object', native_type='ScriptVa lue'),
1333 'Array': TypeData(clazz='Primitive', dart_type='List'), 1342 'Array': TypeData(clazz='Primitive', dart_type='List'),
1334 'custom': TypeData(clazz='Primitive', dart_type='dynamic'), 1343 'custom': TypeData(clazz='Primitive', dart_type='dynamic'),
1335 'Date': TypeData(clazz='Primitive', dart_type='Date', native_type='double'), 1344 'Date': TypeData(clazz='Primitive', dart_type='DateTime', native_type='doubl e'),
1336 'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc riptValue'), 1345 'DOMObject': TypeData(clazz='Primitive', dart_type='Object', native_type='Sc riptValue'),
1337 'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St ring'), 1346 'DOMString': TypeData(clazz='Primitive', dart_type='String', native_type='St ring'),
1338 # TODO(vsm): This won't actually work until we convert the Map to 1347 # TODO(vsm): This won't actually work until we convert the Map to
1339 # a native JS Map for JS DOM. 1348 # a native JS Map for JS DOM.
1340 'Dictionary': TypeData(clazz='Primitive', dart_type='Map'), 1349 'Dictionary': TypeData(clazz='Primitive', dart_type='Map'),
1341 'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un signed long long'), 1350 'DOMTimeStamp': TypeData(clazz='Primitive', dart_type='int', native_type='un signed long long'),
1342 'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip tValue'), 1351 'object': TypeData(clazz='Primitive', dart_type='Object', native_type='Scrip tValue'),
1343 'ObjectArray': TypeData(clazz='Primitive', dart_type='List'), 1352 'ObjectArray': TypeData(clazz='Primitive', dart_type='List'),
1344 'PositionOptions': TypeData(clazz='Primitive', dart_type='Object'), 1353 'PositionOptions': TypeData(clazz='Primitive', dart_type='Object'),
1345 # TODO(sra): Come up with some meaningful name so that where this appears in 1354 # TODO(sra): Come up with some meaningful name so that where this appears in
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 self) 1497 self)
1489 1498
1490 if type_data.clazz == 'SVGTearOff': 1499 if type_data.clazz == 'SVGTearOff':
1491 dart_interface_name = self._renamer.RenameInterface( 1500 dart_interface_name = self._renamer.RenameInterface(
1492 self._database.GetInterface(type_name)) 1501 self._database.GetInterface(type_name))
1493 return SVGTearOffIDLTypeInfo( 1502 return SVGTearOffIDLTypeInfo(
1494 type_name, type_data, dart_interface_name, self) 1503 type_name, type_data, dart_interface_name, self)
1495 1504
1496 class_name = '%sIDLTypeInfo' % type_data.clazz 1505 class_name = '%sIDLTypeInfo' % type_data.clazz
1497 return globals()[class_name](type_name, type_data) 1506 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698