Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

60 linhas
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