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

Unified Diff: tools/json_schema_compiler/cpp_util.py

Issue 23549025: Clean up JSON Schema Compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removed enum test and added blank lines. Created 7 years, 3 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
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/dart_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2de42293fba9c4b444978f64292ced4153f986e5..2d4934393443e25ebcfb29986c9b2d49a265e18a 100644
--- a/tools/json_schema_compiler/cpp_util.py
+++ b/tools/json_schema_compiler/cpp_util.py
@@ -7,7 +7,7 @@
from code import Code
from datetime import datetime
-from model import Property, PropertyType, Type
+from model import PropertyType
import os
import re
@@ -34,6 +34,7 @@ def Classname(s):
"""
return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)])
+
def GetAsFundamentalValue(type_, src, dst):
"""Returns the C++ code for retrieving a fundamental type from a
Value into a variable.
@@ -48,6 +49,7 @@ def GetAsFundamentalValue(type_, src, dst):
PropertyType.STRING: '%s->GetAsString(%s)',
}[type_.property_type] % (src, dst)
+
def GetValueType(type_):
"""Returns the Value::Type corresponding to the model.Type.
"""
@@ -64,6 +66,7 @@ def GetValueType(type_):
PropertyType.STRING: 'base::Value::TYPE_STRING',
}[type_.property_type]
+
def GetParameterDeclaration(param, type_):
"""Gets a parameter declaration of a given model.Property and its C++
type.
@@ -82,6 +85,7 @@ def GetParameterDeclaration(param, type_):
'name': param.unix_name,
}
+
def GenerateIfndefName(path, filename):
"""Formats a path and filename as a #define name.
@@ -90,12 +94,14 @@ def GenerateIfndefName(path, filename):
return (('%s_%s_H__' % (path, filename))
.upper().replace(os.sep, '_').replace('/', '_'))
+
def PadForGenerics(var):
"""Appends a space to |var| if it ends with a >, so that it can be compiled
within generic types.
"""
return ('%s ' % var) if var.endswith('>') else var
+
def OpenNamespace(namespace):
"""Get opening root namespace declarations.
"""
@@ -104,6 +110,7 @@ def OpenNamespace(namespace):
c.Append('namespace %s {' % component)
return c
+
def CloseNamespace(namespace):
"""Get closing root namespace declarations.
"""
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/dart_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698