my.map 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. Ref<AppConfig> O_OBJECT_SLIC3R_T
  159. GLShader* O_OBJECT_SLIC3R
  160. Ref<GLShader> O_OBJECT_SLIC3R_T
  161. GLVolume* O_OBJECT_SLIC3R
  162. Ref<GLVolume> O_OBJECT_SLIC3R_T
  163. GLVolumeCollection* O_OBJECT_SLIC3R
  164. Ref<GLVolumeCollection> O_OBJECT_SLIC3R_T
  165. Preset* O_OBJECT_SLIC3R
  166. Ref<Preset> O_OBJECT_SLIC3R_T
  167. PresetCollection* O_OBJECT_SLIC3R
  168. Ref<PresetCollection> O_OBJECT_SLIC3R_T
  169. PresetBundle* O_OBJECT_SLIC3R
  170. Ref<PresetBundle> O_OBJECT_SLIC3R_T
  171. PresetHints* O_OBJECT_SLIC3R
  172. Ref<PresetHints> O_OBJECT_SLIC3R_T
  173. TabIface* O_OBJECT_SLIC3R
  174. Ref<TabIface> O_OBJECT_SLIC3R_T
  175. Axis T_UV
  176. ExtrusionLoopRole T_UV
  177. ExtrusionRole T_UV
  178. ExtrusionSimulationType T_UV
  179. FlowRole T_UV
  180. PrintStep T_UV
  181. PrintObjectStep T_UV
  182. SurfaceType T_UV
  183. ClipperLib::JoinType T_UV
  184. ClipperLib::PolyFillType T_UV
  185. # we return these types whenever we want the items to be cloned
  186. Points T_ARRAYREF
  187. Pointfs T_ARRAYREF
  188. Lines T_ARRAYREF
  189. Polygons T_ARRAYREF
  190. Polylines T_ARRAYREF
  191. ExPolygons T_ARRAYREF
  192. ExtrusionPaths T_ARRAYREF
  193. Surfaces T_ARRAYREF
  194. # we return these types whenever we want the items to be returned
  195. # by reference and marked ::Ref because they're contained in another
  196. # Perl object
  197. Polygons* T_ARRAYREF_PTR
  198. ModelObjectPtrs* T_PTR_ARRAYREF_PTR
  199. ModelVolumePtrs* T_PTR_ARRAYREF_PTR
  200. ModelInstancePtrs* T_PTR_ARRAYREF_PTR
  201. PrintRegionPtrs* T_PTR_ARRAYREF_PTR
  202. PrintObjectPtrs* T_PTR_ARRAYREF_PTR
  203. LayerPtrs* T_PTR_ARRAYREF_PTR
  204. SupportLayerPtrs* T_PTR_ARRAYREF_PTR
  205. # we return these types whenever we want the items to be returned
  206. # by reference and not marked ::Ref because they're newly allocated
  207. # and not referenced by any Perl object
  208. TriangleMeshPtrs T_PTR_ARRAYREF
  209. INPUT
  210. T_STD_STRING
  211. {
  212. size_t len;
  213. // const char * c = SvPV($arg, len);
  214. // Always convert strings to UTF-8 before passing them to XS
  215. const char * c = SvPVutf8($arg, len);
  216. $var = std::string(c, len);
  217. }
  218. INPUT
  219. T_STD_STRING_LOCAL_ENCODING
  220. {
  221. size_t len;
  222. const char * c = SvPV($arg, len);
  223. $var = std::string(c, len);
  224. }
  225. T_STD_VECTOR_STD_STRING
  226. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  227. AV* av = (AV*)SvRV($arg);
  228. const unsigned int alen = av_len(av)+1;
  229. $var = std::vector<std::string>(alen);
  230. STRLEN len;
  231. char* tmp;
  232. SV** elem;
  233. for (unsigned int i = 0; i < alen; i++) {
  234. elem = av_fetch(av, i, 0);
  235. if (elem != NULL) {
  236. tmp = SvPV(*elem, len);
  237. ${var}[i] = std::string(tmp, len);
  238. }
  239. else
  240. ${var}[i] = std::string(\"\");
  241. }
  242. }
  243. else
  244. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  245. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  246. \"$var\");
  247. T_STD_VECTOR_INT
  248. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  249. AV* av = (AV*)SvRV($arg);
  250. const unsigned int len = av_len(av)+1;
  251. $var = std::vector<int>(len);
  252. SV** elem;
  253. for (unsigned int i = 0; i < len; i++) {
  254. elem = av_fetch(av, i, 0);
  255. if (elem != NULL)
  256. ${var}[i] = SvIV(*elem);
  257. else
  258. ${var}[i] = 0;
  259. }
  260. }
  261. else
  262. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  263. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  264. \"$var\");
  265. T_STD_VECTOR_UINT
  266. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  267. AV* av = (AV*)SvRV($arg);
  268. const unsigned int len = av_len(av)+1;
  269. $var = std::vector<unsigned int>(len);
  270. SV** elem;
  271. for (unsigned int i = 0; i < len; i++) {
  272. elem = av_fetch(av, i, 0);
  273. if (elem != NULL)
  274. ${var}[i] = SvUV(*elem);
  275. else
  276. ${var}[i] = 0;
  277. }
  278. }
  279. else
  280. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  281. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  282. \"$var\");
  283. T_STD_VECTOR_DOUBLE
  284. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  285. AV* av = (AV*)SvRV($arg);
  286. const unsigned int len = av_len(av)+1;
  287. $var = std::vector<double>(len);
  288. SV** elem;
  289. for (unsigned int i = 0; i < len; i++) {
  290. elem = av_fetch(av, i, 0);
  291. if (elem != NULL)
  292. ${var}[i] = SvNV(*elem);
  293. else
  294. ${var}[i] = 0.;
  295. }
  296. }
  297. else
  298. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  299. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  300. \"$var\");
  301. O_OBJECT_SLIC3R
  302. if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
  303. if ( sv_isa($arg, Slic3r::perl_class_name($var) ) || sv_isa($arg, Slic3r::perl_class_name_ref($var) )) {
  304. $var = ($type)SvIV((SV*)SvRV( $arg ));
  305. } else {
  306. croak(\"$var is not of type %s (got %s)\", Slic3r::perl_class_name($var), HvNAME(SvSTASH(SvRV($arg))));
  307. XSRETURN_UNDEF;
  308. }
  309. } else {
  310. warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
  311. XSRETURN_UNDEF;
  312. }
  313. T_ARRAYREF
  314. if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
  315. AV* av = (AV*)SvRV($arg);
  316. const unsigned int len = av_len(av)+1;
  317. $var.resize(len);
  318. for (unsigned int i = 0; i < len; i++) {
  319. SV** elem = av_fetch(av, i, 0);
  320. from_SV_check(*elem, &$var\[i]);
  321. }
  322. } else
  323. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  324. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  325. \"$var\");
  326. T_LAYER_HEIGHT_RANGES
  327. {
  328. if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) {
  329. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  330. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  331. \"$var\");
  332. }
  333. AV* av = (AV*)SvRV($arg);
  334. const unsigned int len = av_len(av)+1;
  335. t_layer_height_ranges tmp_ranges;
  336. for (unsigned int i = 0; i < len; i++) {
  337. SV* elem = *av_fetch(av, i, 0);
  338. if (!SvROK(elem) || SvTYPE(SvRV(elem)) != SVt_PVAV) {
  339. Perl_croak(
  340. aTHX_ \"%s: %s contains something that is not an array reference\",
  341. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  342. \"$var\");
  343. }
  344. AV* elemAV = (AV*)SvRV(elem);
  345. if (av_len(elemAV) + 1 != 3) {
  346. Perl_croak(
  347. aTHX_ \"%s: %s contains an array that isn't 3 elements long\",
  348. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  349. \"$var\");
  350. }
  351. coordf_t vals[3];
  352. for (unsigned int j = 0; j < 3; ++j) {
  353. SV *elem_elem = *av_fetch(elemAV, j, 0);
  354. if (!looks_like_number(elem_elem)) {
  355. Perl_croak(
  356. aTHX_ \"%s: layer ranges and heights must be numbers\",
  357. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]});
  358. }
  359. vals[j] = SvNV(elem_elem);
  360. }
  361. tmp_ranges[t_layer_height_range(vals[0], vals[1])] = vals[2];
  362. }
  363. $var = tmp_ranges;
  364. }
  365. OUTPUT
  366. T_STD_STRING
  367. $arg = newSVpvn_utf8( $var.c_str(), $var.length(), true );
  368. T_STD_STRING_LOCAL_ENCODING
  369. $arg = newSVpvn( $var.c_str(), $var.length() );
  370. T_STD_VECTOR_STD_STRING
  371. AV* av = newAV();
  372. $arg = newRV_noinc((SV*)av);
  373. sv_2mortal($arg);
  374. const unsigned int len = $var.size();
  375. if (len)
  376. av_extend(av, len-1);
  377. for (unsigned int i = 0; i < len; i++) {
  378. const std::string& str = ${var}[i];
  379. STRLEN len = str.length();
  380. av_store(av, i, newSVpvn_utf8(str.c_str(), len, true));
  381. }
  382. T_STD_VECTOR_INT
  383. AV* av = newAV();
  384. $arg = newRV_noinc((SV*)av);
  385. sv_2mortal($arg);
  386. const unsigned int len = $var.size();
  387. if (len)
  388. av_extend(av, len-1);
  389. for (unsigned int i = 0; i < len; i++) {
  390. av_store(av, i, newSViv(${var}[i]));
  391. }
  392. T_STD_VECTOR_UINT
  393. AV* av = newAV();
  394. $arg = newRV_noinc((SV*)av);
  395. sv_2mortal($arg);
  396. const unsigned int len = $var.size();
  397. if (len)
  398. av_extend(av, len-1);
  399. for (unsigned int i = 0; i < len; i++) {
  400. av_store(av, i, newSVuv(${var}[i]));
  401. }
  402. T_STD_VECTOR_DOUBLE
  403. AV* av = newAV();
  404. $arg = newRV_noinc((SV*)av);
  405. sv_2mortal($arg);
  406. const unsigned int len = $var.size();
  407. if (len)
  408. av_extend(av, len-1);
  409. for (unsigned int i = 0; i < len; i++) {
  410. av_store(av, i, newSVnv(${var}[i]));
  411. }
  412. # return object from pointer
  413. O_OBJECT_SLIC3R
  414. if ($var == NULL)
  415. XSRETURN_UNDEF;
  416. sv_setref_pv( $arg, Slic3r::perl_class_name($var), (void*)$var );
  417. # return value handled by template class
  418. O_OBJECT_SLIC3R_T
  419. if ($var == NULL)
  420. XSRETURN_UNDEF;
  421. sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );
  422. T_ARRAYREF
  423. AV* av = newAV();
  424. $arg = newRV_noinc((SV*)av);
  425. sv_2mortal($arg);
  426. const unsigned int len = $var.size();
  427. if (len > 0) av_extend(av, len-1);
  428. int i = 0;
  429. for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) {
  430. av_store(av, i++, perl_to_SV_clone_ref(*it));
  431. }
  432. T_ARRAYREF_PTR
  433. AV* av = newAV();
  434. $arg = newRV_noinc((SV*)av);
  435. sv_2mortal($arg);
  436. const unsigned int len = $var->size();
  437. if (len > 0) av_extend(av, len-1);
  438. int i = 0;
  439. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  440. av_store(av, i++, perl_to_SV_ref(*it));
  441. }
  442. T_PTR_ARRAYREF_PTR
  443. AV* av = newAV();
  444. $arg = newRV_noinc((SV*)av);
  445. sv_2mortal($arg);
  446. const unsigned int len = $var->size();
  447. if (len > 0) av_extend(av, len-1);
  448. int i = 0;
  449. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  450. av_store(av, i++, perl_to_SV_ref(**it));
  451. }
  452. T_PTR_ARRAYREF
  453. AV* av = newAV();
  454. $arg = newRV_noinc((SV*)av);
  455. sv_2mortal($arg);
  456. const unsigned int len = $var.size();
  457. if (len > 0) av_extend(av, len-1);
  458. int i = 0;
  459. for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
  460. av_store(av, i++, to_SV(*it));
  461. }
  462. T_LAYER_HEIGHT_RANGES
  463. AV* av = newAV();
  464. $arg = newRV_noinc((SV*)av);
  465. sv_2mortal($arg);
  466. const unsigned int len = $var.size();
  467. if (len > 0) av_extend(av, len-1);
  468. // map is sorted, so we can just copy it in order
  469. int i = 0;
  470. for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
  471. const coordf_t range_values[] = {
  472. it->first.first, // key's first = minz
  473. it->first.second, // key's second = maxz
  474. it->second, // value = height
  475. };
  476. AV *rangeAV = newAV();
  477. av_extend(rangeAV, 2);
  478. for (int j = 0; j < 3; ++j) {
  479. av_store(rangeAV, j, newSVnv(range_values[j]));
  480. }
  481. av_store(av, i++, (SV*)newRV_noinc((SV*)rangeAV));
  482. }