Skip to content

Commit ad853d7

Browse files
committed
Get rid of gccxml version of __read_location method
1 parent 5f59687 commit ad853d7

File tree

1 file changed

+15
-38
lines changed

1 file changed

+15
-38
lines changed

pygccxml/parser/scanner.py

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,20 @@ def __init__(self, xml_file, decl_factory, config, *args):
158158
self.__mangled_suffix = ' *INTERNAL* '
159159
self.__mangled_suffix_len = len(self.__mangled_suffix)
160160

161-
self.__name_attrs_to_skip = []
162-
self.__read_location = \
163-
lambda decl, attrs, to_skip: self.__read_location_bootstrap(
164-
self, decl, attrs, to_skip)
161+
# These fields are generated by clang, and have no location.
162+
# Just set an empty location for them.
163+
# bug #19: gp_offset, fp_offset, overflow_arg_area, reg_save_area
164+
# bug #32: isa, flags, str and length were added in llvm 3.9
165+
self.__name_attrs_to_skip = [
166+
"gp_offset",
167+
"fp_offset",
168+
"overflow_arg_area",
169+
"reg_save_area",
170+
"isa",
171+
"flags",
172+
"str",
173+
"length",
174+
]
165175

166176
self.__xml_generator_from_xml_file = None
167177

@@ -275,41 +285,8 @@ def endElement(self, name):
275285
if name in self.deep_declarations:
276286
self.__inst = None
277287

278-
def __read_location_bootstrap(self, inst, decl, attrs, _):
279-
""" This function monkey patches the __read_location function to either
280-
__read_location_gccxml or __read_location_castxml depending on the
281-
xml generator in use
282-
"""
283-
284-
if self.__xml_generator_from_xml_file.is_castxml:
285-
# These fields are generated by clang, and have no location.
286-
# Just set an empty location for them. Gccxml does not have
287-
# this problem.
288-
# bug #19: gp_offset, fp_offset, overflow_arg_area, reg_save_area
289-
# bug #32: isa, flags, str and length were added in llvm 3.9
290-
inst.__name_attrs_to_skip = [
291-
"gp_offset",
292-
"fp_offset",
293-
"overflow_arg_area",
294-
"reg_save_area",
295-
"isa",
296-
"flags",
297-
"str",
298-
"length"
299-
]
300-
inst.__read_location = inst.__read_location_castxml
301-
else:
302-
inst.__read_location = inst.__read_location_gccxml
303-
return inst.__read_location(decl, attrs, inst.__name_attrs_to_skip)
304-
305-
@staticmethod
306-
def __read_location_gccxml(decl, attrs, _):
307-
decl.location = declarations.location_t(
308-
file_name=attrs[XML_AN_FILE],
309-
line=int(attrs[XML_AN_LINE]))
310-
311288
@staticmethod
312-
def __read_location_castxml(decl, attrs, to_skip):
289+
def __read_location(decl, attrs, to_skip):
313290
if "name" in attrs and attrs["name"] in to_skip:
314291
decl.location = declarations.location_t('', -1)
315292
else:

0 commit comments

Comments
 (0)