s = s.rstrip() + ' # <<<<<<<<<<<<<< ' + '\n'
context += " * " + s
- marker = '"%s":%d\n%s' % (str(source_desc).encode('ASCII', 'replace'), line, context)
+ marker = '"%s":%d\n%s' % (source_desc.get_description().encode('ASCII', 'replace'), line, context)
if self.last_marker != marker:
self.marker = marker
self.position = position
self.message = message
if position:
- pos_str = "%s:%d:%d: " % position
+ pos_str = "%s:%d:%d: " % (position[0].get_description(), position[1], position[2])
cont = context(position)
else:
pos_str = ""
code.putln("static char *%s[] = {" % Naming.filenames_cname)
if code.filename_list:
for source_desc in code.filename_list:
- filename = os.path.basename(str(source_desc))
+ filename = os.path.basename(source_desc.get_filenametable_entry())
escaped_filename = filename.replace("\\", "\\\\").replace('"', r'\"')
code.putln('"%s",' %
escaped_filename)
#------------------------------------------------------------------
class SourceDescriptor:
- pass
+ def __str__(self):
+ assert False # To catch all places where a descriptor is used directly as a filename
class FileSourceDescriptor(SourceDescriptor):
"""
else:
return open(self.filename)
- def __str__(self):
+ def get_description(self):
+ return self.filename
+
+ def get_filenametable_entry(self):
return self.filename
def __repr__(self):
def get_lines(self, decode=False):
return self.codelines
- def __str__(self):
+ def get_description(self):
return self.name
+ def get_filenametable_entry(self):
+ return "stringsource"
+
def __repr__(self):
return "<StringSourceDescriptor:%s>" % self