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

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

Issue 12041098: Initial commit of the Dart Chrome Extension APIs generators (Closed) Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix
Patch Set: Kalman fixes 2 (nocompile ignored in bundle mode) Created 7 years, 10 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 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 datetime import datetime 9 from datetime import datetime
9 from model import Property, PropertyType, Type 10 from model import Property, PropertyType, Type
10 import os 11 import os
11 12
12 CHROMIUM_LICENSE = ( 13 CHROMIUM_LICENSE = (
13 """// Copyright (c) %d The Chromium Authors. All rights reserved. 14 """// Copyright (c) %d The Chromium Authors. All rights reserved.
14 // Use of this source code is governed by a BSD-style license that can be 15 // Use of this source code is governed by a BSD-style license that can be
15 // found in the LICENSE file.""" % datetime.now().year 16 // found in the LICENSE file.""" % datetime.now().year
16 ) 17 )
17 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN 18 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__. 85 e.g chrome/extensions/gen, file.h becomes CHROME_EXTENSIONS_GEN_FILE_H__.
85 """ 86 """
86 return (('%s_%s_H__' % (path, filename)) 87 return (('%s_%s_H__' % (path, filename))
87 .upper().replace(os.sep, '_').replace('/', '_')) 88 .upper().replace(os.sep, '_').replace('/', '_'))
88 89
89 def PadForGenerics(var): 90 def PadForGenerics(var):
90 """Appends a space to |var| if it ends with a >, so that it can be compiled 91 """Appends a space to |var| if it ends with a >, so that it can be compiled
91 within generic types. 92 within generic types.
92 """ 93 """
93 return ('%s ' % var) if var.endswith('>') else var 94 return ('%s ' % var) if var.endswith('>') else var
95
96 def OpenNamespace(namespace):
97 """Get opening root namespace declarations.
98 """
99 c = Code()
100 for component in namespace.split('::'):
101 c.Append('namespace %s {' % component)
102 return c
103
104 def CloseNamespace(namespace):
105 """Get closing root namespace declarations.
106 """
107 c = Code()
108 for component in reversed(namespace.split('::')):
109 c.Append('} // namespace %s' % component)
110 return c
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/cpp_type_generator_test.py ('k') | tools/json_schema_compiler/cpp_util_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698