python: Move more code into m5.util allow SCons to use that code.
Get rid of misc.py and just stick misc things in __init__.py Move utility functions out of SCons files and into m5.util Move utility type stuff from m5/__init__.py to m5/util/__init__.py Remove buildEnv from m5 and allow access only from m5.defines Rename AddToPath to addToPath while we're moving it to m5.util Rename read_command to readCommand while we're moving it Rename compare_versions to compareVersions while we're moving it. --HG-- rename : src/python/m5/convert.py => src/python/m5/util/convert.py rename : src/python/m5/smartdict.py => src/python/m5/util/smartdict.py
This commit is contained in:
@@ -50,13 +50,10 @@ import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
import convert
|
||||
import proxy
|
||||
import ticks
|
||||
from util import *
|
||||
|
||||
import SimObject
|
||||
|
||||
def isSimObject(*args, **kwargs):
|
||||
return SimObject.isSimObject(*args, **kwargs)
|
||||
|
||||
@@ -711,32 +708,31 @@ class MetaEnum(MetaParamValue):
|
||||
|
||||
super(MetaEnum, cls).__init__(name, bases, init_dict)
|
||||
|
||||
def __str__(cls):
|
||||
return cls.__name__
|
||||
|
||||
# Generate C++ class declaration for this enum type.
|
||||
# Note that we wrap the enum in a class/struct to act as a namespace,
|
||||
# so that the enum strings can be brief w/o worrying about collisions.
|
||||
def cxx_decl(cls):
|
||||
code = "#ifndef __ENUM__%s\n" % cls
|
||||
code += '#define __ENUM__%s\n' % cls
|
||||
name = cls.__name__
|
||||
code = "#ifndef __ENUM__%s\n" % name
|
||||
code += '#define __ENUM__%s\n' % name
|
||||
code += '\n'
|
||||
code += 'namespace Enums {\n'
|
||||
code += ' enum %s {\n' % cls
|
||||
code += ' enum %s {\n' % name
|
||||
for val in cls.vals:
|
||||
code += ' %s = %d,\n' % (val, cls.map[val])
|
||||
code += ' Num_%s = %d,\n' % (cls, len(cls.vals))
|
||||
code += ' Num_%s = %d,\n' % (name, len(cls.vals))
|
||||
code += ' };\n'
|
||||
code += ' extern const char *%sStrings[Num_%s];\n' % (cls, cls)
|
||||
code += ' extern const char *%sStrings[Num_%s];\n' % (name, name)
|
||||
code += '}\n'
|
||||
code += '\n'
|
||||
code += '#endif\n'
|
||||
return code
|
||||
|
||||
def cxx_def(cls):
|
||||
code = '#include "enums/%s.hh"\n' % cls
|
||||
name = cls.__name__
|
||||
code = '#include "enums/%s.hh"\n' % name
|
||||
code += 'namespace Enums {\n'
|
||||
code += ' const char *%sStrings[Num_%s] =\n' % (cls, cls)
|
||||
code += ' const char *%sStrings[Num_%s] =\n' % (name, name)
|
||||
code += ' {\n'
|
||||
for val in cls.vals:
|
||||
code += ' "%s",\n' % val
|
||||
@@ -1170,6 +1166,15 @@ class PortParamDesc(object):
|
||||
ptype_str = 'Port'
|
||||
ptype = Port
|
||||
|
||||
baseEnums = allEnums.copy()
|
||||
baseParams = allParams.copy()
|
||||
|
||||
def clear():
|
||||
global allEnums, allParams
|
||||
|
||||
allEnums = baseEnums.copy()
|
||||
allParams = baseParams.copy()
|
||||
|
||||
__all__ = ['Param', 'VectorParam',
|
||||
'Enum', 'Bool', 'String', 'Float',
|
||||
'Int', 'Unsigned', 'Int8', 'UInt8', 'Int16', 'UInt16',
|
||||
@@ -1184,3 +1189,5 @@ __all__ = ['Param', 'VectorParam',
|
||||
'Time',
|
||||
'NextEthernetAddr', 'NULL',
|
||||
'Port', 'VectorPort']
|
||||
|
||||
import SimObject
|
||||
|
||||
Reference in New Issue
Block a user