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 import os | 9 import os |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 PropertyType.STRING): | 68 PropertyType.STRING): |
69 arg = '%(type)s& %(name)s' | 69 arg = '%(type)s& %(name)s' |
70 else: | 70 else: |
71 arg = '%(type)s %(name)s' | 71 arg = '%(type)s %(name)s' |
72 return arg % { | 72 return arg % { |
73 'type': type_, | 73 'type': type_, |
74 'name': param.unix_name, | 74 'name': param.unix_name, |
75 } | 75 } |
76 | 76 |
77 def GenerateIfndefName(path, filename): | 77 def GenerateIfndefName(path, filename): |
78 """Formats a path and filename as a #define name. | 78 """Formats a path and filename as a #define name. |
79 | 79 |
80 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. | 80 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. |
81 """ | 81 """ |
82 return (('%s_%s_H__' % (path, filename)) | 82 return (('%s_%s_H__' % (path, filename)) |
83 .upper().replace(os.sep, '_').replace('/', '_')) | 83 .upper().replace(os.sep, '_').replace('/', '_')) |
84 | |
85 def GenerateTypeConversionCall(prop, from_, to): | |
86 """Converts from prop.type_ to prop.compiled_type. | |
87 | |
88 from_: The variable name of the type to be converted from. | |
not at google - send to devlin
2012/07/27 04:14:28
... as plain data or a reference.
mitchellwrosen
2012/07/30 20:52:45
Done.
| |
89 to: The variable name of the type to be converted to. | |
not at google - send to devlin
2012/07/27 04:14:28
... as a pointer.
mitchellwrosen
2012/07/30 20:52:45
Done.
| |
90 """ | |
91 # TODO(mwrosen): Add support for more from/to combinations as necessary. | |
92 return { | |
93 PropertyType.STRING: { | |
94 PropertyType.INTEGER: 'base::StringToInt(%s, %s)', | |
95 PropertyType.INT64: 'base::StringToInt64(%s, %s)' | |
96 }[prop.compiled_type] % (from_, to) | |
not at google - send to devlin
2012/07/27 04:14:28
see previous comment about NotImplementedError.
mitchellwrosen
2012/07/30 20:52:45
Done.
| |
97 }[prop.type_] | |
OLD | NEW |