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.
 
 
 
 
 
 

60 regels
2.4 KiB

  1. /*
  2. * libcaca Ruby bindings
  3. * Copyright (c) 2007-2010 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. #ifndef __COMMON_H__
  12. #define __COMMON_H__
  13. #define _SELF (DATA_PTR(self))
  14. #define get_singleton_double_list(x) \
  15. static VALUE x##_list(void) \
  16. { \
  17. VALUE ary, ary2; \
  18. char const* const* list; \
  19. \
  20. list = caca_get_##x##_list(); \
  21. ary = rb_ary_new(); \
  22. while (*list != NULL) \
  23. { \
  24. ary2 = rb_ary_new(); \
  25. rb_ary_push(ary2, rb_str_new2(*list)); \
  26. list++; \
  27. rb_ary_push(ary2, rb_str_new2(*list)); \
  28. list++; \
  29. rb_ary_push(ary, ary2); \
  30. } \
  31. \
  32. return ary; \
  33. }
  34. #define get_double_list(x) \
  35. static VALUE x##_list(VALUE self) \
  36. { \
  37. VALUE ary, ary2; \
  38. char const* const* list; \
  39. \
  40. list = caca_get_##x##_list(_SELF); \
  41. ary = rb_ary_new(); \
  42. while (*list != NULL) \
  43. { \
  44. ary2 = rb_ary_new(); \
  45. rb_ary_push(ary2, rb_str_new2(*list)); \
  46. list++; \
  47. rb_ary_push(ary2, rb_str_new2(*list)); \
  48. list++; \
  49. rb_ary_push(ary, ary2); \
  50. } \
  51. \
  52. return ary; \
  53. }
  54. #endif