4 # Produce a dump of name->constant of the poolitem values, to make interpreting things in the debugger easier
10 macroNameToValue
= dict()
11 macroNameToOriginalLine
= dict()
14 def extractMacroValue(macroValue
):
15 if isinstance(macroValue
, int):
17 elif macroValue
.isdigit():
18 return int(macroValue
)
19 elif macroValue
[0:2] == "0x":
20 return int(macroValue
, 16)
21 elif macroValue
.find("+") != -1:
22 tokens
= macroValue
.split("+")
23 tokens1
= tokens
[0].strip()
24 tokens2
= tokens
[1].strip()
25 return extractMacroValue(tokens1
) + extractMacroValue(tokens2
)
26 elif macroValue
.find("-") != -1:
27 tokens
= macroValue
.split("-")
28 tokens1
= tokens
[0].strip()
29 tokens2
= tokens
[1].strip()
30 return extractMacroValue(tokens1
) - extractMacroValue(tokens2
)
31 rv
= extractMacroValue(macroNameToValue
[macroValue
])
32 macroNameToValue
[macroValue
] = rv
36 a
= subprocess
.Popen("cpp -E -dD -Iinclude/ include/editeng/eeitem.hxx", stdout
=subprocess
.PIPE
, shell
=True)
42 if not line
.startswith("#define "): continue
43 # strip the '#define' off the front
45 line
= line
[idx1
: len(line
)].strip()
48 if (idx1
== -1): continue
49 macroName
= line
[0 : idx1
].strip()
50 line
= line
[idx1
: len(line
)].strip()
51 # ignore internal stuff
52 if macroName
.startswith("_"): continue
53 # strip any trailing comments
54 idx1
= line
.find("//")
56 line
= line
[0 : idx1
].strip()
57 idx1
= line
.find("/*")
59 line
= line
[0 : idx1
].strip()
60 if len(line
) == 0: continue
62 if line
[0] == "(": line
= line
[1:]
63 if line
[len(line
)-1] == ")": line
= line
[0:len(line
)-1]
64 macroValue
= line
.strip()
65 # ignore macros that #define strings, not interested in those
66 if (macroValue
.find("\"") != -1): continue
67 # ignore the multiline macros
68 if (macroValue
.find("\\") != -1): continue
69 # check for redefinitions
70 if macroNameToValue
.has_key(macroName
):
71 print "Redefinition:\n\t", macroNameToOriginalLine
[macroName
], "\n\t" , originalLine
73 macroNameToValue
[macroName
] = macroValue
74 macroNameToOriginalLine
[macroName
] = originalLine
76 # decode the constants into their numeric values recursively
77 macroValueToName
= dict()
78 for macroName
in macroNameToValue
:
79 macroValue
= macroNameToValue
[macroName
]
81 macroValue
= extractMacroValue(macroName
)
82 macroValueToName
[macroValue
] = macroName
84 print "warning: could not decode macro ", macroName
86 for macroValue
in sorted(macroValueToName
):
87 macroName
= macroValueToName
[macroValue
]
88 print repr(macroNameToValue
[macroName
]).rjust(5), " ", macroName