PrusaSlicer-NonPlainar/xs/xsp/my.map
Petr Ledvina 115aa6885f 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.
2014-04-27 19:38:56 +02:00

177 lines
5.4 KiB
Plaintext

std::vector<Points::size_type> T_STD_VECTOR_INT
std::vector<size_t> T_STD_VECTOR_INT
t_config_option_key T_STD_STRING
BoundingBox* O_OBJECT_SLIC3R
Ref<BoundingBox> O_OBJECT_SLIC3R_T
Clone<BoundingBox> O_OBJECT_SLIC3R_T
BoundingBoxf3* O_OBJECT_SLIC3R
Ref<BoundingBoxf3> O_OBJECT_SLIC3R_T
Clone<BoundingBoxf3> O_OBJECT_SLIC3R_T
DynamicPrintConfig* O_OBJECT_SLIC3R
PrintObjectConfig* O_OBJECT_SLIC3R
PrintRegionConfig* O_OBJECT_SLIC3R
PrintConfig* O_OBJECT_SLIC3R
FullPrintConfig* O_OBJECT_SLIC3R
ZTable* O_OBJECT
TriangleMesh* O_OBJECT_SLIC3R
Ref<TriangleMesh> O_OBJECT_SLIC3R_T
Clone<TriangleMesh> O_OBJECT_SLIC3R_T
Point* O_OBJECT_SLIC3R
Ref<Point> O_OBJECT_SLIC3R_T
Clone<Point> O_OBJECT_SLIC3R_T
Pointf3* O_OBJECT_SLIC3R
Ref<Pointf3> O_OBJECT_SLIC3R_T
Clone<Pointf3> O_OBJECT_SLIC3R_T
Line* O_OBJECT_SLIC3R
Ref<Line> O_OBJECT_SLIC3R_T
Clone<Line> O_OBJECT_SLIC3R_T
Polyline* O_OBJECT_SLIC3R
Ref<Polyline> O_OBJECT_SLIC3R_T
Clone<Polyline> O_OBJECT_SLIC3R_T
PolylineCollection* O_OBJECT_SLIC3R
Ref<PolylineCollection> O_OBJECT_SLIC3R_T
Clone<PolylineCollection> O_OBJECT_SLIC3R_T
Polygon* O_OBJECT_SLIC3R
Ref<Polygon> O_OBJECT_SLIC3R_T
Clone<Polygon> O_OBJECT_SLIC3R_T
ExPolygon* O_OBJECT_SLIC3R
Ref<ExPolygon> O_OBJECT_SLIC3R_T
Clone<ExPolygon> O_OBJECT_SLIC3R_T
ExPolygonCollection* O_OBJECT_SLIC3R
Ref<ExPolygonCollection> O_OBJECT_SLIC3R_T
Clone<ExPolygonCollection> O_OBJECT_SLIC3R_T
ExtrusionEntityCollection* O_OBJECT_SLIC3R
Ref<ExtrusionEntityCollection> O_OBJECT_SLIC3R_T
Clone<ExtrusionEntityCollection> O_OBJECT_SLIC3R_T
ExtrusionPath* O_OBJECT_SLIC3R
Ref<ExtrusionPath> O_OBJECT_SLIC3R_T
Clone<ExtrusionPath> O_OBJECT_SLIC3R_T
ExtrusionLoop* O_OBJECT_SLIC3R
Ref<ExtrusionLoop> O_OBJECT_SLIC3R_T
Clone<ExtrusionLoop> O_OBJECT_SLIC3R_T
Flow* O_OBJECT_SLIC3R
Ref<Flow> O_OBJECT_SLIC3R_T
Clone<Flow> O_OBJECT_SLIC3R_T
PrintState* O_OBJECT_SLIC3R
Surface* O_OBJECT_SLIC3R
Ref<Surface> O_OBJECT_SLIC3R_T
Clone<Surface> O_OBJECT_SLIC3R_T
SurfaceCollection* O_OBJECT_SLIC3R
ExtrusionRole T_UV
FlowRole T_UV
PrintStep T_UV
SurfaceType T_UV
ClipperLib::JoinType T_UV
ClipperLib::PolyFillType T_UV
# we return these types whenever we want the items to be cloned
Points T_ARRAYREF
Pointfs T_ARRAYREF
Lines T_ARRAYREF
Polygons T_ARRAYREF
Polylines T_ARRAYREF
ExPolygons T_ARRAYREF
Surfaces T_ARRAYREF
# we return these types whenever we want the items to be returned
# by reference and marked ::Ref because they're contained in another
# Perl object
Polygons* T_ARRAYREF_PTR
# we return these types whenever we want the items to be returned
# by reference and not marked ::Ref because they're newly allocated
# and not referenced by any Perl object
TriangleMeshPtrs T_PTR_ARRAYREF
INPUT
O_OBJECT_SLIC3R
if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
if ( sv_isa($arg, perl_class_name($var) ) || sv_isa($arg, perl_class_name_ref($var) )) {
$var = ($type)SvIV((SV*)SvRV( $arg ));
} else {
croak(\"$var is not of type %s (got %s)\", perl_class_name($var), HvNAME(SvSTASH(SvRV($arg))));
XSRETURN_UNDEF;
}
} else {
warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
XSRETURN_UNDEF;
}
T_ARRAYREF
if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
AV* av = (AV*)SvRV($arg);
const unsigned int len = av_len(av)+1;
$type* tmp = new $type(len);
for (unsigned int i = 0; i < len; i++) {
SV** elem = av_fetch(av, i, 0);
(*tmp)[i].from_SV_check(*elem);
}
$var = *tmp;
delete tmp;
} else
Perl_croak(aTHX_ \"%s: %s is not an array reference\",
${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
\"$var\");
OUTPUT
# return object from pointer
O_OBJECT_SLIC3R
sv_setref_pv( $arg, perl_class_name($var), (void*)$var );
# return value handled by template class
O_OBJECT_SLIC3R_T
sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );
T_ARRAYREF
AV* av = newAV();
$arg = newRV_noinc((SV*)av);
sv_2mortal($arg);
av_extend(av, $var.size()-1);
int i = 0;
for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) {
av_store(av, i++, it->to_SV_clone_ref());
}
$var.clear();
T_ARRAYREF_PTR
AV* av = newAV();
$arg = newRV_noinc((SV*)av);
sv_2mortal($arg);
av_extend(av, $var->size()-1);
int i = 0;
for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
av_store(av, i++, it->to_SV_ref());
}
T_PTR_ARRAYREF
AV* av = newAV();
$arg = newRV_noinc((SV*)av);
sv_2mortal($arg);
av_extend(av, $var.size()-1);
int i = 0;
for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
av_store(av, i++, (*it)->to_SV());
}