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

Side by Side Diff: tools/json_schema_compiler/cpp_util.py

Issue 10796114: Added ToJson to JSON schema compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed scope Created 8 years, 4 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 unified diff | Download patch
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 PropertyType.FUNCTION: 'Value::TYPE_DICTIONARY', 58 PropertyType.FUNCTION: 'Value::TYPE_DICTIONARY',
59 PropertyType.ARRAY: 'Value::TYPE_LIST', 59 PropertyType.ARRAY: 'Value::TYPE_LIST',
60 PropertyType.BINARY: 'Value::TYPE_BINARY', 60 PropertyType.BINARY: 'Value::TYPE_BINARY',
61 }[type_] 61 }[type_]
62 62
63 def GetParameterDeclaration(param, type_): 63 def GetParameterDeclaration(param, type_):
64 """Gets a parameter declaration of a given model.Property and its C++ 64 """Gets a parameter declaration of a given model.Property and its C++
65 type. 65 type.
66 """ 66 """
67 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, 67 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY,
68 PropertyType.STRING): 68 PropertyType.STRING, PropertyType.ANY):
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('/', '_'))
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator_test.py ('k') | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698