ruby-dcl 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (319) hide show
  1. data/ChangeLog +321 -0
  2. data/GenWrapper/Makefile +14 -0
  3. data/GenWrapper/cproto2init.rb +41 -0
  4. data/GenWrapper/dcl_narrayed_funcs.rb +181 -0
  5. data/GenWrapper/dcl_rb_footing +29 -0
  6. data/GenWrapper/dcl_rb_heading +129 -0
  7. data/GenWrapper/def.rb +20 -0
  8. data/GenWrapper/elim_ary_size.rb +398 -0
  9. data/GenWrapper/etc/Mk_proto +375 -0
  10. data/GenWrapper/etc/dcl_gen +13 -0
  11. data/GenWrapper/etc/p_header +63 -0
  12. data/GenWrapper/etc/p_init +410 -0
  13. data/GenWrapper/pparse.rb +137 -0
  14. data/GenWrapper/proto/Makefile +35 -0
  15. data/GenWrapper/proto/grph1_00 +17 -0
  16. data/GenWrapper/proto/grph1_csgi.fp +27 -0
  17. data/GenWrapper/proto/grph1_scpack.fp +442 -0
  18. data/GenWrapper/proto/grph1_sgpack.fp +1406 -0
  19. data/GenWrapper/proto/grph1_slpack.fp +316 -0
  20. data/GenWrapper/proto/grph1_stpack.fp +411 -0
  21. data/GenWrapper/proto/grph1_swpack.fp +746 -0
  22. data/GenWrapper/proto/grph2_00 +16 -0
  23. data/GenWrapper/proto/grph2_grpack.fp +139 -0
  24. data/GenWrapper/proto/grph2_ucpack.fp +522 -0
  25. data/GenWrapper/proto/grph2_udpack.fp +692 -0
  26. data/GenWrapper/proto/grph2_uepack.fp +601 -0
  27. data/GenWrapper/proto/grph2_ugpack.fp +436 -0
  28. data/GenWrapper/proto/grph2_uhpack.fp +246 -0
  29. data/GenWrapper/proto/grph2_ulpack.fp +516 -0
  30. data/GenWrapper/proto/grph2_umpack.fp +676 -0
  31. data/GenWrapper/proto/grph2_uspack.fp +989 -0
  32. data/GenWrapper/proto/grph2_uupack.fp +663 -0
  33. data/GenWrapper/proto/grph2_uvpack.fp +246 -0
  34. data/GenWrapper/proto/grph2_uwpack.fp +203 -0
  35. data/GenWrapper/proto/grph2_uxpack.fp +295 -0
  36. data/GenWrapper/proto/grph2_uypack.fp +295 -0
  37. data/GenWrapper/proto/grph2_uzpack.fp +574 -0
  38. data/GenWrapper/proto/math1_00 +12 -0
  39. data/GenWrapper/proto/math1_blklib.fp +58 -0
  40. data/GenWrapper/proto/math1_chrlib.fp +83 -0
  41. data/GenWrapper/proto/math1_fnclib.fp +79 -0
  42. data/GenWrapper/proto/math1_gnmlib.fp +118 -0
  43. data/GenWrapper/proto/math1_gt2dlib.fp +144 -0
  44. data/GenWrapper/proto/math1_ifalib.fp +123 -0
  45. data/GenWrapper/proto/math1_indxlib.fp +222 -0
  46. data/GenWrapper/proto/math1_intlib.fp +46 -0
  47. data/GenWrapper/proto/math1_lrllib.fp +276 -0
  48. data/GenWrapper/proto/math1_maplib.fp +24 -0
  49. data/GenWrapper/proto/math1_oslib.fp +28 -0
  50. data/GenWrapper/proto/math1_rfalib.fp +420 -0
  51. data/GenWrapper/proto/math1_rfblib.fp +51 -0
  52. data/GenWrapper/proto/math1_sublib.fp +60 -0
  53. data/GenWrapper/proto/math1_syslib.fp +767 -0
  54. data/GenWrapper/proto/math1_vialib.fp +339 -0
  55. data/GenWrapper/proto/math1_viblib.fp +264 -0
  56. data/GenWrapper/proto/math1_vralib.fp +339 -0
  57. data/GenWrapper/proto/math1_vrblib.fp +264 -0
  58. data/GenWrapper/proto/math1_xfclib.fp +68 -0
  59. data/GenWrapper/proto/math2_00 +12 -0
  60. data/GenWrapper/proto/math2_fftlib.fp +803 -0
  61. data/GenWrapper/proto/math2_intrlib.fp +32 -0
  62. data/GenWrapper/proto/math2_odelib.fp_notused +568 -0
  63. data/GenWrapper/proto/math2_rnmlib.fp +54 -0
  64. data/GenWrapper/proto/math2_shtlib.fp +1292 -0
  65. data/GenWrapper/proto/math2_shtlib.fp_old +1294 -0
  66. data/GenWrapper/proto/math2_vstlib.fp +84 -0
  67. data/GenWrapper/proto/misc1_00 +17 -0
  68. data/GenWrapper/proto/misc1_chnlib.fp +47 -0
  69. data/GenWrapper/proto/misc1_datelib.fp +352 -0
  70. data/GenWrapper/proto/misc1_fmtlib.fp +19 -0
  71. data/GenWrapper/proto/misc1_misclib.fp +26 -0
  72. data/GenWrapper/proto/misc1_randlib.fp +36 -0
  73. data/GenWrapper/proto/misc1_timelib.fp +151 -0
  74. data/GenWrapper/proto2c.rb +13 -0
  75. data/GenWrapper/prototype.rb +209 -0
  76. data/GenWrapper/util.rb +9 -0
  77. data/GenWrapper/variable.rb +671 -0
  78. data/README +29 -0
  79. data/Rakefile +44 -0
  80. data/ToDo +2 -0
  81. data/dcl_cary2obj.c +354 -0
  82. data/dcl_narrayed_funcs.c +518 -0
  83. data/dcl_obj2cary.c +512 -0
  84. data/dcl_rubydcloriginal.c +129 -0
  85. data/demo/gokuraku/hop/hop.rb +26 -0
  86. data/demo/gokuraku/jump/jump1.rb +64 -0
  87. data/demo/gokuraku/jump/jump2.rb +50 -0
  88. data/demo/gokuraku/layout/lay1.rb +46 -0
  89. data/demo/gokuraku/layout/lay2.rb +44 -0
  90. data/demo/gokuraku/step/step0.rb +34 -0
  91. data/demo/gokuraku/step/step1.rb +84 -0
  92. data/demo/gokuraku/step/step2.rb +62 -0
  93. data/demo/gokuraku/u1d/u1d1.rb +37 -0
  94. data/demo/gokuraku/u1d/u1d2.rb +50 -0
  95. data/demo/gokuraku/u2d/u2d1.rb +46 -0
  96. data/demo/gokuraku/u2d/u2d2.rb +49 -0
  97. data/demo/gokuraku/u2d/u2d3.rb +45 -0
  98. data/demo/gokuraku/u2d/u2d4.rb +61 -0
  99. data/demo/grph1/scpack/scpkt2.rb +40 -0
  100. data/demo/grph1/scpack/scpkt3.rb +102 -0
  101. data/demo/grph1/scpack/scpkt6.rb +84 -0
  102. data/demo/grph1/scpack/scpkt7.rb +59 -0
  103. data/demo/grph1/scpack/scpkt8.rb +60 -0
  104. data/demo/grph1/scpack/t810630.dat +296 -0
  105. data/demo/grph1/scpack/t811231.dat +296 -0
  106. data/demo/grph1/sgpack/sgfont.rb +52 -0
  107. data/demo/grph1/sgpack/sgfonz.rb +53 -0
  108. data/demo/grph1/sgpack/sgksx1.rb +44 -0
  109. data/demo/grph1/sgpack/sgksx2.rb +90 -0
  110. data/demo/grph1/sgpack/sgksx3.rb +75 -0
  111. data/demo/grph1/sgpack/sglidx.rb +40 -0
  112. data/demo/grph1/sgpack/sgltyp.rb +48 -0
  113. data/demo/grph1/sgpack/sgpk01.rb +39 -0
  114. data/demo/grph1/sgpack/sgpk02.rb +79 -0
  115. data/demo/grph1/sgpack/sgpk03.rb +107 -0
  116. data/demo/grph1/sgpack/sgpk04.rb +86 -0
  117. data/demo/grph1/sgpack/sgpk05.rb +66 -0
  118. data/demo/grph1/sgpack/sgpk06.rb +91 -0
  119. data/demo/grph1/sgpack/sgpk07.rb +66 -0
  120. data/demo/grph1/sgpack/sgpk08.rb +67 -0
  121. data/demo/grph1/sgpack/sgpk09.rb +61 -0
  122. data/demo/grph1/sgpack/sgpk10.rb +58 -0
  123. data/demo/grph1/sgpack/sgtclr.rb +59 -0
  124. data/demo/grph1/sgpack/sgtone.rb +70 -0
  125. data/demo/grph1/sgpack/sgtonz.rb +66 -0
  126. data/demo/grph1/slpack/slpk01.rb +37 -0
  127. data/demo/grph1/slpack/slpk02.rb +29 -0
  128. data/demo/grph1/slpack/slpk03.rb +36 -0
  129. data/demo/grph1/slpack/slpk04.rb +36 -0
  130. data/demo/grph2/g2pack/g2pk01.rb +78 -0
  131. data/demo/grph2/g2pack/g2pk02.rb +75 -0
  132. data/demo/grph2/grpack/grpk01.rb +65 -0
  133. data/demo/grph2/ucpack/ucpk01.rb +95 -0
  134. data/demo/grph2/ucpack/ucpk02.rb +95 -0
  135. data/demo/grph2/udegpk/u2df01.rb +50 -0
  136. data/demo/grph2/udegpk/u2df02.rb +76 -0
  137. data/demo/grph2/udegpk/u2df03.rb +80 -0
  138. data/demo/grph2/udegpk/u2df04.rb +52 -0
  139. data/demo/grph2/udegpk/u2df05.rb +70 -0
  140. data/demo/grph2/udegpk/u2df06.rb +59 -0
  141. data/demo/grph2/udegpk/u2df07.rb +68 -0
  142. data/demo/grph2/udegpk/u2df08.rb +91 -0
  143. data/demo/grph2/udegpk/u2df09b.rb +88 -0
  144. data/demo/grph2/udegpk/u2df09c.rb +89 -0
  145. data/demo/grph2/udegpk/u2df09e.rb +88 -0
  146. data/demo/grph2/udegpk/u2df09f.rb +89 -0
  147. data/demo/grph2/ulpack/ulpk01.rb +111 -0
  148. data/demo/grph2/ulpack/ulpk01n.rb +111 -0
  149. data/demo/grph2/ulpack/ulpk02.rb +111 -0
  150. data/demo/grph2/ulpack/ulpk02n.rb +111 -0
  151. data/demo/grph2/umpack/t811231.dat +296 -0
  152. data/demo/grph2/umpack/test01.rb +69 -0
  153. data/demo/grph2/umpack/test02.rb +64 -0
  154. data/demo/grph2/umpack/test03.rb +84 -0
  155. data/demo/grph2/umpack/test04.rb +54 -0
  156. data/demo/grph2/umpack/test05.rb +85 -0
  157. data/demo/grph2/umpack/test06.rb +44 -0
  158. data/demo/grph2/umpack/test07.rb +43 -0
  159. data/demo/grph2/umpack/test08.rb +37 -0
  160. data/demo/grph2/umpack/test09.rb +86 -0
  161. data/demo/grph2/umpack/test10.rb +52 -0
  162. data/demo/grph2/umpack/umpk01.rb +65 -0
  163. data/demo/grph2/umpack/umpk02.rb +54 -0
  164. data/demo/grph2/umpack/umpk03.rb +46 -0
  165. data/demo/grph2/umpack/umpk04.rb +65 -0
  166. data/demo/grph2/umpack/umpk05.rb +84 -0
  167. data/demo/grph2/uspack/uspk01.rb +39 -0
  168. data/demo/grph2/uspack/uspk02.rb +47 -0
  169. data/demo/grph2/uspack/uspk03.rb +38 -0
  170. data/demo/grph2/uspack/uspk04.rb +64 -0
  171. data/demo/grph2/uspack/uspk05.rb +68 -0
  172. data/demo/grph2/uspack/uspk06.rb +43 -0
  173. data/demo/grph2/uspack/uspk07.rb +62 -0
  174. data/demo/grph2/uspack/uspk08.rb +46 -0
  175. data/demo/grph2/uspack/uspk09.rb +89 -0
  176. data/demo/grph2/uspack/uspk10.rb +48 -0
  177. data/demo/grph2/uspack/uspk11.rb +71 -0
  178. data/demo/grph2/uspack/uspk12.rb +51 -0
  179. data/demo/grph2/uupack/uupk01.rb +50 -0
  180. data/demo/grph2/uupack/uupk02.rb +74 -0
  181. data/demo/grph2/uupack/uupk03.rb +56 -0
  182. data/demo/grph2/uupack/uupk04.rb +84 -0
  183. data/demo/grph2/uupack/uupk05.rb +74 -0
  184. data/demo/grph2/uupack/uupk06.rb +77 -0
  185. data/demo/grph2/uupack/uupk07.rb +88 -0
  186. data/demo/grph2/uxyzpk/uxyz01.rb +38 -0
  187. data/demo/grph2/uxyzpk/uxyz02.rb +36 -0
  188. data/demo/grph2/uxyzpk/uxyz03.rb +37 -0
  189. data/demo/grph2/uxyzpk/uxyz04.rb +54 -0
  190. data/demo/grph2/uxyzpk/uxyz05.rb +41 -0
  191. data/demo/grph2/uxyzpk/uxyz06.rb +42 -0
  192. data/demo/grph2/uxyzpk/uxyz07.rb +38 -0
  193. data/demo/grph2/uxyzpk/uxyz08.rb +60 -0
  194. data/demo/grph2/uxyzpk/uxyz09.rb +52 -0
  195. data/demo/grph2/uxyzpk/uxyz10.rb +57 -0
  196. data/demo/grph2/ximage/MEMO +23 -0
  197. data/demo/grph2/ximage/tomsclm.dat +1344 -0
  198. data/demo/grph2/ximage/ximg01.rb +145 -0
  199. data/demo/math1/gt2dlib/gt2d01.rb +33 -0
  200. data/demo/math2/fftlib/fftl01.rb +28 -0
  201. data/demo/math2/fftlib/fftl02.rb +224 -0
  202. data/demo/math2/intrlib/intr01.rb +22 -0
  203. data/demo/math2/rnmlib/rnml01.rb +21 -0
  204. data/demo/math2/vstlib/vstl01.rb +29 -0
  205. data/demo/math2/vstlib/vstl02.rb +38 -0
  206. data/demo/rakuraku/color/color1.rb +61 -0
  207. data/demo/rakuraku/color/color2.rb +57 -0
  208. data/demo/rakuraku/color/color3.rb +81 -0
  209. data/demo/rakuraku/kihon/kihon1.rb +39 -0
  210. data/demo/rakuraku/kihon/kihon2.rb +56 -0
  211. data/demo/rakuraku/kihon/kihon3.rb +57 -0
  212. data/demo/rakuraku/kihon/kihon4.rb +70 -0
  213. data/demo/rakuraku/kihon/kihon5.rb +56 -0
  214. data/demo/rakuraku/kihon/kihon6.rb +40 -0
  215. data/demo/rakuraku/kihon/kihon7.rb +98 -0
  216. data/demo/rakuraku/kihon/kihon8.rb +93 -0
  217. data/demo/rakuraku/kihon/kihon9.rb +77 -0
  218. data/demo/rakuraku/kihon/kihona.rb +123 -0
  219. data/demo/rakuraku/kihon/kihonb.rb +73 -0
  220. data/demo/rakuraku/kihon/kihonc.rb +110 -0
  221. data/demo/rakuraku/layout/lay1.rb +29 -0
  222. data/demo/rakuraku/layout/lay2.rb +28 -0
  223. data/demo/rakuraku/layout/lay3.rb +29 -0
  224. data/demo/rakuraku/map3d/map3d1.rb +68 -0
  225. data/demo/rakuraku/map3d/map3d2.rb +67 -0
  226. data/demo/rakuraku/map3d/map3d3.rb +66 -0
  227. data/demo/rakuraku/map3d/map3d4.rb +107 -0
  228. data/demo/rakuraku/map3d/map3d5.rb +118 -0
  229. data/demo/rakuraku/map3d/map3d6.rb +96 -0
  230. data/demo/rakuraku/map3d/map3d7.rb +98 -0
  231. data/demo/rakuraku/miss/miss1.rb +76 -0
  232. data/demo/rakuraku/miss/miss2.rb +60 -0
  233. data/demo/rakuraku/quick/quick1.rb +35 -0
  234. data/demo/rakuraku/quick/quick2.rb +33 -0
  235. data/demo/rakuraku/quick/quick3.rb +46 -0
  236. data/demo/rakuraku/quick/quick4.rb +47 -0
  237. data/demo/rakuraku/quick/quick5.rb +46 -0
  238. data/demo/rakuraku/u2d/u2d1.rb +50 -0
  239. data/demo/rakuraku/u2d/u2d2.rb +51 -0
  240. data/demo/rakuraku/u2d/u2d3.rb +70 -0
  241. data/demo/rakuraku/u2d/u2d4.rb +59 -0
  242. data/demo/rakuraku/u2d/u2d5.rb +61 -0
  243. data/demo/rakuraku/u2d/u2d6.rb +57 -0
  244. data/demo/rakuraku/u2d/u2d7.rb +103 -0
  245. data/demo/rakuraku/uspack/uspac1.rb +35 -0
  246. data/demo/rakuraku/uspack/uspac2.rb +66 -0
  247. data/demo/rakuraku/uspack/uspac3.rb +37 -0
  248. data/demo/rakuraku/uspack/uspac4.rb +49 -0
  249. data/demo/rakuraku/uxyz/uxyz1.rb +37 -0
  250. data/demo/rakuraku/uxyz/uxyz2.rb +35 -0
  251. data/demo/rakuraku/uxyz/uxyz3.rb +38 -0
  252. data/demo/rakuraku/uxyz/uxyz4.rb +36 -0
  253. data/demo/rakuraku/uxyz/uxyz5.rb +57 -0
  254. data/demo/rakuraku/uxyz/uxyz6.rb +43 -0
  255. data/demo/rakuraku/uxyz/uxyz7.rb +39 -0
  256. data/demo/rakuraku/uxyz/uxyz8.rb +56 -0
  257. data/demo/rubydcloriginal/uemrkz1.rb +37 -0
  258. data/dummy.c +9 -0
  259. data/extconf.rb +133 -0
  260. data/grph1_csgi.c +119 -0
  261. data/grph1_scpack.c +1388 -0
  262. data/grph1_sgpack.c +3876 -0
  263. data/grph1_slpack.c +432 -0
  264. data/grph1_stpack.c +1044 -0
  265. data/grph1_swpack.c +1922 -0
  266. data/grph1_zgpack.c.org +141 -0
  267. data/grph2_grpack.c +368 -0
  268. data/grph2_ucpack.c +1232 -0
  269. data/grph2_udpack.c +1404 -0
  270. data/grph2_uepack.c +1443 -0
  271. data/grph2_ugpack.c +1073 -0
  272. data/grph2_uhpack.c +943 -0
  273. data/grph2_ulpack.c +1304 -0
  274. data/grph2_umpack.c +1540 -0
  275. data/grph2_uspack.c +2481 -0
  276. data/grph2_uupack.c +1689 -0
  277. data/grph2_uvpack.c +943 -0
  278. data/grph2_uwpack.c +552 -0
  279. data/grph2_uxpack.c +555 -0
  280. data/grph2_uypack.c +555 -0
  281. data/grph2_uzpack.c +1455 -0
  282. data/init.c.default +187 -0
  283. data/init.c.gtk +189 -0
  284. data/lib/dcl.rb +5084 -0
  285. data/math1_blklib.c +227 -0
  286. data/math1_chrlib.c +239 -0
  287. data/math1_fnclib.c +254 -0
  288. data/math1_gnmlib.c +356 -0
  289. data/math1_gt2dlib.c +514 -0
  290. data/math1_ifalib.c +427 -0
  291. data/math1_indxlib.c +709 -0
  292. data/math1_intlib.c +167 -0
  293. data/math1_lrllib.c +817 -0
  294. data/math1_maplib.c +172 -0
  295. data/math1_oslib.c +111 -0
  296. data/math1_rfalib.c +1417 -0
  297. data/math1_rfblib.c +232 -0
  298. data/math1_sublib.c +221 -0
  299. data/math1_syslib.c +2025 -0
  300. data/math1_vialib.c +1156 -0
  301. data/math1_viblib.c +1027 -0
  302. data/math1_vralib.c +1156 -0
  303. data/math1_vrblib.c +1027 -0
  304. data/math1_xfclib.c +142 -0
  305. data/math2_fftlib.c +833 -0
  306. data/math2_intrlib.c +138 -0
  307. data/math2_rnmlib.c +226 -0
  308. data/math2_shtlib.c +1568 -0
  309. data/math2_vstlib.c +366 -0
  310. data/misc1_chnlib.c +179 -0
  311. data/misc1_datelib.c +953 -0
  312. data/misc1_fmtlib.c +99 -0
  313. data/misc1_misclib.c +118 -0
  314. data/misc1_randlib.c +142 -0
  315. data/misc1_timelib.c +380 -0
  316. data/obsolete/README +2 -0
  317. data/obsolete/dcl_ext.html +112 -0
  318. data/obsolete/dcl_ext.rb +313 -0
  319. metadata +433 -0
