Commit 1301ffcd authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Simplified anonymous_object by inheriting dict.

parent fc942c4d
......@@ -468,34 +468,19 @@ TYPEDEF = typedef(None, None)
ARRAY = array(None, None)
STRUCT = struct({})
class anonymous_object(object):
def __init__(self):
self._attr = {}
class anonymous_object(dict):
def __setattr__(self, name, value):
if name.startswith("_"):
super(anonymous_object, self).__setattr__(name, value)
else:
self._attr[name] = value
self[name] = value
def __getattr__(self, name):
if name.startswith("_"):
return super(anonymous_object, self).__getattr__(name)
else:
return self._attr[name]
def __getattribute__(self, name):
if name.startswith("_"):
return super(anonymous_object, self).__getattribute__(name)
else:
return self._attr[name]
def __iter__(self):
return self._attr.iteritems()
return self[name]
def __repr__(self):
return self._attr.__repr__()
class Codec(object):
def __init__(self):
self.type_to_name = {}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment