File:  [CENS] / python / pyGiNaC / wrappers4 / symbol.cpp
Revision 1.6: download - view: text, annotated - select for diffs - revision graph
Mon Nov 26 22:37:44 2001 UTC (15 years, 11 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
See NEWS.txt (impl. matrix)

/*
  This file is part of the PyGiNaC package.
  http://cens.ioc.ee/projects/pyginac/

  $Revision: 1.6 $
  $Id: symbol.cpp,v 1.6 2001-11-26 22:37:44 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.
*/

#ifndef PYGINAC_SYMBOL_CPP
#define PYGINAC_SYMBOL_CPP
/* prototypes */

GiNaC::ex symbol(const std::string & name);
GiNaC::ex symbol(const std::string & name, const std::string & texname);

BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE

GiNaC::symbol & from_python(PyObject* o, py::type<GiNaC::symbol &>);
const GiNaC::symbol & from_python (PyObject* o, py::type<const GiNaC::symbol &>);

BOOST_PYTHON_END_CONVERSION_NAMESPACE

#else
#ifndef PYGINAC_SYMBOL_CPP_1
#define PYGINAC_SYMBOL_CPP_1
/* definitions */

this_module.def((GiNaC::ex(*)(const std::string&))symbol, "symbol");
this_module.def((GiNaC::ex(*)(const std::string&,const std::string&))symbol, "symbol");
ex_class.def(&GiNaC::symbol::get_name, "symbol_get_name");
ex_class.def(&GiNaC::symbol::set_name, "symbol_set_name");

#else
/* implementation */

GiNaC::ex symbol(const std::string & name) {
  return GiNaC::symbol(name);
}
GiNaC::ex symbol(const std::string & name, const std::string & texname) {
  return GiNaC::symbol(name, texname);
}

BOOST_PYTHON_BEGIN_CONVERSION_NAMESPACE

GiNaC::symbol & from_python(PyObject* o, py::type<GiNaC::symbol &>) {
  if (PYOBJ_IS_EX(o)) {
    GiNaC::ex & e = pyobj_get_ex_nonconst(o);
    if (GiNaC::is_a<GiNaC::symbol>(e))
      return GiNaC::ex_to_nonconst<GiNaC::symbol>(e);
  }
  PyErr_SetString(PyExc_TypeError,(std::string("from_python(obj, symbol) expected symbol but got ")+PyString_AsString(PyObject_Repr(PyObject_Type(o)))).c_str());
  throw py::error_already_set();
}

const GiNaC::symbol & from_python (PyObject* o, py::type<const GiNaC::symbol &>) {
  return from_python(o, py::type<GiNaC::symbol &>());
}

BOOST_PYTHON_END_CONVERSION_NAMESPACE
#endif
#endif

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