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

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

Issue 23594008: Initial code generation for features. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merged from Master. 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/code.py ('k') | tools/json_schema_compiler/features_cc_generator.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 """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
11 import os 11 import os
12 import re 12 import re
13 13
14 CHROMIUM_LICENSE = ( 14 CHROMIUM_LICENSE = (
15 """// Copyright (c) %d The Chromium Authors. All rights reserved. 15 """// Copyright (c) %d The Chromium Authors. All rights reserved.
16 // Use of this source code is governed by a BSD-style license that can be 16 // Use of this source code is governed by a BSD-style license that can be
17 // found in the LICENSE file.""" % datetime.now().year 17 // found in the LICENSE file.""" % datetime.now().year
18 ) 18 )
19 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN 19 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN
20 // %s 20 // %s
21 // DO NOT EDIT. 21 // DO NOT EDIT.
22 """ 22 """
23 GENERATED_BUNDLE_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITIONS IN 23 GENERATED_BUNDLE_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITIONS IN
24 // %s 24 // %s
25 // DO NOT EDIT. 25 // DO NOT EDIT.
26 """ 26 """
27 GENERATED_FEATURE_MESSAGE = """// GENERATED FROM THE FEATURE DEFINITIONS IN
28 // %s
29 // DO NOT EDIT.
30 """
27 31
28 def Classname(s): 32 def Classname(s):
29 """Translates a namespace name or function name into something more 33 """Translates a namespace name or function name into something more
30 suited to C++. 34 suited to C++.
31 35
32 eg experimental.downloads -> Experimental_Downloads 36 eg experimental.downloads -> Experimental_Downloads
33 updateAll -> UpdateAll. 37 updateAll -> UpdateAll.
34 """ 38 """
35 return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)]) 39 return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)])
36 40
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return c 115 return c
112 116
113 117
114 def CloseNamespace(namespace): 118 def CloseNamespace(namespace):
115 """Get closing root namespace declarations. 119 """Get closing root namespace declarations.
116 """ 120 """
117 c = Code() 121 c = Code()
118 for component in reversed(namespace.split('::')): 122 for component in reversed(namespace.split('::')):
119 c.Append('} // namespace %s' % component) 123 c.Append('} // namespace %s' % component)
120 return c 124 return c
125
126
127 def ConstantName(feature_name):
128 """Returns a kName for a feature's name.
129 """
130 return ('k' + ''.join(word[0].upper() + word[1:]
131 for word in feature_name.replace('.', ' ').split()))
132
133
134 def CamelCase(unix_name):
135 return ''.join(word.capitalize() for word in unix_name.split('_'))
136
137
138 def ClassName(filepath):
139 return CamelCase(os.path.split(filepath)[1])
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/code.py ('k') | tools/json_schema_compiler/features_cc_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698