You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

645 lines
17 KiB

  1. /*
  2. * libcucul Ruby bindings
  3. * Copyright (c) 2007 Pascal Terjan <pterjan@linuxfr.org>
  4. *
  5. * This library is free software. It comes without any warranty, to
  6. * the extent permitted by applicable law. You can redistribute it
  7. * and/or modify it under the terms of the Do What The Fuck You Want
  8. * To Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. #include <ruby.h>
  12. #include <cucul.h>
  13. #include <errno.h>
  14. #include "cucul-canvas.h"
  15. #define _SELF (DATA_PTR(self))
  16. #define simple_func(x) \
  17. static VALUE x (VALUE self) \
  18. { \
  19. if( cucul_##x (_SELF) <0) \
  20. rb_raise(rb_eRuntimeError, strerror(errno)); \
  21. \
  22. return self; \
  23. }
  24. #define get_int(x) \
  25. static VALUE get_##x (VALUE self) \
  26. { \
  27. return INT2NUM(cucul_get_##x (_SELF)); \
  28. }
  29. static void canvas_free(void * p)
  30. {
  31. cucul_free_canvas((cucul_canvas_t *)p);
  32. }
  33. static VALUE canvas_alloc(VALUE klass)
  34. {
  35. cucul_canvas_t *canvas;
  36. VALUE obj;
  37. canvas = cucul_create_canvas(0, 0);
  38. obj = Data_Wrap_Struct(klass, 0, canvas_free, canvas);
  39. return obj;
  40. }
  41. static VALUE canvas_initialize(VALUE self, VALUE width, VALUE height)
  42. {
  43. unsigned int w, h;
  44. w = NUM2INT(width);
  45. h = NUM2INT(height);
  46. cucul_set_canvas_size(_SELF, w, h);
  47. return self;
  48. }
  49. get_int(canvas_height)
  50. get_int(canvas_width)
  51. static VALUE set_canvas_width(VALUE self, VALUE width)
  52. {
  53. cucul_set_canvas_size(_SELF, NUM2INT(width), cucul_get_canvas_height(_SELF));
  54. return width;
  55. }
  56. static VALUE set_canvas_width2(VALUE self, VALUE width)
  57. {
  58. set_canvas_width(self, width);
  59. return self;
  60. }
  61. static VALUE set_canvas_height(VALUE self, VALUE height)
  62. {
  63. cucul_set_canvas_size(_SELF, cucul_get_canvas_width(_SELF), NUM2INT(height));
  64. return height;
  65. }
  66. static VALUE set_canvas_height2(VALUE self, VALUE height)
  67. {
  68. set_canvas_height(self, height);
  69. return self;
  70. }
  71. static VALUE set_canvas_size(VALUE self, VALUE height, VALUE width)
  72. {
  73. cucul_set_canvas_size(_SELF, NUM2INT(width), NUM2INT(height));
  74. return self;
  75. }
  76. /****/
  77. static VALUE gotoxy(VALUE self, VALUE x, VALUE y)
  78. {
  79. if( cucul_gotoxy(_SELF, NUM2INT(x), NUM2INT(y)) <0) {
  80. rb_raise(rb_eRuntimeError, strerror(errno));
  81. }
  82. return self;
  83. }
  84. get_int(cursor_x)
  85. get_int(cursor_y)
  86. simple_func(clear_canvas)
  87. static VALUE put_char(VALUE self, VALUE x, VALUE y, VALUE ch)
  88. {
  89. cucul_put_char(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(ch));
  90. return self;
  91. }
  92. static VALUE get_char(VALUE self, VALUE x, VALUE y)
  93. {
  94. unsigned long int ch;
  95. ch = cucul_get_char(_SELF, NUM2INT(x), NUM2INT(y));
  96. return INT2NUM(ch);
  97. }
  98. static VALUE put_str(VALUE self, VALUE x, VALUE y, VALUE str)
  99. {
  100. cucul_put_str(_SELF, NUM2INT(x), NUM2INT(y), StringValuePtr(str));
  101. return self;
  102. }
  103. static VALUE get_attr(VALUE self, VALUE x, VALUE y)
  104. {
  105. unsigned long int ch;
  106. ch = cucul_get_attr(_SELF, NUM2INT(x), NUM2INT(y));
  107. return INT2NUM(ch);
  108. }
  109. static VALUE set_attr(VALUE self, VALUE attr)
  110. {
  111. if(cucul_set_attr(_SELF, NUM2ULONG(attr)) <0)
  112. rb_raise(rb_eRuntimeError, strerror(errno));
  113. return self;
  114. }
  115. static VALUE set_attr2(VALUE self, VALUE attr)
  116. {
  117. set_attr(self, attr);
  118. return self;
  119. }
  120. static VALUE put_attr(VALUE self, VALUE x, VALUE y, VALUE attr)
  121. {
  122. if(cucul_put_attr(_SELF, NUM2INT(x), NUM2INT(y), NUM2ULONG(attr)) <0)
  123. rb_raise(rb_eRuntimeError, strerror(errno));
  124. return self;
  125. }
  126. static VALUE set_color_ansi(VALUE self, VALUE fg, VALUE bg)
  127. {
  128. if(cucul_set_color_ansi(_SELF, NUM2INT(fg), NUM2INT(bg)) <0)
  129. rb_raise(rb_eRuntimeError, strerror(errno));
  130. return self;
  131. }
  132. static VALUE set_color_argb(VALUE self, VALUE fg, VALUE bg)
  133. {
  134. if(cucul_set_color_argb(_SELF, NUM2UINT(fg), NUM2UINT(bg)) <0) {
  135. rb_raise(rb_eRuntimeError, strerror(errno));
  136. }
  137. return self;
  138. }
  139. static VALUE cprintf(int argc, VALUE* argv, VALUE self)
  140. {
  141. int x, y;
  142. VALUE rx, ry, format, rest, string;
  143. rb_scan_args(argc, argv, "3*", &rx, &ry, &format, &rest);
  144. x = NUM2INT(rx);
  145. y = NUM2INT(ry);
  146. string = rb_funcall2(rb_mKernel, rb_intern("sprintf"), argc-2, argv+2);
  147. cucul_put_str(_SELF, x, y, StringValuePtr(string));
  148. return self;
  149. }
  150. get_int(canvas_handle_x)
  151. get_int(canvas_handle_y)
  152. static VALUE set_canvas_handle(VALUE self, VALUE x, VALUE y)
  153. {
  154. cucul_set_canvas_handle(_SELF, NUM2INT(x), NUM2INT(y));
  155. return self;
  156. }
  157. static VALUE blit(int argc, VALUE* argv, VALUE self) {
  158. VALUE x, y, src, mask;
  159. cucul_canvas_t *csrc, *cmask;
  160. rb_scan_args(argc, argv, "31", &x, &y, &src, &mask);
  161. Check_Type(x, T_FIXNUM);
  162. Check_Type(y, T_FIXNUM);
  163. Check_Type(src, TYPE(self));
  164. Data_Get_Struct(src, cucul_canvas_t, csrc);
  165. if(!NIL_P(mask))
  166. {
  167. Check_Type(mask, TYPE(self));
  168. Data_Get_Struct(mask, cucul_canvas_t, cmask);
  169. }
  170. else
  171. cmask = NULL;
  172. if(cucul_blit(_SELF, NUM2INT(x), NUM2INT(y), csrc, cmask)<0)
  173. rb_raise(rb_eRuntimeError, strerror(errno));
  174. return self;
  175. }
  176. static VALUE set_canvas_boundaries(VALUE self, VALUE x, VALUE y, VALUE w, VALUE h)
  177. {
  178. if(cucul_set_canvas_boundaries(_SELF, NUM2INT(x), NUM2INT(y), NUM2UINT(w), NUM2UINT(h))<0)
  179. {
  180. rb_raise(rb_eRuntimeError, strerror(errno));
  181. }
  182. return self;
  183. }
  184. /****/
  185. simple_func(invert)
  186. simple_func(flip)
  187. simple_func(flop)
  188. simple_func(rotate_180)
  189. simple_func(rotate_left)
  190. simple_func(rotate_right)
  191. simple_func(stretch_left)
  192. simple_func(stretch_right)
  193. /****/
  194. static VALUE draw_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE ch)
  195. {
  196. cucul_draw_line(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2),NUM2ULONG(ch));
  197. return self;
  198. }
  199. static VALUE draw_polyline(VALUE self, VALUE points, VALUE ch)
  200. {
  201. int i, n;
  202. int *ax, *ay;
  203. int error = 0;
  204. VALUE v, x, y;
  205. n = RARRAY(points)->len;
  206. ax = (int*)malloc(n*sizeof(int));
  207. if(!ax)
  208. rb_raise(rb_eNoMemError,"Out of memory");
  209. ay = (int*)malloc(n*sizeof(int));
  210. if(!ay)
  211. {
  212. free(ax);
  213. rb_raise(rb_eNoMemError,"Out of memory");
  214. }
  215. for(i=0; i<n; i++)
  216. {
  217. v = rb_ary_entry(points, i);
  218. if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
  219. {
  220. x = rb_ary_entry(v,0);
  221. y = rb_ary_entry(v,1);
  222. if(rb_obj_is_kind_of(x, rb_cInteger) &&
  223. rb_obj_is_kind_of(y, rb_cInteger))
  224. {
  225. ax[i] = NUM2INT(x);
  226. ay[i] = NUM2INT(y);
  227. } else
  228. error = 1;
  229. }
  230. else
  231. error = 1;
  232. }
  233. if(error)
  234. {
  235. free(ax);
  236. free(ay);
  237. rb_raise(rb_eArgError, "Invalid list of points");
  238. }
  239. n--;
  240. cucul_draw_polyline(_SELF, ax, ay, n, NUM2ULONG(ch));
  241. free(ax);
  242. free(ay);
  243. return self;
  244. }
  245. static VALUE draw_thin_line(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
  246. {
  247. cucul_draw_thin_line(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2));
  248. return self;
  249. }
  250. static VALUE draw_thin_polyline(VALUE self, VALUE points)
  251. {
  252. int i, n;
  253. int *ax, *ay;
  254. int error = 0;
  255. VALUE v, x, y;
  256. n = RARRAY(points)->len;
  257. ax = (int*)malloc(n*sizeof(int));
  258. if(!ax)
  259. rb_raise(rb_eNoMemError,"Out of memory");
  260. ay = (int*)malloc(n*sizeof(int));
  261. if(!ay)
  262. {
  263. free(ax);
  264. rb_raise(rb_eNoMemError,"Out of memory");
  265. }
  266. for(i=0; i<n; i++)
  267. {
  268. v = rb_ary_entry(points, i);
  269. if((TYPE(v) == T_ARRAY) && (RARRAY(v)->len == 2))
  270. {
  271. x = rb_ary_entry(v,0);
  272. y = rb_ary_entry(v,1);
  273. if(rb_obj_is_kind_of(x, rb_cInteger) &&
  274. rb_obj_is_kind_of(y, rb_cInteger))
  275. {
  276. ax[i] = NUM2INT(x);
  277. ay[i] = NUM2INT(y);
  278. } else
  279. error = 1;
  280. }
  281. else
  282. error = 1;
  283. }
  284. if(error)
  285. {
  286. free(ax);
  287. free(ay);
  288. rb_raise(rb_eArgError, "Invalid list of points");
  289. }
  290. n--;
  291. cucul_draw_thin_polyline(_SELF, ax, ay, n);
  292. free(ax);
  293. free(ay);
  294. return self;
  295. }
  296. static VALUE draw_circle(VALUE self, VALUE x, VALUE y, VALUE r, VALUE ch)
  297. {
  298. cucul_draw_circle(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(r), NUM2ULONG(ch));
  299. return self;
  300. }
  301. static VALUE draw_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b, VALUE ch)
  302. {
  303. cucul_draw_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b), NUM2ULONG(ch));
  304. return self;
  305. }
  306. static VALUE draw_thin_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b)
  307. {
  308. cucul_draw_thin_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b));
  309. return self;
  310. }
  311. static VALUE fill_ellipse(VALUE self, VALUE x, VALUE y, VALUE a, VALUE b, VALUE ch)
  312. {
  313. cucul_fill_ellipse(_SELF, NUM2INT(x), NUM2INT(y), NUM2INT(a), NUM2INT(b), NUM2ULONG(ch));
  314. return self;
  315. }
  316. static VALUE draw_box(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE ch)
  317. {
  318. cucul_draw_box(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2ULONG(ch));
  319. return self;
  320. }
  321. static VALUE draw_thin_box(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
  322. {
  323. cucul_draw_thin_box(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2));
  324. return self;
  325. }
  326. static VALUE draw_cp437_box(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2)
  327. {
  328. cucul_draw_cp437_box(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2));
  329. return self;
  330. }
  331. static VALUE fill_box(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE ch)
  332. {
  333. cucul_fill_box(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2ULONG(ch));
  334. return self;
  335. }
  336. static VALUE draw_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE ch)
  337. {
  338. cucul_draw_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3), NUM2ULONG(ch));
  339. return self;
  340. }
  341. static VALUE draw_thin_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3)
  342. {
  343. cucul_draw_thin_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3));
  344. return self;
  345. }
  346. static VALUE fill_triangle(VALUE self, VALUE x1, VALUE y1, VALUE x2, VALUE y2, VALUE x3, VALUE y3, VALUE ch)
  347. {
  348. cucul_fill_triangle(_SELF, NUM2INT(x1), NUM2INT(y1), NUM2INT(x2), NUM2INT(y2), NUM2INT(x3), NUM2INT(y3), NUM2ULONG(ch));
  349. return self;
  350. }
  351. /****/
  352. get_int(frame_count)
  353. static VALUE set_frame(VALUE self, VALUE id)
  354. {
  355. if(cucul_set_frame(_SELF, NUM2INT(id))<0)
  356. rb_raise(rb_eArgError, strerror(errno));
  357. return self;
  358. }
  359. static VALUE set_frame2(VALUE self, VALUE id)
  360. {
  361. set_frame(self, id);
  362. return self;
  363. }
  364. static VALUE get_frame_name(VALUE self)
  365. {
  366. return rb_str_new2(cucul_get_frame_name(_SELF));
  367. }
  368. static VALUE set_frame_name(VALUE self, VALUE name)
  369. {
  370. if(cucul_set_frame_name(_SELF, StringValuePtr(name))<0)
  371. rb_raise(rb_eRuntimeError, strerror(errno));
  372. return self;
  373. }
  374. static VALUE set_frame_name2(VALUE self, VALUE name)
  375. {
  376. set_frame_name(self, name);
  377. return self;
  378. }
  379. static VALUE create_frame(VALUE self, VALUE id)
  380. {
  381. if(cucul_create_frame(_SELF, NUM2INT(id))<0) {
  382. rb_raise(rb_eRuntimeError, strerror(errno));
  383. }
  384. return self;
  385. }
  386. static VALUE free_frame(VALUE self, VALUE id)
  387. {
  388. if(cucul_free_frame(_SELF, NUM2INT(id))<0) {
  389. rb_raise(rb_eArgError, strerror(errno));
  390. }
  391. return self;
  392. }
  393. /****/
  394. static VALUE import_memory(VALUE self, VALUE data, VALUE format)
  395. {
  396. long int bytes;
  397. bytes = cucul_import_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
  398. if(bytes <= 0)
  399. rb_raise(rb_eRuntimeError, strerror(errno));
  400. return self;
  401. }
  402. static VALUE import_file(VALUE self, VALUE filename, VALUE format)
  403. {
  404. long int bytes;
  405. bytes = cucul_import_file (_SELF, StringValuePtr(filename), StringValuePtr(format));
  406. if(bytes <= 0)
  407. rb_raise(rb_eRuntimeError, strerror(errno));
  408. return self;
  409. }
  410. static VALUE export_memory(VALUE self, VALUE format)
  411. {
  412. unsigned long int bytes;
  413. void *result;
  414. VALUE ret;
  415. result = cucul_export_memory (_SELF, StringValuePtr(format), &bytes);
  416. ret = rb_str_new(result, bytes);
  417. free(result);
  418. return ret;
  419. }
  420. static VALUE export_list(void)
  421. {
  422. VALUE ary, ary2;
  423. char const* const* list;
  424. list = cucul_get_export_list();
  425. ary = rb_ary_new();
  426. while (*list != NULL)
  427. {
  428. ary2 = rb_ary_new();
  429. rb_ary_push(ary2, rb_str_new2(*list));
  430. list++;
  431. rb_ary_push(ary2, rb_str_new2(*list));
  432. list++;
  433. rb_ary_push(ary, ary2);
  434. }
  435. return ary;
  436. }
  437. static VALUE import_list(void)
  438. {
  439. VALUE ary, ary2;
  440. char const* const* list;
  441. list = cucul_get_import_list();
  442. ary = rb_ary_new();
  443. while (*list != NULL)
  444. {
  445. ary2 = rb_ary_new();
  446. rb_ary_push(ary2, rb_str_new2(*list));
  447. list++;
  448. rb_ary_push(ary2, rb_str_new2(*list));
  449. list++;
  450. rb_ary_push(ary, ary2);
  451. }
  452. return ary;
  453. }
  454. /****/
  455. void Init_cucul_canvas(VALUE mCucul)
  456. {
  457. VALUE cCanvas = rb_define_class_under(mCucul, "Canvas", rb_cObject);
  458. rb_define_alloc_func(cCanvas, canvas_alloc);
  459. rb_define_method(cCanvas, "initialize", canvas_initialize, 2);
  460. rb_define_method(cCanvas, "width", get_canvas_width, 0);
  461. rb_define_method(cCanvas, "width=", set_canvas_width, 1);
  462. rb_define_method(cCanvas, "set_width", set_canvas_width2, 1);
  463. rb_define_method(cCanvas, "height", get_canvas_height, 0);
  464. rb_define_method(cCanvas, "height=", set_canvas_height, 1);
  465. rb_define_method(cCanvas, "set_height", set_canvas_height2, 1);
  466. rb_define_method(cCanvas, "set_size", set_canvas_size, 2);
  467. rb_define_method(cCanvas, "gotoxy", gotoxy, 2);
  468. rb_define_method(cCanvas, "cursor_x", get_cursor_x, 0);
  469. rb_define_method(cCanvas, "cursor_y", get_cursor_y, 0);
  470. rb_define_method(cCanvas, "handle_x", get_canvas_handle_x, 0);
  471. rb_define_method(cCanvas, "handle_y", get_canvas_handle_y, 0);
  472. rb_define_method(cCanvas, "set_handle", set_canvas_handle, 2);
  473. rb_define_method(cCanvas, "blit", blit, -1);
  474. rb_define_method(cCanvas, "set_boundaries", set_canvas_boundaries, 4);
  475. rb_define_method(cCanvas, "clear", clear_canvas, 0);
  476. rb_define_method(cCanvas, "put_char", put_char, 3);
  477. rb_define_method(cCanvas, "get_char", get_char, 2);
  478. rb_define_method(cCanvas, "put_str", put_str, 3);
  479. rb_define_method(cCanvas, "printf", cprintf, -1);
  480. rb_define_method(cCanvas, "get_attr", get_attr, 3);
  481. rb_define_method(cCanvas, "attr=", set_attr, 1);
  482. rb_define_method(cCanvas, "set_attr", set_attr2, 1);
  483. rb_define_method(cCanvas, "put_attr", put_attr, 3);
  484. rb_define_method(cCanvas, "set_color_ansi", set_color_ansi, 2);
  485. rb_define_method(cCanvas, "set_color_argb", set_color_argb, 2);
  486. rb_define_method(cCanvas, "invert", invert, 0);
  487. rb_define_method(cCanvas, "flip", flip, 0);
  488. rb_define_method(cCanvas, "flop", flop, 0);
  489. rb_define_method(cCanvas, "rotate_180", rotate_180, 0);
  490. rb_define_method(cCanvas, "rotate_left", rotate_left, 0);
  491. rb_define_method(cCanvas, "rotate_right", rotate_right, 0);
  492. rb_define_method(cCanvas, "stretch_left", stretch_left, 0);
  493. rb_define_method(cCanvas, "stretch_right", stretch_right, 0);
  494. rb_define_method(cCanvas, "draw_line", draw_line, 5);
  495. rb_define_method(cCanvas, "draw_polyline", draw_polyline, 2);
  496. rb_define_method(cCanvas, "draw_thin_line", draw_thin_line, 4);
  497. rb_define_method(cCanvas, "draw_thin_polyline", draw_thin_polyline, 1);
  498. rb_define_method(cCanvas, "draw_circle", draw_circle, 4);
  499. rb_define_method(cCanvas, "draw_ellipse", draw_ellipse, 5);
  500. rb_define_method(cCanvas, "draw_thin_ellipse", draw_thin_ellipse, 4);
  501. rb_define_method(cCanvas, "fill_ellipse", fill_ellipse, 5);
  502. rb_define_method(cCanvas, "draw_box", draw_box, 5);
  503. rb_define_method(cCanvas, "draw_thin_box", draw_thin_box, 4);
  504. rb_define_method(cCanvas, "draw_cp437_box", draw_cp437_box, 4);
  505. rb_define_method(cCanvas, "fill_box", fill_box, 5);
  506. rb_define_method(cCanvas, "draw_triangle", draw_triangle, 7);
  507. rb_define_method(cCanvas, "draw_thin_triangle", draw_thin_triangle, 6);
  508. rb_define_method(cCanvas, "fill_triangle", fill_triangle, 7);
  509. rb_define_method(cCanvas, "frame_count", get_frame_count, 0);
  510. rb_define_method(cCanvas, "frame=", set_frame, 1);
  511. rb_define_method(cCanvas, "set_frame", set_frame2, 1);
  512. rb_define_method(cCanvas, "frame_name", get_frame_name, 0);
  513. rb_define_method(cCanvas, "frame_name=", set_frame_name, 1);
  514. rb_define_method(cCanvas, "set_frame_name", set_frame_name2, 1);
  515. rb_define_method(cCanvas, "create_frame", create_frame, 1);
  516. rb_define_method(cCanvas, "free_frame", free_frame, 1);
  517. rb_define_method(cCanvas, "import_memory", import_memory, 2);
  518. rb_define_method(cCanvas, "import_file", import_file, 2);
  519. rb_define_method(cCanvas, "export_memory", export_memory, 1);
  520. rb_define_singleton_method(cCanvas, "export_list", export_list, 0);
  521. rb_define_singleton_method(cCanvas, "import_list", import_list, 0);
  522. }