File:  [CENS] / python / pyGiNaC / wrappers / color.py
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Wed Apr 11 20:31:30 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Exposed lots of functions. Documented most important classes/functions. minor_version = 2

# This file is part of the PyGiNaC package.
# http://cens.ioc.ee/projects/pyginac/
#
# $Revision: 1.3 $
# $Id: color.py,v 1.3 2001-04-11 20:31:30 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.
#
# TODO:
# ask GiNaC people to make color::representation_label protected

depends = ['indexed']

uses = ['ex']

wrapperclass = '''

static GiNaC::color ex_to_color_or_ex_w(const GiNaC::ex &);

class color_w : public GiNaC::color {
  PyObject * self;
public:
  color_w(python::ref v)
  : GiNaC::color(ex_w(v)) {
    DEBUG_C("color_w(raw:ref)");
  }
  color_w(PyObject * self_, const GiNaC::ex & m)
  : GiNaC::color(ex_to_color_or_ex_w(m)), self(self_) {
    DEBUG_C("color_w(ex(color|*))");
  }
  color_w(PyObject * self_, const GiNaC::basic & m)
  : GiNaC::color(ex_to_color_or_ex_w(GiNaC::ex(m))), self(self_) {
    DEBUG_C("color_w(basic)");
  }
  color_w(PyObject * self_, python::ref b)
  : GiNaC::color(ex_w(b)), self(self_) {
    DEBUG_C("color_w(ref)");
  }
  color_w(PyObject * self_, python::ref b, unsigned rl)
  : GiNaC::color(ex_w(b),rl), self(self_) {
    DEBUG_C("color_w(ref,unsigned)");
  }
  color_w(PyObject * self_, python::ref b, python::ref i1)
  : GiNaC::color(ex_w(b),ex_w(i1)), self(self_) {
    DEBUG_C("color_w(ref,ref)");
  }
  color_w(PyObject * self_, python::ref b, python::ref i1, unsigned rl)
  : GiNaC::color(ex_w(b),ex_w(i1),rl), self(self_) {
    DEBUG_C("color_w(ref,ref,unsigned)");
  }
  color_w(PyObject * self_, unsigned rl, python::ref v)
  : GiNaC::color(rl, exvector_w(v)), self(self_) {
    DEBUG_C("color_w(unsigned, ref)");
  }
  ~color_w() {
    DEBUG_C("color_w::~color_w()");
  }
};
inline UNEX_RET color_ONE1_w(void) { return UNEX(GiNaC::color_ONE()); }
inline UNEX_RET color_ONE2_w(unsigned rl) { return UNEX(GiNaC::color_ONE(rl)); }
inline UNEX_RET color_T1_w(python::ref a) { return UNEX(GiNaC::color_T(ex_w(a))); }
inline UNEX_RET color_T2_w(python::ref a,unsigned rl) { return UNEX(GiNaC::color_T(ex_w(a),rl)); }
inline UNEX_RET color_f_w(python::ref a,python::ref b,python::ref c) {
  return UNEX(GiNaC::color_f(ex_w(a),ex_w(b),ex_w(c))); }
inline UNEX_RET color_d_w(python::ref a,python::ref b,python::ref c) {
  return UNEX(GiNaC::color_d(ex_w(a),ex_w(b),ex_w(c))); }
inline UNEX_RET color_h_w(python::ref a,python::ref b,python::ref c) {
  return UNEX(GiNaC::color_h(ex_w(a),ex_w(b),ex_w(c))); }

'''

builder = '''
python::class_builder<color_w> color_w_class(this_module, "_color_w");
python::class_builder<GiNaC::color, color_w> color_class(this_module, "color");
color_py_class = python::as_object(color_class.get_extension_class());
color_class.declare_base(color_w_class);
color_class.declare_base(indexed_class);
color_class.declare_base(basic_class);
'''

constructors = '''
color_class.def(python::constructor<const GiNaC::basic &>());
color_class.def(python::constructor<const GiNaC::ex &>());
color_class.def(python::constructor<python::ref>());
color_class.def(python::constructor<unsigned, python::ref>());
color_class.def(python::constructor<python::ref, unsigned>());
color_class.def(python::constructor<python::ref, python::ref>());
color_class.def(python::constructor<python::ref, python::ref, unsigned>());
'''

defs = '''
color_class.def(&basic_w::python_str, "__str__");
color_class.def(&basic_w::python_repr, "__repr__");

this_module.def(color_ONE1_w,"color_ONE");
this_module.def(color_ONE2_w,"color_ONE");
this_module.def(color_T1_w,"color_T");
this_module.def(color_T2_w,"color_T");
this_module.def(color_f_w,"color_f");
this_module.def(color_d_w,"color_d");
this_module.def(color_h_w,"color_h");
'''

protos = '''
'''

implementation = '''
EX_TO_BASIC(color)

static GiNaC::color ex_to_color_or_ex_w(const GiNaC::ex & ib) {
  if (is_ex_exactly_of_type(ib, color))
    return GiNaC::ex_to_color(ib);
  else
    return GiNaC::color(ib);
}
'''

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