Hi all,
I'm helping a student to wrap some C++ code using Cython, and noticed
that the example in the documentation is incomplete. A header file,
Rectangle.h, is provided, but no implementation is given, so the
example cannot be compiled.
It would be great if you could add an implementation (see attached)
and modify the setup.py accordingly, i.e.
Extension(
"rectangle",
["rectangle.pyx", "Rectangle.cc"],
language="c++")
Cheers
Stéfan
#include "Rectangle.h"
#define abs(a) ((a > 0) ? (a) : -(a))
Rectangle::Rectangle(int x0, int y0, int x1, int y1) {
this->x0 = x0;
this->x1 = x1;
this->y0 = y0;
this->y1 = y1;
}
Rectangle::~Rectangle() {}
int Rectangle::getWidth() {
return abs(x0 - x1);
}
int Rectangle::getHeight() {
return abs(y0 - y1);
}
int Rectangle::getArea() {
return abs((x0 - x1) * (y0 - y1));
}
void Rectangle::move(int dx, int dy) {
x0 += dx;
x1 += dx;
y0 += dy;
y1 += dy;
}
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev