File:  [CENS] / python / pyGiNaC / wrappers / tinfo.py
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Tue Apr 10 19:22:15 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Introduced UNEX: everything returned to Python are basic instances (does not work for +-/* yet)

# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.1 $
# $Id: tinfo.py,v 1.1 2001-04-10 19:22:15 pearu Exp $
#
# Copyright 2001 Pearu Peterson all rights reserved,
# Pearu Peterson <pearu@cens.ioc.ee>
# Permission to use, modify, and distribute this software is given under the
# terms of the LGPL.  See http://www.fsf.org
#
# NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
#

defs = '''
  PyObject *tinfo_dict = PyDict_New();
  GiNaC::registered_class_info *p = GiNaC::first_registered_class;
  while (p) {
    //if (PyDict_SetItemString(tinfo_dict,(char *)p->name,Py_BuildValue("i",p->tinfo_key)))
    if (PyDict_SetItem(tinfo_dict,Py_BuildValue("i",p->tinfo_key),Py_BuildValue("s",p->name)))
      throw python::error_already_set();
    p = p->next;
  }
  this_module.add(tinfo_dict, "_tinfo");
  PyObject *w_class_dict = PyDict_New();
'''

for cl in ['basic',
           'expairseq','add','mul',
           'symbol','constant',
           'exprseq','function','ncmul'
           'lst','matrix','power','relational','fail',
           'numeric','pseries','indexed','structure',
           'idx','varidx',
           'tensor','tensdelta','tensmetric','minkmetric','tensepsilon',
           'exvector','expair','exlist','epvector','ex'
           ]:
    defs += '''
#ifdef PYGINAC_#class#
  Py_INCREF(#class#_py_class);
  if (PyDict_SetItemString(w_class_dict,"#class#",#class#_py_class))
    throw python::error_already_set();
#endif
'''.replace('#class#',cl)
defs += '''
  this_module.add(w_class_dict, "_py_class");
  this_module.add(Py_BuildValue("i",%s), "_nof_lst_params");
  this_module.add(Py_BuildValue("i",%s), "_nof_ncmul_params");
  this_module.add(Py_BuildValue("i",%s), "_nof_function_params");
'''%(nof_lst_params,nof_ncmul_params,nof_function_params)

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