summaryrefslogtreecommitdiff
path: root/libopie2/tools
Unidiff
Diffstat (limited to 'libopie2/tools') (more/less context) (ignore whitespace changes)
-rwxr-xr-xlibopie2/tools/regen.py52
1 files changed, 41 insertions, 11 deletions
diff --git a/libopie2/tools/regen.py b/libopie2/tools/regen.py
index 2f7f418..9ad5352 100755
--- a/libopie2/tools/regen.py
+++ b/libopie2/tools/regen.py
@@ -17,48 +17,78 @@ try:
17 tablecfile = file( sys.argv[1]+".cpp", "w" ) 17 tablecfile = file( sys.argv[1]+".cpp", "w" )
18except: 18except:
19 tablecfile = sys.stdout 19 tablecfile = sys.stdout
20 20
21print >>tablehfile,""" 21print >>tablehfile,"""
22/* 22/*
23 * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 23 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
24 */ 24 */
25 25
26#ifndef IOCTLMAP_H 26#ifndef DEBUGMAPPER_H
27#define IOCTLMAP_H 27#define DEBUGMAPPER_H
28 28
29#include <qstring.h> 29#include <qstring.h>
30#include <qintdict.h> 30#include <qintdict.h>
31 31
32typedef QIntDict<QString> IntStringMap; 32typedef QIntDict<QString> IntStringMap;
33 33
34IntStringMap* constructIoctlMap(); 34class DebugMapper
35{
36 public:
37 DebugMapper();
38 ~DebugMapper();
39
40 const QString& map( int value ) const;
41 private:
42 IntStringMap _map;
43};
35 44
36#endif 45#endif
37""" 46"""
38 47
39print >>tablecfile,""" 48print >>tablecfile,"""
40/* 49/*
41 * ioctl table - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 50 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
42 */ 51 */
43 52
44#include "%s" 53#include "%s"
45 54
46IntStringMap* constructIoctlMap() 55DebugMapper::DebugMapper()
47{ 56{
48\tIntStringMap* map = new IntStringMap(); 57 qDebug( "DebugMapper::DebugMapper()" );
49 58
50""" % (tablehfile.name) 59""" % (tablehfile.name)
51 60
52for line in result: 61for line in result:
53 l = line.split() 62 l = line.split()
54 if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ): 63 if not l[0].startswith( "#define" ) or not l[2].startswith( "0x" ):
55 print >>sys.stderr, "can't parse line: %s" % l 64 print >>sys.stderr, "can't parse line: %s" % l
56 continue 65 continue
57 #print >>tablecfile, "\tqDebug( \"adding %s = %s\" );" % ( l[2], l[1] ) 66 print >>tablecfile, " _map.insert( %s, new QString(\"%s\") );" % ( l[2], l[1] )
58 print >>tablecfile, "\tmap->insert( %s, new QString(\"%s\") );" % ( l[2], l[1] )
59 67
60 68
61print >>tablecfile,""" 69print >>tablecfile,"""
62\treturn map;
63}; 70};
64""" \ No newline at end of file 71
72
73DebugMapper::~DebugMapper()
74{
75 qDebug( "DebugMapper::~DebugMapper()" );
76}
77
78
79const QString& DebugMapper::map( int value ) const
80{
81 QString* result = _map[ value ];
82
83 if ( !result )
84 {
85 qDebug( "DebugMapper::map() - value not found." );
86 return QString::null;
87 }
88 else
89 {
90 return *result;
91 }
92}
93
94"""