1.1 --- a/micropython/table.py Wed Aug 27 00:45:14 2008 +0200
1.2 +++ b/micropython/table.py Mon Sep 01 01:32:32 2008 +0200
1.3 @@ -46,6 +46,12 @@
1.4 def __getitem__(self, i):
1.5 return self.displaced[i]
1.6
1.7 + def get_code(self, name):
1.8 +
1.9 + "Return the code/offset of the given 'name'."
1.10 +
1.11 + return self.offsets.get(name)
1.12 +
1.13 # Simulation methods.
1.14
1.15 def access(self, objname, attrname):
1.16 @@ -222,15 +228,6 @@
1.17 self.names = self.names or list(self.attributes)
1.18 return self.names
1.19
1.20 - def get_code(self, name):
1.21 -
1.22 - "Return the code of the given 'name'."
1.23 -
1.24 - try:
1.25 - return self.object_names().index(name)
1.26 - except ValueError:
1.27 - raise TableError, "Name %r is not registered as an object in the table." % name
1.28 -
1.29 def get_index(self, name):
1.30
1.31 "Return the index of the given 'name'."
1.32 @@ -320,6 +317,12 @@
1.33
1.34 return self.displaced_list
1.35
1.36 + def as_raw(self):
1.37 +
1.38 + "Return the raw contents of the table as a list of values."
1.39 +
1.40 + return self.as_list().as_raw()
1.41 +
1.42 class ObjectTable(Table):
1.43
1.44 "An object table."