File: intvec_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 (37 lines) | stat: -rw-r--r-- 786 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
#include "kernel/mod2.h"
#ifdef HAVE_PYTHON_MOD
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include "IIntvec.h"
#include "intvec_wrap.h"


using namespace boost::python;
static boost::python::object intvec_as_str(const Intvec& p)
{
  using boost::python::str;
  //ring r=p.getRing();
  str helper;
  list tojoin;
  int i;
  int s=p.size();
  tojoin.append("[");
  for(i=0;i<s;i++){
    tojoin.append(str(p[i]));
    if (i<s-1)
      tojoin.append(", ");
  }
  tojoin.append("]");
  str res=helper.join(tojoin);
  return res;

}

void export_intvec(){
boost::python::class_<Intvec>("IntVector")
      .def("__str__", intvec_as_str)
     .def(boost::python::init <>())
     .def(boost::python::vector_indexing_suite<Intvec>());
}
#endif