Debian Codegraph @

utils/qmidb/qmidb.py

raw
1 #!/usr/bin/env python
2 # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 #
4 # This program is free software; you can redistribute it and/or modify it under
5 # the terms of the GNU General Public License as published by the Free Software
6 # Foundation, version 2.
7 #
8 # This program is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 # details.
12 #
13 # You should have received a copy of the GNU General Public License along with
14 # this program; if not, write to the Free Software Foundation, Inc., 51
15 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 #
17 # Copyright (C) 2011 - 2012 Red Hat, Inc.
18 #
19
20 import sys
21 import Entities
22 import Enums
23 import Fields
24 import Structs
25
26 if len(sys.argv) > 2:
27 print "Usage: qmidb.py <path to Entity.txt>"
28 sys.exit(1)
29 path = ""
30 if len(sys.argv) == 2:
31 path = sys.argv[1] + "/"
32
33 enums = Enums.Enums(path)
34 entities = Entities.Entities(path)
35 fields = Fields.Fields(path)
36 structs = Structs.Structs(path)
37
38 structs.validate(fields)
39 entities.validate(structs)
40
41 print '/* GENERATED CODE. DO NOT EDIT. */'
42 print '\ntypedef uint8 bool;\n'
43 enums.emit()
44
45 print '\n\n'
46
47 structs_used = entities.emit(fields, structs, enums)
48
49 # emit structs that weren't associated with an entity
50 structs.emit_unused(structs_used, fields, enums)
51