Deleted Added
sdiff udiff text old ( 2711:2cbc3999ec58 ) new ( 2712:aa0891b4a110 )
full compact
1# Copyright (c) 2004-2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 197 unchanged lines hidden (view full) ---

206 def __init__(cls, name, bases, dict):
207 # calls type.__init__()... I think that's a no-op, but leave
208 # it here just in case it's not.
209 super(MetaSimObject, cls).__init__(name, bases, dict)
210
211 # initialize required attributes
212 cls._params = multidict()
213 cls._values = multidict()
214 cls._anon_subclass_counter = 0
215
216 # We don't support multiple inheritance. If you want to, you
217 # must fix multidict to deal with it properly.
218 if len(bases) > 1:
219 raise TypeError, "SimObjects do not support multiple inheritance"
220
221 base = bases[0]
222
223 # the only time the following is not true is when we define
224 # the SimObject class itself
225 if isinstance(base, MetaSimObject):
226 cls._params.parent = base._params
227 cls._values.parent = base._values
228
229 # now process the _init_dict items
230 for key,val in cls._init_dict.items():
231 if isinstance(val, (types.FunctionType, types.TypeType)):
232 type.__setattr__(cls, key, val)
233
234 # param descriptions
235 elif isinstance(val, ParamDesc):

--- 58 unchanged lines hidden (view full) ---

294 if cls.keywords.has_key(attr):
295 cls._set_keyword(attr, value, cls.keywords[attr])
296 return
297
298 # must be SimObject param
299 param = cls._params.get(attr, None)
300 if param:
301 # It's ok: set attribute by delegating to 'object' class.
302 try:
303 cls._values[attr] = param.convert(value)
304 except Exception, e:
305 msg = "%s\nError setting param %s.%s to %s\n" % \
306 (e, cls.__name__, attr, value)
307 e.args = (msg, )
308 raise
309 # I would love to get rid of this

--- 71 unchanged lines hidden (view full) ---

381 # no pre-existing object, so remember this one here
382 _memo[self.__class__] = self
383 else:
384 # This is a new top-level instantiation... don't memoize
385 # this objcet, but prepare to memoize any recursively
386 # instantiated objects.
387 _memo = {}
388
389 self._children = {}
390 # Inherit parameter values from class using multidict so
391 # individual value settings can be overridden.
392 self._values = multidict(self.__class__._values)
393 # For SimObject-valued parameters, the class should have
394 # classes (not instances) for the values. We need to
395 # instantiate these classes rather than just inheriting the
396 # class object.

--- 1019 unchanged lines hidden ---