params.py (4168:846a831f6c0b) | params.py (4380:1cbb5d3e4288) |
---|---|
1# Copyright (c) 2004-2006 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 --- 37 unchanged lines hidden (view full) --- 46 47import copy 48import datetime 49import inspect 50import sys 51import time 52 53import convert | 1# Copyright (c) 2004-2006 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 --- 37 unchanged lines hidden (view full) --- 46 47import copy 48import datetime 49import inspect 50import sys 51import time 52 53import convert |
54import proxy |
|
54import ticks 55from util import * 56 57# Dummy base class to identify types that are legitimate for SimObject 58# parameters. 59class ParamValue(object): 60 61 cxx_predecls = [] --- 410 unchanged lines hidden (view full) --- 472 val,rem = divmod(bytes[i], 256) 473 bytes[i] = rem 474 if val == 0: 475 break 476 bytes[i - 1] += val 477 assert(bytes[0] <= 255) 478 return ':'.join(map(lambda x: '%02x' % x, bytes)) 479 | 55import ticks 56from util import * 57 58# Dummy base class to identify types that are legitimate for SimObject 59# parameters. 60class ParamValue(object): 61 62 cxx_predecls = [] --- 410 unchanged lines hidden (view full) --- 473 val,rem = divmod(bytes[i], 256) 474 bytes[i] = rem 475 if val == 0: 476 break 477 bytes[i - 1] += val 478 assert(bytes[0] <= 255) 479 return ':'.join(map(lambda x: '%02x' % x, bytes)) 480 |
480class NextEthernetAddr(object): 481 addr = "00:90:00:00:00:01" | 481_NextEthernetAddr = "00:90:00:00:00:01" 482def NextEthernetAddr(): 483 global _NextEthernetAddr |
482 | 484 |
483 def __init__(self, inc = 1): 484 self.value = NextEthernetAddr.addr 485 NextEthernetAddr.addr = IncEthernetAddr(NextEthernetAddr.addr, inc) | 485 value = _NextEthernetAddr 486 _NextEthernetAddr = IncEthernetAddr(_NextEthernetAddr, 1) 487 return value |
486 487class EthernetAddr(ParamValue): 488 cxx_type = 'Net::EthAddr' 489 cxx_predecls = ['#include "base/inet.hh"'] 490 swig_predecls = ['class Net::EthAddr;'] 491 def __init__(self, value): 492 if value == NextEthernetAddr: 493 self.value = value --- 9 unchanged lines hidden (view full) --- 503 for byte in bytes: 504 if not 0 <= int(byte) <= 256: 505 raise TypeError, 'invalid ethernet address %s' % value 506 507 self.value = value 508 509 def unproxy(self, base): 510 if self.value == NextEthernetAddr: | 488 489class EthernetAddr(ParamValue): 490 cxx_type = 'Net::EthAddr' 491 cxx_predecls = ['#include "base/inet.hh"'] 492 swig_predecls = ['class Net::EthAddr;'] 493 def __init__(self, value): 494 if value == NextEthernetAddr: 495 self.value = value --- 9 unchanged lines hidden (view full) --- 505 for byte in bytes: 506 if not 0 <= int(byte) <= 256: 507 raise TypeError, 'invalid ethernet address %s' % value 508 509 self.value = value 510 511 def unproxy(self, base): 512 if self.value == NextEthernetAddr: |
511 self.addr = self.value().value | 513 return EthernetAddr(self.value()) |
512 return self 513 | 514 return self 515 |
514 def __str__(self): 515 if self.value == NextEthernetAddr: 516 if hasattr(self, 'addr'): 517 return self.addr 518 else: 519 return "NextEthernetAddr (unresolved)" 520 else: 521 return self.value | 516 def ini_str(self): 517 return self.value |
522 523time_formats = [ "%a %b %d %H:%M:%S %Z %Y", 524 "%a %b %d %H:%M:%S %Z %Y", 525 "%Y/%m/%d %H:%M:%S", 526 "%Y/%m/%d %H:%M", 527 "%Y/%m/%d", 528 "%m/%d/%Y %H:%M:%S", 529 "%m/%d/%Y %H:%M", --- 493 unchanged lines hidden (view full) --- 1023 'Range', 'AddrRange', 'TickRange', 1024 'MaxAddr', 'MaxTick', 'AllMemory', 1025 'Time', 1026 'NextEthernetAddr', 'NULL', 1027 'Port', 'VectorPort'] 1028 1029# see comment on imports at end of __init__.py. 1030from SimObject import isSimObject, isSimObjectSequence, isSimObjectClass | 518 519time_formats = [ "%a %b %d %H:%M:%S %Z %Y", 520 "%a %b %d %H:%M:%S %Z %Y", 521 "%Y/%m/%d %H:%M:%S", 522 "%Y/%m/%d %H:%M", 523 "%Y/%m/%d", 524 "%m/%d/%Y %H:%M:%S", 525 "%m/%d/%Y %H:%M", --- 493 unchanged lines hidden (view full) --- 1019 'Range', 'AddrRange', 'TickRange', 1020 'MaxAddr', 'MaxTick', 'AllMemory', 1021 'Time', 1022 'NextEthernetAddr', 'NULL', 1023 'Port', 'VectorPort'] 1024 1025# see comment on imports at end of __init__.py. 1026from SimObject import isSimObject, isSimObjectSequence, isSimObjectClass |
1031import proxy | |
1032import objects 1033import internal | 1027import objects 1028import internal |