File: ring_wrap.cc

package info (click to toggle)
singular 1%3A4.1.1-p2%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 35,856 kB
  • sloc: cpp: 288,280; ansic: 17,387; lisp: 4,242; yacc: 1,654; python: 1,608; makefile: 1,424; lex: 1,387; perl: 632; sh: 567; xml: 182
file content (39 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "kernel/mod2.h"
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include "Singular/ipshell.h"
#include "ring_wrap.h"
#include "poly_wrap.h"
static boost::python::object Ring_as_str(const Ring& r)
{
  using boost::python::str;
  StringSetS("");
  rWrite(r.pimpl.get());
  char* out=StringEndS();
  return boost::python::str(out,strlen(out));
}
void ring_set(Ring & R)
{
    ring r=R.pimpl.get();
    idhdl h=rFindHdl(r,NULL);
    if (h==NULL)
    {
      char name_buffer[100];
      static int ending=0;
      ending++;
      sprintf(name_buffer, "PYTHON_RING_VAR%d",ending);
      h=enterid(name_buffer,0,RING_CMD,&IDROOT);
      IDRING(h)=r;
      r->ref++;
    }
    rSetHdl(h);
    for(int i=myynest;i>=0;i--) iiLocalRing[i]=r;
}
void export_ring()
{
boost::python::class_<Ring>("Ring", "reference to a Singular ring")
     .def("__str__", Ring_as_str)
     .def("set", ring_set,"equivalent to the singular command setring, which is not mapped as it is a command")
     .def(boost::python::init <>());
}
#endif