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 """Utilies and constants specific to Chromium C++ code. | 4 """Utilies and constants specific to Chromium C++ code. |
5 """ | 5 """ |
6 | 6 |
7 from datetime import datetime | 7 from datetime import datetime |
8 from model import PropertyType | 8 from model import PropertyType |
9 | 9 |
10 CHROMIUM_LICENSE = ( | 10 CHROMIUM_LICENSE = ( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 """ | 45 """ |
46 return { | 46 return { |
47 PropertyType.STRING: 'Value::TYPE_STRING', | 47 PropertyType.STRING: 'Value::TYPE_STRING', |
48 PropertyType.INTEGER: 'Value::TYPE_INTEGER', | 48 PropertyType.INTEGER: 'Value::TYPE_INTEGER', |
49 PropertyType.BOOLEAN: 'Value::TYPE_BOOLEAN', | 49 PropertyType.BOOLEAN: 'Value::TYPE_BOOLEAN', |
50 PropertyType.DOUBLE: 'Value::TYPE_DOUBLE', | 50 PropertyType.DOUBLE: 'Value::TYPE_DOUBLE', |
51 PropertyType.ENUM: 'Value::TYPE_STRING', | 51 PropertyType.ENUM: 'Value::TYPE_STRING', |
52 PropertyType.REF: 'Value::TYPE_DICTIONARY', | 52 PropertyType.REF: 'Value::TYPE_DICTIONARY', |
53 PropertyType.OBJECT: 'Value::TYPE_DICTIONARY', | 53 PropertyType.OBJECT: 'Value::TYPE_DICTIONARY', |
54 PropertyType.ARRAY: 'Value::TYPE_LIST', | 54 PropertyType.ARRAY: 'Value::TYPE_LIST', |
55 PropertyType.ANY: 'Value::TYPE_DICTIONARY', | |
56 }[prop.type_] | 55 }[prop.type_] |
57 | 56 |
58 def GetParameterDeclaration(param, type_): | 57 def GetParameterDeclaration(param, type_): |
59 """Gets a parameter declaration of a given model.Property and its C++ | 58 """Gets a parameter declaration of a given model.Property and its C++ |
60 type. | 59 type. |
61 """ | 60 """ |
62 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, | 61 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, |
63 PropertyType.STRING): | 62 PropertyType.STRING): |
64 arg = '%(type)s& %(name)s' | 63 arg = '%(type)s& %(name)s' |
65 else: | 64 else: |
66 arg = '%(type)s %(name)s' | 65 arg = '%(type)s %(name)s' |
67 return arg % { | 66 return arg % { |
68 'type': type_, | 67 'type': type_, |
69 'name': param.unix_name, | 68 'name': param.unix_name, |
70 } | 69 } |
OLD | NEW |