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