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

Unified Diff: tools/json_schema_compiler/cpp_util.py

Issue 10825029: Added JSON schema compiler support for serialized types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
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.

Powered by Google App Engine
This is Rietveld 408576698