diff options
author | Nathan Binkert <nate@binkert.org> | 2007-08-02 22:50:02 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2007-08-02 22:50:02 -0700 |
commit | 0536d0cde931e89d33b10228950d455dd54d8a5f (patch) | |
tree | e4d8335f239b5216942768a48d6879f184182f6c /src/python/generate.py | |
parent | dc7a38dce785cf0deabb35022bb2dbfc1cc8ea3a (diff) | |
download | gem5-0536d0cde931e89d33b10228950d455dd54d8a5f.tar.xz |
python: Improve support for python calling back to C++ member functions.
Add support for declaring SimObjects to swig so their members can be wrapped.
Make sim_object.i only contain declarations for SimObject.
Create system.i to contain declarations for System.
Update python code to properly call the C++ given the new changes.
--HG--
extra : convert_revision : 82076ee69e8122d56e91b92d6767e356baae420a
Diffstat (limited to 'src/python/generate.py')
-rw-r--r-- | src/python/generate.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/python/generate.py b/src/python/generate.py index 6a09b8106..99d0fb68c 100644 --- a/src/python/generate.py +++ b/src/python/generate.py @@ -274,17 +274,29 @@ class Generate(object): print >>out for obj in ordered_objs: - code = 'class %s ' % obj.cxx_class - if str(obj) != 'SimObject': - code += ': public %s ' % obj.__bases__[0] - code += '{};' + if obj.swig_objdecls: + for decl in obj.swig_objdecls: + print >>out, decl + continue + + code = '' + base = obj.get_base() + + code += '// stop swig from creating/wrapping default ctor/dtor\n' + code += '%%nodefault %s;\n' % obj.cxx_class + code += 'class %s ' % obj.cxx_class + if base: + code += ': public %s' % base + code += ' {};\n' klass = obj.cxx_class; if hasattr(obj, 'cxx_namespace'): - code = 'namespace %s { %s }' % (obj.cxx_namespace, code) + new_code = 'namespace %s {\n' % obj.cxx_namespace + new_code += code + new_code += '}\n' + code = new_code klass = '%s::%s' % (obj.cxx_namespace, klass) - print >>out, '%%ignore %s;' % klass print >>out, code for obj in ordered_objs: |