OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ Generator for C style prototypes and definitions """ | 6 """ Generator for C style prototypes and definitions """ |
7 | 7 |
8 import glob | 8 import glob |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 }, | 141 }, |
142 'cstr_t': { | 142 'cstr_t': { |
143 'in': '%s', | 143 'in': '%s', |
144 'inout': '%s*', | 144 'inout': '%s*', |
145 'out': '%s*', | 145 'out': '%s*', |
146 'return': '%s', | 146 'return': '%s', |
147 'store': '%s' | 147 'store': '%s' |
148 }, | 148 }, |
149 'TypeValue': { | 149 'TypeValue': { |
150 'in': '%s', | 150 'in': '%s', |
| 151 'constptr_in': 'const %s*', # So we can use const* for PP_Var sometimes. |
151 'inout': '%s*', | 152 'inout': '%s*', |
152 'out': '%s*', | 153 'out': '%s*', |
153 'return': '%s', | 154 'return': '%s', |
154 'store': '%s' | 155 'store': '%s' |
155 }, | 156 }, |
156 } | 157 } |
157 | 158 |
158 | 159 |
159 # | 160 # |
160 # RemapName | 161 # RemapName |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 self.LogExit('GetTypeByMode %s = %s' % (node, out)) | 376 self.LogExit('GetTypeByMode %s = %s' % (node, out)) |
376 return out | 377 return out |
377 | 378 |
378 | 379 |
379 # Get the passing mode of the object (in, out, inout). | 380 # Get the passing mode of the object (in, out, inout). |
380 def GetParamMode(self, node): | 381 def GetParamMode(self, node): |
381 self.Log('GetParamMode for %s' % node) | 382 self.Log('GetParamMode for %s' % node) |
382 if node.GetProperty('in'): return 'in' | 383 if node.GetProperty('in'): return 'in' |
383 if node.GetProperty('out'): return 'out' | 384 if node.GetProperty('out'): return 'out' |
384 if node.GetProperty('inout'): return 'inout' | 385 if node.GetProperty('inout'): return 'inout' |
| 386 if node.GetProperty('constptr_in'): return 'constptr_in' |
385 return 'return' | 387 return 'return' |
386 | 388 |
387 # | 389 # |
388 # GetComponents | 390 # GetComponents |
389 # | 391 # |
390 # Returns the signature components of an object as a tuple of | 392 # Returns the signature components of an object as a tuple of |
391 # (rtype, name, arrays, callspec) where: | 393 # (rtype, name, arrays, callspec) where: |
392 # rtype - The store or return type of the object. | 394 # rtype - The store or return type of the object. |
393 # name - The name of the object. | 395 # name - The name of the object. |
394 # arrays - A list of array dimensions as [] or [<fixed_num>]. | 396 # arrays - A list of array dimensions as [] or [<fixed_num>]. |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 for f in ast.GetListOf('File'): | 810 for f in ast.GetListOf('File'): |
809 if f.GetProperty('ERRORS') > 0: | 811 if f.GetProperty('ERRORS') > 0: |
810 print 'Skipping %s' % f.GetName() | 812 print 'Skipping %s' % f.GetName() |
811 continue | 813 continue |
812 for node in f.GetChildren()[2:]: | 814 for node in f.GetChildren()[2:]: |
813 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') | 815 print cgen.Define(node, ast.releases, comment=True, prefix='tst_') |
814 | 816 |
815 | 817 |
816 if __name__ == '__main__': | 818 if __name__ == '__main__': |
817 sys.exit(main(sys.argv[1:])) | 819 sys.exit(main(sys.argv[1:])) |
OLD | NEW |