1.1 --- a/micropython/table.py Sat Aug 23 22:32:17 2008 +0200
1.2 +++ b/micropython/table.py Sun Aug 24 03:06:00 2008 +0200
1.3 @@ -143,27 +143,51 @@
1.4 if entry is None:
1.5 result.append(None)
1.6 else:
1.7 - offset, attr = entry
1.8 - if attr.parent is not None:
1.9 - location = attr.parent.location or 0
1.10 - else:
1.11 - location = 0
1.12 - if attr.position is not None:
1.13 - position = attr.position + location + 1 # skip structure header
1.14 - else:
1.15 - position = None # NOTE: Should fix unpositioned attributes.
1.16 -
1.17 - # Class offset/code, attribute type, context instance override flag, location/position.
1.18 -
1.19 - result.append((offset, attr.is_class_attribute(), attr.defined_within_hierarchy(), position))
1.20 + result.append(self.entry_as_raw(entry))
1.21
1.22 return result
1.23
1.24 +class ObjectList(List):
1.25 +
1.26 + "An object list."
1.27 +
1.28 + def entry_as_raw(self, entry):
1.29 + offset, attr = entry
1.30 +
1.31 + if attr.parent is not None:
1.32 + location = attr.parent.location or 0
1.33 + else:
1.34 + location = 0
1.35 + if attr.position is not None:
1.36 + position = attr.position + location + 1 # skip structure header
1.37 + else:
1.38 + position = None # NOTE: Should fix unpositioned attributes.
1.39 +
1.40 + # Class offset/code, attribute type, context instance override flag, location/position.
1.41 +
1.42 + return (offset, attr.is_class_attribute(), attr.defined_within_hierarchy(), position)
1.43 +
1.44 +class ClassList(List):
1.45 +
1.46 + "A class list."
1.47 +
1.48 + def entry_as_raw(self, entry):
1.49 + offset, attr = entry
1.50 + return offset
1.51 +
1.52 +class ParameterList(List):
1.53 +
1.54 + "A parameter list."
1.55 +
1.56 + def entry_as_raw(self, entry):
1.57 + return entry
1.58 +
1.59 class Table:
1.60
1.61 "A lookup table."
1.62
1.63 TableError = TableError
1.64 + list_class = None # overridden
1.65
1.66 def __init__(self):
1.67 self.attributes = set()
1.68 @@ -275,7 +299,7 @@
1.69 """
1.70
1.71 if self.displaced_list is None:
1.72 - self.displaced_list = List(self.attribute_names())
1.73 + self.displaced_list = self.list_class(self.attribute_names())
1.74
1.75 # Visit each row of the matrix.
1.76
1.77 @@ -284,4 +308,22 @@
1.78
1.79 return self.displaced_list
1.80
1.81 +class ObjectTable(Table):
1.82 +
1.83 + "An object table."
1.84 +
1.85 + list_class = ObjectList
1.86 +
1.87 +class ClassTable(Table):
1.88 +
1.89 + "A class table."
1.90 +
1.91 + list_class = ClassList
1.92 +
1.93 +class ParameterTable(Table):
1.94 +
1.95 + "A parameter table."
1.96 +
1.97 + list_class = ParameterList
1.98 +
1.99 # vim: tabstop=4 expandtab shiftwidth=4