Deleted Added
sdiff udiff text old ( 9254:f1b35c618252 ) new ( 9338:97b4a2be1e5b )
full compact
1# Copyright (c) 2012 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

--- 91 unchanged lines hidden (view full) ---

100#####################################################################
101
102# list of all SimObject classes
103allClasses = {}
104
105# dict to look up SimObjects based on path
106instanceDict = {}
107
108# Did any of the SimObjects lack a header file?
109noCxxHeader = False
110
111def public_value(key, value):
112 return key.startswith('_') or \
113 isinstance(value, (FunctionType, MethodType, ModuleType,
114 classmethod, type))
115
116# The metaclass for SimObject. This class controls how new classes
117# that derive from SimObject are instantiated, and provides inherited
118# class behavior (just like a class controls how instances of that
119# class are instantiated, and provides inherited instance behavior).
120class MetaSimObject(type):
121 # Attributes that can be set only at initialization time
122 init_keywords = { 'abstract' : bool,
123 'cxx_class' : str,
124 'cxx_type' : str,
125 'cxx_header' : str,
126 'type' : str }
127 # Attributes that can be set any time
128 keywords = { 'check' : FunctionType }
129
130 # __new__ is called before __init__, and is where the statements
131 # in the body of the class definition get loaded into the class's
132 # __dict__. We intercept this to filter out parameter & port assignments
133 # and only allow "private" attributes to be passed to the base

--- 68 unchanged lines hidden (view full) ---

202
203 # default keyword values
204 if 'type' in cls._value_dict:
205 if 'cxx_class' not in cls._value_dict:
206 cls._value_dict['cxx_class'] = cls._value_dict['type']
207
208 cls._value_dict['cxx_type'] = '%s *' % cls._value_dict['cxx_class']
209
210 if 'cxx_header' not in cls._value_dict:
211 global noCxxHeader
212 noCxxHeader = True
213 print >> sys.stderr, \
214 "warning: No header file specified for SimObject: %s" % name
215
216 # Export methods are automatically inherited via C++, so we
217 # don't want the method declarations to get inherited on the
218 # python side (and thus end up getting repeated in the wrapped
219 # versions of derived classes). The code below basicallly
220 # suppresses inheritance by substituting in the base (null)
221 # versions of these methods unless a different version is
222 # explicitly supplied.
223 for method_name in ('export_methods', 'export_method_cxx_predecls',

--- 188 unchanged lines hidden (view full) ---

412 ports = cls._ports.local
413
414 code('%module(package="m5.internal") param_$cls')
415 code()
416 code('%{')
417 code('#include "params/$cls.hh"')
418 for param in params:
419 param.cxx_predecls(code)
420 code('#include "${{cls.cxx_header}}"')
421 cls.export_method_cxx_predecls(code)
422 code('''\
423/**
424 * This is a workaround for bug in swig. Prior to gcc 4.6.1 the STL
425 * headers like vector, string, etc. used to automatically pull in
426 * the cstddef header but starting with gcc 4.6.1 they no longer do.
427 * This leads to swig generated a file that does not compile so we
428 * explicitly include cstddef. Additionally, including version 2.0.4,

--- 145 unchanged lines hidden (view full) ---

574# the code in this class deals with the configuration hierarchy itself
575# (parent/child node relationships).
576class SimObject(object):
577 # Specify metaclass. Any class inheriting from SimObject will
578 # get this metaclass.
579 __metaclass__ = MetaSimObject
580 type = 'SimObject'
581 abstract = True
582 cxx_header = "sim/sim_object.hh"
583
584 @classmethod
585 def export_method_swig_predecls(cls, code):
586 code('''
587%include <std_string.i>
588''')
589
590 @classmethod
591 def export_methods(cls, code):
592 code('''

--- 504 unchanged lines hidden (view full) ---

1097 if value is None:
1098 raise TypeError, "SimObject or SimObjectVector expected"
1099 return value
1100
1101baseClasses = allClasses.copy()
1102baseInstances = instanceDict.copy()
1103
1104def clear():
1105 global allClasses, instanceDict, noCxxHeader
1106
1107 allClasses = baseClasses.copy()
1108 instanceDict = baseInstances.copy()
1109 noCxxHeader = False
1110
1111# __all__ defines the list of symbols that get exported when
1112# 'from config import *' is invoked. Try to keep this reasonably
1113# short to avoid polluting other namespaces.
1114__all__ = [ 'SimObject' ]