My Project
Loading...
Searching...
No Matches
number_wrap.cc
Go to the documentation of this file.
1#include "kernel/mod2.h"
2#ifdef HAVE_PYTHON
3#include <boost/python.hpp>
4#include "Number.h"
5#include "number_wrap.h"
6#include "ring_wrap.h"
7using boost::python::self;
8static boost::python::object Number_as_str(const Number& n)
9{
10 using boost::python::str;
11 StringSetS("");
12 n.write();
13 char* out=StringEndS();
14 return boost::python::str(out,strlen(out));
15}
16static Ring Number_get_Ring(const Number & n){
17 return n.getRing();
18}
20{
21 boost::python::class_<Number>("Number")
22 .def(boost::python::init <int>("creates a number in currRing by default, more complex constructs can be fetched from the interpreter"))
23 .def("__str__", Number_as_str)
24 .def(-self)
25 .def(self*=self)
26 .def(self+=self)
27 .def(self-=self)
28 .def(self/=self)
29 .def(self==self)
30 .def(self+self)
31 .def(self*self)
32 .def(self/self)
33 .def(self-self)
34 .def(int()==self)
35 .def(int()+self)
36 .def(int()*self)
37 .def(int()/self)
38 .def(int()-self)
39 .def(self==int())
40 .def(self+int())
41 .def(self*int())
42 .def(self/int())
43 .def(self-int())
44 .def(self*=int())
45 .def(self+=int())
46 .def(self-=int())
47 .def(self/=int())
48 .def("ring",Number_get_Ring);
49}
50#endif
Definition: Number.h:34
ring getRing() const
Definition: Number.h:212
void write() const
Definition: Number.h:202
Definition: ring_wrap.h:21
static Ring Number_get_Ring(const Number &n)
Definition: number_wrap.cc:16
void export_number()
Definition: number_wrap.cc:19
static boost::python::object Number_as_str(const Number &n)
Definition: number_wrap.cc:8
void StringSetS(const char *st)
Definition: reporter.cc:128
char * StringEndS()
Definition: reporter.cc:151