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.
 
 
 
 
 
 

49 lines
2.0 KiB

  1. #ifndef __COMMON_H__
  2. #define __COMMON_H__
  3. #define _SELF (DATA_PTR(self))
  4. #define get_singleton_double_list(x) \
  5. static VALUE x##_list(void) \
  6. { \
  7. VALUE ary, ary2; \
  8. char const* const* list; \
  9. \
  10. list = caca_get_##x##_list(); \
  11. ary = rb_ary_new(); \
  12. while (*list != NULL) \
  13. { \
  14. ary2 = rb_ary_new(); \
  15. rb_ary_push(ary2, rb_str_new2(*list)); \
  16. list++; \
  17. rb_ary_push(ary2, rb_str_new2(*list)); \
  18. list++; \
  19. rb_ary_push(ary, ary2); \
  20. } \
  21. \
  22. return ary; \
  23. }
  24. #define get_double_list(x) \
  25. static VALUE x##_list(VALUE self) \
  26. { \
  27. VALUE ary, ary2; \
  28. char const* const* list; \
  29. \
  30. list = caca_get_##x##_list(_SELF); \
  31. ary = rb_ary_new(); \
  32. while (*list != NULL) \
  33. { \
  34. ary2 = rb_ary_new(); \
  35. rb_ary_push(ary2, rb_str_new2(*list)); \
  36. list++; \
  37. rb_ary_push(ary2, rb_str_new2(*list)); \
  38. list++; \
  39. rb_ary_push(ary, ary2); \
  40. } \
  41. \
  42. return ary; \
  43. }
  44. #endif