1.1 --- a/micropython/basicdata.py Mon Oct 22 00:11:06 2012 +0200
1.2 +++ b/micropython/basicdata.py Sun Oct 28 18:01:30 2012 +0100
1.3 @@ -39,10 +39,29 @@
1.4 else:
1.5 return self.parent.full_name()
1.6
1.7 +class Namespace:
1.8 +
1.9 + "A mix-in providing basic namespace functionality."
1.10 +
1.11 + def get_static_attribute(self, name):
1.12 +
1.13 + """
1.14 + Return a static attribute for the given 'name' or None if no such
1.15 + attribute exists.
1.16 + """
1.17 +
1.18 + return None
1.19 +
1.20 +class Constant:
1.21 +
1.22 + "A superclass for all constant or context-free structures."
1.23 +
1.24 + pass
1.25 +
1.26 # Instances are special in that they need to be wrapped together with context in
1.27 # a running program, but they are not generally constant.
1.28
1.29 -class Instance:
1.30 +class Instance(Namespace):
1.31
1.32 "A placeholder indicating the involvement of an instance."
1.33
1.34 @@ -74,12 +93,6 @@
1.35 def make_instance():
1.36 return common_instance
1.37
1.38 -class Constant:
1.39 -
1.40 - "A superclass for all constant or context-free structures."
1.41 -
1.42 - pass
1.43 -
1.44 # Data objects appearing in programs before run-time.
1.45
1.46 class Const(Constant, Instance):
2.1 --- a/micropython/data.py Mon Oct 22 00:11:06 2012 +0200
2.2 +++ b/micropython/data.py Sun Oct 28 18:01:30 2012 +0100
2.3 @@ -65,7 +65,7 @@
2.4 except NameError:
2.5 from sets import Set as set
2.6
2.7 -class NamespaceDict:
2.8 +class NamespaceDict(Namespace):
2.9
2.10 "A mix-in providing dictionary methods."
2.11
2.12 @@ -1656,6 +1656,15 @@
2.13 self.allattr[name] = attr
2.14 return self.allattr
2.15
2.16 + def get_static_attribute(self, name):
2.17 +
2.18 + """
2.19 + Return a static attribute for the given 'name' or None if no such
2.20 + attribute exists.
2.21 + """
2.22 +
2.23 + return self.all_class_attributes().get(name)
2.24 +
2.25 class TypeClass(Class):
2.26
2.27 "A special class for the type class."
2.28 @@ -2080,6 +2089,15 @@
2.29
2.30 return dict(self)
2.31
2.32 + def get_static_attribute(self, name):
2.33 +
2.34 + """
2.35 + Return a static attribute for the given 'name' or None if no such
2.36 + attribute exists.
2.37 + """
2.38 +
2.39 + return self.get(name)
2.40 +
2.41 def modify_name(self, name):
2.42
2.43 """