1.1 --- a/classfile.py Fri Nov 19 15:43:43 2004 +0100
1.2 +++ b/classfile.py Fri Nov 19 15:45:02 2004 +0100
1.3 @@ -15,6 +15,9 @@
1.4 def u2(data):
1.5 return struct.unpack(">H", data[0:2])[0]
1.6
1.7 +def s2(data):
1.8 + return struct.unpack(">h", data[0:2])[0]
1.9 +
1.10 def u4(data):
1.11 return struct.unpack(">L", data[0:4])[0]
1.12
1.13 @@ -223,12 +226,24 @@
1.14 def __unicode__(self):
1.15 return unicode(self.bytes, "utf-8")
1.16
1.17 + def get_value(self):
1.18 + return str(self)
1.19 +
1.20 class StringInfo:
1.21 def init(self, data, class_file):
1.22 self.class_file = class_file
1.23 self.string_index = u2(data[0:2])
1.24 return data[2:]
1.25
1.26 + def __str__(self):
1.27 + return str(self.class_file.constants[self.string_index - 1])
1.28 +
1.29 + def __unicode__(self):
1.30 + return unicode(self.class_file.constants[self.string_index - 1])
1.31 +
1.32 + def get_value(self):
1.33 + return str(self)
1.34 +
1.35 class SmallNumInfo:
1.36 def init(self, data, class_file):
1.37 self.class_file = class_file
1.38 @@ -246,8 +261,8 @@
1.39 class LargeNumInfo:
1.40 def init(self, data, class_file):
1.41 self.class_file = class_file
1.42 - self.high_bytes = u4(data[0:4])
1.43 - self.low_bytes = u4(data[4:8])
1.44 + self.high_bytes = data[0:4]
1.45 + self.low_bytes = data[4:8]
1.46 return data[8:]
1.47
1.48 class LongInfo(LargeNumInfo):
1.49 @@ -292,6 +307,7 @@
1.50 self.attribute_length = u4(data[0:4])
1.51 # Permit the NameUtils mix-in.
1.52 self.name_index = self.sourcefile_index = u2(data[4:6])
1.53 + return data[6:]
1.54
1.55 class ConstantValueAttributeInfo(AttributeInfo):
1.56 def init(self, data, class_file):