micropython

Changeset

535:bbcb39c67201
2012-06-09 Paul Boddie raw files shortlog changelog graph Introduced a method for getting objects from the table using their full names.
micropython/__init__.py (file) micropython/table.py (file) micropython/trans.py (file)
     1.1 --- a/micropython/__init__.py	Sat Jun 09 19:53:00 2012 +0200
     1.2 +++ b/micropython/__init__.py	Sat Jun 09 23:24:18 2012 +0200
     1.3 @@ -754,7 +754,7 @@
     1.4                              # Get the parent object using the special
     1.5                              # table entry.
     1.6  
     1.7 -                            parent = objtable.access(objname, "#" + objname)
     1.8 +                            parent = objtable.get_object(objname)
     1.9  
    1.10                              # Permit assignment to known instance attributes
    1.11                              # only.
     2.1 --- a/micropython/table.py	Sat Jun 09 19:53:00 2012 +0200
     2.2 +++ b/micropython/table.py	Sat Jun 09 23:24:18 2012 +0200
     2.3 @@ -3,7 +3,7 @@
     2.4  """
     2.5  Preparation of run-time attribute lookup tables.
     2.6  
     2.7 -Copyright (C) 2007, 2008, 2009, 2010, 2011 Paul Boddie <paul@boddie.org.uk>
     2.8 +Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 Paul Boddie <paul@boddie.org.uk>
     2.9  
    2.10  This program is free software; you can redistribute it and/or modify it under
    2.11  the terms of the GNU General Public License as published by the Free Software
    2.12 @@ -450,6 +450,18 @@
    2.13              self.any_cache[names] = self._objects_plus_status(names, self.any_possible_objects)
    2.14          return self.any_cache[names]
    2.15  
    2.16 +    def get_object(self, objname):
    2.17 +
    2.18 +        """
    2.19 +        Return the object for the given 'objname' using a special entry in the
    2.20 +        table.
    2.21 +        """
    2.22 +
    2.23 +        # NOTE: This depends on a special entry in the table for class
    2.24 +        # NOTE: equivalence tests.
    2.25 +
    2.26 +        return self.access(objname, "#" + objname)
    2.27 +
    2.28  class ParameterTable(Table):
    2.29  
    2.30      "A parameter table."
     3.1 --- a/micropython/trans.py	Sat Jun 09 19:53:00 2012 +0200
     3.2 +++ b/micropython/trans.py	Sat Jun 09 23:24:18 2012 +0200
     3.3 @@ -49,11 +49,11 @@
     3.4                  target_name, is_static = list(targets)[0]
     3.5  
     3.6                  # Access the object table to get the attribute.
     3.7 -                # NOTE: This depends on the special entry in the table
     3.8 -                # NOTE: for class equivalence tests.
     3.9 +                # This depends on a special entry in the table for class
    3.10 +                # equivalence tests.
    3.11  
    3.12                  try:
    3.13 -                    obj = self.objtable.access(target_name, "#" + target_name)
    3.14 +                    obj = self.objtable.get_object(target_name)
    3.15  
    3.16                  # Where no attribute entry exists, the target could be a module.
    3.17                  # NOTE: Should perhaps raise an error.