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

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 fd13235e8bd7e8800273345f4072d46fabf7e6c6..f003d98eacca8c1a9927c64801c72279275aaf48 100644
--- a/tools/json_schema_compiler/cpp_util.py
+++ b/tools/json_schema_compiler/cpp_util.py
@@ -75,9 +75,23 @@ 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 GenerateTypeConversionCall(prop, from_, to):
+ """Converts from prop.type_ to prop.compiled_type.
+
+ 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.
+ 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.
+ """
+ # 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.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.
+ }[prop.type_]

Powered by Google App Engine
This is Rietveld 408576698