File:  [CENS] / python / pyGiNaC / tools / build_ginac.py
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Tue Mar 13 06:38:40 2001 UTC (16 years, 8 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Got add(vxvector()) to work

#!/usr/bin/env python

import time
modulename = '_ginac'

tab = 4*' '

f = open('../src/%s.cpp'%(modulename),'w')

def fwrite(s):
    f.write(s.replace('\t',tab))

fwrite('''
// This file (%s.cpp) is auto-generated with pyGiNaC/tools/runme.sh.
// Date: %s
// Author: Pearu Peterson <pearu@cens.ioc.ee>
// $Id: build_ginac.py,v 1.3 2001-03-13 06:38:40 pearu Exp $

//#include <cln/cln.h>
#include <ginac/ginac.h>
#include <boost/python/class_builder.hpp>


namespace python = boost::python;

namespace { // Avoid cluttering the global namespace.


'''%(modulename,time.asctime(time.localtime())))

fwrite(open('../src/typedef_proto._cpp','r').read())
fwrite(open('../src/class_wrapper._cpp','r').read())

fwrite('''
}

BOOST_PYTHON_MODULE_INIT(%s)
{
\ttry
\t{
\t\tpython::module_builder this_module("%s");
'''%(modulename,modulename))

fwrite(open('../src/class._cpp','r').read())
fwrite(open('../src/typedef_class._cpp','r').read())

fwrite(open('../src/class_constructor._cpp','r').read())
fwrite(open('../src/class_method._cpp','r').read())
fwrite(open('../src/typedef_method._cpp','r').read())

fwrite('''\
\t}
\tcatch(...)
\t{
\t\tpython::handle_exception(); // Deal with the exception for Python
\t}
}

namespace { // Avoid cluttering the global namespace.
''')

fwrite(open('../src/typedef_wrapper._cpp','r').read())

fwrite('''}''')

f.close()



FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>