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

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

Issue 39113003: Docserver: Display enum value descriptions in API docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4
5 from code import Code 5 from code import Code
6 from model import PropertyType 6 from model import PropertyType
7 import cpp_util 7 import cpp_util
8 from json_parse import OrderedDict 8 from json_parse import OrderedDict
9 import schema_util 9 import schema_util
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 been set. 58 been set.
59 """ 59 """
60 return '%s_NONE' % self.FollowRef(type_).unix_name.upper() 60 return '%s_NONE' % self.FollowRef(type_).unix_name.upper()
61 61
62 def GetEnumValue(self, type_, enum_value): 62 def GetEnumValue(self, type_, enum_value):
63 """Gets the enum value of the given model.Property of the given type. 63 """Gets the enum value of the given model.Property of the given type.
64 64
65 e.g VAR_STRING 65 e.g VAR_STRING
66 """ 66 """
67 value = '%s_%s' % (self.FollowRef(type_).unix_name.upper(), 67 value = '%s_%s' % (self.FollowRef(type_).unix_name.upper(),
68 cpp_util.Classname(enum_value.upper())) 68 cpp_util.Classname(enum_value.name.upper()))
69 # To avoid collisions with built-in OS_* preprocessor definitions, we add a 69 # To avoid collisions with built-in OS_* preprocessor definitions, we add a
70 # trailing slash to enum names that start with OS_. 70 # trailing slash to enum names that start with OS_.
71 if value.startswith("OS_"): 71 if value.startswith("OS_"):
72 value += "_" 72 value += "_"
73 return value 73 return value
74 74
75 def GetCppType(self, type_, is_ptr=False, is_in_container=False): 75 def GetCppType(self, type_, is_ptr=False, is_in_container=False):
76 """Translates a model.Property or model.Type into its C++ type. 76 """Translates a model.Property or model.Type into its C++ type.
77 77
78 If REF types from different namespaces are referenced, will resolve 78 If REF types from different namespaces are referenced, will resolve
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 child_code = self.GeneratePropertyValues(child_property, 267 child_code = self.GeneratePropertyValues(child_property,
268 line, 268 line,
269 nodoc=nodoc) 269 nodoc=nodoc)
270 if child_code: 270 if child_code:
271 has_child_code = True 271 has_child_code = True
272 c.Concat(child_code) 272 c.Concat(child_code)
273 c.Eblock('} // namespace %s' % property.name) 273 c.Eblock('} // namespace %s' % property.name)
274 if not has_child_code: 274 if not has_child_code:
275 c = None 275 c = None
276 return c 276 return c
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cc_generator.py ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698