mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-11-02 12:41:18 -07:00
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:
parent
e68b6b6f4c
commit
115aa6885f
35 changed files with 426 additions and 173 deletions
|
|
@ -3,13 +3,14 @@
|
|||
%{
|
||||
#include <myinit.h>
|
||||
#include "Point.hpp"
|
||||
#include "perlglue.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Point} class Point {
|
||||
Point(long _x = 0, long _y = 0);
|
||||
~Point();
|
||||
Point* clone()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(*THIS); %};
|
||||
Clone<Point> clone()
|
||||
%code{% RETVAL=THIS; %};
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
SV* arrayref()
|
||||
|
|
@ -22,7 +23,7 @@
|
|||
%code{% RETVAL = THIS->y; %};
|
||||
int nearest_point_index(Points points);
|
||||
Point* nearest_point(Points points)
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %};
|
||||
%code{% RETVAL = new Point(); THIS->nearest_point(points, RETVAL); %};
|
||||
double distance_to(Point* point)
|
||||
%code{% RETVAL = THIS->distance_to(*point); %};
|
||||
double distance_to_line(Line* line)
|
||||
|
|
@ -58,8 +59,8 @@ Point::coincides_with(point_sv)
|
|||
%name{Slic3r::Pointf3} class Pointf3 {
|
||||
Pointf3(double _x = 0, double _y = 0, double _z = 0);
|
||||
~Pointf3();
|
||||
Pointf3* clone()
|
||||
%code{% const char* CLASS = "Slic3r::Pointf3"; RETVAL = new Pointf3(*THIS); %};
|
||||
Clone<Pointf3> clone()
|
||||
%code{% RETVAL = THIS; %};
|
||||
double x()
|
||||
%code{% RETVAL = THIS->x; %};
|
||||
double y()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue