| OLD | NEW |
| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 'handle_t': 'int', | 98 'handle_t': 'int', |
| 99 'mem_t': 'void*', | 99 'mem_t': 'void*', |
| 100 'str_t': 'char*', | 100 'str_t': 'char*', |
| 101 'interface_t' : 'const void*' | 101 'interface_t' : 'const void*' |
| 102 } | 102 } |
| 103 | 103 |
| 104 def __init__(self): | 104 def __init__(self): |
| 105 self.dbg_depth = 0 | 105 self.dbg_depth = 0 |
| 106 self.vmin = 0.0 | 106 self.vmin = 0.0 |
| 107 self.vmax = 1e100 | 107 self.vmax = 1e100 |
| 108 self.release = 'M14' | 108 self.release = GetOption('release') |
| 109 | 109 |
| 110 def SetVersionMap(self, node): | 110 def SetVersionMap(self, node): |
| 111 self.vmin = 0.0 | 111 self.vmin = 0.0 |
| 112 self.vmax = 1e100 | 112 self.vmax = 1e100 |
| 113 for version in node.GetListOf('LabelItem'): | 113 for version in node.GetListOf('LabelItem'): |
| 114 if version.GetName() == GetOption('version'): | 114 if version.GetName() == GetOption('release'): |
| 115 self.vmin = float(version.GetProperty('VALUE')) | 115 self.vmin = float(version.GetProperty('VALUE')) |
| 116 self.vmax = float(version.GetProperty('VALUE')) | 116 self.vmax = float(version.GetProperty('VALUE')) |
| 117 | 117 |
| 118 # | 118 # |
| 119 # Debug Logging functions | 119 # Debug Logging functions |
| 120 # | 120 # |
| 121 def Log(self, txt): | 121 def Log(self, txt): |
| 122 if not GetOption('cgen_debug'): return | 122 if not GetOption('cgen_debug'): return |
| 123 tabs = '' | 123 tabs = '' |
| 124 for tab in range(self.dbg_depth): tabs += ' ' | 124 for tab in range(self.dbg_depth): tabs += ' ' |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 # out = '' | 378 # out = '' |
| 379 # if comment: | 379 # if comment: |
| 380 # for doc in node.GetListOf('Comment'): | 380 # for doc in node.GetListOf('Comment'): |
| 381 # out += self.Comment(doc) | 381 # out += self.Comment(doc) |
| 382 out = '%s;' % self.GetSignature(node, 'store', '', True) | 382 out = '%s;' % self.GetSignature(node, 'store', '', True) |
| 383 self.LogExit('Exit DefineMember') | 383 self.LogExit('Exit DefineMember') |
| 384 return out | 384 return out |
| 385 | 385 |
| 386 def InterfaceDefs(self, node): | 386 def InterfaceDefs(self, node): |
| 387 out = '' | 387 out = '' |
| 388 release = 'M14' | |
| 389 name = node.GetName() | 388 name = node.GetName() |
| 390 macro = node.GetProperty('macro') | 389 macro = node.GetProperty('macro') |
| 391 if not macro: | 390 if not macro: |
| 392 macro = self.GetMacro(node) | 391 macro = self.GetMacro(node) |
| 393 label = node.GetLabel() | 392 label = node.GetLabel() |
| 394 if label: | 393 if label: |
| 395 for vers in label.versions: | 394 for vers in label.versions: |
| 396 strver = str(vers).replace('.', '_') | 395 strver = str(vers).replace('.', '_') |
| 397 out += self.GetDefine('%s_%s' % (macro, strver), | 396 out += self.GetDefine('%s_%s' % (macro, strver), |
| 398 '"%s;%s"' % (name, vers)) | 397 '"%s;%s"' % (name, vers)) |
| 399 if label.GetRelease(vers) == release: | 398 if label.GetRelease(vers) == self.release: |
| 400 out += self.GetDefine(macro, '%s_%s' % (macro, strver)) | 399 out += self.GetDefine(macro, '%s_%s' % (macro, strver)) |
| 401 out += '\n' | 400 out += '\n' |
| 402 return out | 401 return out |
| 403 | 402 |
| 404 # Define a Struct. | 403 # Define a Struct. |
| 405 def DefineStruct(self, node, prefix='', comment=False): | 404 def DefineStruct(self, node, prefix='', comment=False): |
| 406 out = '' | 405 out = '' |
| 407 | 406 |
| 408 self.LogEnter('DefineStruct %s' % node) | 407 self.LogEnter('DefineStruct %s' % node) |
| 409 if node.GetProperty('union'): | 408 if node.GetProperty('union'): |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 else: | 470 else: |
| 472 node_nim = 0.0 | 471 node_nim = 0.0 |
| 473 | 472 |
| 474 if node_max is not None: | 473 if node_max is not None: |
| 475 node_max = float(node_max) | 474 node_max = float(node_max) |
| 476 else: | 475 else: |
| 477 node_max = 1.0e100 | 476 node_max = 1.0e100 |
| 478 | 477 |
| 479 label = node.GetLabel() | 478 label = node.GetLabel() |
| 480 if label: | 479 if label: |
| 481 lver = label.GetVersion('M14') | 480 lver = label.GetVersion(self.release) |
| 482 | 481 |
| 483 # Verify that we are in a valid version. | 482 # Verify that we are in a valid version. |
| 484 if node_max <= lver: return '' | 483 if node_max <= lver: return '' |
| 485 if node_nim > lver: return '' | 484 if node_nim > lver: return '' |
| 486 | 485 |
| 487 declmap = { | 486 declmap = { |
| 488 'Describe' : CGen.DefineType, | 487 'Describe' : CGen.DefineType, |
| 489 'Enum' : CGen.DefineEnum, | 488 'Enum' : CGen.DefineEnum, |
| 490 'Function' : CGen.DefineMember, | 489 'Function' : CGen.DefineMember, |
| 491 'Interface' : CGen.DefineStruct, | 490 'Interface' : CGen.DefineStruct, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 print 'Skipping %s' % f.GetName() | 615 print 'Skipping %s' % f.GetName() |
| 617 continue | 616 continue |
| 618 print DefineDepends(node) | 617 print DefineDepends(node) |
| 619 for node in f.GetChildren()[2:]: | 618 for node in f.GetChildren()[2:]: |
| 620 print Define(node, comment=True, prefix='tst_') | 619 print Define(node, comment=True, prefix='tst_') |
| 621 | 620 |
| 622 | 621 |
| 623 if __name__ == '__main__': | 622 if __name__ == '__main__': |
| 624 sys.exit(Main(sys.argv[1:])) | 623 sys.exit(Main(sys.argv[1:])) |
| 625 | 624 |
| OLD | NEW |