-rwxr-xr-x | libopie2/tools/regen.py | 52 |
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 | |||
@@ -19,46 +19,76 @@ except: | |||
19 | tablecfile = sys.stdout | 19 | tablecfile = sys.stdout |
20 | 20 | ||
21 | print >>tablehfile,""" | 21 | print >>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 | ||
32 | typedef QIntDict<QString> IntStringMap; | 32 | typedef QIntDict<QString> IntStringMap; |
33 | 33 | ||
34 | IntStringMap* constructIoctlMap(); | 34 | class 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 | ||
39 | print >>tablecfile,""" | 48 | print >>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 | ||
46 | IntStringMap* constructIoctlMap() | 55 | DebugMapper::DebugMapper() |
47 | { | 56 | { |
48 | \tIntStringMap* map = new IntStringMap(); | 57 | qDebug( "DebugMapper::DebugMapper()" ); |
49 | 58 | ||
50 | """ % (tablehfile.name) | 59 | """ % (tablehfile.name) |
51 | 60 | ||
52 | for line in result: | 61 | for 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 | ||
61 | print >>tablecfile,""" | 69 | print >>tablecfile,""" |
62 | \treturn map; | ||
63 | }; | 70 | }; |
64 | """ \ No newline at end of file | 71 | |
72 | |||
73 | DebugMapper::~DebugMapper() | ||
74 | { | ||
75 | qDebug( "DebugMapper::~DebugMapper()" ); | ||
76 | } | ||
77 | |||
78 | |||
79 | const 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 | """ | ||