spielwiese
Last change
on this file since 0a8b32 was
0a8b32,
checked in by Hans Schoenemann <hannes@…>, 7 years ago
|
dyn_mod: python: syntax
|
-
Property mode set to
100644
|
File size:
978 bytes
|
Line | |
---|
1 | |
---|
2 | #include <boost/python.hpp> |
---|
3 | #include <kernel/mod2.h> |
---|
4 | #include "ring_wrap.h" |
---|
5 | #include "poly_wrap.h" |
---|
6 | static boost::python::object Ring_as_str(const Ring& r) |
---|
7 | { |
---|
8 | using boost::python::str; |
---|
9 | StringSetS(""); |
---|
10 | rWrite(r.pimpl.get()); |
---|
11 | char* out=StringEndS(); |
---|
12 | return boost::python::str(out,strlen(out)); |
---|
13 | } |
---|
14 | void ring_set(Ring & r) |
---|
15 | { |
---|
16 | //FIXME: only a hack, no solution |
---|
17 | char name_buffer[100]; |
---|
18 | static int ending=0; |
---|
19 | ending++; |
---|
20 | sprintf(name_buffer, "PYTHON_RING_VAR%d",ending); |
---|
21 | idhdl shadow_hdl=enterid(name_buffer,0,RING_CMD,&IDROOT); |
---|
22 | r.pimpl.get()->ref++; |
---|
23 | shadow_hdl->data.uring=r.pimpl.get(); |
---|
24 | rChangeCurrRing(r.pimpl.get()); |
---|
25 | currRingHdl=shadow_hdl; |
---|
26 | |
---|
27 | } |
---|
28 | void export_ring() |
---|
29 | { |
---|
30 | boost::python::class_<Ring>("Ring", "reference to a Singular ring") |
---|
31 | .def("__str__", Ring_as_str) |
---|
32 | .def("set", ring_set,"equivalent to the singular command setring, which is not mapped as it is a command") |
---|
33 | .def(boost::python::init <>()); |
---|
34 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.