| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """ | 4 """ |
| 5 Generator language component for compiler.py that adds Dart language support. | 5 Generator language component for compiler.py that adds Dart language support. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 from code import Code | 8 from code import Code |
| 9 from model import * | 9 from model import Function, PropertyType |
| 10 from schema_util import * | 10 from schema_util import StripNamespace |
| 11 | 11 |
| 12 import os | 12 import os |
| 13 from datetime import datetime | 13 from datetime import datetime |
| 14 | 14 |
| 15 LICENSE = ( | 15 LICENSE = ( |
| 16 """// Copyright (c) %s, the Dart project authors. Please see the AUTHORS file | 16 """// Copyright (c) %s, the Dart project authors. Please see the AUTHORS file |
| 17 // for details. All rights reserved. Use of this source code is governed by a | 17 // for details. All rights reserved. Use of this source code is governed by a |
| 18 // BSD-style license that can be found in the LICENSE file.""" % | 18 // BSD-style license that can be found in the LICENSE file.""" % |
| 19 datetime.now().year) | 19 datetime.now().year) |
| 20 | 20 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 c.Comment(line, comment_prefix='/// ') | 271 c.Comment(line, comment_prefix='/// ') |
| 272 return c | 272 return c |
| 273 | 273 |
| 274 def _GenerateFunction(self, f): | 274 def _GenerateFunction(self, f): |
| 275 """Returns the Code object for the given function. | 275 """Returns the Code object for the given function. |
| 276 """ | 276 """ |
| 277 c = Code() | 277 c = Code() |
| 278 c.Concat(self._GenerateDocumentation(f)) | 278 c.Concat(self._GenerateDocumentation(f)) |
| 279 | 279 |
| 280 if not self._NeedsProxiedCallback(f): | 280 if not self._NeedsProxiedCallback(f): |
| 281 c.Append("%s => %s;" % (self._GenerateFunctionSignature(f), | 281 c.Append("%s => %s;" % (self._GenerateFunctionSignature(f), |
| 282 self._GenerateProxyCall(f))) | 282 self._GenerateProxyCall(f))) |
| 283 return c | 283 return c |
| 284 | 284 |
| 285 (c.Sblock("%s {" % self._GenerateFunctionSignature(f)) | 285 (c.Sblock("%s {" % self._GenerateFunctionSignature(f)) |
| 286 .Concat(self._GenerateProxiedFunction(f.callback, f.callback.name)) | 286 .Concat(self._GenerateProxiedFunction(f.callback, f.callback.name)) |
| 287 .Append('%s;' % self._GenerateProxyCall(f)) | 287 .Append('%s;' % self._GenerateProxyCall(f)) |
| 288 .Eblock('}') | 288 .Eblock('}') |
| 289 ) | 289 ) |
| 290 | 290 |
| 291 return c | 291 return c |
| 292 | 292 |
| 293 def _GenerateProxiedFunction(self, f, callback_name): | 293 def _GenerateProxiedFunction(self, f, callback_name): |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 return 'Object' | 753 return 'Object' |
| 754 elif prop_type is PropertyType.FUNCTION: | 754 elif prop_type is PropertyType.FUNCTION: |
| 755 return 'Function' | 755 return 'Function' |
| 756 elif prop_type is PropertyType.ARRAY: | 756 elif prop_type is PropertyType.ARRAY: |
| 757 return 'List<%s>' % self._GetDartType(type_.item_type) | 757 return 'List<%s>' % self._GetDartType(type_.item_type) |
| 758 elif prop_type is PropertyType.BINARY: | 758 elif prop_type is PropertyType.BINARY: |
| 759 return 'String' | 759 return 'String' |
| 760 else: | 760 else: |
| 761 raise NotImplementedError(prop_type) | 761 raise NotImplementedError(prop_type) |
| 762 | 762 |
| OLD | NEW |