diff options
author | Steve Reinhardt <stever@eecs.umich.edu> | 2006-09-04 17:14:07 -0700 |
---|---|---|
committer | Steve Reinhardt <stever@eecs.umich.edu> | 2006-09-04 17:14:07 -0700 |
commit | c39aea440c884f0abb29ecc2293fd6df608bc00c (patch) | |
tree | 21642bd3db3f2e10989cb6c5cf34892b9efe6267 /src/python/m5/SimObject.py | |
parent | 1233dbb9981ad27abeb22f9dcba20bd77abab041 (diff) | |
download | gem5-c39aea440c884f0abb29ecc2293fd6df608bc00c.tar.xz |
More Python hacking to deal with config.py split
and resulting recursive import trickiness.
--HG--
extra : convert_revision : 1ea93861eb8d260c9f3920dda0b8106db3e03705
Diffstat (limited to 'src/python/m5/SimObject.py')
-rw-r--r-- | src/python/m5/SimObject.py | 87 |
1 files changed, 37 insertions, 50 deletions
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 33fa51665..b8b931d81 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -29,11 +29,40 @@ import sys, types -import m5 -from m5 import panic, cc_main -from convert import * +from util import * from multidict import multidict +# These utility functions have to come first because they're +# referenced in params.py... otherwise they won't be defined when we +# import params below, and the recursive import of this file from +# params.py will not find these names. +def isSimObject(value): + return isinstance(value, SimObject) + +def isSimObjectClass(value): + return issubclass(value, SimObject) + +def isSimObjectSequence(value): + if not isinstance(value, (list, tuple)) or len(value) == 0: + return False + + for val in value: + if not isNullPointer(val) and not isSimObject(val): + return False + + return True + +def isSimObjectOrSequence(value): + return isSimObject(value) or isSimObjectSequence(value) + +# Have to import params up top since Param is referenced on initial +# load (when SimObject class references Param to create a class +# variable, the 'name' param)... +from params import * +# There are a few things we need that aren't in params.__all__ since +# normal users don't need them +from params import ParamDesc, isNullPointer, SimObjVector + noDot = False try: import pydot @@ -564,7 +593,7 @@ class SimObject(object): for param in param_names: value = self._values.get(param, None) if value != None: - if isproxy(value): + if proxy.isproxy(value): try: value = value.unproxy(self) except: @@ -679,52 +708,6 @@ class SimObject(object): class ParamContext(SimObject): pass -# Special class for NULL pointers. Note the special check in -# make_param_value() above that lets these be assigned where a -# SimObject is required. -# only one copy of a particular node -class NullSimObject(object): - __metaclass__ = Singleton - - def __call__(cls): - return cls - - def _instantiate(self, parent = None, path = ''): - pass - - def ini_str(self): - return 'Null' - - def unproxy(self, base): - return self - - def set_path(self, parent, name): - pass - def __str__(self): - return 'Null' - -# The only instance you'll ever need... -Null = NULL = NullSimObject() - -def isSimObject(value): - return isinstance(value, SimObject) - -def isNullPointer(value): - return isinstance(value, NullSimObject) - -def isSimObjectSequence(value): - if not isinstance(value, (list, tuple)) or len(value) == 0: - return False - - for val in value: - if not isNullPointer(val) and not isSimObject(val): - return False - - return True - -def isSimObjectOrSequence(value): - return isSimObject(value) or isSimObjectSequence(value) - # Function to provide to C++ so it can look up instances based on paths def resolveSimObject(name): obj = instanceDict[name] @@ -735,3 +718,7 @@ def resolveSimObject(name): # short to avoid polluting other namespaces. __all__ = ['SimObject', 'ParamContext'] + +# see comment on imports at end of __init__.py. +import proxy +import cc_main |