Index: tools/json_schema_compiler/cpp_util.py |
diff --git a/tools/json_schema_compiler/cpp_util.py b/tools/json_schema_compiler/cpp_util.py |
index e58ff1d045da13434beecb8fa470172818d78351..d06506a2247a7ae1ff66d014915d99113cd473db 100644 |
--- a/tools/json_schema_compiler/cpp_util.py |
+++ b/tools/json_schema_compiler/cpp_util.py |
@@ -74,9 +74,20 @@ def GetParameterDeclaration(param, type_): |
} |
def GenerateIfndefName(path, filename): |
- """Formats a path and filename as a #define name. |
+ """Formats a path and filename as a #define name. |
- e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. |
- """ |
- return (('%s_%s_H__' % (path, filename)) |
- .upper().replace(os.sep, '_').replace('/', '_')) |
+ e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. |
+ """ |
+ return (('%s_%s_H__' % (path, filename)) |
+ .upper().replace(os.sep, '_').replace('/', '_')) |
+ |
+def DoConversion(prop, from_, to): |
+ """Converts from prop.type_ to prop.serialized_type. |
not at google - send to devlin
2012/07/26 04:51:42
erm maybe a less ambiguous name, like GenerateType
mitchellwrosen
2012/07/26 20:00:27
Done.
|
+ """ |
+ # TODO(mwrosen): Add support for more from/to combinations as necessary. |
+ return { |
+ PropertyType.STRING: { |
+ PropertyType.INTEGER: 'base::StringToInt(%s, %s)', |
+ PropertyType.INT64: 'base::StringToInt64(%s, %s)' |
+ }[prop.serialized_type] % (from_, to) |
+ }[prop.type_] |
not at google - send to devlin
2012/07/26 04:51:42
here and above, what happens if the types aren't s
mitchellwrosen
2012/07/26 20:00:27
It'll return a KeyError. Should I catch that and r
not at google - send to devlin
2012/07/27 04:14:28
Yeah, would be nice to include in the exception wh
mitchellwrosen
2012/07/30 20:52:45
Done.
|