test-asmobs-lib.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* Copyright (C) 1999,2000,2001,2003, 2006, 2008 Free Software Foundation, Inc.
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public License
  5. * as published by the Free Software Foundation; either version 3 of
  6. * the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. */
  18. #ifdef HAVE_CONFIG_H
  19. # include <config.h>
  20. #endif
  21. #include <libguile.h>
  22. long asmob000;
  23. long asmob100;
  24. long asmob010;
  25. long asmob001;
  26. long asmob200;
  27. long asmob110;
  28. long asmob020;
  29. long asmob101;
  30. long asmob011;
  31. long asmob300;
  32. long asmob210;
  33. long asmob120;
  34. long asmob030;
  35. long asmob201;
  36. long asmob021;
  37. long asmob111;
  38. /* since we don't have SCM_DEFINE_STATIC or similar */
  39. SCM scm_make_asmob000 (void);
  40. SCM scm_make_asmob001 (void);
  41. SCM scm_make_asmob010 (void);
  42. SCM scm_make_asmob011 (void);
  43. SCM scm_make_asmob100 (void);
  44. SCM scm_make_asmob101 (void);
  45. SCM scm_make_asmob110 (void);
  46. SCM scm_make_asmob111 (void);
  47. SCM scm_make_asmob120 (void);
  48. SCM scm_make_asmob020 (void);
  49. SCM scm_make_asmob021 (void);
  50. SCM scm_make_asmob200 (void);
  51. SCM scm_make_asmob201 (void);
  52. SCM scm_make_asmob210 (void);
  53. SCM scm_make_asmob030 (void);
  54. SCM scm_make_asmob300 (void);
  55. SCM_DEFINE (scm_make_asmob000, "make-asmob000", 0, 0, 0, (), "")
  56. {
  57. SCM_RETURN_NEWSMOB (asmob000, 0);
  58. }
  59. SCM_DEFINE (scm_make_asmob100, "make-asmob100", 0, 0, 0, (), "")
  60. {
  61. SCM_RETURN_NEWSMOB (asmob100, 0);
  62. }
  63. SCM_DEFINE (scm_make_asmob010, "make-asmob010", 0, 0, 0, (), "")
  64. {
  65. SCM_RETURN_NEWSMOB (asmob010, 0);
  66. }
  67. SCM_DEFINE (scm_make_asmob001, "make-asmob001", 0, 0, 0, (), "")
  68. {
  69. SCM_RETURN_NEWSMOB (asmob001, 0);
  70. }
  71. SCM_DEFINE (scm_make_asmob200, "make-asmob200", 0, 0, 0, (), "")
  72. {
  73. SCM_RETURN_NEWSMOB (asmob200, 0);
  74. }
  75. SCM_DEFINE (scm_make_asmob110, "make-asmob110", 0, 0, 0, (), "")
  76. {
  77. SCM_RETURN_NEWSMOB (asmob110, 0);
  78. }
  79. SCM_DEFINE (scm_make_asmob020, "make-asmob020", 0, 0, 0, (), "")
  80. {
  81. SCM_RETURN_NEWSMOB (asmob020, 0);
  82. }
  83. SCM_DEFINE (scm_make_asmob101, "make-asmob101", 0, 0, 0, (), "")
  84. {
  85. SCM_RETURN_NEWSMOB (asmob101, 0);
  86. }
  87. SCM_DEFINE (scm_make_asmob011, "make-asmob011", 0, 0, 0, (), "")
  88. {
  89. SCM_RETURN_NEWSMOB (asmob011, 0);
  90. }
  91. SCM_DEFINE (scm_make_asmob300, "make-asmob300", 0, 0, 0, (), "")
  92. {
  93. SCM_RETURN_NEWSMOB (asmob300, 0);
  94. }
  95. SCM_DEFINE (scm_make_asmob210, "make-asmob210", 0, 0, 0, (), "")
  96. {
  97. SCM_RETURN_NEWSMOB (asmob210, 0);
  98. }
  99. SCM_DEFINE (scm_make_asmob120, "make-asmob120", 0, 0, 0, (), "")
  100. {
  101. SCM_RETURN_NEWSMOB (asmob120, 0);
  102. }
  103. SCM_DEFINE (scm_make_asmob030, "make-asmob030", 0, 0, 0, (), "")
  104. {
  105. SCM_RETURN_NEWSMOB (asmob030, 0);
  106. }
  107. SCM_DEFINE (scm_make_asmob201, "make-asmob201", 0, 0, 0, (), "")
  108. {
  109. SCM_RETURN_NEWSMOB (asmob201, 0);
  110. }
  111. SCM_DEFINE (scm_make_asmob021, "make-asmob021", 0, 0, 0, (), "")
  112. {
  113. SCM_RETURN_NEWSMOB (asmob021, 0);
  114. }
  115. SCM_DEFINE (scm_make_asmob111, "make-asmob111", 0, 0, 0, (), "")
  116. {
  117. SCM_RETURN_NEWSMOB (asmob111, 0);
  118. }
  119. static SCM
  120. apply0 (SCM smob)
  121. {
  122. return SCM_EOL;
  123. }
  124. static SCM
  125. apply1 (SCM smob, SCM a1)
  126. {
  127. if (SCM_UNBNDP (a1)) a1 = SCM_BOOL_F;
  128. return scm_list_1 (a1);
  129. }
  130. static SCM
  131. apply2 (SCM smob, SCM a1, SCM a2)
  132. {
  133. if (SCM_UNBNDP (a1)) a1 = SCM_BOOL_F;
  134. if (SCM_UNBNDP (a2)) a2 = SCM_BOOL_F;
  135. return scm_list_2 (a1, a2);
  136. }
  137. static SCM
  138. apply3 (SCM smob, SCM a1, SCM a2, SCM rest)
  139. {
  140. if (SCM_UNBNDP (a1)) a1 = SCM_BOOL_F;
  141. if (SCM_UNBNDP (a2)) a2 = SCM_BOOL_F;
  142. if (SCM_UNBNDP (rest)) rest = SCM_BOOL_F;
  143. return scm_list_3 (a1, a2, rest);
  144. }
  145. void libtest_asmobs_init (void);
  146. void
  147. libtest_asmobs_init ()
  148. {
  149. asmob000 = scm_make_smob_type ("asmob000", 0);
  150. scm_set_smob_apply (asmob000, apply0, 0, 0, 0);
  151. asmob100 = scm_make_smob_type ("asmob100", 0);
  152. scm_set_smob_apply (asmob100, apply1, 1, 0, 0);
  153. asmob010 = scm_make_smob_type ("asmob010", 0);
  154. scm_set_smob_apply (asmob010, apply1, 0, 1, 0);
  155. asmob001 = scm_make_smob_type ("asmob001", 0);
  156. scm_set_smob_apply (asmob001, apply1, 0, 0, 1);
  157. asmob200 = scm_make_smob_type ("asmob200", 0);
  158. scm_set_smob_apply (asmob200, apply2, 2, 0, 0);
  159. asmob110 = scm_make_smob_type ("asmob110", 0);
  160. scm_set_smob_apply (asmob110, apply2, 1, 1, 0);
  161. asmob020 = scm_make_smob_type ("asmob020", 0);
  162. scm_set_smob_apply (asmob020, apply2, 0, 2, 0);
  163. asmob101 = scm_make_smob_type ("asmob101", 0);
  164. scm_set_smob_apply (asmob101, apply2, 1, 0, 1);
  165. asmob011 = scm_make_smob_type ("asmob011", 0);
  166. scm_set_smob_apply (asmob011, apply2, 0, 1, 1);
  167. asmob300 = scm_make_smob_type ("asmob300", 0);
  168. scm_set_smob_apply (asmob300, apply3, 3, 0, 0);
  169. asmob210 = scm_make_smob_type ("asmob210", 0);
  170. scm_set_smob_apply (asmob210, apply3, 2, 1, 0);
  171. asmob120 = scm_make_smob_type ("asmob120", 0);
  172. scm_set_smob_apply (asmob120, apply3, 1, 2, 0);
  173. asmob030 = scm_make_smob_type ("asmob030", 0);
  174. scm_set_smob_apply (asmob030, apply3, 0, 3, 0);
  175. asmob201 = scm_make_smob_type ("asmob201", 0);
  176. scm_set_smob_apply (asmob201, apply3, 2, 0, 1);
  177. asmob021 = scm_make_smob_type ("asmob021", 0);
  178. scm_set_smob_apply (asmob021, apply3, 0, 2, 1);
  179. asmob111 = scm_make_smob_type ("asmob111", 0);
  180. scm_set_smob_apply (asmob111, apply3, 1, 1, 1);
  181. # include "test-asmobs-lib.x"
  182. }