my.map 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. coordf_t T_NV
  2. std::string T_STD_STRING
  3. local_encoded_string T_STD_STRING_LOCAL_ENCODING
  4. t_config_option_key T_STD_STRING
  5. t_model_material_id T_STD_STRING
  6. std::vector<std::string> T_STD_VECTOR_STD_STRING
  7. std::vector<int> T_STD_VECTOR_INT
  8. std::vector<Points::size_type> T_STD_VECTOR_INT
  9. std::vector<size_t> T_STD_VECTOR_INT
  10. std::vector<unsigned int> T_STD_VECTOR_UINT
  11. std::vector<double> T_STD_VECTOR_DOUBLE
  12. t_layer_height_ranges T_LAYER_HEIGHT_RANGES
  13. BoundingBox* O_OBJECT_SLIC3R
  14. Ref<BoundingBox> O_OBJECT_SLIC3R_T
  15. Clone<BoundingBox> O_OBJECT_SLIC3R_T
  16. BoundingBoxf* O_OBJECT_SLIC3R
  17. Ref<BoundingBoxf> O_OBJECT_SLIC3R_T
  18. Clone<BoundingBoxf> O_OBJECT_SLIC3R_T
  19. BoundingBoxf3* O_OBJECT_SLIC3R
  20. Ref<BoundingBoxf3> O_OBJECT_SLIC3R_T
  21. Clone<BoundingBoxf3> O_OBJECT_SLIC3R_T
  22. DynamicPrintConfig* O_OBJECT_SLIC3R
  23. Ref<DynamicPrintConfig> O_OBJECT_SLIC3R_T
  24. Clone<DynamicPrintConfig> O_OBJECT_SLIC3R_T
  25. StaticPrintConfig* O_OBJECT_SLIC3R
  26. Ref<StaticPrintConfig> O_OBJECT_SLIC3R_T
  27. PrintObjectConfig* O_OBJECT_SLIC3R
  28. Ref<PrintObjectConfig> O_OBJECT_SLIC3R_T
  29. PrintRegionConfig* O_OBJECT_SLIC3R
  30. Ref<PrintRegionConfig> O_OBJECT_SLIC3R_T
  31. GCodeConfig* O_OBJECT_SLIC3R
  32. Ref<GCodeConfig> O_OBJECT_SLIC3R_T
  33. PrintConfig* O_OBJECT_SLIC3R
  34. Ref<PrintConfig> O_OBJECT_SLIC3R_T
  35. FullPrintConfig* O_OBJECT_SLIC3R
  36. Ref<FullPrintConfig> O_OBJECT_SLIC3R_T
  37. ZTable* O_OBJECT
  38. TriangleMesh* O_OBJECT_SLIC3R
  39. Ref<TriangleMesh> O_OBJECT_SLIC3R_T
  40. Clone<TriangleMesh> O_OBJECT_SLIC3R_T
  41. Point* O_OBJECT_SLIC3R
  42. Ref<Point> O_OBJECT_SLIC3R_T
  43. Clone<Point> O_OBJECT_SLIC3R_T
  44. Point3* O_OBJECT_SLIC3R
  45. Ref<Point3> O_OBJECT_SLIC3R_T
  46. Clone<Point3> O_OBJECT_SLIC3R_T
  47. Pointf* O_OBJECT_SLIC3R
  48. Ref<Pointf> O_OBJECT_SLIC3R_T
  49. Clone<Pointf> O_OBJECT_SLIC3R_T
  50. Pointf3* O_OBJECT_SLIC3R
  51. Ref<Pointf3> O_OBJECT_SLIC3R_T
  52. Clone<Pointf3> O_OBJECT_SLIC3R_T
  53. Line* O_OBJECT_SLIC3R
  54. Ref<Line> O_OBJECT_SLIC3R_T
  55. Clone<Line> O_OBJECT_SLIC3R_T
  56. Linef3* O_OBJECT_SLIC3R
  57. Ref<Linef3> O_OBJECT_SLIC3R_T
  58. Clone<Linef3> O_OBJECT_SLIC3R_T
  59. Polyline* O_OBJECT_SLIC3R
  60. Ref<Polyline> O_OBJECT_SLIC3R_T
  61. Clone<Polyline> O_OBJECT_SLIC3R_T
  62. PolylineCollection* O_OBJECT_SLIC3R
  63. Ref<PolylineCollection> O_OBJECT_SLIC3R_T
  64. Clone<PolylineCollection> O_OBJECT_SLIC3R_T
  65. Polygon* O_OBJECT_SLIC3R
  66. Ref<Polygon> O_OBJECT_SLIC3R_T
  67. Clone<Polygon> O_OBJECT_SLIC3R_T
  68. ExPolygon* O_OBJECT_SLIC3R
  69. Ref<ExPolygon> O_OBJECT_SLIC3R_T
  70. Clone<ExPolygon> O_OBJECT_SLIC3R_T
  71. ExPolygonCollection* O_OBJECT_SLIC3R
  72. Ref<ExPolygonCollection> O_OBJECT_SLIC3R_T
  73. Clone<ExPolygonCollection> O_OBJECT_SLIC3R_T
  74. ExtrusionEntityCollection* O_OBJECT_SLIC3R
  75. Ref<ExtrusionEntityCollection> O_OBJECT_SLIC3R_T
  76. Clone<ExtrusionEntityCollection> O_OBJECT_SLIC3R_T
  77. ExtrusionMultiPath* O_OBJECT_SLIC3R
  78. Ref<ExtrusionMultiPath> O_OBJECT_SLIC3R_T
  79. Clone<ExtrusionMultiPath> O_OBJECT_SLIC3R_T
  80. ExtrusionPath* O_OBJECT_SLIC3R
  81. Ref<ExtrusionPath> O_OBJECT_SLIC3R_T
  82. Clone<ExtrusionPath> O_OBJECT_SLIC3R_T
  83. ExtrusionLoop* O_OBJECT_SLIC3R
  84. Ref<ExtrusionLoop> O_OBJECT_SLIC3R_T
  85. Clone<ExtrusionLoop> O_OBJECT_SLIC3R_T
  86. ExtrusionSimulator* O_OBJECT_SLIC3R
  87. Ref<ExtrusionSimulator> O_OBJECT_SLIC3R_T
  88. Clone<ExtrusionSimulator> O_OBJECT_SLIC3R_T
  89. Filler* O_OBJECT_SLIC3R
  90. Ref<Filler> O_OBJECT_SLIC3R_T
  91. Clone<Filler> O_OBJECT_SLIC3R_T
  92. Flow* O_OBJECT_SLIC3R
  93. Ref<Flow> O_OBJECT_SLIC3R_T
  94. Clone<Flow> O_OBJECT_SLIC3R_T
  95. PrintState* O_OBJECT_SLIC3R
  96. Ref<PrintState> O_OBJECT_SLIC3R_T
  97. Surface* O_OBJECT_SLIC3R
  98. Ref<Surface> O_OBJECT_SLIC3R_T
  99. Clone<Surface> O_OBJECT_SLIC3R_T
  100. SurfaceCollection* O_OBJECT_SLIC3R
  101. Ref<SurfaceCollection> O_OBJECT_SLIC3R_T
  102. Model* O_OBJECT_SLIC3R
  103. Ref<Model> O_OBJECT_SLIC3R_T
  104. Clone<Model> O_OBJECT_SLIC3R_T
  105. ModelMaterial* O_OBJECT_SLIC3R
  106. Ref<ModelMaterial> O_OBJECT_SLIC3R_T
  107. Clone<ModelMaterial> O_OBJECT_SLIC3R_T
  108. ModelObject* O_OBJECT_SLIC3R
  109. Ref<ModelObject> O_OBJECT_SLIC3R_T
  110. Clone<ModelObject> O_OBJECT_SLIC3R_T
  111. ModelVolume* O_OBJECT_SLIC3R
  112. Ref<ModelVolume> O_OBJECT_SLIC3R_T
  113. Clone<ModelVolume> O_OBJECT_SLIC3R_T
  114. ModelInstance* O_OBJECT_SLIC3R
  115. Ref<ModelInstance> O_OBJECT_SLIC3R_T
  116. Clone<ModelInstance> O_OBJECT_SLIC3R_T
  117. PrintRegion* O_OBJECT_SLIC3R
  118. Ref<PrintRegion> O_OBJECT_SLIC3R_T
  119. PrintObject* O_OBJECT_SLIC3R
  120. Ref<PrintObject> O_OBJECT_SLIC3R_T
  121. Print* O_OBJECT_SLIC3R
  122. Ref<Print> O_OBJECT_SLIC3R_T
  123. Clone<Print> O_OBJECT_SLIC3R_T
  124. LayerRegion* O_OBJECT_SLIC3R
  125. Ref<LayerRegion> O_OBJECT_SLIC3R_T
  126. Layer* O_OBJECT_SLIC3R
  127. Ref<Layer> O_OBJECT_SLIC3R_T
  128. SupportLayer* O_OBJECT_SLIC3R
  129. Ref<SupportLayer> O_OBJECT_SLIC3R_T
  130. PlaceholderParser* O_OBJECT_SLIC3R
  131. Ref<PlaceholderParser> O_OBJECT_SLIC3R_T
  132. Clone<PlaceholderParser> O_OBJECT_SLIC3R_T
  133. CoolingBuffer* O_OBJECT_SLIC3R
  134. Ref<CoolingBuffer> O_OBJECT_SLIC3R_T
  135. Clone<CoolingBuffer> O_OBJECT_SLIC3R_T
  136. GCode* O_OBJECT_SLIC3R
  137. Ref<GCode> O_OBJECT_SLIC3R_T
  138. Clone<GCode> O_OBJECT_SLIC3R_T
  139. GCodePreviewData* O_OBJECT_SLIC3R
  140. Ref<GCodePreviewData> O_OBJECT_SLIC3R_T
  141. Clone<GCodePreviewData> O_OBJECT_SLIC3R_T
  142. MotionPlanner* O_OBJECT_SLIC3R
  143. Ref<MotionPlanner> O_OBJECT_SLIC3R_T
  144. Clone<MotionPlanner> O_OBJECT_SLIC3R_T
  145. GCodeSender* O_OBJECT_SLIC3R
  146. Ref<GCodeSender> O_OBJECT_SLIC3R_T
  147. Clone<GCodeSender> O_OBJECT_SLIC3R_T
  148. BridgeDetector* O_OBJECT_SLIC3R
  149. Ref<BridgeDetector> O_OBJECT_SLIC3R_T
  150. Clone<BridgeDetector> O_OBJECT_SLIC3R_T
  151. PerimeterGenerator* O_OBJECT_SLIC3R
  152. Ref<PerimeterGenerator> O_OBJECT_SLIC3R_T
  153. Clone<PerimeterGenerator> O_OBJECT_SLIC3R_T
  154. PrintObjectSupportMaterial* O_OBJECT_SLIC3R
  155. Ref<PrintObjectSupportMaterial> O_OBJECT_SLIC3R_T
  156. Clone<PrintObjectSupportMaterial> O_OBJECT_SLIC3R_T
  157. AppConfig* O_OBJECT_SLIC3R
  158. AppController* O_OBJECT_SLIC3R
  159. PrintController* O_OBJECT_SLIC3R
  160. Ref<AppConfig> O_OBJECT_SLIC3R_T
  161. GLShader* O_OBJECT_SLIC3R
  162. Ref<GLShader> O_OBJECT_SLIC3R_T
  163. GLVolume* O_OBJECT_SLIC3R
  164. Ref<GLVolume> O_OBJECT_SLIC3R_T
  165. GLVolumeCollection* O_OBJECT_SLIC3R
  166. Ref<GLVolumeCollection> O_OBJECT_SLIC3R_T
  167. Preset* O_OBJECT_SLIC3R
  168. Ref<Preset> O_OBJECT_SLIC3R_T
  169. PresetCollection* O_OBJECT_SLIC3R
  170. Ref<PresetCollection> O_OBJECT_SLIC3R_T
  171. PresetBundle* O_OBJECT_SLIC3R
  172. Ref<PresetBundle> O_OBJECT_SLIC3R_T
  173. TabIface* O_OBJECT_SLIC3R
  174. Ref<TabIface> O_OBJECT_SLIC3R_T
  175. PresetUpdater* O_OBJECT_SLIC3R
  176. Ref<PresetUpdater> O_OBJECT_SLIC3R_T
  177. PrintHost* O_OBJECT_SLIC3R
  178. Axis T_UV
  179. ExtrusionLoopRole T_UV
  180. ExtrusionRole T_UV
  181. ExtrusionSimulationType T_UV
  182. FlowRole T_UV
  183. PrintStep T_UV
  184. PrintObjectStep T_UV
  185. SurfaceType T_UV
  186. ClipperLib::JoinType T_UV
  187. ClipperLib::PolyFillType T_UV
  188. # we return these types whenever we want the items to be cloned
  189. Points T_ARRAYREF
  190. Pointfs T_ARRAYREF
  191. Lines T_ARRAYREF
  192. Polygons T_ARRAYREF
  193. Polylines T_ARRAYREF
  194. ExPolygons T_ARRAYREF
  195. ExtrusionPaths T_ARRAYREF
  196. Surfaces T_ARRAYREF
  197. # we return these types whenever we want the items to be returned
  198. # by reference and marked ::Ref because they're contained in another
  199. # Perl object
  200. Polygons* T_ARRAYREF_PTR
  201. ModelObjectPtrs* T_PTR_ARRAYREF_PTR
  202. ModelVolumePtrs* T_PTR_ARRAYREF_PTR
  203. ModelInstancePtrs* T_PTR_ARRAYREF_PTR
  204. PrintRegionPtrs* T_PTR_ARRAYREF_PTR
  205. PrintObjectPtrs* T_PTR_ARRAYREF_PTR
  206. LayerPtrs* T_PTR_ARRAYREF_PTR
  207. SupportLayerPtrs* T_PTR_ARRAYREF_PTR
  208. # we return these types whenever we want the items to be returned
  209. # by reference and not marked ::Ref because they're newly allocated
  210. # and not referenced by any Perl object
  211. TriangleMeshPtrs T_PTR_ARRAYREF
  212. INPUT
  213. T_STD_STRING
  214. {
  215. size_t len;
  216. // const char * c = SvPV($arg, len);
  217. // Always convert strings to UTF-8 before passing them to XS
  218. const char * c = SvPVutf8($arg, len);
  219. $var = std::string(c, len);
  220. }
  221. INPUT
  222. T_STD_STRING_LOCAL_ENCODING
  223. {
  224. size_t len;
  225. const char * c = SvPV($arg, len);
  226. $var = std::string(c, len);
  227. }
  228. T_STD_VECTOR_STD_STRING
  229. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  230. AV* av = (AV*)SvRV($arg);
  231. const unsigned int alen = av_len(av)+1;
  232. $var = std::vector<std::string>(alen);
  233. STRLEN len;
  234. char* tmp;
  235. SV** elem;
  236. for (unsigned int i = 0; i < alen; i++) {
  237. elem = av_fetch(av, i, 0);
  238. if (elem != NULL) {
  239. tmp = SvPV(*elem, len);
  240. ${var}[i] = std::string(tmp, len);
  241. }
  242. else
  243. ${var}[i] = std::string(\"\");
  244. }
  245. }
  246. else
  247. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  248. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  249. \"$var\");
  250. T_STD_VECTOR_INT
  251. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  252. AV* av = (AV*)SvRV($arg);
  253. const unsigned int len = av_len(av)+1;
  254. $var = std::vector<int>(len);
  255. SV** elem;
  256. for (unsigned int i = 0; i < len; i++) {
  257. elem = av_fetch(av, i, 0);
  258. if (elem != NULL)
  259. ${var}[i] = SvIV(*elem);
  260. else
  261. ${var}[i] = 0;
  262. }
  263. }
  264. else
  265. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  266. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  267. \"$var\");
  268. T_STD_VECTOR_UINT
  269. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  270. AV* av = (AV*)SvRV($arg);
  271. const unsigned int len = av_len(av)+1;
  272. $var = std::vector<unsigned int>(len);
  273. SV** elem;
  274. for (unsigned int i = 0; i < len; i++) {
  275. elem = av_fetch(av, i, 0);
  276. if (elem != NULL)
  277. ${var}[i] = SvUV(*elem);
  278. else
  279. ${var}[i] = 0;
  280. }
  281. }
  282. else
  283. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  284. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  285. \"$var\");
  286. T_STD_VECTOR_DOUBLE
  287. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  288. AV* av = (AV*)SvRV($arg);
  289. const unsigned int len = av_len(av)+1;
  290. $var = std::vector<double>(len);
  291. SV** elem;
  292. for (unsigned int i = 0; i < len; i++) {
  293. elem = av_fetch(av, i, 0);
  294. if (elem != NULL)
  295. ${var}[i] = SvNV(*elem);
  296. else
  297. ${var}[i] = 0.;
  298. }
  299. }
  300. else
  301. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  302. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  303. \"$var\");
  304. O_OBJECT_SLIC3R
  305. if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
  306. if ( sv_isa($arg, Slic3r::perl_class_name($var) ) || sv_isa($arg, Slic3r::perl_class_name_ref($var) )) {
  307. $var = ($type)SvIV((SV*)SvRV( $arg ));
  308. } else {
  309. croak(\"$var is not of type %s (got %s)\", Slic3r::perl_class_name($var), HvNAME(SvSTASH(SvRV($arg))));
  310. XSRETURN_UNDEF;
  311. }
  312. } else {
  313. warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
  314. XSRETURN_UNDEF;
  315. }
  316. T_ARRAYREF
  317. if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
  318. AV* av = (AV*)SvRV($arg);
  319. const unsigned int len = av_len(av)+1;
  320. $var.resize(len);
  321. for (unsigned int i = 0; i < len; i++) {
  322. SV** elem = av_fetch(av, i, 0);
  323. from_SV_check(*elem, &$var\[i]);
  324. }
  325. } else
  326. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  327. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  328. \"$var\");
  329. T_LAYER_HEIGHT_RANGES
  330. {
  331. if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) {
  332. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  333. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  334. \"$var\");
  335. }
  336. AV* av = (AV*)SvRV($arg);
  337. const unsigned int len = av_len(av)+1;
  338. t_layer_height_ranges tmp_ranges;
  339. for (unsigned int i = 0; i < len; i++) {
  340. SV* elem = *av_fetch(av, i, 0);
  341. if (!SvROK(elem) || SvTYPE(SvRV(elem)) != SVt_PVAV) {
  342. Perl_croak(
  343. aTHX_ \"%s: %s contains something that is not an array reference\",
  344. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  345. \"$var\");
  346. }
  347. AV* elemAV = (AV*)SvRV(elem);
  348. if (av_len(elemAV) + 1 != 3) {
  349. Perl_croak(
  350. aTHX_ \"%s: %s contains an array that isn't 3 elements long\",
  351. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  352. \"$var\");
  353. }
  354. coordf_t vals[3];
  355. for (unsigned int j = 0; j < 3; ++j) {
  356. SV *elem_elem = *av_fetch(elemAV, j, 0);
  357. if (!looks_like_number(elem_elem)) {
  358. Perl_croak(
  359. aTHX_ \"%s: layer ranges and heights must be numbers\",
  360. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]});
  361. }
  362. vals[j] = SvNV(elem_elem);
  363. }
  364. tmp_ranges[t_layer_height_range(vals[0], vals[1])] = vals[2];
  365. }
  366. $var = tmp_ranges;
  367. }
  368. OUTPUT
  369. T_STD_STRING
  370. $arg = newSVpvn_utf8( $var.c_str(), $var.length(), true );
  371. T_STD_STRING_LOCAL_ENCODING
  372. $arg = newSVpvn( $var.c_str(), $var.length() );
  373. T_STD_VECTOR_STD_STRING
  374. AV* av = newAV();
  375. $arg = newRV_noinc((SV*)av);
  376. sv_2mortal($arg);
  377. const unsigned int len = $var.size();
  378. if (len)
  379. av_extend(av, len-1);
  380. for (unsigned int i = 0; i < len; i++) {
  381. const std::string& str = ${var}[i];
  382. STRLEN len = str.length();
  383. av_store(av, i, newSVpvn_utf8(str.c_str(), len, true));
  384. }
  385. T_STD_VECTOR_INT
  386. AV* av = newAV();
  387. $arg = newRV_noinc((SV*)av);
  388. sv_2mortal($arg);
  389. const unsigned int len = $var.size();
  390. if (len)
  391. av_extend(av, len-1);
  392. for (unsigned int i = 0; i < len; i++) {
  393. av_store(av, i, newSViv(${var}[i]));
  394. }
  395. T_STD_VECTOR_UINT
  396. AV* av = newAV();
  397. $arg = newRV_noinc((SV*)av);
  398. sv_2mortal($arg);
  399. const unsigned int len = $var.size();
  400. if (len)
  401. av_extend(av, len-1);
  402. for (unsigned int i = 0; i < len; i++) {
  403. av_store(av, i, newSVuv(${var}[i]));
  404. }
  405. T_STD_VECTOR_DOUBLE
  406. AV* av = newAV();
  407. $arg = newRV_noinc((SV*)av);
  408. sv_2mortal($arg);
  409. const unsigned int len = $var.size();
  410. if (len)
  411. av_extend(av, len-1);
  412. for (unsigned int i = 0; i < len; i++) {
  413. av_store(av, i, newSVnv(${var}[i]));
  414. }
  415. # return object from pointer
  416. O_OBJECT_SLIC3R
  417. if ($var == NULL)
  418. XSRETURN_UNDEF;
  419. sv_setref_pv( $arg, Slic3r::perl_class_name($var), (void*)$var );
  420. # return value handled by template class
  421. O_OBJECT_SLIC3R_T
  422. if ($var == NULL)
  423. XSRETURN_UNDEF;
  424. sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );
  425. T_ARRAYREF
  426. AV* av = newAV();
  427. $arg = newRV_noinc((SV*)av);
  428. sv_2mortal($arg);
  429. const unsigned int len = $var.size();
  430. if (len > 0) av_extend(av, len-1);
  431. int i = 0;
  432. for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) {
  433. av_store(av, i++, perl_to_SV_clone_ref(*it));
  434. }
  435. T_ARRAYREF_PTR
  436. AV* av = newAV();
  437. $arg = newRV_noinc((SV*)av);
  438. sv_2mortal($arg);
  439. const unsigned int len = $var->size();
  440. if (len > 0) av_extend(av, len-1);
  441. int i = 0;
  442. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  443. av_store(av, i++, perl_to_SV_ref(*it));
  444. }
  445. T_PTR_ARRAYREF_PTR
  446. AV* av = newAV();
  447. $arg = newRV_noinc((SV*)av);
  448. sv_2mortal($arg);
  449. const unsigned int len = $var->size();
  450. if (len > 0) av_extend(av, len-1);
  451. int i = 0;
  452. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  453. av_store(av, i++, perl_to_SV_ref(**it));
  454. }
  455. T_PTR_ARRAYREF
  456. AV* av = newAV();
  457. $arg = newRV_noinc((SV*)av);
  458. sv_2mortal($arg);
  459. const unsigned int len = $var.size();
  460. if (len > 0) av_extend(av, len-1);
  461. int i = 0;
  462. for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
  463. av_store(av, i++, to_SV(*it));
  464. }
  465. T_LAYER_HEIGHT_RANGES
  466. AV* av = newAV();
  467. $arg = newRV_noinc((SV*)av);
  468. sv_2mortal($arg);
  469. const unsigned int len = $var.size();
  470. if (len > 0) av_extend(av, len-1);
  471. // map is sorted, so we can just copy it in order
  472. int i = 0;
  473. for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
  474. const coordf_t range_values[] = {
  475. it->first.first, // key's first = minz
  476. it->first.second, // key's second = maxz
  477. it->second, // value = height
  478. };
  479. AV *rangeAV = newAV();
  480. av_extend(rangeAV, 2);
  481. for (int j = 0; j < 3; ++j) {
  482. av_store(rangeAV, j, newSVnv(range_values[j]));
  483. }
  484. av_store(av, i++, (SV*)newRV_noinc((SV*)rangeAV));
  485. }