Fix NextEthernetAddr
python/m5/config.py: NextEthernetAddr shouldnt' be a Singleton since we want __init__ to be called more than once. Make the EthernetAddr class a "proxy" so that unproxy will be called and NextEthernetAddr will generally work correctly. --HG-- extra : convert_revision : c89bf268e805e202ae71030fcea4833867c7e477
This commit is contained in:
parent
1e2c16c912
commit
38da461fd7
1 changed files with 15 additions and 7 deletions
|
@ -417,6 +417,9 @@ class SimObject(object):
|
||||||
found_obj = match_obj
|
found_obj = match_obj
|
||||||
return found_obj, found_obj != None
|
return found_obj, found_obj != None
|
||||||
|
|
||||||
|
def unproxy(self, base):
|
||||||
|
return self
|
||||||
|
|
||||||
def print_ini(self):
|
def print_ini(self):
|
||||||
print '[' + self.path() + ']' # .ini section header
|
print '[' + self.path() + ']' # .ini section header
|
||||||
|
|
||||||
|
@ -632,7 +635,7 @@ class AnyProxy(BaseProxy):
|
||||||
return 'any'
|
return 'any'
|
||||||
|
|
||||||
def isproxy(obj):
|
def isproxy(obj):
|
||||||
if isinstance(obj, BaseProxy):
|
if isinstance(obj, (BaseProxy, EthernetAddr)):
|
||||||
return True
|
return True
|
||||||
elif isinstance(obj, (list, tuple)):
|
elif isinstance(obj, (list, tuple)):
|
||||||
for v in obj:
|
for v in obj:
|
||||||
|
@ -980,12 +983,11 @@ def IncEthernetAddr(addr, val = 1):
|
||||||
return ':'.join(map(lambda x: '%02x' % x, bytes))
|
return ':'.join(map(lambda x: '%02x' % x, bytes))
|
||||||
|
|
||||||
class NextEthernetAddr(object):
|
class NextEthernetAddr(object):
|
||||||
__metaclass__ = Singleton
|
|
||||||
addr = "00:90:00:00:00:01"
|
addr = "00:90:00:00:00:01"
|
||||||
|
|
||||||
def __init__(self, inc = 1):
|
def __init__(self, inc = 1):
|
||||||
self.value = self.addr
|
self.value = NextEthernetAddr.addr
|
||||||
self.addr = IncEthernetAddr(self.addr, inc)
|
NextEthernetAddr.addr = IncEthernetAddr(NextEthernetAddr.addr, inc)
|
||||||
|
|
||||||
class EthernetAddr(ParamValue):
|
class EthernetAddr(ParamValue):
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
|
@ -1006,9 +1008,15 @@ class EthernetAddr(ParamValue):
|
||||||
|
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
def unproxy(self, base):
|
||||||
|
if self.value == NextEthernetAddr:
|
||||||
|
self.addr = self.value().value
|
||||||
|
return self
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.value == NextEthernetAddr:
|
if self.value == NextEthernetAddr:
|
||||||
self.value = self.value().value
|
return self.addr
|
||||||
|
else:
|
||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
# Special class for NULL pointers. Note the special check in
|
# Special class for NULL pointers. Note the special check in
|
||||||
|
|
Loading…
Reference in a new issue