mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 23:31:13 -06: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,32 +3,31 @@
|
|||
%{
|
||||
#include <myinit.h>
|
||||
#include "Line.hpp"
|
||||
#include "perlglue.hpp"
|
||||
%}
|
||||
|
||||
%name{Slic3r::Line} class Line {
|
||||
~Line();
|
||||
Line* clone()
|
||||
%code{% const char* CLASS = "Slic3r::Line"; RETVAL = new Line(*THIS); %};
|
||||
Clone<Line> clone()
|
||||
%code{% RETVAL = THIS; %};
|
||||
SV* arrayref()
|
||||
%code{% RETVAL = THIS->to_AV(); %};
|
||||
SV* pp()
|
||||
%code{% RETVAL = THIS->to_SV_pureperl(); %};
|
||||
Point* a()
|
||||
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->a); %};
|
||||
Point* b()
|
||||
%code{% const char* CLASS = "Slic3r::Point::Ref"; RETVAL = &(THIS->b); %};
|
||||
Ref<Point> a()
|
||||
%code{% RETVAL=&THIS->a; %};
|
||||
Ref<Point> b()
|
||||
%code{% RETVAL=&THIS->b; %};
|
||||
void reverse();
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
double length();
|
||||
double atan2_();
|
||||
double direction();
|
||||
Point* midpoint()
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = THIS->midpoint(); %};
|
||||
Point* point_at(double distance)
|
||||
%code{% const char* CLASS = "Slic3r::Point"; RETVAL = new Point(THIS->point_at(distance)); %};
|
||||
Point* midpoint();
|
||||
Clone<Point> point_at(double distance);
|
||||
Polyline* as_polyline()
|
||||
%code{% const char* CLASS = "Slic3r::Polyline"; RETVAL = new Polyline(*THIS); %};
|
||||
%code{% RETVAL = new Polyline(*THIS); %};
|
||||
%{
|
||||
|
||||
Line*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue