python: Move native wrappers to the _m5 namespace

Swig wrappers for native objects currently share the _m5.internal name
space with Python code. This is undesirable if we ever want to switch
from Swig to some other framework for native binding (e.g., PyBind11
or Boost::Python). This changeset moves all of such wrappers to the
_m5 namespace, which is now reserved for native code.

Change-Id: I2d2bc12dbc05b57b7c5a75f072e08124413d77f3
Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Curtis Dunham <curtis.dunham@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Andreas Sandberg
2017-01-27 12:40:01 +00:00
parent e387521527
commit 2974dc7a37
27 changed files with 129 additions and 102 deletions

View File

@@ -483,7 +483,7 @@ class DictImporter(object):
if fullname == 'm5.objects':
return self
if fullname.startswith('m5.internal'):
if fullname.startswith('_m5'):
return None
source = self.modules.get(fullname, None)
@@ -588,14 +588,14 @@ def makeDefinesPyFile(target, source, env):
code = code_formatter()
code("""
import m5.internal
import _m5.core
import m5.util
buildEnv = m5.util.SmartDict($build_env)
compileDate = m5.internal.core.compileDate
compileDate = _m5.core.compileDate
_globals = globals()
for key,val in m5.internal.core.__dict__.iteritems():
for key,val in _m5.core.__dict__.iteritems():
if key.startswith('flag_'):
flag = key[5:]
_globals[flag] = val
@@ -773,13 +773,13 @@ if GetOption('with_cxx_config'):
# Generate any needed param SWIG wrapper files
params_i_files = []
for name,param in sorted(params_to_swig.iteritems()):
i_file = File('python/m5/internal/%s.i' % (param.swig_module_name()))
i_file = File('python/_m5/%s.i' % (param.swig_module_name()))
params_i_files.append(i_file)
env.Command(i_file, Value(name),
MakeAction(createParamSwigWrapper, Transform("SW PARAM")))
env.Depends(i_file, depends)
env.Depends(SWIG, i_file)
SwigSource('m5.internal', i_file)
SwigSource('_m5', i_file)
# Generate all enum header files
for name,enum in sorted(all_enums.iteritems()):
@@ -799,22 +799,22 @@ for name,enum in sorted(all_enums.iteritems()):
env.Depends(hh_file, depends + extra_deps)
env.Depends(SWIG, hh_file)
i_file = File('python/m5/internal/enum_%s.i' % name)
i_file = File('python/_m5/enum_%s.i' % name)
env.Command(i_file, Value(name),
MakeAction(createEnumSwigWrapper, Transform("ENUMSWIG")))
env.Depends(i_file, depends + extra_deps)
env.Depends(SWIG, i_file)
SwigSource('m5.internal', i_file)
SwigSource('_m5', i_file)
# Generate SimObject SWIG wrapper files
for name,simobj in sorted(sim_objects.iteritems()):
py_source = PySource.modules[simobj.__module__]
extra_deps = [ py_source.tnode ]
i_file = File('python/m5/internal/param_%s.i' % name)
i_file = File('python/_m5/param_%s.i' % name)
env.Command(i_file, Value(name),
MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG")))
env.Depends(i_file, depends + extra_deps)
SwigSource('m5.internal', i_file)
SwigSource('_m5', i_file)
# Generate the main swig init file
def makeEmbeddedSwigInit(package):