Skip to content

Commit

Permalink
fix build problems on Linux/OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Nov 22, 2016
1 parent 9bdad96 commit 03ab1a4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 32 deletions.
31 changes: 18 additions & 13 deletions src/Base/GeometryPyCXX.cpp
Expand Up @@ -23,6 +23,7 @@

#include "PreCompiled.h"
#ifndef _PreComp_
# include <sstream>
#endif

#include "GeometryPyCXX.h"
Expand Down Expand Up @@ -92,20 +93,11 @@ namespace Base {
Vector2dPy::Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds)
: Py::PythonClass<Vector2dPy>::PythonClass(self, args, kwds)
{
}

Vector2dPy::Vector2dPy()
: Py::PythonClass<Vector2dPy>::PythonClass
(reinterpret_cast<Py::PythonClassInstance *>
(Vector2dPy::type_object()), Py::Tuple(), Py::Dict())
{
}
double x=0,y=0;
if (!PyArg_ParseTuple(args.ptr(), "|dd", &x, &y)) {
throw Py::Exception();
}

Vector2dPy::Vector2dPy(double x, double y)
: Py::PythonClass<Vector2dPy>::PythonClass
(reinterpret_cast<Py::PythonClassInstance *>
(Vector2dPy::type_object()), Py::Tuple(), Py::Dict())
{
v.x = x;
v.y = y;
}
Expand All @@ -120,10 +112,23 @@ void Vector2dPy::init_type(void)
behaviors().doc( "Vector2d class" );
behaviors().supportGetattro();
behaviors().supportSetattro();
behaviors().supportRepr();
// Call to make the type ready for use
behaviors().readyType();
}

Py::Object Vector2dPy::repr()
{
Py::Float x(v.x);
Py::Float y(v.y);
std::stringstream str;
str << "Vector2 (";
str << (std::string)x.repr() << ", "<< (std::string)y.repr();
str << ")";

return Py::String(str.str());
}

Py::Object Vector2dPy::getattro(const Py::String &name_)
{
std::string name( name_.as_std_string( "utf-8" ) );
Expand Down
5 changes: 2 additions & 3 deletions src/Base/GeometryPyCXX.h
Expand Up @@ -51,14 +51,13 @@ class BaseExport Vector2dPy : public Py::PythonClass<Vector2dPy>
{
public:
Vector2dPy(Py::PythonClassInstance *self, Py::Tuple &args, Py::Dict &kwds);
Vector2dPy();
Vector2dPy(double, double);
virtual ~Vector2dPy();

static void init_type(void);
Py::Object getattro(const Py::String &name_);
int setattro(const Py::String &name_, const Py::Object &value);
inline const Vector2d& getValue() const {
virtual Py::Object repr();
inline const Vector2d& value() const {
return v;
}
inline void setValue(const Vector2d& n) {
Expand Down
18 changes: 2 additions & 16 deletions src/Mod/Part/App/CMakeLists.txt
Expand Up @@ -83,22 +83,8 @@ generate_from_xml(TopoShapeSolidPy)
generate_from_xml(TopoShapeVertexPy)
generate_from_xml(TopoShapeWirePy)
generate_from_xml(BRepOffsetAPI_MakePipeShellPy)
generate_from_xml(Geom2d/ArcOfCircle2dPy)
generate_from_xml(Geom2d/ArcOfConic2dPy)
generate_from_xml(Geom2d/ArcOfEllipse2dPy)
generate_from_xml(Geom2d/ArcOfHyperbola2dPy)
generate_from_xml(Geom2d/ArcOfParabola2dPy)
generate_from_xml(Geom2d/BezierCurve2dPy)
generate_from_xml(Geom2d/BSplineCurve2dPy)
generate_from_xml(Geom2d/Circle2dPy)
generate_from_xml(Geom2d/Conic2dPy)
generate_from_xml(Geom2d/Ellipse2dPy)
generate_from_xml(Geom2d/Geometry2dPy)
generate_from_xml(Geom2d/Hyperbola2dPy)
generate_from_xml(Geom2d/Curve2dPy)
generate_from_xml(Geom2d/Line2dSegmentPy)
generate_from_xml(Geom2d/OffsetCurve2dPy)
generate_from_xml(Geom2d/Parabola2dPy)

add_subdirectory(Geom2d)

SET(Features_SRCS
FeaturePartBoolean.cpp
Expand Down
16 changes: 16 additions & 0 deletions src/Mod/Part/App/Geom2d/CMakeLists.txt
@@ -0,0 +1,16 @@
generate_from_xml(ArcOfCircle2dPy)
generate_from_xml(ArcOfConic2dPy)
generate_from_xml(ArcOfEllipse2dPy)
generate_from_xml(ArcOfHyperbola2dPy)
generate_from_xml(ArcOfParabola2dPy)
generate_from_xml(BezierCurve2dPy)
generate_from_xml(BSplineCurve2dPy)
generate_from_xml(Circle2dPy)
generate_from_xml(Conic2dPy)
generate_from_xml(Ellipse2dPy)
generate_from_xml(Geometry2dPy)
generate_from_xml(Hyperbola2dPy)
generate_from_xml(Curve2dPy)
generate_from_xml(Line2dSegmentPy)
generate_from_xml(OffsetCurve2dPy)
generate_from_xml(Parabola2dPy)

0 comments on commit 03ab1a4

Please sign in to comment.