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

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

Issue 2594053002: [Schema Compiler] Remove cpp_util.PadForGenerics() (Closed)
Patch Set: Created 4 years 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 4
5 """Utilies and constants specific to Chromium C++ code. 5 """Utilies and constants specific to Chromium C++ code.
6 """ 6 """
7 7
8 from code import Code 8 from code import Code
9 from datetime import datetime 9 from datetime import datetime
10 from model import PropertyType 10 from model import PropertyType
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 file, or there's little point in generating a #define for it. 98 file, or there's little point in generating a #define for it.
99 99
100 e.g chrome/extensions/gen/file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. 100 e.g chrome/extensions/gen/file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__.
101 """ 101 """
102 return (('%s__' % file_path).upper() 102 return (('%s__' % file_path).upper()
103 .replace('\\', '_') 103 .replace('\\', '_')
104 .replace('/', '_') 104 .replace('/', '_')
105 .replace('.', '_')) 105 .replace('.', '_'))
106 106
107 107
108 def PadForGenerics(var):
109 """Appends a space to |var| if it ends with a >, so that it can be compiled
110 within generic types.
111 """
112 return ('%s ' % var) if var.endswith('>') else var
113
114
115
116 def OpenNamespace(cpp_namespace): 108 def OpenNamespace(cpp_namespace):
117 """Get opening root namespace declarations. 109 """Get opening root namespace declarations.
118 """ 110 """
119 c = Code() 111 c = Code()
120 for component in cpp_namespace.split('::'): 112 for component in cpp_namespace.split('::'):
121 c.Append('namespace %s {' % component) 113 c.Append('namespace %s {' % component)
122 return c 114 return c
123 115
124 116
125 def CloseNamespace(cpp_namespace): 117 def CloseNamespace(cpp_namespace):
(...skipping 26 matching lines...) Expand all
152 has been passed as a flag to compiler.py from GYP/GN. 144 has been passed as a flag to compiler.py from GYP/GN.
153 ''' 145 '''
154 # For some reason Windows builds escape the % characters, so unescape them. 146 # For some reason Windows builds escape the % characters, so unescape them.
155 # This means that %% can never appear legitimately within a pattern, but 147 # This means that %% can never appear legitimately within a pattern, but
156 # that's ok. It should never happen. 148 # that's ok. It should never happen.
157 cpp_namespace = pattern.replace('%%', '%') % { 'namespace': namespace } 149 cpp_namespace = pattern.replace('%%', '%') % { 'namespace': namespace }
158 assert '%' not in cpp_namespace, \ 150 assert '%' not in cpp_namespace, \
159 ('Did not manage to fully substitute namespace "%s" into pattern "%s"' 151 ('Did not manage to fully substitute namespace "%s" into pattern "%s"'
160 % (namespace, pattern)) 152 % (namespace, pattern))
161 return cpp_namespace 153 return cpp_namespace
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator.py ('k') | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698