File:  [CENS] / python / pyGiNaC / wrappers2 / basic_py.cpp
Revision 1.2: download - view: text, annotated - select for diffs - revision graph
Thu Apr 19 10:00:35 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
*** empty log message ***

/*
# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.2 $
# $Id: basic_py.cpp,v 1.2 2001-04-19 10:00:35 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.
#
*/

#include "basic_py.hpp"
#include "python_repr.hpp"
#include "symbol_py.hpp"
  
BOOST_PYTHON_MODULE_INIT(_basic)
{
  try
    {
      py::module_builder this_module("_basic");
      py::import_converters< symbol_py::symbol > class_basic_converters("symbol", "symbol");
      
      py::class_builder<basic_py::basic> basic_w_class(this_module, "_basic_w");
      py::class_builder<GiNaC::basic, basic_py::basic> basic_class(this_module, "basic");
      py::export_converters_noncopyable(basic_class);


      //basic_py_class = py::as_object(basic_class.get_extension_class());
      basic_class.declare_base(basic_w_class);

      basic_class.def(py::constructor<>());
      
      basic_class.def(&basic_py::basic::python_repr, "__repr__");
    }
  catch(...)
    {
      py::handle_exception();
    }
}

namespace basic_py {

  std::string basic::python_repr(void) const
  {
    std::ostrstream os;
    GiNaC::python_repr(os, GiNaC::ex(*this));
    os << std::ends;
    return os.str();
  }

}

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