my.map 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. coordf_t T_NV
  2. std::string T_STD_STRING
  3. t_config_option_key T_STD_STRING
  4. t_model_material_id T_STD_STRING
  5. std::vector<std::string> T_STD_VECTOR_STD_STRING
  6. std::vector<int> T_STD_VECTOR_INT
  7. std::vector<Points::size_type> T_STD_VECTOR_INT
  8. std::vector<size_t> T_STD_VECTOR_INT
  9. std::vector<unsigned int> T_STD_VECTOR_UINT
  10. std::vector<double> T_STD_VECTOR_DOUBLE
  11. DynamicPrintConfig* O_OBJECT_SLIC3R
  12. Ref<DynamicPrintConfig> O_OBJECT_SLIC3R_T
  13. Clone<DynamicPrintConfig> O_OBJECT_SLIC3R_T
  14. StaticPrintConfig* O_OBJECT_SLIC3R
  15. Ref<StaticPrintConfig> O_OBJECT_SLIC3R_T
  16. GCodeConfig* O_OBJECT_SLIC3R
  17. Ref<GCodeConfig> O_OBJECT_SLIC3R_T
  18. PrintConfig* O_OBJECT_SLIC3R
  19. Ref<PrintConfig> O_OBJECT_SLIC3R_T
  20. FullPrintConfig* O_OBJECT_SLIC3R
  21. Ref<FullPrintConfig> O_OBJECT_SLIC3R_T
  22. TriangleMesh* O_OBJECT_SLIC3R
  23. Ref<TriangleMesh> O_OBJECT_SLIC3R_T
  24. Clone<TriangleMesh> O_OBJECT_SLIC3R_T
  25. Point* O_OBJECT_SLIC3R
  26. Ref<Point> O_OBJECT_SLIC3R_T
  27. Clone<Point> O_OBJECT_SLIC3R_T
  28. Point3* O_OBJECT_SLIC3R
  29. Ref<Point3> O_OBJECT_SLIC3R_T
  30. Clone<Point3> O_OBJECT_SLIC3R_T
  31. Vec2d* O_OBJECT_SLIC3R
  32. Ref<Vec2d> O_OBJECT_SLIC3R_T
  33. Clone<Vec2d> O_OBJECT_SLIC3R_T
  34. Vec3d* O_OBJECT_SLIC3R
  35. Ref<Vec3d> O_OBJECT_SLIC3R_T
  36. Clone<Vec3d> O_OBJECT_SLIC3R_T
  37. Line* O_OBJECT_SLIC3R
  38. Ref<Line> O_OBJECT_SLIC3R_T
  39. Clone<Line> O_OBJECT_SLIC3R_T
  40. Polyline* O_OBJECT_SLIC3R
  41. Ref<Polyline> O_OBJECT_SLIC3R_T
  42. Clone<Polyline> O_OBJECT_SLIC3R_T
  43. Polygon* O_OBJECT_SLIC3R
  44. Ref<Polygon> O_OBJECT_SLIC3R_T
  45. Clone<Polygon> O_OBJECT_SLIC3R_T
  46. ExPolygon* O_OBJECT_SLIC3R
  47. Ref<ExPolygon> O_OBJECT_SLIC3R_T
  48. Clone<ExPolygon> O_OBJECT_SLIC3R_T
  49. Model* O_OBJECT_SLIC3R
  50. Ref<Model> O_OBJECT_SLIC3R_T
  51. Clone<Model> O_OBJECT_SLIC3R_T
  52. ModelMaterial* O_OBJECT_SLIC3R
  53. Ref<ModelMaterial> O_OBJECT_SLIC3R_T
  54. Clone<ModelMaterial> O_OBJECT_SLIC3R_T
  55. ModelObject* O_OBJECT_SLIC3R
  56. Ref<ModelObject> O_OBJECT_SLIC3R_T
  57. Clone<ModelObject> O_OBJECT_SLIC3R_T
  58. ModelVolume* O_OBJECT_SLIC3R
  59. Ref<ModelVolume> O_OBJECT_SLIC3R_T
  60. Clone<ModelVolume> O_OBJECT_SLIC3R_T
  61. ModelInstance* O_OBJECT_SLIC3R
  62. Ref<ModelInstance> O_OBJECT_SLIC3R_T
  63. Clone<ModelInstance> O_OBJECT_SLIC3R_T
  64. Print* O_OBJECT_SLIC3R
  65. Ref<Print> O_OBJECT_SLIC3R_T
  66. Clone<Print> O_OBJECT_SLIC3R_T
  67. Axis T_UV
  68. ExtrusionLoopRole T_UV
  69. ExtrusionRole T_UV
  70. SurfaceType T_UV
  71. # we return these types whenever we want the items to be cloned
  72. Points T_ARRAYREF
  73. Pointfs T_ARRAYREF
  74. Lines T_ARRAYREF
  75. Polygons T_ARRAYREF
  76. Polylines T_ARRAYREF
  77. ExPolygons T_ARRAYREF
  78. # we return these types whenever we want the items to be returned
  79. # by reference and marked ::Ref because they're contained in another
  80. # Perl object
  81. Polygons* T_ARRAYREF_PTR
  82. ModelObjectPtrs* T_PTR_ARRAYREF_PTR
  83. ModelVolumePtrs* T_PTR_ARRAYREF_PTR
  84. ModelInstancePtrs* T_PTR_ARRAYREF_PTR
  85. # we return these types whenever we want the items to be returned
  86. # by reference and not marked ::Ref because they're newly allocated
  87. # and not referenced by any Perl object
  88. INPUT
  89. T_STD_STRING
  90. {
  91. size_t len;
  92. // const char * c = SvPV($arg, len);
  93. // Always convert strings to UTF-8 before passing them to XS
  94. const char * c = SvPVutf8($arg, len);
  95. $var = std::string(c, len);
  96. }
  97. T_STD_VECTOR_STD_STRING
  98. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  99. AV* av = (AV*)SvRV($arg);
  100. const unsigned int alen = av_len(av)+1;
  101. $var = std::vector<std::string>(alen);
  102. STRLEN len;
  103. char* tmp;
  104. SV** elem;
  105. for (unsigned int i = 0; i < alen; i++) {
  106. elem = av_fetch(av, i, 0);
  107. if (elem != NULL) {
  108. tmp = SvPV(*elem, len);
  109. ${var}[i] = std::string(tmp, len);
  110. }
  111. else
  112. ${var}[i] = std::string(\"\");
  113. }
  114. }
  115. else
  116. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  117. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  118. \"$var\");
  119. T_STD_VECTOR_INT
  120. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  121. AV* av = (AV*)SvRV($arg);
  122. const unsigned int len = av_len(av)+1;
  123. $var = std::vector<int>(len);
  124. SV** elem;
  125. for (unsigned int i = 0; i < len; i++) {
  126. elem = av_fetch(av, i, 0);
  127. if (elem != NULL)
  128. ${var}[i] = SvIV(*elem);
  129. else
  130. ${var}[i] = 0;
  131. }
  132. }
  133. else
  134. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  135. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  136. \"$var\");
  137. T_STD_VECTOR_UINT
  138. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  139. AV* av = (AV*)SvRV($arg);
  140. const unsigned int len = av_len(av)+1;
  141. $var = std::vector<unsigned int>(len);
  142. SV** elem;
  143. for (unsigned int i = 0; i < len; i++) {
  144. elem = av_fetch(av, i, 0);
  145. if (elem != NULL)
  146. ${var}[i] = SvUV(*elem);
  147. else
  148. ${var}[i] = 0;
  149. }
  150. }
  151. else
  152. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  153. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  154. \"$var\");
  155. T_STD_VECTOR_DOUBLE
  156. if (SvROK($arg) && SvTYPE(SvRV($arg))==SVt_PVAV) {
  157. AV* av = (AV*)SvRV($arg);
  158. const unsigned int len = av_len(av)+1;
  159. $var = std::vector<double>(len);
  160. SV** elem;
  161. for (unsigned int i = 0; i < len; i++) {
  162. elem = av_fetch(av, i, 0);
  163. if (elem != NULL)
  164. ${var}[i] = SvNV(*elem);
  165. else
  166. ${var}[i] = 0.;
  167. }
  168. }
  169. else
  170. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  171. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  172. \"$var\");
  173. O_OBJECT_SLIC3R
  174. if( sv_isobject($arg) && (SvTYPE(SvRV($arg)) == SVt_PVMG) ) {
  175. if ( sv_isa($arg, Slic3r::perl_class_name($var) ) || sv_isa($arg, Slic3r::perl_class_name_ref($var) )) {
  176. $var = ($type)SvIV((SV*)SvRV( $arg ));
  177. } else {
  178. croak(\"$var is not of type %s (got %s)\", Slic3r::perl_class_name($var), HvNAME(SvSTASH(SvRV($arg))));
  179. XSRETURN_UNDEF;
  180. }
  181. } else {
  182. warn( \"${Package}::$func_name() -- $var is not a blessed SV reference\" );
  183. XSRETURN_UNDEF;
  184. }
  185. T_ARRAYREF
  186. if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV) {
  187. AV* av = (AV*)SvRV($arg);
  188. const unsigned int len = av_len(av)+1;
  189. $var.resize(len);
  190. for (unsigned int i = 0; i < len; i++) {
  191. SV** elem = av_fetch(av, i, 0);
  192. from_SV_check(*elem, &$var\[i]);
  193. }
  194. } else
  195. Perl_croak(aTHX_ \"%s: %s is not an array reference\",
  196. ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]},
  197. \"$var\");
  198. OUTPUT
  199. T_STD_STRING
  200. $arg = newSVpvn_utf8( $var.c_str(), $var.length(), true );
  201. T_STD_VECTOR_STD_STRING
  202. AV* av = newAV();
  203. $arg = newRV_noinc((SV*)av);
  204. sv_2mortal($arg);
  205. const unsigned int len = $var.size();
  206. if (len)
  207. av_extend(av, len-1);
  208. for (unsigned int i = 0; i < len; i++) {
  209. const std::string& str = ${var}[i];
  210. STRLEN len = str.length();
  211. av_store(av, i, newSVpvn_utf8(str.c_str(), len, true));
  212. }
  213. T_STD_VECTOR_INT
  214. AV* av = newAV();
  215. $arg = newRV_noinc((SV*)av);
  216. sv_2mortal($arg);
  217. const unsigned int len = $var.size();
  218. if (len)
  219. av_extend(av, len-1);
  220. for (unsigned int i = 0; i < len; i++) {
  221. av_store(av, i, newSViv(${var}[i]));
  222. }
  223. T_STD_VECTOR_UINT
  224. AV* av = newAV();
  225. $arg = newRV_noinc((SV*)av);
  226. sv_2mortal($arg);
  227. const unsigned int len = $var.size();
  228. if (len)
  229. av_extend(av, len-1);
  230. for (unsigned int i = 0; i < len; i++) {
  231. av_store(av, i, newSVuv(${var}[i]));
  232. }
  233. T_STD_VECTOR_DOUBLE
  234. AV* av = newAV();
  235. $arg = newRV_noinc((SV*)av);
  236. sv_2mortal($arg);
  237. const unsigned int len = $var.size();
  238. if (len)
  239. av_extend(av, len-1);
  240. for (unsigned int i = 0; i < len; i++) {
  241. av_store(av, i, newSVnv(${var}[i]));
  242. }
  243. # return object from pointer
  244. O_OBJECT_SLIC3R
  245. if ($var == NULL)
  246. XSRETURN_UNDEF;
  247. sv_setref_pv( $arg, Slic3r::perl_class_name($var), (void*)$var );
  248. # return value handled by template class
  249. O_OBJECT_SLIC3R_T
  250. if ($var == NULL)
  251. XSRETURN_UNDEF;
  252. sv_setref_pv( $arg, $type\::CLASS(), (void*)$var );
  253. T_ARRAYREF
  254. AV* av = newAV();
  255. $arg = newRV_noinc((SV*)av);
  256. sv_2mortal($arg);
  257. const unsigned int len = $var.size();
  258. if (len > 0) av_extend(av, len-1);
  259. int i = 0;
  260. for (${type}::const_iterator it = $var.begin(); it != $var.end(); ++it) {
  261. av_store(av, i++, perl_to_SV_clone_ref(*it));
  262. }
  263. T_ARRAYREF_PTR
  264. AV* av = newAV();
  265. $arg = newRV_noinc((SV*)av);
  266. sv_2mortal($arg);
  267. const unsigned int len = $var->size();
  268. if (len > 0) av_extend(av, len-1);
  269. int i = 0;
  270. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  271. av_store(av, i++, perl_to_SV_ref(*it));
  272. }
  273. T_PTR_ARRAYREF_PTR
  274. AV* av = newAV();
  275. $arg = newRV_noinc((SV*)av);
  276. sv_2mortal($arg);
  277. const unsigned int len = $var->size();
  278. if (len > 0) av_extend(av, len-1);
  279. int i = 0;
  280. for (${ my $t = $type; $t =~ s/\*$//; \$t }::iterator it = $var->begin(); it != $var->end(); ++it) {
  281. av_store(av, i++, perl_to_SV_ref(**it));
  282. }
  283. T_PTR_ARRAYREF
  284. AV* av = newAV();
  285. $arg = newRV_noinc((SV*)av);
  286. sv_2mortal($arg);
  287. const unsigned int len = $var.size();
  288. if (len > 0) av_extend(av, len-1);
  289. int i = 0;
  290. for (${type}::iterator it = $var.begin(); it != $var.end(); ++it) {
  291. av_store(av, i++, to_SV(*it));
  292. }