diff -r a6cf14d529da -r 48c0c388c006 src/SConscript --- a/src/SConscript Sat Sep 24 09:54:01 2011 -0700 +++ b/src/SConscript Sat Sep 24 09:54:13 2011 -0700 @@ -602,12 +602,12 @@ # Generate any needed param SWIG wrapper files params_i_files = [] for name,param in params_to_swig.iteritems(): - i_file = File('python/m5/internal/%s.i' % (param.swig_module_name())) + i_file = File('python/m5/internal/swig/%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) - SwigSource('m5.internal', i_file) + SwigSource('m5.internal.swig', i_file) # Generate all enum header files for name,enum in sorted(all_enums.iteritems()): @@ -625,19 +625,19 @@ MakeAction(createEnumDecls, Transform("ENUMDECL"))) env.Depends(hh_file, depends + extra_deps) - i_file = File('python/m5/internal/enum_%s.i' % name) + i_file = File('python/m5/internal/swig/enum_%s.i' % name) env.Command(i_file, Value(name), MakeAction(createEnumSwigWrapper, Transform("ENUMSWIG"))) env.Depends(i_file, depends + extra_deps) - SwigSource('m5.internal', i_file) + SwigSource('m5.internal.swig', i_file) # Generate SimObject SWIG wrapper files for name in sim_objects.iterkeys(): - i_file = File('python/m5/internal/param_%s.i' % name) + i_file = File('python/m5/internal/swig/%s.i' % name) env.Command(i_file, Value(name), MakeAction(createSimObjectSwigWrapper, Transform("SO SWIG"))) env.Depends(i_file, depends) - SwigSource('m5.internal', i_file) + SwigSource('m5.internal.swig', i_file) # Generate the main swig init file def makeEmbeddedSwigInit(target, source, env): diff -r a6cf14d529da -r 48c0c388c006 src/python/SConscript --- a/src/python/SConscript Sat Sep 24 09:54:01 2011 -0700 +++ b/src/python/SConscript Sat Sep 24 09:54:13 2011 -0700 @@ -66,9 +66,11 @@ SwigSource('m5.internal', 'swig/core.i') SwigSource('m5.internal', 'swig/debug.i') SwigSource('m5.internal', 'swig/event.i') +SwigSource('m5.internal', 'swig/inet.i') SwigSource('m5.internal', 'swig/pyobject.i') SwigSource('m5.internal', 'swig/range.i') SwigSource('m5.internal', 'swig/stats.i') +SwigSource('m5.internal', 'swig/time.i') SwigSource('m5.internal', 'swig/trace.i') PySource('m5.internal', 'm5/internal/__init__.py') -PySource('m5.internal', 'm5/internal/params.py') +PySource('m5.internal.swig', 'm5/internal/swig/__init__.py') diff -r a6cf14d529da -r 48c0c388c006 src/python/m5/SimObject.py --- a/src/python/m5/SimObject.py Sat Sep 24 09:54:01 2011 -0700 +++ b/src/python/m5/SimObject.py Sat Sep 24 09:54:13 2011 -0700 @@ -352,7 +352,7 @@ # See ParamValue.swig_predecls for description. def swig_predecls(cls, code): - code('%import "python/m5/internal/param_$cls.i"') + code('%import "python/m5/internal/swig/$cls.i"') # Hook for exporting additional C++ methods to Python via SWIG. # Default is none, override using @classmethod in class definition. @@ -389,7 +389,7 @@ # here). params = cls._params.local.values() - code('%module(package="m5.internal") param_$cls') + code('%module(package="m5.internal.swig") $cls') code() code('%{') code('#include "params/$cls.hh"') @@ -405,7 +405,7 @@ code() if cls._base: - code('%import "python/m5/internal/param_${{cls._base}}.i"') + code('%import "python/m5/internal/swig/${{cls._base}}.i"') code() for ns in namespaces: @@ -901,7 +901,8 @@ if self._ccParams: return self._ccParams - cc_params_struct = getattr(m5.internal.params, '%sParams' % self.type) + exec("from m5.internal.swig.%s import %sParams as cc_params_struct" \ + % (self.type, self.type)) cc_params = cc_params_struct() cc_params.pyobj = self cc_params.name = str(self) diff -r a6cf14d529da -r 48c0c388c006 src/python/m5/internal/params.py --- a/src/python/m5/internal/params.py Sat Sep 24 09:54:01 2011 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -# Copyright (c) 2010 The Hewlett-Packard Development Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer; -# redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution; -# neither the name of the copyright holders nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# Authors: Nathan Binkert - -try: - modules = __loader__.modules -except NameError: - modules = { } - -for module in modules.iterkeys(): - if module.startswith('m5.internal.param_') or \ - module.startswith('m5.internal.enum_'): - exec "from %s import *" % module diff -r a6cf14d529da -r 48c0c388c006 src/python/m5/internal/swig/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/python/m5/internal/swig/__init__.py Sat Sep 24 09:54:13 2011 -0700 @@ -0,0 +1,2 @@ +# This file exists just to mark m5.internals.swig as a valid Python package. +# The subpackages in this package are all auto-generated by SWIG. diff -r a6cf14d529da -r 48c0c388c006 src/python/m5/objects/__init__.py --- a/src/python/m5/objects/__init__.py Sat Sep 24 09:54:01 2011 -0700 +++ b/src/python/m5/objects/__init__.py Sat Sep 24 09:54:13 2011 -0700 @@ -26,7 +26,6 @@ # # Authors: Nathan Binkert -from m5.internal import params from m5.SimObject import * try: diff -r a6cf14d529da -r 48c0c388c006 src/python/m5/params.py --- a/src/python/m5/params.py Sat Sep 24 09:54:01 2011 -0700 +++ b/src/python/m5/params.py Sat Sep 24 09:54:13 2011 -0700 @@ -250,7 +250,7 @@ code('%import "${{self.swig_module_name()}}.i"') def swig_decl(self, code): - code('%module(package="m5.internal") ${{self.swig_module_name()}}') + code('%module(package="m5.internal.swig") ${{self.swig_module_name()}}') code('%{') self.ptype.cxx_predecls(code) code('%}') @@ -650,7 +650,7 @@ @classmethod def swig_predecls(cls, code): - code('%include "python/swig/inet.i"') + code('%import "python/swig/inet.i"') def __init__(self, value): if value == NextEthernetAddr: @@ -676,7 +676,7 @@ return self def getValue(self): - from m5.internal.params import EthAddr + from m5.internal.inet import EthAddr return EthAddr(self.value) def ini_str(self): @@ -693,7 +693,7 @@ @classmethod def swig_predecls(cls, code): - code('%include "python/swig/inet.i"') + code('%import "python/swig/inet.i"') def __init__(self, value): if isinstance(value, IpAddress): @@ -728,7 +728,7 @@ raise TypeError, "invalid ip address %#08x" % self.ip def getValue(self): - from m5.internal.params import IpAddress + from m5.internal.inet import IpAddress return IpAddress(self.ip) # When initializing an IpNetmask, pass in an existing IpNetmask, a string of @@ -743,7 +743,7 @@ @classmethod def swig_predecls(cls, code): - code('%include "python/swig/inet.i"') + code('%import "python/swig/inet.i"') def __init__(self, *args, **kwargs): def handle_kwarg(self, kwargs, key, elseVal = None): @@ -801,7 +801,7 @@ raise TypeError, "invalid netmask %d" % netmask def getValue(self): - from m5.internal.params import IpNetmask + from m5.internal.inet import IpNetmask return IpNetmask(self.ip, self.netmask) # When initializing an IpWithPort, pass in an existing IpWithPort, a string of @@ -815,7 +815,7 @@ @classmethod def swig_predecls(cls, code): - code('%include "python/swig/inet.i"') + code('%import "python/swig/inet.i"') def __init__(self, *args, **kwargs): def handle_kwarg(self, kwargs, key, elseVal = None): @@ -873,7 +873,7 @@ raise TypeError, "invalid port %d" % self.port def getValue(self): - from m5.internal.params import IpWithPort + from m5.internal.inet import IpWithPort return IpWithPort(self.ip, self.port) time_formats = [ "%a %b %d %H:%M:%S %Z %Y", @@ -923,13 +923,13 @@ @classmethod def swig_predecls(cls, code): - code('%include "python/swig/time.i"') + code('%import "python/swig/time.i"') def __init__(self, value): self.value = parse_time(value) def getValue(self): - from m5.internal.params import tm + from m5.internal.time import tm c_time = tm() py_time = self.value @@ -1053,7 +1053,7 @@ def swig_decl(cls, code): name = cls.__name__ code('''\ -%module(package="m5.internal") enum_$name +%module(package="m5.internal.swig") enum_$name %{ #include "enums/$name.hh" @@ -1080,7 +1080,7 @@ @classmethod def swig_predecls(cls, code): - code('%import "python/m5/internal/enum_$0.i"', cls.__name__) + code('%import "python/m5/internal/swig/enum_$0.i"', cls.__name__) def getValue(self): return int(self.map[self.value]) diff -r a6cf14d529da -r 48c0c388c006 src/python/swig/inet.i --- a/src/python/swig/inet.i Sat Sep 24 09:54:01 2011 -0700 +++ b/src/python/swig/inet.i Sat Sep 24 09:54:13 2011 -0700 @@ -30,6 +30,8 @@ * Gabe Black */ +%module(package="m5.internal") inet + %{ #include "base/inet.hh" %} diff -r a6cf14d529da -r 48c0c388c006 src/python/swig/time.i --- a/src/python/swig/time.i Sat Sep 24 09:54:01 2011 -0700 +++ b/src/python/swig/time.i Sat Sep 24 09:54:13 2011 -0700 @@ -28,6 +28,8 @@ * Authors: Nathan Binkert */ +%module(package="m5.internal") time + %{ #include %}