1
#include "pycxx_iter.hxx"
2
#include "CXX/Objects.hxx"
4
void IterT::init_type()
6
behaviors().name("IterT");
7
behaviors().doc("IterT(ini_count)");
8
// you must have overwritten the virtual functions
9
// Py::Object iter() and Py::Object iternext()
10
behaviors().supportIter(); // set entries in the Type Table
11
behaviors().supportRepr();
12
add_varargs_method("reversed",&IterT::reversed,"reversed()");
15
class MyIterModule : public Py::ExtensionModule<MyIterModule>
19
MyIterModule() : Py::ExtensionModule<MyIterModule>("pycxx_iter")
22
add_varargs_method("IterT",&MyIterModule::new_IterT,"IterT(from,last)");
23
initialize("MyIterModule documentation"); // register with Python
26
virtual ~MyIterModule() {}
29
Py::Object new_IterT(const Py::Tuple& args)
31
if (args.length() != 2)
33
throw Py::RuntimeError("Incorrect # of args to IterT(from,to).");
35
return Py::asObject(new IterT(Py::Int(args[0]),Py::Int(args[1])));
39
extern "C" void initpycxx_iter()
41
// the following constructor call registers our extension module
42
// with the Python runtime system
43
static MyIterModule* IterTest = new MyIterModule;