Implement type checking for XS objects

Type handling is mainly done using templates.
Template Slic3r::ClassTraits is used to store info about exported types (perl class name). Currently only perl class name and refference name is used.
Template values are initialized by REGISTER_CLASS macro. This macro is used in .cpp file of class ( it needs to be used exactly for each type).

Ref<type> class is used to return value as perl reference. Operator overloading is used to make c++ and XSpp happy, only pointer value should be possible to return.

Clone<type> class is used to return copy of value ( using new and copy constructor). Copy is created on assigment, this should be probably improved (memory leak on multiple assignments).
It is overloaded to be able to return type, type* and type&.

Typechecking in ExtrusionEntityCollection updated to check all passed types.
This commit is contained in:
Petr Ledvina 2014-04-27 19:18:53 +02:00
parent e68b6b6f4c
commit 115aa6885f
35 changed files with 426 additions and 173 deletions

View file

@ -1,8 +1,11 @@
#include <sstream>
#include "ExtrusionEntity.hpp"
#include "ExtrusionEntityCollection.hpp"
#include "ExPolygonCollection.hpp"
#include "ClipperUtils.hpp"
#include <sstream>
#ifdef SLIC3RXS
#include "perlglue.hpp"
#endif
namespace Slic3r {
@ -102,6 +105,9 @@ ExtrusionPath::_inflate_collection(const Polylines &polylines, ExtrusionEntityCo
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExtrusionPath, "ExtrusionPath");
std::string
ExtrusionPath::gcode(SV* extruder, double e, double F,
double xofs, double yofs, std::string extrusion_axis,
@ -212,4 +218,8 @@ ExtrusionLoop::last_point() const
return this->polygon.points.front(); // in polygons, first == last
}
#ifdef SLIC3RXS
REGISTER_CLASS(ExtrusionLoop, "ExtrusionLoop");
#endif
}