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

Side by Side Diff: ppapi/generators/idl_c_header.py

Issue 7753042: Update generator for Chrome generation as the default case (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « ppapi/generators/generator.py ('k') | ppapi/generators/idl_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 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """ Generator for C style prototypes and definitions """ 7 """ Generator for C style prototypes and definitions """
8 8
9 import glob 9 import glob
10 import os 10 import os
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 name = node.GetName() 107 name = node.GetName()
108 name = name.upper() 108 name = name.upper()
109 return "%s_INTERFACE" % name 109 return "%s_INTERFACE" % name
110 110
111 def GetDefine(self, name, value): 111 def GetDefine(self, name, value):
112 out = '#define %s %s' % (name, value) 112 out = '#define %s %s' % (name, value)
113 if len(out) > 80: 113 if len(out) > 80:
114 out = '#define %s \\\n %s' % (name, value) 114 out = '#define %s \\\n %s' % (name, value)
115 return '%s\n' % out 115 return '%s\n' % out
116 116
117 def GetVersionString(self, node):
118 # If an interface name is specified, use that
119 iname = node.GetProperty('iname')
120 if iname: return iname
121
122 # Otherwise, the interface name is the object's name
123 # With '_Dev' replaced by '(Dev)' if it's a Dev interface.
124 name = node.GetName()
125 if len(name) > 4 and name[-4:] == '_Dev':
126 name = '%s(Dev)' % name[:-4]
127 return name
117 128
118 def GetOutFile(self, filenode, options): 129 def GetOutFile(self, filenode, options):
119 savename = GetOutFileName(filenode, GetOption('dstroot')) 130 savename = GetOutFileName(filenode, GetOption('dstroot'))
120 return IDLOutFile(savename) 131 return IDLOutFile(savename)
121 132
122 def GenerateHead(self, out, filenode, releases, options): 133 def GenerateHead(self, out, filenode, releases, options):
123 cgen = CGen() 134 cgen = CGen()
124 gpath = GetOption('guard') 135 gpath = GetOption('guard')
125 release = releases[0] 136 release = releases[0]
126 def_guard = GetOutFileName(filenode, relpath=gpath) 137 def_guard = GetOutFileName(filenode, relpath=gpath)
(...skipping 29 matching lines...) Expand all
156 includes = sorted(set(includes)) 167 includes = sorted(set(includes))
157 cur_include = GetOutFileName(filenode, relpath=gpath) 168 cur_include = GetOutFileName(filenode, relpath=gpath)
158 for include in includes: 169 for include in includes:
159 if include == cur_include: continue 170 if include == cur_include: continue
160 out.Write('#include "%s"\n' % include) 171 out.Write('#include "%s"\n' % include)
161 172
162 # Generate all interface defines 173 # Generate all interface defines
163 out.Write('\n') 174 out.Write('\n')
164 for node in filenode.GetListOf('Interface'): 175 for node in filenode.GetListOf('Interface'):
165 idefs = '' 176 idefs = ''
166 name = node.GetName() 177 name = self.GetVersionString(node)
167 macro = node.GetProperty('macro') 178 macro = node.GetProperty('macro')
168 if not macro: 179 if not macro:
169 macro = self.GetMacro(node) 180 macro = self.GetMacro(node)
170 181
171 unique = node.GetUniqueReleases(releases) 182 unique = node.GetUniqueReleases(releases)
172 for rel in unique: 183 for rel in unique:
173 version = node.GetVersion(rel) 184 version = node.GetVersion(rel)
174 strver = str(version).replace('.', '_') 185 strver = str(version).replace('.', '_')
175 idefs += self.GetDefine('%s_%s' % (macro, strver), 186 idefs += self.GetDefine('%s_%s' % (macro, strver),
176 '"%s;%s"' % (name, version)) 187 '"%s;%s"' % (name, version))
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 failed =1 232 failed =1
222 else: 233 else:
223 print "Golden file for M13-M15 passed." 234 print "Golden file for M13-M15 passed."
224 235
225 return failed 236 return failed
226 237
227 if __name__ == '__main__': 238 if __name__ == '__main__':
228 retval = Main(sys.argv[1:]) 239 retval = Main(sys.argv[1:])
229 sys.exit(retval) 240 sys.exit(retval)
230 241
OLDNEW
« no previous file with comments | « ppapi/generators/generator.py ('k') | ppapi/generators/idl_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698