data/dcl_obj2cary.c ADDED
@@ -0,0 +1,512 @@
1
+ /*
2
+ * dcl_obj2cary.c
3
+ * $Id: dcl_obj2cary.c,v 1.1.1.1 2011-02-23 07:21:26 horinout Exp $
4
+ */
5
+
6
+ #include <math.h>
7
+ #include "ruby.h"
8
+ #include "libtinyf2c.h"
9
+ #include "narray.h"
10
+
11
+ /* for compatibility with ruby 1.6 */
12
+ #ifndef RFLOAT_VALUE
13
+ #define RFLOAT_VALUE(x) ((real)(RFLOAT(x)->value))
14
+ #endif
15
+ #ifndef RARRAY_PTR
16
+ #define RARRAY_PTR(a) (RARRAY(a)->ptr)
17
+ #endif
18
+ #ifndef RARRAY_LEN
19
+ #define RARRAY_LEN(a) (RARRAY(a)->len)
20
+ #endif
21
+ #ifndef StringValuePtr
22
+ #define StringValuePtr(s) STR2CSTR(s)
23
+ #endif
24
+
25
+ extern VALUE mDCL;
26
+
27
+ /* functions */
28
+ char *obj2ccharary(VALUE, int, int);
29
+ integer *obj2cintegerary(VALUE);
30
+ real *obj2crealary(VALUE);
31
+ complex *obj2ccomplexary(VALUE);
32
+ logical *obj2clogicalary(VALUE);
33
+
34
+ void dcl_freeccharary(char *);
35
+ void dcl_freecintegerary(integer *);
36
+ void dcl_freecrealary(real *);
37
+ void dcl_freeccomplexary(complex *);
38
+ void dcl_freeclogicalary(logical *);
39
+
40
+ static char *ary2ccharary(VALUE, int, int);
41
+ static integer *ary2cintegerary(VALUE);
42
+ static real *ary2crealary(VALUE);
43
+ static logical *ary2clogicalary(VALUE);
44
+ /* not implemented
45
+ static complex *ary2ccomplexary(VALUE);
46
+ */
47
+
48
+ static real *na2crealary(VALUE);
49
+ static logical *na2clogicalary(VALUE);
50
+ static integer *na2cintegerary(VALUE);
51
+ /* not implemented
52
+ static complex *na2ccomplexary(VALUE);
53
+ */
54
+
55
+ /* defines */
56
+ #define BE_INTEGER(x) ((integer)(NUM2INT(rb_Integer(x))))
57
+ #define BE_REAL(x) ((real)(RFLOAT_VALUE(rb_Float(x))))
58
+ #define BE_LOGICAL(x) (((x == Qnil) || (x == Qfalse)) ? FALSE_ : TRUE_ )
59
+ /* not implemented
60
+ #define BE_COMPLEX(x) ...
61
+ */
62
+
63
+
64
+ /*
65
+ * dcl_obj2cxxxary() : convert ruby object to c xxx type array
66
+ * dcl_obj2ccharary()
67
+ * dcl_obj2cintegerary()
68
+ * dcl_obj2crealary()
69
+ * dcl_obj2ccomplexary() : not implemented
70
+ * dcl_obj2clogicalary()
71
+ */
72
+ char *
73
+ dcl_obj2ccharary(src, size, len)
74
+ VALUE src;
75
+ int size;
76
+ int len;
77
+ {
78
+ VALUE chk;
79
+ char *rtn;
80
+
81
+ switch (TYPE(src)){
82
+ case T_ARRAY:
83
+ rtn = ary2ccharary(src, size, len);
84
+ break;
85
+ default:
86
+ rb_raise(rb_eTypeError, "expect integer array");
87
+ break;
88
+ }
89
+ return rtn;
90
+ }
91
+
92
+ integer *
93
+ dcl_obj2cintegerary(src)
94
+ VALUE src;
95
+ {
96
+ VALUE chk;
97
+ integer *rtn;
98
+
99
+ switch (TYPE(src)){
100
+ case T_DATA:
101
+ chk = rb_obj_is_kind_of(src, cNArray);
102
+ if (chk == Qfalse) {
103
+ rb_raise(rb_eTypeError, "expect integer array");
104
+ }
105
+ rtn = na2cintegerary(src);
106
+ break;
107
+ case T_ARRAY:
108
+ rtn = ary2cintegerary(src);
109
+ break;
110
+ default:
111
+ rb_raise(rb_eTypeError, "expect integer array");
112
+ break;
113
+ }
114
+
115
+ return rtn;
116
+ }
117
+
118
+ real *
119
+ dcl_obj2crealary(src)
120
+ VALUE src;
121
+ {
122
+ VALUE chk;
123
+ real *rtn;
124
+ char *klass;
125
+ VALUE klass_tmp;
126
+ VALUE rmiss;
127
+
128
+ switch (TYPE(src)){
129
+ case T_OBJECT:
130
+ klass_tmp = rb_funcall(rb_funcall(src, rb_intern("class"),0),
131
+ rb_intern("to_s"),0);
132
+ klass = StringValuePtr(klass_tmp);
133
+ if (strncmp(klass,"NArrayMiss",10) != 0) {
134
+ rb_raise(rb_eTypeError, "a numeric array expected");
135
+ }
136
+ rmiss = rb_funcall(mDCL,rb_intern("glrget"),1,rb_str_new2("rmiss"));
137
+ src = rb_funcall( src, rb_intern("to_na"), 1, rmiss );
138
+ case T_DATA:
139
+ chk = rb_obj_is_kind_of(src, cNArray);
140
+ rtn = na2crealary(src);
141
+ break;
142
+ case T_ARRAY:
143
+ rtn = ary2crealary(src);
144
+ break;
145
+ default:
146
+ rb_raise(rb_eTypeError, "expect real array");
147
+ break;
148
+ }
149
+
150
+ return rtn;
151
+ }
152
+
153
+ /* not implemented
154
+ complex *
155
+ dcl_obj2ccomplexary(src)
156
+ VALUE src;
157
+ {
158
+ VALUE chk;
159
+ complex *rtn;
160
+
161
+ switch (TYPE(src)){
162
+ case T_DATA:
163
+ chk = rb_obj_is_kind_of(src, cNArray);
164
+ if (chk == Qfalse) {
165
+ rb_raise(rb_eTypeError, "expect complex array");
166
+ }
167
+ rtn = na2ccomplexary(src);
168
+ break;
169
+ case T_ARRAY:
170
+ rtn = ary2ccomplexary(src);
171
+ break;
172
+ default:
173
+ rb_raise(rb_eTypeError, "expect complex array");
174
+ break;
175
+ }
176
+
177
+ return rtn;
178
+ }
179
+ */
180
+
181
+ logical *
182
+ dcl_obj2clogicalary(src)
183
+ VALUE src;
184
+ {
185
+ VALUE chk;
186
+ logical *rtn;
187
+
188
+ switch (TYPE(src)){
189
+ case T_DATA:
190
+ chk = rb_obj_is_kind_of(src, cNArray);
191
+ if (chk == Qfalse) {
192
+ rb_raise(rb_eTypeError, "expect logical array");
193
+ }
194
+ rtn = na2clogicalary(src);
195
+ break;
196
+ case T_ARRAY:
197
+ rtn = ary2clogicalary(src);
198
+ break;
199
+ default:
200
+ rb_raise(rb_eTypeError, "expect logical array");
201
+ break;
202
+ }
203
+
204
+ return rtn;
205
+ }
206
+
207
+ /*
208
+ * dcl_freecxxxary() : free c xxx type array
209
+ * allocated by ary2cxxxary() or na2cxxxary()
210
+ * dcl_freeccharary()
211
+ * dcl_freecintegerary()
212
+ * dcl_freecrealary()
213
+ * dcl_freeccomplexary() : not implemented
214
+ * dcl_freeclogicalary()
215
+ */
216
+ void
217
+ dcl_freeccharary(cary)
218
+ char *cary;
219
+ {
220
+ if ( cary != NULL ) {
221
+ free(cary);
222
+ }
223
+ return;
224
+ }
225
+
226
+ void
227
+ dcl_freecintegerary(cary)
228
+ integer *cary;
229
+ {
230
+ if ( cary != NULL ) {
231
+ free(cary);
232
+ }
233
+ return;
234
+ }
235
+
236
+ void
237
+ dcl_freecrealary(cary)
238
+ real *cary;
239
+ {
240
+ if ( cary != NULL ) {
241
+ free(cary);
242
+ }
243
+ return;
244
+ }
245
+
246
+ /* not implemented
247
+ void
248
+ dcl_freeccomplexary(cary)
249
+ complex *cary;
250
+ {
251
+ if ( cary != NULL ) {
252
+ free(cary);
253
+ }
254
+ return;
255
+ }
256
+ */
257
+
258
+ void
259
+ dcl_freeclogicalary(cary)
260
+ logical *cary;
261
+ {
262
+ if ( cary != NULL ) {
263
+ free(cary);
264
+ }
265
+ return;
266
+ }
267
+
268
+
269
+ /*
270
+ * ary2cxxxary() : convert Array object to c xxx type array
271
+ * called by obj2cxxxary()
272
+ * ary2ccharary()
273
+ * ary2cintegerary()
274
+ * ary2crealary()
275
+ * ary2ccomplexary() : not implemented
276
+ * ary2clogicalary()
277
+ */
278
+ static char *
279
+ ary2ccharary(src, size, charlen)
280
+ VALUE src;
281
+ int size;
282
+ int charlen;
283
+ {
284
+ VALUE *ptr;
285
+ long len, i, j;
286
+ #ifdef StringValue
287
+ // Ruby version 1.8 or later
288
+ long rlen;
289
+ #else
290
+ // Ruby version 1.7 or before
291
+ int rlen;
292
+ #endif
293
+ char *rtn, *wk, *rwk;
294
+
295
+ Check_Type(src, T_ARRAY);
296
+
297
+ len = RARRAY_LEN(src);
298
+ ptr = RARRAY_PTR(src);
299
+
300
+ rtn = ALLOC_N(char, size);
301
+ memset(rtn, '\0', size);
302
+ wk = rtn;
303
+ for (i = 0; i < len; i++) {
304
+ #ifdef StringValue
305
+ // Ruby version 1.8 or later
306
+ StringValue(ptr[i]);
307
+ rwk = RSTRING_PTR(ptr[i]);
308
+ rlen = RSTRING_LEN(ptr[i]);
309
+ #else
310
+ // Ruby version 1.7 or before
311
+ rwk = rb_str2cstr(ptr[i], &rlen);
312
+ #endif
313
+ j = rlen;
314
+ strncpy(wk, rwk, charlen);
315
+ while (j < charlen) {
316
+ wk[j++] = ' ';
317
+ }
318
+ wk += charlen;
319
+ }
320
+ return rtn;
321
+ }
322
+
323
+ static integer *
324
+ ary2cintegerary(src)
325
+ VALUE src;
326
+ {
327
+ VALUE *ptr;
328
+ int len, i;
329
+ integer *rtn;
330
+
331
+ Check_Type(src, T_ARRAY);
332
+
333
+ len = RARRAY_LEN(src);
334
+ ptr = RARRAY_PTR(src);
335
+
336
+ rtn = ALLOC_N(integer, len);
337
+
338
+ for (i = 0; i < len; i++) {
339
+ rtn[i] = BE_INTEGER(ptr[i]);
340
+ }
341
+
342
+ return rtn;
343
+ }
344
+
345
+ static real *
346
+ ary2crealary(src)
347
+ VALUE src;
348
+ {
349
+ VALUE *ptr;
350
+ int len, i;
351
+ real *rtn;
352
+
353
+ Check_Type(src, T_ARRAY);
354
+
355
+ len = RARRAY_LEN(src);
356
+ ptr = RARRAY_PTR(src);
357
+
358
+ rtn = ALLOC_N(real, len);
359
+
360
+ for (i = 0; i < len; i++) {
361
+ rtn[i] = BE_REAL(ptr[i]);
362
+ }
363
+
364
+ return rtn;
365
+ }
366
+
367
+ /* not implemented
368
+ static complex *
369
+ ary2ccomplexary(src)
370
+ VALUE src;
371
+ {
372
+ VALUE *ptr;
373
+ int len, i;
374
+ complex *rtn;
375
+
376
+ Check_Type(src, T_ARRAY);
377
+
378
+ len = RARRAY_LEN(src);
379
+ ptr = RARRAY_PTR(src);
380
+
381
+ rtn = ALLOC_N(complex, len);
382
+
383
+ for (i = 0; i < len; i++) {
384
+ rtn[i] = BE_COMPLEX(src...);
385
+ }
386
+
387
+ return rtn;
388
+ }
389
+ */
390
+
391
+ static logical *
392
+ ary2clogicalary(src)
393
+ VALUE src;
394
+ {
395
+ VALUE *ptr;
396
+ int len, i;
397
+ logical *rtn;
398
+
399
+ Check_Type(src, T_ARRAY);
400
+
401
+ len = RARRAY_LEN(src);
402
+ ptr = RARRAY_PTR(src);
403
+
404
+ rtn = ALLOC_N(logical, len);
405
+
406
+ for (i = 0; i < len; i++) {
407
+ rtn[i] = BE_LOGICAL(ptr[i]);
408
+ }
409
+
410
+ return rtn;
411
+ }
412
+
413
+
414
+ #define NA2PTR(obj) ((NA*)DATA_PTR(obj))->bna->ptr
415
+ #define NA2LEN(obj) ((NA*)DATA_PTR(obj))->bna->len
416
+
417
+ /*
418
+ * na2cxxxary() : convert NArray object to c xxx type array
419
+ * called by obj2cxxxary()
420
+ * na2cintegerary() : not implemented
421
+ * na2crealary()
422
+ * na2ccomplexary() : not implemented
423
+ * na2clogicalary()
424
+ */
425
+ static real *
426
+ na2crealary(src)
427
+ VALUE src;
428
+ {
429
+ VALUE chk;
430
+ int len, i;
431
+ real *rtn;
432
+ float *ptr;
433
+ struct NARRAY *na;
434
+
435
+ chk = rb_obj_is_kind_of(src, cNArray);
436
+ if (chk == Qfalse) {
437
+ rb_raise(rb_eTypeError, "expect NArray");
438
+ }
439
+
440
+ src = na_cast_object(src, NA_SFLOAT);
441
+ GetNArray(src, na);
442
+ len = na->total;
443
+ ptr = (float *)NA_PTR(na, 0);
444
+
445
+ rtn = ALLOC_N(real, len);
446
+
447
+ for (i = 0; i < len; i++) {
448
+ rtn[i] = (real)ptr[i];
449
+ }
450
+
451
+ return rtn;
452
+ }
453
+ static integer *
454
+ na2cintegerary(src)
455
+ VALUE src;
456
+ {
457
+ VALUE chk;
458
+ int len, i;
459
+ integer *rtn;
460
+ int32_t *ptr;
461
+ struct NARRAY *na;
462
+
463
+ chk = rb_obj_is_kind_of(src, cNArray);
464
+ if (chk == Qfalse) {
465
+ rb_raise(rb_eTypeError, "expect NArray");
466
+ }
467
+
468
+ src = na_cast_object(src, NA_LINT);
469
+ GetNArray(src, na);
470
+ len = na->total;
471
+ ptr = (int32_t *)NA_PTR(na, 0);
472
+
473
+ rtn = ALLOC_N(integer, len);
474
+
475
+ for (i = 0; i < len; i++) {
476
+ rtn[i] = (integer)ptr[i];
477
+ }
478
+
479
+ return rtn;
480
+ }
481
+
482
+ static logical *
483
+ na2clogicalary(src)
484
+ VALUE src;
485
+ {
486
+ VALUE chk;
487
+ struct NARRAY *na;
488
+ int len, i;
489
+ logical *rtn;
490
+ unsigned char *ptr;
491
+
492
+ chk = rb_obj_is_kind_of(src, cNArray);
493
+ if (chk == Qfalse) {
494
+ rb_raise(rb_eTypeError, "expect NArray");
495
+ }
496
+
497
+ src = na_cast_object(src, NA_BYTE);
498
+ GetNArray(src, na);
499
+ len = na->total;
500
+ ptr = (unsigned char *)NA_PTR(na, 0);
501
+
502
+ rtn = ALLOC_N(logical, len);
503
+
504
+ for (i = 0; i < len; i++) {
505
+ rtn[i] = (logical)ptr[i];
506
+ }
507
+
508
+ return rtn;
509
+ }
510
+
511
+
512
+