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
108def public_value(key, value):
109 return key.startswith('_') or \
110 isinstance(value, (FunctionType, MethodType, ModuleType,
111 classmethod, type))
112
113# The metaclass for SimObject. This class controls how new classes
114# that derive from SimObject are instantiated, and provides inherited
115# class behavior (just like a class controls how instances of that
116# class are instantiated, and provides inherited instance behavior).
117class MetaSimObject(type):
118 # Attributes that can be set only at initialization time
119 init_keywords = { 'abstract' : bool,
120 'cxx_class' : str,
121 'cxx_type' : str,
122 'type' : str }
123 # Attributes that can be set any time
124 keywords = { 'check' : FunctionType }
125
126 # __new__ is called before __init__, and is where the statements
127 # in the body of the class definition get loaded into the class's
128 # __dict__. We intercept this to filter out parameter & port assignments
129 # and only allow "private" attributes to be passed to the base

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

198
199 # default keyword values
200 if 'type' in cls._value_dict:
201 if 'cxx_class' not in cls._value_dict:
202 cls._value_dict['cxx_class'] = cls._value_dict['type']
203
204 cls._value_dict['cxx_type'] = '%s *' % cls._value_dict['cxx_class']
205
206 # Export methods are automatically inherited via C++, so we
207 # don't want the method declarations to get inherited on the
208 # python side (and thus end up getting repeated in the wrapped
209 # versions of derived classes). The code below basicallly
210 # suppresses inheritance by substituting in the base (null)
211 # versions of these methods unless a different version is
212 # explicitly supplied.
213 for method_name in ('export_methods', 'export_method_cxx_predecls',

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

402 ports = cls._ports.local
403
404 code('%module(package="m5.internal") param_$cls')
405 code()
406 code('%{')
407 code('#include "params/$cls.hh"')
408 for param in params:
409 param.cxx_predecls(code)
410 cls.export_method_cxx_predecls(code)
411 code('''\
412/**
413 * This is a workaround for bug in swig. Prior to gcc 4.6.1 the STL
414 * headers like vector, string, etc. used to automatically pull in
415 * the cstddef header but starting with gcc 4.6.1 they no longer do.
416 * This leads to swig generated a file that does not compile so we
417 * explicitly include cstddef. Additionally, including version 2.0.4,

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

563# the code in this class deals with the configuration hierarchy itself
564# (parent/child node relationships).
565class SimObject(object):
566 # Specify metaclass. Any class inheriting from SimObject will
567 # get this metaclass.
568 __metaclass__ = MetaSimObject
569 type = 'SimObject'
570 abstract = True
571
572 @classmethod
573 def export_method_cxx_predecls(cls, code):
574 code('''
575#include <Python.h>
576
577#include "sim/serialize.hh"
578#include "sim/sim_object.hh"
579''')
580
581 @classmethod
582 def export_method_swig_predecls(cls, code):
583 code('''
584%include <std_string.i>
585''')
586
587 @classmethod
588 def export_methods(cls, code):
589 code('''

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

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