my.map 16 KB

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