my.map 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  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. ClipperLib::JoinType T_UV
  157. 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. TriangleMeshPtrs T_PTR_ARRAYREF
  182. INPUT
  183. T_STD_STRING
  184. {
  185. size_t len;
  186. // const char * c = SvPV($arg, len);
  187. // Always convert strings to UTF-8 before passing them to XS
  188. const char * c = SvPVutf8($arg, len);
  189. $var = std::string(c, len);
  190. }
  191. INPUT
  192. T_STD_STRING_LOCAL_ENCODING
  193. {
  194. size_t len;
  195. const char * c = SvPV($arg, len);
  196. $var = std::string(c, len);
  197. }
  198. T_STD_VECTOR_STD_STRING
  199. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  200. AV* av = (AV*)SvRV($arg);
  201. const unsigned int alen = av_len(av)+1;
  202. $var = std::vector<std::string>(alen);
  203. STRLEN len;
  204. char* tmp;
  205. SV** elem;
  206. for (unsigned int i = 0; i < alen; i++) {
  207. elem = av_fetch(av, i, 0);
  208. if (elem != NULL) {
  209. tmp = SvPV(*elem, len);
  210. ${var}[i] = std::string(tmp, len);
  211. }
  212. else
  213. ${var}[i] = std::string(\"\");
  214. }
  215. }
  216. else
  217. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  218. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  219. \"$var\");
  220. T_STD_VECTOR_INT
  221. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  222. AV* av = (AV*)SvRV($arg);
  223. const unsigned int len = av_len(av)+1;
  224. $var = std::vector<int>(len);
  225. SV** elem;
  226. for (unsigned int i = 0; i < len; i++) {
  227. elem = av_fetch(av, i, 0);
  228. if (elem != NULL)
  229. ${var}[i] = SvIV(*elem);
  230. else
  231. ${var}[i] = 0;
  232. }
  233. }
  234. else
  235. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  236. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  237. \"$var\");
  238. T_STD_VECTOR_UINT
  239. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  240. AV* av = (AV*)SvRV($arg);
  241. const unsigned int len = av_len(av)+1;
  242. $var = std::vector<unsigned int>(len);
  243. SV** elem;
  244. for (unsigned int i = 0; i < len; i++) {
  245. elem = av_fetch(av, i, 0);
  246. if (elem != NULL)
  247. ${var}[i] = SvUV(*elem);
  248. else
  249. ${var}[i] = 0;
  250. }
  251. }
  252. else
  253. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  254. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  255. \"$var\");
  256. T_STD_VECTOR_DOUBLE
  257. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  258. AV* av = (AV*)SvRV($arg);
  259. const unsigned int len = av_len(av)+1;
  260. $var = std::vector<double>(len);
  261. SV** elem;
  262. for (unsigned int i = 0; i < len; i++) {
  263. elem = av_fetch(av, i, 0);
  264. if (elem != NULL)
  265. ${var}[i] = SvNV(*elem);
  266. else
  267. ${var}[i] = 0.;
  268. }
  269. }
  270. else
  271. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  272. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  273. \"$var\");
  274. O_OBJECT_SLIC3R
  275. if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
  276. if ( sv_isa($arg, Slic3r::perl_class_name($var) ) || sv_isa($arg, Slic3r::perl_class_name_ref($var) )) {
  277. $var = ($type)SvIV((SV*)SvRV( $arg ));
  278. } else {
  279. croak(\"$var is not of type %s (got %s)\", Slic3r::perl_class_name($var), HvNAME(SvSTASH(SvRV($arg))));
  280. XSRETURN_UNDEF;
  281. }
  282. } else {
  283. warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
  284. XSRETURN_UNDEF;
  285. }
  286. T_ARRAYREF
  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.resize(len);
  291. for (unsigned int i = 0; i < len; i++) {
  292. SV** elem = av_fetch(av, i, 0);
  293. from_SV_check(*elem, &$var\[i]);
  294. }
  295. } else
  296. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  297. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  298. \"$var\");
  299. T_LAYER_HEIGHT_RANGES
  300. {
  301. if (!SvROK($arg) || SvTYPE(SvRV($arg)) != SVt_PVAV) {
  302. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  303. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  304. \"$var\");
  305. }
  306. AV* av = (AV*)SvRV($arg);
  307. const unsigned int len = av_len(av)+1;
  308. t_layer_height_ranges tmp_ranges;
  309. for (unsigned int i = 0; i < len; i++) {
  310. SV* elem = *av_fetch(av, i, 0);
  311. if (!SvROK(elem) || SvTYPE(SvRV(elem)) != SVt_PVAV) {
  312. Perl_croak(
  313. aTHX_ \"%s: %s contains something that is not an array reference\",
  314. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  315. \"$var\");
  316. }
  317. AV* elemAV = (AV*)SvRV(elem);
  318. if (av_len(elemAV) + 1 != 3) {
  319. Perl_croak(
  320. aTHX_ \"%s: %s contains an array that isn't 3 elements long\",
  321. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  322. \"$var\");
  323. }
  324. coordf_t vals[3];
  325. for (unsigned int j = 0; j < 3; ++j) {
  326. SV *elem_elem = *av_fetch(elemAV, j, 0);
  327. if (!looks_like_number(elem_elem)) {
  328. Perl_croak(
  329. aTHX_ \"%s: layer ranges and heights must be numbers\",
  330. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]});
  331. }
  332. vals[j] = SvNV(elem_elem);
  333. }
  334. tmp_ranges[t_layer_height_range(vals[0], vals[1])] = vals[2];
  335. }
  336. $var = tmp_ranges;
  337. }
  338. OUTPUT
  339. T_STD_STRING
  340. $arg = newSVpvn_utf8( $var.c_str(), $var.length(), true );
  341. T_STD_STRING_LOCAL_ENCODING
  342. $arg = newSVpvn( $var.c_str(), $var.length() );
  343. T_STD_VECTOR_STD_STRING
  344. AV* av = newAV();
  345. $arg = newRV_noinc((SV*)av);
  346. sv_2mortal($arg);
  347. const unsigned int len = $var.size();
  348. if (len)
  349. av_extend(av, len-1);
  350. for (unsigned int i = 0; i < len; i++) {
  351. const std::string& str = ${var}[i];
  352. STRLEN len = str.length();
  353. av_store(av, i, newSVpvn_utf8(str.c_str(), len, true));
  354. }
  355. T_STD_VECTOR_INT
  356. AV* av = newAV();
  357. $arg = newRV_noinc((SV*)av);
  358. sv_2mortal($arg);
  359. const unsigned int len = $var.size();
  360. if (len)
  361. av_extend(av, len-1);
  362. for (unsigned int i = 0; i < len; i++) {
  363. av_store(av, i, newSViv(${var}[i]));
  364. }
  365. T_STD_VECTOR_UINT
  366. AV* av = newAV();
  367. $arg = newRV_noinc((SV*)av);
  368. sv_2mortal($arg);
  369. const unsigned int len = $var.size();
  370. if (len)
  371. av_extend(av, len-1);
  372. for (unsigned int i = 0; i < len; i++) {
  373. av_store(av, i, newSVuv(${var}[i]));
  374. }
  375. T_STD_VECTOR_DOUBLE
  376. AV* av = newAV();
  377. $arg = newRV_noinc((SV*)av);
  378. sv_2mortal($arg);
  379. const unsigned int len = $var.size();
  380. if (len)
  381. av_extend(av, len-1);
  382. for (unsigned int i = 0; i < len; i++) {
  383. av_store(av, i, newSVnv(${var}[i]));
  384. }
  385. # return object from pointer
  386. O_OBJECT_SLIC3R
  387. if ($var == NULL)
  388. XSRETURN_UNDEF;
  389. sv_setref_pv( $arg, Slic3r::perl_class_name($var), (void*)$var );
  390. # return value handled by template class
  391. O_OBJECT_SLIC3R_T
  392. if ($var == NULL)
  393. XSRETURN_UNDEF;
  394. sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );
  395. T_ARRAYREF
  396. AV* av = newAV();
  397. $arg = newRV_noinc((SV*)av);
  398. sv_2mortal($arg);
  399. const unsigned int len = $var.size();
  400. if (len > 0) av_extend(av, len-1);
  401. int i = 0;
  402. for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) {
  403. av_store(av, i++, perl_to_SV_clone_ref(*it));
  404. }
  405. T_ARRAYREF_PTR
  406. AV* av = newAV();
  407. $arg = newRV_noinc((SV*)av);
  408. sv_2mortal($arg);
  409. const unsigned int len = $var->size();
  410. if (len > 0) av_extend(av, len-1);
  411. int i = 0;
  412. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  413. av_store(av, i++, perl_to_SV_ref(*it));
  414. }
  415. T_PTR_ARRAYREF_PTR
  416. AV* av = newAV();
  417. $arg = newRV_noinc((SV*)av);
  418. sv_2mortal($arg);
  419. const unsigned int len = $var->size();
  420. if (len > 0) av_extend(av, len-1);
  421. int i = 0;
  422. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  423. av_store(av, i++, perl_to_SV_ref(**it));
  424. }
  425. T_PTR_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}::iterator it = $var.begin(); it != $var.end(); ++it) {
  433. av_store(av, i++, to_SV(*it));
  434. }
  435. T_LAYER_HEIGHT_RANGES
  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. // map is sorted, so we can just copy it in order
  442. int i = 0;
  443. for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
  444. const coordf_t range_values[] = {
  445. it->first.first, // key's first = minz
  446. it->first.second, // key's second = maxz
  447. it->second, // value = height
  448. };
  449. AV *rangeAV = newAV();
  450. av_extend(rangeAV, 2);
  451. for (int j = 0; j < 3; ++j) {
  452. av_store(rangeAV, j, newSVnv(range_values[j]));
  453. }
  454. av_store(av, i++, (SV*)newRV_noinc((SV*)rangeAV));
  455. }