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

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

Issue 9491002: json_schema_compiler: any, additionalProperties, functions on types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add any in arrays to util.h Created 8 years, 9 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 9
10 CHROMIUM_LICENSE = ( 10 CHROMIUM_LICENSE = (
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 """ 45 """
46 return { 46 return {
47 PropertyType.STRING: 'Value::TYPE_STRING', 47 PropertyType.STRING: 'Value::TYPE_STRING',
48 PropertyType.INTEGER: 'Value::TYPE_INTEGER', 48 PropertyType.INTEGER: 'Value::TYPE_INTEGER',
49 PropertyType.BOOLEAN: 'Value::TYPE_BOOLEAN', 49 PropertyType.BOOLEAN: 'Value::TYPE_BOOLEAN',
50 PropertyType.DOUBLE: 'Value::TYPE_DOUBLE', 50 PropertyType.DOUBLE: 'Value::TYPE_DOUBLE',
51 PropertyType.ENUM: 'Value::TYPE_STRING', 51 PropertyType.ENUM: 'Value::TYPE_STRING',
52 PropertyType.REF: 'Value::TYPE_DICTIONARY', 52 PropertyType.REF: 'Value::TYPE_DICTIONARY',
53 PropertyType.OBJECT: 'Value::TYPE_DICTIONARY', 53 PropertyType.OBJECT: 'Value::TYPE_DICTIONARY',
54 PropertyType.ARRAY: 'Value::TYPE_LIST', 54 PropertyType.ARRAY: 'Value::TYPE_LIST',
55 PropertyType.ANY: 'Value::TYPE_DICTIONARY',
56 }[prop.type_] 55 }[prop.type_]
57 56
58 def GetParameterDeclaration(param, type_): 57 def GetParameterDeclaration(param, type_):
59 """Gets a parameter declaration of a given model.Property and its C++ 58 """Gets a parameter declaration of a given model.Property and its C++
60 type. 59 type.
61 """ 60 """
62 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY, 61 if param.type_ in (PropertyType.REF, PropertyType.OBJECT, PropertyType.ARRAY,
63 PropertyType.STRING): 62 PropertyType.STRING):
64 arg = '%(type)s& %(name)s' 63 arg = '%(type)s& %(name)s'
65 else: 64 else:
66 arg = '%(type)s %(name)s' 65 arg = '%(type)s %(name)s'
67 return arg % { 66 return arg % {
68 'type': type_, 67 'type': type_,
69 'name': param.unix_name, 68 'name': param.unix_name,
70 } 69 }
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