Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

1727 lines
86KB

  1. #ifndef XEN_H
  2. #define XEN_H
  3. /* macros for extension language support
  4. *
  5. * Ruby: covers 1.8.0 to present
  6. * Forth: covers 1.0 to present
  7. * s7: all versions
  8. * None: all versions
  9. */
  10. #define XEN_MAJOR_VERSION 3
  11. #define XEN_MINOR_VERSION 26
  12. #define XEN_VERSION "3.26"
  13. /* HISTORY:
  14. *
  15. * 29-Jul-16: Xen_define_unsafe_typed_procedure.
  16. * --------
  17. * 20-Aug-15: Xen_define_typed_procedure, Xen_define_typed_dilambda.
  18. * --------
  19. * 27-Dec: Xen_arity in s7 now uses s7_arity. Xen_define_integer_procedure, Xen_define_dilambda.
  20. * 21-Feb: Xen_is_number and friends.
  21. * 7-Jan-14: in s7, C_TO_XEN_STRING and XEN_TO_C_STRING now treat a null string as a string (not #f).
  22. * --------
  23. * 9-Nov: removed XEN_DEFINE_PROCEDURE_WITH_REVERSED_SETTER.
  24. * 11-Oct: removed XEN_EXACT_P.
  25. * 23-Sep: removed *_OR_ELSE, XEN_ARG_*, and OFF_T* macros; added XEN_ARGIFY* to the Forth section.
  26. * 7-Jul-13: removed int64 stuff (it was not used anywhere). Made various Ruby changes (NUM2ULL etc).
  27. * --------
  28. * 5-Nov: minor s7-related changes.
  29. * 9-July: XEN_VECTOR_ELEMENTS and XEN_VECTOR_COPY.
  30. * 4-June: XEN_PROVIDE
  31. * 8-May: added description arg to XEN_DEFINE_SIMPLE_HOOK and XEN_DEFINE_HOOK, only used in scheme.
  32. * 12-Jan-12: added reverse argument to s7 version of XEN_MAKE_OBJECT_TYPE.
  33. * --------
  34. * 20-Oct: XEN_LONG_LONG_P.
  35. * 5-Jun-11: XEN_DEFINE_SAFE_PROCEDURE, an experiment with s7.
  36. * --------
  37. * 25-Nov: updates for Ruby 1.9.*.
  38. * 7-Nov: XEN_ADD_HOOK.
  39. * 23-Oct: use s7_call_with_location, rather than s7_call, for better error reporting.
  40. * 19-Mar: removed s7_define_set_function (removed encapsulation from s7, so it's not useful anymore).
  41. * 17-Feb: various s7 changes.
  42. * 5-Feb-10: XEN_ASSOC_REF and XEN_ASSOC_SET. XEN_ASSOC_REF returns the value, not the key/value pair.
  43. * --------
  44. * 16-Dec: removed Guile support. removed xen_return_first (a guile-ism).
  45. * 2-Nov: XEN_VECTOR_RANK.
  46. * 5-Oct: use s7_c_pointer etc.
  47. * 7-Aug: use s7_new_type_x in XEN_MAKE_OBJECT_TYPE. XEN_DEFINE_SET_PROCEDURE.
  48. * 27-Jul: INT64_T cases paralleling OFF_T (the latter may go away someday).
  49. * 14-Jul: s7_define_function_star via XEN_DEFINE_PROCEDURE_STAR.
  50. * 6-Jul: cleaned up XEN_WRAP_C_POINTER et al (Mike Scholz).
  51. * 29-Jun: some fth changes.
  52. * 30-Mar: added a bunch of file-oriented functions for s7 (xen.c).
  53. * 14-Mar: removed XEN_LOCAL_GC_PROTECT and XEN_LOCAL_GC_UNPROTECT.
  54. * 14-Jan-09: s7_xen_initialize.
  55. * --------
  56. * 17-Nov: use s7_define_constant in XEN_DEFINE_CONSTANT.
  57. * 1-Nov: changed s7 and Guile C_TO_XEN_STRING slightly.
  58. * 16-Oct: removed Gauche support.
  59. * 10-Aug: S7, a TinyScheme derivative.
  60. * changed XEN_NUMERATOR and XEN_DENOMINATOR to return off_t not XEN.
  61. * 23-Jul: be more careful about wrapping POINTERs (they say 64-bit MS C void* == unsigned long long, but not unsigned long).
  62. * 30-Jun: XEN_OFF_T_IF_BOUND_P.
  63. * 19-May: more const char* arg declarations.
  64. * 14-May: changed XEN_ARITY in Guile to use scm_procedure_property.
  65. * 1-May: XEN_NAN_P and XEN_INF_P (Guile).
  66. * 23-Apr: try to get old Gauche (8.7) to work again.
  67. * 1-Mar-08: no ext case now checks arg consistency.
  68. * --------
  69. * 12-Dec: Gauche uses COMPNUM, not COMPLEX (after 0.8.7?), NUMBERP for complex?
  70. * 21-Nov: XEN_HAVE_COMPLEX_NUMBERS.
  71. * 18-Jul: Gauche error handling changes.
  72. * 28-Apr: Gauche API changes in versions 0.8.8, 0.8.10, and 0.9.
  73. * 14-Feb: XEN_PUTS and friends for fth (Mike).
  74. * 17-Jan-07: rb_errinfo changes (Mike Scholz).
  75. * --------
  76. * 14-Nov: check for Scm_EvalRec (Gauche 0.8.8).
  77. * 9-Sep: XEN_LOAD_PATH and XEN_ADD_TO_LOAD_PATH
  78. * 1-Sep: string and array changes for Ruby (from Mike).
  79. * 7-Aug: more careful list length handling in Ruby (from Mike).
  80. * 23-May: added xen_rb_repl_set_prompt to set (no-gui) Ruby repl prompt.
  81. * 12-May: changed HAVE_RATIOS to XEN_HAVE_RATIOS.
  82. * 17-Apr: removed XEN_MAKE_OBJECT.
  83. * 15-Apr: Gauche support.
  84. * 28-Mar-06: Forth support thanks to Mike Scholz.
  85. * --------
  86. * 7-Nov: xen_rb_defined_p (Mike Scholz).
  87. * 16-Sep: removed some debugging extras that caused confusion on 64-bit machines.
  88. * 12-Aug: include guile setter procedure names for better error reporting.
  89. * 14-Jun: XEN_DEFINE (XEN value, not assumed to be int as in XEN_DEFINE_CONSTANT).
  90. * XEN_ASSOC, XEN_MEMBER, and XEN_PROCEDURE_NAME for Scheme side.
  91. * XEN_DEFINE_HOOK and XEN_DEFINE_SIMPLE_HOOK no longer take the "Var" arg.
  92. * 18-May: deprecate XEN_NUMBER_OR_BOOLEAN_IF_BOUND_P and XEN_NUMBER_OR_BOOLEAN_P.
  93. * 29-Mar: C_TO_XEN_STRINGN changes.
  94. * 24-Mar: Ruby properties (Mike Scholz).
  95. * 8-Mar: Ruby improvements in keywords and hooks (Mike Scholz).
  96. * 7-Mar: C99 complex number changes (creal, _Complex_I) (Steve Bankowitz).
  97. * 2-Mar: Ruby support for off_t (Mike Scholz).
  98. * 4-Jan-05: more guile changes.
  99. * --------
  100. * 31-Dec: removed "caller" arg from *_NO_CATCH.
  101. * 10-Nov: scm_c_vector* (new Guile functions)
  102. * 21-Oct: XEN_LIST_REVERSE, (using rb_ary_dup available in 1.8)
  103. * 7-Oct: keyword changes for new Guile.
  104. * 28-Sep: deprecated *_WITH_CALLER -- these no longer do anything useful in Guile.
  105. * NaNs and Infs -> 0 or 0.0 in XEN_TO_C_INT|DOUBLE -- perhaps I should add another set of macros?
  106. * 23-Aug: more Guile name changes.
  107. * 12-Aug: more Guile name changes, C_TO_XEN_STRINGN (Guile)
  108. * 3-Aug: xen_to_c_int bugfix thanks to Kjetil S. Matheussen.
  109. * 29-Jul: deprecated XEN_TO_C_BOOLEAN_OR_TRUE.
  110. * 21-Jul: deprecated XEN_TO_SMALL_C_INT and C_TO_SMALL_XEN_INT.
  111. * use new Guile 1.7 numerical function names (under flag HAVE_SCM_TO_SIGNED_INTEGER).
  112. * 28-Jun: XEN_REQUIRED_ARGS_OK to make it easier to turn off this check.
  113. * 9-June: complex number conversions (Guile) -- Ruby complex numbers are an optional module?
  114. * 21-May: plug some memory leaks in Ruby cases.
  115. * 23-Feb: changed DEBUGGING to XEN_DEBUGGING, added redefinition checks under that switch.
  116. * 2-Feb: C_TO_XEN_CHAR, ratio support (Guile), XEN_CONS_P, XEN_PAIR_P, etc
  117. * 6-Jan: XEN_VARIABLE_REF in Guile changed to support 1.4 and older versions.
  118. * 5-Jan-04: hook support in Ruby thanks to Michael Scholz.
  119. * --------
  120. * 1-Nov: protect several macros from hidden double evaluations.
  121. * 29-Sep: fixed incorrect assumption in xen_rb_cons (xen.c) that arg2 was list.
  122. * 8-Sep: removed xen_malloc -- can't remember now why this existed.
  123. * 19-Aug: xen_rb_str_new2 to avoid unwanted side-effects.
  124. * 12-Aug: various changes for ISO C99.
  125. * 30-Jul: use new SCM_VECTOR_REF/SET macros if they're defined.
  126. * 7-Apr: changes to error handlers for more perspicuous error messages
  127. * changed XEN_PROTECT_FROM_GC in Ruby to use rb_gc_register_address, added XEN_UNPROTECT_FROM_GC (rb_gc_unregister_address)
  128. * 10-Mar: XEN_OUT_OF_RANGE_ERROR, XEN_BAD_ARITY_ERROR
  129. * 17-Feb: XEN_HOOK_P
  130. * 20-Jan-03: added Windows case for auto-import loader bugfix.
  131. * --------
  132. * 19-Dec: proc arg checks for Ruby (to make sure XEN_[N|V]ARGIFY|DEFINE_PROCEDURE[etc] agree)
  133. * 29-Jul: SCM_WRITABLE_VELTS for current CVS Guile
  134. * 28-May: off_t equivalents in Ruby 1.7
  135. * 6-May: off_t (long long) macros.
  136. * 2-Jan-02: removed TIMING and MCHECK debugging stuff, VARIABLE_REF -> XEN_VARIABLE_REF
  137. * --------
  138. * 22-Sep-01: removed (redundant) UNSIGNED_LONG macros -- use ULONG instead
  139. */
  140. #ifndef __cplusplus
  141. #include <sys/types.h>
  142. #ifndef _MSC_VER
  143. #include <stdbool.h>
  144. #else
  145. #ifndef true
  146. #define bool unsigned char
  147. #define true 1
  148. #define false 0
  149. #endif
  150. #endif
  151. #endif
  152. #if ((!__NetBSD__) && ((_MSC_VER) || (!defined(__STC__)) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ < 199901L))))
  153. #define __func__ __FUNCTION__
  154. #endif
  155. /* ------------------------------ RUBY ------------------------------ */
  156. /* other possibilities:
  157. * XEN_DEFINE_METHOD, XEN_DEFINE_ALIAS, rb_ary_unsift = XEN_LIST_PREPEND?,
  158. * various property macros -- in Scheme as well, rb_const_defined, rb_yield, XEN_INCLUDE_MODULE,
  159. * rb_id2name (XEN_SYMBOL...), rb_raise.
  160. */
  161. #if HAVE_RUBY
  162. #ifdef _GNU_SOURCE
  163. #undef _GNU_SOURCE
  164. #endif
  165. #include <ruby.h>
  166. #if defined(__GNUC__) && (!(defined(__cplusplus)))
  167. #ifndef _GNU_SOURCE
  168. #define _GNU_SOURCE
  169. #endif
  170. #endif
  171. #define XEN_OK 1
  172. #define XEN VALUE
  173. #define XEN_FILE_EXTENSION "rb"
  174. #define XEN_COMMENT_STRING "#"
  175. #define XEN_LANGUAGE_NAME "Ruby"
  176. #define XEN_FALSE Qfalse
  177. #define XEN_TRUE Qtrue
  178. #define XEN_TRUE_P(a) ((a) == Qtrue)
  179. #define XEN_FALSE_P(a) ((a) == Qfalse)
  180. #define C_TO_XEN_BOOLEAN(a) ((a) ? Qtrue : Qfalse)
  181. #define XEN_TO_C_BOOLEAN(a) (!(XEN_FALSE_P(a)))
  182. /* #define XEN_UNDEFINED Qundef */
  183. #define XEN_UNDEFINED ID2SYM(rb_intern("undefined"))
  184. #define XEN_BOUND_P(Arg) ((Arg) != XEN_UNDEFINED)
  185. #if defined(__GNUC__) && (!(defined(__cplusplus)))
  186. #define XEN_BOOLEAN_P(Arg) ({ XEN _xen_h_7_ = Arg; (XEN_TRUE_P(_xen_h_7_) || XEN_FALSE_P(_xen_h_7_)); })
  187. #define XEN_NUMBER_P(Arg) ({ int _xen_h_8_ = TYPE(Arg); ((_xen_h_8_ == T_FLOAT) || (_xen_h_8_ == T_FIXNUM) || (_xen_h_8_ == T_BIGNUM)); })
  188. #define XEN_INTEGER_P(Arg) ({ int _xen_h_9_ = TYPE(Arg); ((_xen_h_9_ == T_FIXNUM) || (_xen_h_9_ == T_BIGNUM)); })
  189. #define XEN_PROCEDURE_P(Arg) ({ XEN _xen_h_10_ = Arg; (XEN_BOUND_P(_xen_h_10_) && (rb_obj_is_kind_of(_xen_h_10_, rb_cProc))); })
  190. #define XEN_KEYWORD_P(Obj) ({ XEN _xen_h_12_ = Obj; (XEN_BOUND_P(_xen_h_12_) && SYMBOL_P(_xen_h_12_)); })
  191. #else
  192. #define XEN_BOOLEAN_P(Arg) (XEN_TRUE_P(Arg) || XEN_FALSE_P(Arg))
  193. #define XEN_NUMBER_P(Arg) ((TYPE(Arg) == T_FLOAT) || (TYPE(Arg) == T_FIXNUM) || (TYPE(Arg) == T_BIGNUM))
  194. #define XEN_INTEGER_P(Arg) ((TYPE(Arg) == T_FIXNUM) || (TYPE(Arg) == T_BIGNUM))
  195. #define XEN_PROCEDURE_P(Arg) (XEN_BOUND_P(Arg) && (rb_obj_is_kind_of(Arg, rb_cProc)))
  196. #define XEN_KEYWORD_P(Obj) (XEN_BOUND_P(Obj) && SYMBOL_P(Obj))
  197. #endif
  198. /* ---- lists ---- */
  199. #define XEN_EMPTY_LIST Qnil
  200. #define XEN_NULL_P(a) (XEN_LIST_LENGTH(a) == 0)
  201. #define XEN_CONS_P(Arg) (TYPE(Arg) == T_ARRAY)
  202. #define XEN_PAIR_P(Arg) (TYPE(Arg) == T_ARRAY)
  203. #define XEN_CONS(Arg1, Arg2) xen_rb_cons(Arg1, Arg2)
  204. #define XEN_CONS_2(Arg1, Arg2, Arg3) xen_rb_cons2(Arg1, Arg2, Arg3)
  205. #define XEN_CAR(a) xen_rb_list_ref(a, 0)
  206. #define XEN_CADR(a) xen_rb_list_ref(a, 1)
  207. #define XEN_CADDR(a) xen_rb_list_ref(a, 2)
  208. #define XEN_CADDDR(a) xen_rb_list_ref(a, 3)
  209. #define XEN_CDR(a) xen_rb_cdr(a)
  210. #define XEN_CDDR(a) XEN_CDR(XEN_CDR(a))
  211. #define XEN_CDDDR(a) XEN_CDR(XEN_CDR(XEN_CDR(a)))
  212. #define XEN_LIST_P(Arg) ((Arg) == XEN_EMPTY_LIST || XEN_CONS_P(Arg))
  213. #define XEN_LIST_P_WITH_LENGTH(Arg, Len) ((Len = XEN_LIST_LENGTH(Arg)) >= 0)
  214. #define XEN_LIST_LENGTH(Arg) xen_rb_list_length(Arg)
  215. #define XEN_EQ_P(a, b) ((a) == (b))
  216. #define XEN_LIST_1(a) rb_ary_new3(1, a)
  217. #define XEN_LIST_2(a, b) rb_ary_new3(2, a, b)
  218. #define XEN_LIST_3(a, b, c) rb_ary_new3(3, a, b, c)
  219. #define XEN_LIST_4(a, b, c, d) rb_ary_new3(4, a, b, c, d)
  220. #define XEN_LIST_5(a, b, c, d, e) rb_ary_new3(5, a, b, c, d, e)
  221. #define XEN_LIST_6(a, b, c, d, e, f) rb_ary_new3(6, a, b, c, d, e, f)
  222. #define XEN_LIST_7(a, b, c, d, e, f, g) rb_ary_new3(7, a, b, c, d, e, f, g)
  223. #define XEN_LIST_8(a, b, c, d, e, f, g, h) rb_ary_new3(8, a, b, c, d, e, f, g, h)
  224. #define XEN_LIST_9(a, b, c, d, e, f, g, h, i) rb_ary_new3(9, a, b, c, d, e, f, g, h, i)
  225. #define XEN_COPY_ARG(Lst) xen_rb_copy_list(Lst)
  226. #define XEN_LIST_REF(Lst, Num) xen_rb_list_ref(Lst, Num)
  227. #define XEN_LIST_SET(Lst, Num, Val) xen_rb_list_set(Lst, Num, Val)
  228. #define XEN_APPEND(X, Y) rb_ary_concat(X, Y)
  229. #define XEN_LIST_REVERSE(Lst) ((Lst == XEN_EMPTY_LIST) ? XEN_EMPTY_LIST : rb_ary_reverse(XEN_COPY_ARG(Lst)))
  230. /* ---- numbers ---- */
  231. #define XEN_ZERO INT2NUM(0)
  232. #define XEN_DOUBLE_P(Arg) XEN_NUMBER_P(Arg)
  233. #define XEN_TO_C_DOUBLE(a) NUM2DBL(a)
  234. #define C_TO_XEN_DOUBLE(a) rb_float_new(a)
  235. #define XEN_TO_C_INT(a) rb_num2long(a)
  236. /* apparently no complex numbers (built-in) in Ruby? */
  237. #define XEN_COMPLEX_P(Arg) 1
  238. #define C_TO_XEN_COMPLEX(a) XEN_ZERO
  239. #define XEN_TO_C_COMPLEX(a) 0.0
  240. #define XEN_ULONG_P(Arg1) XEN_INTEGER_P(Arg1)
  241. #define XEN_WRAPPED_C_POINTER_P(Arg1) XEN_INTEGER_P(Arg1)
  242. #define C_TO_XEN_INT(a) INT2NUM(a)
  243. #define XEN_TO_C_ULONG(a) NUM2ULONG(a)
  244. #ifdef ULONG2NUM
  245. #define C_TO_XEN_ULONG(a) ULONG2NUM((unsigned long)a)
  246. #else
  247. #define C_TO_XEN_ULONG(a) UINT2NUM((unsigned long)a)
  248. #endif
  249. #ifdef NUM2ULL
  250. /* ruby 1.9.3 */
  251. #define C_TO_XEN_LONG_LONG(a) LL2NUM(a)
  252. #define XEN_TO_C_LONG_LONG(a) NUM2LL(a)
  253. #define XEN_ULONG_LONG_P(Arg) XEN_INTEGER_P(Arg)
  254. #define XEN_TO_C_ULONG_LONG(Arg) NUM2ULL(Arg) /* NUM2ULONG(Arg) */
  255. #define C_TO_XEN_ULONG_LONG(Arg) ULL2NUM(Arg) /* INT2NUM(Arg) */
  256. #else
  257. /* older versions -- no dependable version number in ruby -- these macros may not work on a 64-bit machine */
  258. #ifndef OFFT2NUM
  259. #define OFFT2NUM(a) INT2NUM(a)
  260. #endif
  261. #ifndef NUM2OFFT
  262. #define NUM2OFFT(a) NUM2LONG(a)
  263. #endif
  264. #define C_TO_XEN_LONG_LONG(a) OFFT2NUM(a)
  265. #define XEN_TO_C_LONG_LONG(a) NUM2OFFT(a)
  266. #define XEN_ULONG_LONG_P(Arg) XEN_INTEGER_P(Arg)
  267. #define XEN_TO_C_ULONG_LONG(Arg) NUM2OFFT(Arg)
  268. #define C_TO_XEN_ULONG_LONG(Arg) OFFT2NUM(Arg)
  269. #endif
  270. /* ---- strings ---- */
  271. #define XEN_STRING_P(Arg) ((TYPE(Arg) == T_STRING) && (!SYMBOL_P(Arg)))
  272. #define C_TO_XEN_STRING(a) xen_rb_str_new2((char *)a)
  273. #define C_TO_XEN_STRINGN(a, len) rb_str_new((char *)a, len)
  274. #ifndef RSTRING_PTR
  275. #define XEN_TO_C_STRING(Str) RSTRING(Str)->ptr
  276. #else
  277. #define XEN_TO_C_STRING(Str) RSTRING_PTR(Str)
  278. #endif
  279. #define XEN_CHAR_P(Arg) XEN_STRING_P(Arg)
  280. #define XEN_TO_C_CHAR(Arg) XEN_TO_C_STRING(Arg)[0]
  281. #define C_TO_XEN_CHAR(Arg) rb_str_new((char *)(&(Arg)), 1)
  282. #define XEN_NAME_AS_C_STRING_TO_VALUE(a) xen_rb_gv_get(a)
  283. #define XEN_EVAL_C_STRING(Arg) xen_rb_eval_string_with_error(Arg)
  284. #define XEN_TO_STRING(Obj) xen_rb_obj_as_string(Obj)
  285. #define XEN_LOAD_FILE(a) xen_rb_load_file_with_error(C_TO_XEN_STRING(a))
  286. #define XEN_LOAD_PATH XEN_NAME_AS_C_STRING_TO_VALUE("$LOAD_PATH")
  287. #define XEN_ADD_TO_LOAD_PATH(Path) xen_rb_add_to_load_path(Path)
  288. /* ---- hooks ---- */
  289. #define XEN_HOOK_P(Arg) xen_rb_hook_p(Arg)
  290. #define XEN_HOOK_PROCEDURES(a) xen_rb_hook_to_a(a)
  291. #define XEN_CLEAR_HOOK(a) xen_rb_hook_reset_hook(a)
  292. #define XEN_HOOKED(a) (!xen_rb_hook_empty_p(a))
  293. #define XEN_DEFINE_HOOK(Name, Descr, Arity, Help) xen_rb_create_hook((char *)(Name), Arity, (char *)Help)
  294. #define XEN_DEFINE_SIMPLE_HOOK(Descr, Arity) xen_rb_create_simple_hook(Arity);
  295. #define XEN_ADD_HOOK(Hook, Func, Name, Doc) xen_rb_add_hook(Hook, (XEN (*)())Func, Name, Doc)
  296. /* ---- vectors ---- */
  297. #define XEN_VECTOR_P(Arg) (TYPE(Arg) == T_ARRAY)
  298. #define XEN_VECTOR_LENGTH(Arg) xen_rb_list_length(Arg)
  299. #define XEN_VECTOR_REF(Vect, Num) xen_rb_list_ref(Vect, Num)
  300. #define XEN_VECTOR_SET(Vect, Num, Val) xen_rb_list_set(Vect, Num, Val)
  301. #define XEN_MAKE_VECTOR(Num, Fill) xen_rb_ary_new_with_initial_element(Num, Fill)
  302. #define XEN_VECTOR_TO_LIST(a) a
  303. #define XEN_VECTOR_COPY(Vect) rb_ary_dup(Vect)
  304. #define XEN_ASSOC_REF(Item, Lst) xen_assoc(Item, Lst)
  305. #define XEN_ASSOC_SET(Sym, Val, Lst) xen_set_assoc(Sym, Val, Lst)
  306. /* ---- symbols ---- */
  307. #define XEN_SYMBOL_P(Arg) SYMBOL_P(Arg)
  308. #define XEN_SYMBOL_TO_C_STRING(a) ((char *)rb_id2name(SYM2ID(a)))
  309. #define C_STRING_TO_XEN_SYMBOL(a) ID2SYM(rb_intern(a))
  310. #define XEN_SYMBOL_TO_STRING(Sym) C_TO_XEN_STRING(XEN_SYMBOL_TO_C_STRING(Sym))
  311. #define XEN_DOCUMENTATION_SYMBOL C_STRING_TO_XEN_SYMBOL("documentation")
  312. #define XEN_OBJECT_HELP(Name) rb_documentation(Name)
  313. #define XEN_SET_OBJECT_HELP(Name, Help) rb_set_documentation(Name, Help)
  314. #define C_SET_OBJECT_HELP(name, help) XEN_SET_OBJECT_HELP(C_TO_XEN_STRING(name), C_TO_XEN_STRING(help))
  315. #define XEN_VARIABLE_SET(a, b) xen_rb_gv_set(a, b)
  316. #define XEN_VARIABLE_REF(a) xen_rb_gv_get(a)
  317. #define XEN_DEFINE_CONSTANT(Name, Value, Help) \
  318. do { \
  319. char *temp; \
  320. temp = xen_scheme_constant_to_ruby(Name); \
  321. rb_define_global_const(temp, C_TO_XEN_INT(Value)); \
  322. if ((Name) && (Help)) C_SET_OBJECT_HELP(temp, Help); \
  323. if (temp) free(temp); \
  324. } while (0)
  325. #define XEN_DEFINE_VARIABLE(Name, Var, Value) \
  326. { \
  327. char *temp; \
  328. Var = Value; \
  329. temp = xen_scheme_global_variable_to_ruby(Name); \
  330. rb_define_variable(temp, (VALUE *)(&Var)); \
  331. if (temp) free(temp); \
  332. }
  333. #define XEN_DEFINE(Name, Value) xen_rb_define(Name, Value)
  334. #define XEN_DEFINED_P(Name) xen_rb_defined_p(Name)
  335. /* ---- C structs ---- */
  336. #define XEN_MARK_OBJECT_TYPE void *
  337. #define XEN_MAKE_AND_RETURN_OBJECT(Tag, Val, Mark, Free) return(Data_Wrap_Struct(Tag, Mark, Free, Val))
  338. #define XEN_MAKE_OBJECT(Tag, Val, Mark, Free) Data_Wrap_Struct(Tag, Mark, Free, Val)
  339. #define XEN_OBJECT_REF(a) DATA_PTR(a)
  340. #define XEN_OBJECT_TYPE VALUE
  341. #define XEN_OBJECT_TYPE_P(OBJ, TAG) (XEN_BOUND_P(OBJ) && (rb_obj_is_instance_of(OBJ, TAG)))
  342. #define XEN_MAKE_OBJECT_TYPE(Typ, Siz) xen_rb_define_class(Typ)
  343. #define XEN_MAKE_OBJECT_FREE_PROCEDURE(Type, Wrapped_Free, Original_Free) \
  344. static void *Wrapped_Free(XEN obj) \
  345. { \
  346. Original_Free((Type *)obj); \
  347. return(NULL); \
  348. }
  349. #define XEN_MAKE_OBJECT_PRINT_PROCEDURE(Type, Wrapped_Print, Original_Print) \
  350. static XEN Wrapped_Print(XEN obj) \
  351. { \
  352. XEN val; \
  353. char *str; \
  354. str = Original_Print((Type *)XEN_OBJECT_REF(obj)); \
  355. val = C_TO_XEN_STRING(str); \
  356. free(str); \
  357. return(val); \
  358. }
  359. /* ---- procedures ---- */
  360. #ifdef __cplusplus
  361. #ifdef ANYARGS
  362. #define XEN_PROCEDURE_CAST (XEN (*)(ANYARGS))
  363. #define XEN_VALUE_ARG_PROCEDURE_CAST (XEN (*)(VALUE))
  364. #else
  365. #define XEN_PROCEDURE_CAST (XEN (*)())
  366. #define XEN_VALUE_ARG_PROCEDURE_CAST (XEN (*)())
  367. #endif
  368. #else
  369. #define XEN_PROCEDURE_CAST
  370. #define XEN_VALUE_ARG_PROCEDURE_CAST
  371. #endif
  372. #define XEN_ARITY(Func) rb_funcall(Func, rb_intern("arity"), 0)
  373. #define XEN_REQUIRED_ARGS(Func) xen_rb_required_args(XEN_ARITY(Func))
  374. #define XEN_REQUIRED_ARGS_OK(Func, Args) (xen_rb_required_args(XEN_ARITY(Func)) == Args)
  375. #define XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) \
  376. do { \
  377. char *temp; \
  378. temp = xen_scheme_procedure_to_ruby(Name); \
  379. rb_define_global_function(temp, XEN_PROCEDURE_CAST Func, ((RstArg > 0) ? -2 : (OptArg > 0) ? -1 : ReqArg)); \
  380. if ((Name) && (Doc)) C_SET_OBJECT_HELP(temp, Doc); \
  381. if (temp) free(temp); \
  382. } while (0)
  383. #define XEN_DEFINE_PROCEDURE_WITH_SETTER(Get_Name, Get_Func, Get_Help, Set_Name, Set_Func, Get_Req, Get_Opt, Set_Req, Set_Opt) \
  384. do { \
  385. XEN_DEFINE_PROCEDURE(Get_Name, XEN_PROCEDURE_CAST Get_Func, Get_Req, Get_Opt, 0, Get_Help); \
  386. XEN_DEFINE_PROCEDURE(Set_Name, XEN_PROCEDURE_CAST Set_Func, Set_Req, Set_Opt, 0, Get_Help); \
  387. } while (0)
  388. #define XEN_DEFINE_SAFE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc)
  389. #define XEN_CALL_0(Func, Caller) xen_rb_funcall_0(Func)
  390. #define XEN_CALL_1(Func, Arg1, Caller) rb_funcall(Func, rb_intern("call"), 1, Arg1)
  391. #define XEN_CALL_2(Func, Arg1, Arg2, Caller) rb_funcall(Func, rb_intern("call"), 2, Arg1, Arg2)
  392. #define XEN_CALL_3(Func, Arg1, Arg2, Arg3, Caller) rb_funcall(Func, rb_intern("call"), 3, Arg1, Arg2, Arg3)
  393. #define XEN_CALL_4(Func, Arg1, Arg2, Arg3, Arg4, Caller) rb_funcall(Func, rb_intern("call"), 4, Arg1, Arg2, Arg3, Arg4)
  394. #define XEN_CALL_5(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Caller) rb_funcall(Func, rb_intern("call"), 5, Arg1, Arg2, Arg3, Arg4, Arg5)
  395. #define XEN_CALL_6(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Caller) rb_funcall(Func, rb_intern("call"), 6, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
  396. #define XEN_APPLY(Func, Args, Caller) xen_rb_apply(Func, Args)
  397. #define XEN_CALL_0_NO_CATCH(Func) xen_rb_funcall_0(Func)
  398. #define XEN_CALL_1_NO_CATCH(Func, Arg1) rb_funcall(Func, rb_intern("call"), 1, Arg1)
  399. #define XEN_CALL_2_NO_CATCH(Func, Arg1, Arg2) rb_funcall(Func, rb_intern("call"), 2, Arg1, Arg2)
  400. #define XEN_CALL_3_NO_CATCH(Func, Arg1, Arg2, Arg3) rb_funcall(Func, rb_intern("call"), 3, Arg1, Arg2, Arg3)
  401. #define XEN_APPLY_NO_CATCH(Func, Args) xen_rb_apply(Func, Args)
  402. /* ---- keywords, etc ---- */
  403. #define XEN_KEYWORD_EQ_P(k1, k2) ((k1) == (k2))
  404. #define XEN_MAKE_KEYWORD(Arg) xen_rb_make_keyword(Arg)
  405. #define XEN_PROVIDE(a) rb_provide(a)
  406. #define XEN_PROTECT_FROM_GC(Var) rb_gc_register_address(&(Var))
  407. #define XEN_UNPROTECT_FROM_GC(Var) rb_gc_unregister_address(&(Var))
  408. /* ---- errors ---- */
  409. #define XEN_ERROR_TYPE(Name) xen_rb_intern(Name)
  410. #if USE_SND
  411. #define XEN_ERROR(Type, Info) snd_rb_raise(Type, Info)
  412. #define XEN_OUT_OF_RANGE_ERROR(Caller, ArgN, Arg, Descr) \
  413. snd_rb_raise(XEN_ERROR_TYPE("out-of-range"), \
  414. XEN_LIST_5(C_TO_XEN_STRING("~A: argument ~A, ~A, is out of range (~A)"), \
  415. C_TO_XEN_STRING(xen_scheme_procedure_to_ruby(Caller)), \
  416. C_TO_XEN_INT(ArgN), \
  417. Arg, \
  418. C_TO_XEN_STRING(Descr)))
  419. #define XEN_WRONG_TYPE_ARG_ERROR(Caller, ArgN, Arg, Descr) \
  420. snd_rb_raise(XEN_ERROR_TYPE("wrong-type-arg"), \
  421. XEN_LIST_5(C_TO_XEN_STRING("~A: argument ~A, ~A, should be ~A"), \
  422. C_TO_XEN_STRING(xen_scheme_procedure_to_ruby(Caller)), \
  423. C_TO_XEN_INT(ArgN), \
  424. Arg, \
  425. C_TO_XEN_STRING(Descr)))
  426. #else
  427. #define XEN_ERROR(Type, Info) xen_rb_raise(Type, Info)
  428. #define XEN_OUT_OF_RANGE_ERROR(Caller, ArgN, Arg, Descr) \
  429. rb_raise(rb_eRangeError, "%s: argument %d, %s, is out of range (%s)\n", \
  430. Caller, (int)ArgN, XEN_AS_STRING(Arg), Descr)
  431. #define XEN_WRONG_TYPE_ARG_ERROR(Caller, ArgN, Arg, Descr) \
  432. rb_raise(rb_eTypeError, "%s: argument %d, %s, should be %s\n", \
  433. Caller, (int)ArgN, XEN_AS_STRING(Arg), Descr)
  434. #endif
  435. #define XEN_ASSERT_TYPE(Assertion, Arg, Position, Caller, Correct_Type) \
  436. if (!(Assertion)) \
  437. XEN_WRONG_TYPE_ARG_ERROR(Caller, Position, Arg, Correct_Type)
  438. #define XEN_THROW(Type, Info) xen_rb_raise(Type, Info)
  439. #define XEN_ARGIFY_1(OutName, InName) \
  440. static XEN OutName(int argc, XEN *argv, XEN self) \
  441. { \
  442. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED)); \
  443. }
  444. #define XEN_ARGIFY_2(OutName, InName) \
  445. static XEN OutName(int argc, XEN *argv, XEN self) \
  446. { \
  447. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  448. (argc > 1) ? argv[1] : XEN_UNDEFINED)); \
  449. }
  450. #define XEN_ARGIFY_3(OutName, InName) \
  451. static XEN OutName(int argc, XEN *argv, XEN self) \
  452. { \
  453. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  454. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  455. (argc > 2) ? argv[2] : XEN_UNDEFINED)); \
  456. }
  457. #define XEN_ARGIFY_4(OutName, InName) \
  458. static XEN OutName(int argc, XEN *argv, XEN self) \
  459. { \
  460. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  461. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  462. (argc > 2) ? argv[2] : XEN_UNDEFINED, \
  463. (argc > 3) ? argv[3] : XEN_UNDEFINED)); \
  464. }
  465. #define XEN_ARGIFY_5(OutName, InName) \
  466. static XEN OutName(int argc, XEN *argv, XEN self) \
  467. { \
  468. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  469. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  470. (argc > 2) ? argv[2] : XEN_UNDEFINED, \
  471. (argc > 3) ? argv[3] : XEN_UNDEFINED, \
  472. (argc > 4) ? argv[4] : XEN_UNDEFINED)); \
  473. }
  474. #define XEN_ARGIFY_6(OutName, InName) \
  475. static XEN OutName(int argc, XEN *argv, XEN self) \
  476. { \
  477. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  478. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  479. (argc > 2) ? argv[2] : XEN_UNDEFINED, \
  480. (argc > 3) ? argv[3] : XEN_UNDEFINED, \
  481. (argc > 4) ? argv[4] : XEN_UNDEFINED, \
  482. (argc > 5) ? argv[5] : XEN_UNDEFINED)); \
  483. }
  484. #define XEN_ARGIFY_7(OutName, InName) \
  485. static XEN OutName(int argc, XEN *argv, XEN self) \
  486. { \
  487. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  488. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  489. (argc > 2) ? argv[2] : XEN_UNDEFINED, \
  490. (argc > 3) ? argv[3] : XEN_UNDEFINED, \
  491. (argc > 4) ? argv[4] : XEN_UNDEFINED, \
  492. (argc > 5) ? argv[5] : XEN_UNDEFINED, \
  493. (argc > 6) ? argv[6] : XEN_UNDEFINED)); \
  494. }
  495. #define XEN_ARGIFY_8(OutName, InName) \
  496. static XEN OutName(int argc, XEN *argv, XEN self) \
  497. { \
  498. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  499. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  500. (argc > 2) ? argv[2] : XEN_UNDEFINED, \
  501. (argc > 3) ? argv[3] : XEN_UNDEFINED, \
  502. (argc > 4) ? argv[4] : XEN_UNDEFINED, \
  503. (argc > 5) ? argv[5] : XEN_UNDEFINED, \
  504. (argc > 6) ? argv[6] : XEN_UNDEFINED, \
  505. (argc > 7) ? argv[7] : XEN_UNDEFINED)); \
  506. }
  507. #define XEN_ARGIFY_9(OutName, InName) \
  508. static XEN OutName(int argc, XEN *argv, XEN self) \
  509. { \
  510. return(InName((argc > 0) ? argv[0] : XEN_UNDEFINED, \
  511. (argc > 1) ? argv[1] : XEN_UNDEFINED, \
  512. (argc > 2) ? argv[2] : XEN_UNDEFINED, \
  513. (argc > 3) ? argv[3] : XEN_UNDEFINED, \
  514. (argc > 4) ? argv[4] : XEN_UNDEFINED, \
  515. (argc > 5) ? argv[5] : XEN_UNDEFINED, \
  516. (argc > 6) ? argv[6] : XEN_UNDEFINED, \
  517. (argc > 7) ? argv[7] : XEN_UNDEFINED, \
  518. (argc > 8) ? argv[8] : XEN_UNDEFINED)); \
  519. }
  520. #define XEN_NARGIFY_0(OutName, InName) \
  521. static XEN OutName(void) {return(InName());}
  522. #define XEN_NARGIFY_1(OutName, InName) \
  523. static XEN OutName(XEN self, XEN Arg) {return(InName(Arg));}
  524. #define XEN_NARGIFY_2(OutName, InName) \
  525. static XEN OutName(XEN self, XEN Arg1, XEN Arg2) {return(InName(Arg1, Arg2));}
  526. #define XEN_NARGIFY_3(OutName, InName) \
  527. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3) {return(InName(Arg1, Arg2, Arg3));}
  528. #define XEN_NARGIFY_4(OutName, InName) \
  529. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3, XEN Arg4) {return(InName(Arg1, Arg2, Arg3, Arg4));}
  530. #define XEN_NARGIFY_5(OutName, InName) \
  531. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3, XEN Arg4, XEN Arg5) {return(InName(Arg1, Arg2, Arg3, Arg4, Arg5));}
  532. #define XEN_NARGIFY_6(OutName, InName) \
  533. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3, XEN Arg4, XEN Arg5, XEN Arg6) {return(InName(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6));}
  534. #define XEN_NARGIFY_7(OutName, InName) \
  535. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3, XEN Arg4, XEN Arg5, XEN Arg6, XEN Arg7) \
  536. {return(InName(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7));}
  537. #define XEN_NARGIFY_8(OutName, InName) \
  538. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3, XEN Arg4, XEN Arg5, XEN Arg6, XEN Arg7, XEN Arg8) \
  539. {return(InName(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8));}
  540. #define XEN_NARGIFY_9(OutName, InName) \
  541. static XEN OutName(XEN self, XEN Arg1, XEN Arg2, XEN Arg3, XEN Arg4, XEN Arg5, XEN Arg6, XEN Arg7, XEN Arg8, XEN Arg9) \
  542. {return(InName(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9));}
  543. #define XEN_VARGIFY(OutName, InName) \
  544. static XEN OutName(XEN self, XEN Args) {return(InName(Args));}
  545. #ifdef __cplusplus
  546. extern "C" {
  547. #endif
  548. XEN xen_rb_gv_get(const char *name);
  549. XEN xen_rb_gv_set(const char *name, XEN new_val);
  550. XEN xen_rb_intern(const char *name);
  551. XEN xen_rb_make_keyword(const char *name);
  552. void xen_rb_define(const char *name, XEN value);
  553. XEN xen_rb_cdr(XEN val);
  554. XEN xen_rb_cons(XEN arg1, XEN arg2);
  555. XEN xen_rb_cons2(XEN arg1, XEN arg2, XEN arg3);
  556. char *xen_scheme_constant_to_ruby(const char *name);
  557. char *xen_scheme_procedure_to_ruby(const char *name);
  558. char *xen_scheme_global_variable_to_ruby(const char *name);
  559. bool xen_rb_defined_p(const char *name);
  560. XEN xen_rb_define_class(const char *name);
  561. int xen_rb_list_length(XEN obj);
  562. XEN xen_rb_list_ref(XEN obj, int index);
  563. XEN xen_rb_list_set(XEN obj, int index, XEN value);
  564. void xen_rb_raise(XEN type, XEN info);
  565. XEN xen_rb_obj_as_string(XEN obj);
  566. XEN xen_rb_eval_string_with_error(const char *str);
  567. XEN xen_rb_load_file_with_error(XEN file);
  568. XEN xen_rb_ary_new_with_initial_element(long num, XEN element);
  569. XEN xen_rb_apply(XEN func, XEN args);
  570. XEN xen_rb_funcall_0(XEN func);
  571. int xen_rb_required_args(XEN val);
  572. XEN xen_rb_copy_list(XEN val);
  573. XEN xen_rb_str_new2(char *arg);
  574. void xen_add_help(char *name, const char *help);
  575. char *xen_help(char *name);
  576. /* class Hook */
  577. bool xen_rb_hook_p(XEN hook);
  578. bool xen_rb_hook_empty_p(XEN hook);
  579. XEN xen_rb_hook_c_new(char *name, int arity, char *help);
  580. XEN xen_rb_hook_reset_hook(XEN hook);
  581. XEN xen_rb_hook_to_a(XEN hook);
  582. void Init_Hook(void);
  583. XEN xen_rb_create_hook(char *name, int arity, char *help);
  584. XEN xen_rb_create_simple_hook(int arity);
  585. XEN xen_rb_add_hook(XEN hook, VALUE (*func)(), const char *name, const char *doc);
  586. typedef XEN (*XEN_CATCH_BODY_TYPE) (void *data);
  587. XEN rb_properties(void);
  588. XEN rb_property(XEN obj, XEN prop);
  589. XEN rb_set_property(XEN obj, XEN prop, XEN val);
  590. XEN rb_documentation(XEN name);
  591. XEN rb_set_documentation(XEN name, XEN help);
  592. bool xen_rb_arity_ok(int rargs, int args);
  593. void xen_rb_repl_set_prompt(const char *prompt);
  594. XEN xen_rb_add_to_load_path(char *path);
  595. XEN xen_set_assoc(XEN key, XEN val, XEN alist);
  596. XEN xen_assoc(XEN key, XEN alist);
  597. #ifdef __cplusplus
  598. }
  599. #endif
  600. #endif
  601. /* end HAVE_RUBY */
  602. /* ------------------------------ FORTH ------------------------------ */
  603. #if HAVE_FORTH
  604. #include <fth.h>
  605. #if USE_SND
  606. # undef gettext_noop
  607. # undef _
  608. # undef N_
  609. #endif
  610. #define XEN_OK true
  611. #define XEN FTH
  612. #define XEN_FILE_EXTENSION FTH_FILE_EXTENSION
  613. #define XEN_COMMENT_STRING "\\"
  614. #define XEN_LANGUAGE_NAME "Forth"
  615. #define XEN_FALSE FTH_FALSE
  616. #define XEN_TRUE FTH_TRUE
  617. #define XEN_EMPTY_LIST FTH_NIL
  618. #define XEN_UNDEFINED FTH_UNDEF
  619. #define XEN_DOCUMENTATION_SYMBOL FTH_DOCUMENTATION_SYMBOL
  620. #define XEN_DEFINED_P(name) fth_defined_p((char *)name)
  621. #define XEN_PROVIDE(feature) fth_add_feature(feature)
  622. /* === Boolean, Bound, Equal === */
  623. #define XEN_BOOLEAN_P(Arg) FTH_BOOLEAN_P(Arg)
  624. #define XEN_TRUE_P(a) FTH_TRUE_P(a)
  625. #define XEN_FALSE_P(a) FTH_FALSE_P(a)
  626. #define C_TO_XEN_BOOLEAN(a) BOOL_TO_FTH(a)
  627. #define XEN_TO_C_BOOLEAN(a) FTH_TO_BOOL(a)
  628. #define XEN_BOUND_P(Arg) FTH_BOUND_P(Arg)
  629. #define XEN_EQ_P(a, b) ((a) == (b))
  630. /* === Number === */
  631. #define XEN_ZERO FTH_ZERO
  632. #define XEN_NUMBER_P(Arg) FTH_NUMBER_P(Arg)
  633. #define XEN_WRAPPED_C_POINTER_P(Arg) FTH_EXACT_P(Arg)
  634. #define XEN_INTEGER_P(Arg) FTH_INTEGER_P(Arg)
  635. #define C_TO_XEN_INT(a) fth_make_int(a)
  636. #define XEN_TO_C_INT(a) fth_int_ref(a)
  637. #define XEN_ULONG_P(Arg) FTH_UNSIGNED_P(Arg)
  638. #define C_TO_XEN_ULONG(a) fth_make_unsigned((unsigned long)(a))
  639. #define XEN_TO_C_ULONG(a) fth_unsigned_ref(a)
  640. #define XEN_ULONG_LONG_P(Arg) XEN_ULONG_P(Arg)
  641. #define XEN_TO_C_ULONG_LONG(Arg) fth_ulong_long_ref(Arg)
  642. #define C_TO_XEN_ULONG_LONG(Arg) fth_make_ulong_long((unsigned long long)Arg)
  643. #define C_TO_XEN_LONG_LONG(a) fth_make_long_long(a)
  644. #define XEN_TO_C_LONG_LONG(a) fth_long_long_ref(a)
  645. #define XEN_DOUBLE_P(Arg) FTH_FLOAT_P(Arg)
  646. #define C_TO_XEN_DOUBLE(a) fth_make_float(a)
  647. #define XEN_TO_C_DOUBLE(a) fth_float_ref(a)
  648. #if HAVE_COMPLEX_NUMBERS
  649. # define XEN_COMPLEX_P(Arg) FTH_NUMBER_P(Arg)
  650. # define C_TO_XEN_COMPLEX(a) fth_make_complex(a)
  651. # define XEN_TO_C_COMPLEX(a) fth_complex_ref(a)
  652. # define XEN_HAVE_COMPLEX_NUMBERS 1
  653. #else
  654. # define XEN_COMPLEX_P(Arg) false
  655. # define C_TO_XEN_COMPLEX(a) XEN_ZERO
  656. # define XEN_TO_C_COMPLEX(a) 0.0
  657. #endif
  658. #if HAVE_MAKE_RATIO
  659. # define XEN_HAVE_RATIOS true
  660. # define XEN_RATIO_P(Arg) FTH_RATIO_P(Arg)
  661. # define XEN_MAKE_RATIO(Num, Den) fth_make_ratio(Num, Den)
  662. # define XEN_NUMERATOR(Arg) XEN_TO_C_LONG_LONG(fth_numerator(Arg))
  663. # define XEN_DENOMINATOR(Arg) XEN_TO_C_LONG_LONG(fth_denominator(Arg))
  664. # define XEN_RATIONALIZE(Arg1, Arg2) fth_rationalize(Arg1, Arg2)
  665. #endif
  666. /* === String, Symbol, Keyword, Eval === */
  667. #define XEN_CHAR_P(Arg) FTH_CHAR_P(Arg)
  668. #define C_TO_XEN_CHAR(Arg) CHAR_TO_FTH(Arg)
  669. #define XEN_TO_C_CHAR(Arg) FTH_TO_CHAR(Arg)
  670. #define XEN_STRING_P(Arg) FTH_STRING_P(Arg)
  671. #define C_TO_XEN_STRING(str) fth_make_string(str)
  672. #define C_TO_XEN_STRINGN(str, len) fth_make_string_len(str, len)
  673. #define XEN_TO_C_STRING(Str) fth_string_ref(Str)
  674. #if HAVE_FTH_PORT_PUTS
  675. /* port = XEN_FALSE means default output handler (snd-print). */
  676. #define XEN_PUTS(Str, Port) fth_port_puts(Port, Str)
  677. #define XEN_DISPLAY(Val, Port) fth_port_display(Port, Val)
  678. #define XEN_FLUSH_PORT(Port) fth_port_flush(Port)
  679. #define XEN_CLOSE_PORT(Port) fth_port_close(Port)
  680. #define XEN_PORT_TO_STRING(Port) fth_port_to_string(Port)
  681. #endif
  682. #define XEN_TO_STRING(Obj) fth_object_to_string(Obj)
  683. #define XEN_SYMBOL_P(Arg) FTH_SYMBOL_P(Arg)
  684. #define C_STRING_TO_XEN_SYMBOL(a) fth_symbol(a)
  685. #define XEN_SYMBOL_TO_C_STRING(Sym) fth_symbol_ref(Sym)
  686. #define XEN_KEYWORD_P(Obj) FTH_KEYWORD_P(Obj)
  687. #define XEN_MAKE_KEYWORD(arg) fth_keyword(arg)
  688. #define XEN_KEYWORD_EQ_P(K1, K2) XEN_EQ_P(K1, K2)
  689. #define XEN_EVAL_C_STRING(arg) fth_eval(arg)
  690. #define XEN_LOAD_FILE(a) fth_load_file(a)
  691. #define XEN_LOAD_PATH XEN_NAME_AS_C_STRING_TO_VALUE("*load-path*")
  692. #define XEN_ADD_TO_LOAD_PATH(Path) fth_add_load_path(Path)
  693. /* === Vector (Array) === */
  694. #define XEN_MAKE_VECTOR(Num, Fill) fth_make_array_with_init(Num, Fill)
  695. #define XEN_VECTOR_P(Arg) FTH_ARRAY_P(Arg)
  696. #define XEN_VECTOR_LENGTH(Arg) ((int)fth_array_length(Arg))
  697. #define XEN_VECTOR_TO_LIST(Vect) fth_array_to_list(Vect)
  698. #define XEN_VECTOR_REF(Vect, Num) fth_array_ref(Vect, Num)
  699. #define XEN_VECTOR_SET(Vect, Num, Val) fth_array_set(Vect, Num, Val)
  700. #define XEN_VECTOR_COPY(Vect) fth_array_copy(Vect)
  701. /* === List === */
  702. #define XEN_NULL_P(a) FTH_NIL_P(a)
  703. #define XEN_LIST_P(Arg) FTH_LIST_P(Arg)
  704. #define XEN_CONS_P(Arg) FTH_CONS_P(Arg)
  705. #define XEN_PAIR_P(Arg) FTH_PAIR_P(Arg)
  706. #define XEN_CONS(Arg1, Arg2) fth_cons(Arg1, Arg2)
  707. #define XEN_CONS_2(Arg1, Arg2, Arg3) fth_cons_2(Arg1, Arg2, Arg3)
  708. #define XEN_LIST_REF(Lst, Num) fth_list_ref(Lst, Num)
  709. #define XEN_LIST_SET(Lst, Num, Val) fth_list_set(Lst, Num, Val)
  710. #define XEN_LIST_REVERSE(Lst) fth_list_reverse(Lst)
  711. #define XEN_LIST_P_WITH_LENGTH(Arg, Len) ((Len = XEN_LIST_LENGTH(Arg)) >= 0)
  712. #define XEN_LIST_LENGTH(Arg) ((int)fth_list_length(Arg))
  713. #define XEN_LIST_1(a) FTH_LIST_1(a)
  714. #define XEN_LIST_2(a, b) FTH_LIST_2(a, b)
  715. #define XEN_LIST_3(a, b, c) FTH_LIST_3(a, b, c)
  716. #define XEN_LIST_4(a, b, c, d) FTH_LIST_4(a, b, c, d)
  717. #define XEN_LIST_5(a, b, c, d, e) FTH_LIST_5(a, b, c, d, e)
  718. #define XEN_LIST_6(a, b, c, d, e, f) FTH_LIST_6(a, b, c, d, e, f)
  719. #define XEN_LIST_7(a, b, c, d, e, f, g) FTH_LIST_7(a, b, c, d, e, f, g)
  720. #define XEN_LIST_8(a, b, c, d, e, f, g, h) FTH_LIST_8(a, b, c, d, e, f, g, h)
  721. #define XEN_LIST_9(a, b, c, d, e, f, g, h, i) FTH_LIST_9(a, b, c, d, e, f, g, h, i)
  722. #define XEN_CAR(a) fth_car(a)
  723. #define XEN_CADR(a) FTH_CADR(a)
  724. #define XEN_CADDR(a) FTH_CADDR(a)
  725. #define XEN_CADDDR(a) FTH_CADDDR(a)
  726. #define XEN_CDR(a) fth_cdr(a)
  727. #define XEN_CDDR(a) FTH_CDDR(a)
  728. #define XEN_CDDDR(a) FTH_CDDDR(a)
  729. #define XEN_COPY_ARG(Lst) fth_list_copy(Lst)
  730. #define XEN_APPEND(a, b) fth_list_append(XEN_LIST_2(a, b))
  731. #define XEN_ASSOC_REF(Item, Lst) fth_list_assoc_ref(Lst, Item)
  732. #define XEN_ASSOC_SET(Sym, Val, Lst) fth_list_assoc_set(Lst, Sym, Val)
  733. #define XEN_ASSOC(Item, Lst) fth_list_assoc_ref(Lst, Item) /* perhaps fth_list_assoc? */
  734. #define XEN_MEMBER(Item, Lst) fth_list_member_p(Lst, Item)
  735. /* === Hook, Procedure === */
  736. #define XEN_HOOK_P(Arg) FTH_HOOK_P(Arg)
  737. #define XEN_HOOKED(a) (!fth_hook_empty_p(a))
  738. #define XEN_DEFINE_HOOK(name, descr, arity, help) fth_make_hook(name, arity, help)
  739. #define XEN_DEFINE_SIMPLE_HOOK(descr, arity) fth_make_simple_hook(arity)
  740. #define XEN_CLEAR_HOOK(Arg) fth_hook_clear(Arg)
  741. #define XEN_HOOK_PROCEDURES(Obj) fth_hook_procedure_list(Obj)
  742. #define XEN_ADD_HOOK(Hook, Func, Name, Doc) fth_add_hook(Hook, (FTH)fth_define_procedure(Name, Func, fth_hook_arity(Hook), 0, false, Doc))
  743. #define XEN_PROCEDURE_P(Arg) FTH_PROC_P(Arg)
  744. #define XEN_PROCEDURE_NAME(Func) C_TO_XEN_STRING(fth_proc_name(Func))
  745. #define XEN_PROCEDURE_HELP(Name) fth_documentation_ref(Name)
  746. #define XEN_ARITY(Func) INT_TO_FIX(XEN_REQUIRED_ARGS(Func))
  747. #define XEN_REQUIRED_ARGS(Func) fth_proc_arity(Func)
  748. #define XEN_REQUIRED_ARGS_OK(Func, args) (XEN_REQUIRED_ARGS(Func) == (args))
  749. #define XEN_CALL_0(Func, Caller) fth_proc_call(Func, Caller, 0)
  750. #define XEN_CALL_1(Func, Arg1, Caller) fth_proc_call(Func, Caller, 1, Arg1)
  751. #define XEN_CALL_2(Func, Arg1, Arg2, Caller) fth_proc_call(Func, Caller, 2, Arg1, Arg2)
  752. #define XEN_CALL_3(Func, Arg1, Arg2, Arg3, Caller) fth_proc_call(Func, Caller, 3, Arg1, Arg2, Arg3)
  753. #define XEN_CALL_4(Func, Arg1, Arg2, Arg3, Arg4, Caller) \
  754. fth_proc_call(Func, Caller, 4, Arg1, Arg2, Arg3, Arg4)
  755. #define XEN_CALL_5(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Caller) \
  756. fth_proc_call(Func, Caller, 5, Arg1, Arg2, Arg3, Arg4, Arg5)
  757. #define XEN_CALL_6(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Caller) \
  758. fth_proc_call(Func, Caller, 6, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)
  759. #define XEN_APPLY(Func, Args, Caller) fth_proc_apply(Func, Args, Caller)
  760. #define XEN_CALL_0_NO_CATCH(Func) XEN_CALL_0(Func, NULL)
  761. #define XEN_CALL_1_NO_CATCH(Func, Arg1) XEN_CALL_1(Func, Arg1, NULL)
  762. #define XEN_CALL_2_NO_CATCH(Func, Arg1, Arg2) XEN_CALL_2(Func, Arg1, Arg2, NULL)
  763. #define XEN_CALL_3_NO_CATCH(Func, Arg1, Arg2, Arg3) XEN_CALL_3(Func, Arg1, Arg2, Arg3, NULL)
  764. #define XEN_APPLY_NO_CATCH(Func, Args) XEN_APPLY(Func, Args, NULL)
  765. /* === Define === */
  766. #define XEN_DEFINE(name, Value) fth_define(name, Value)
  767. #define XEN_DEFINE_CONSTANT(name, Value, help) fth_define_constant(name, Value, help)
  768. #define XEN_DEFINE_VARIABLE(name, Var, Value) (Var = fth_define_variable(name, Value, NULL))
  769. #define XEN_VARIABLE_SET(name, Value) fth_variable_set((char *)(name), Value)
  770. #define XEN_VARIABLE_REF(name) fth_variable_ref((char *)(name))
  771. #define XEN_NAME_AS_C_STRING_TO_VARIABLE(name) fth_word_ref((char *)(name))
  772. #define XEN_NAME_AS_C_STRING_TO_VALUE(name) XEN_VARIABLE_REF(name)
  773. #ifdef __cplusplus
  774. # define XEN_PROCEDURE_CAST (XEN (*)())
  775. #else
  776. # define XEN_PROCEDURE_CAST
  777. #endif
  778. #define XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) \
  779. fth_define_procedure(Name, XEN_PROCEDURE_CAST Func, ReqArg, OptArg, RstArg, Doc)
  780. #define XEN_DEFINE_PROCEDURE_WITH_SETTER(Get_Name, Get_Func, Get_Help, Set_Name, Set_Func, Get_Req, Get_Opt, Set_Req, Set_Opt) \
  781. do { \
  782. XEN_DEFINE_PROCEDURE(Get_Name, XEN_PROCEDURE_CAST Get_Func, Get_Req, Get_Opt, 0, Get_Help); \
  783. XEN_DEFINE_PROCEDURE(Set_Name, XEN_PROCEDURE_CAST Set_Func, Set_Req, Set_Opt, 0, Get_Help); \
  784. } while (0)
  785. #define XEN_DEFINE_SAFE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc)
  786. /* === Object === */
  787. #define XEN_OBJECT_TYPE FTH
  788. #define XEN_MARK_OBJECT_TYPE void
  789. #define XEN_MAKE_AND_RETURN_OBJECT(Tag, Val, Mark, Free) return(fth_make_instance(Tag, Val))
  790. #define XEN_MAKE_OBJECT(Tag, Val, Mark, Free) fth_make_instance(Tag, Val)
  791. #define XEN_OBJECT_TYPE_P(Obj, Tag) fth_object_is_instance_of(Obj, Tag)
  792. #define XEN_OBJECT_REF(Obj) fth_instance_ref_gen(Obj)
  793. #define XEN_MAKE_OBJECT_TYPE(Typ, Siz) fth_make_object_type(Typ)
  794. #define XEN_OBJECT_HELP(Name) fth_documentation_ref(Name)
  795. #define XEN_PROTECT_FROM_GC(Obj) fth_gc_protect(Obj)
  796. #define XEN_UNPROTECT_FROM_GC(Obj) fth_gc_unprotect(Obj)
  797. #define XEN_MAKE_OBJECT_PRINT_PROCEDURE(Type, Wrapped_Print, Original_Print) \
  798. static XEN Wrapped_Print(XEN obj) \
  799. { \
  800. char * str = Original_Print((Type *)XEN_OBJECT_REF(obj)); \
  801. XEN val = C_TO_XEN_STRING(str); \
  802. free(str); \
  803. return val; \
  804. }
  805. #define XEN_MAKE_OBJECT_FREE_PROCEDURE(Type, Wrapped_Free, Original_Free) \
  806. static void Wrapped_Free(XEN obj) \
  807. { \
  808. Original_Free((Type *)XEN_OBJECT_REF(obj)); \
  809. }
  810. /* === Error === */
  811. #define XEN_ASSERT_TYPE(Assertion, Arg, Position, Caller, Correct_Type) \
  812. FTH_ASSERT_TYPE(Assertion, Arg, Position, Caller, Correct_Type)
  813. #define XEN_ERROR_TYPE(Typ) fth_exception(Typ)
  814. #define XEN_ERROR(Type, Info) fth_throw_list(Type, Info)
  815. #define XEN_THROW(Type, Info) XEN_ERROR(Type, Info)
  816. #define XEN_OUT_OF_RANGE_ERROR(Caller, ArgN, Arg, Descr) \
  817. FTH_OUT_OF_RANGE_ERROR(Caller, ArgN, Arg, Descr)
  818. #define XEN_WRONG_TYPE_ARG_ERROR(Caller, ArgN, Arg, Descr) \
  819. FTH_WRONG_TYPE_ARG_ERROR(Caller, ArgN, Arg, Descr)
  820. typedef XEN (*XEN_CATCH_BODY_TYPE) (void *data);
  821. #define XEN_NARGIFY_0(OutName, InName) static XEN (*OutName)(void) = InName;
  822. #define XEN_NARGIFY_1(OutName, InName) static XEN (*OutName)(XEN a1) = InName;
  823. #define XEN_NARGIFY_2(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2) = InName;
  824. #define XEN_NARGIFY_3(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3) = InName;
  825. #define XEN_NARGIFY_4(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4) = InName;
  826. #define XEN_NARGIFY_5(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5) = InName;
  827. #define XEN_NARGIFY_6(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6) = InName;
  828. #define XEN_NARGIFY_7(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6, XEN a7) = InName;
  829. #define XEN_NARGIFY_8(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6, XEN a7, XEN a8) = InName;
  830. #define XEN_NARGIFY_9(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6, XEN a7, XEN a8, XEN a9) = InName;
  831. #define XEN_ARGIFY_1(OutName, InName) static XEN (*OutName)(XEN a1) = InName;
  832. #define XEN_ARGIFY_2(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2) = InName;
  833. #define XEN_ARGIFY_3(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3) = InName;
  834. #define XEN_ARGIFY_4(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4) = InName;
  835. #define XEN_ARGIFY_5(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5) = InName;
  836. #define XEN_ARGIFY_6(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6) = InName;
  837. #define XEN_ARGIFY_7(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6, XEN a7) = InName;
  838. #define XEN_ARGIFY_8(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6, XEN a7, XEN a8) = InName;
  839. #define XEN_ARGIFY_9(OutName, InName) static XEN (*OutName)(XEN a1, XEN a2, XEN a3, XEN a4, XEN a5, XEN a6, XEN a7, XEN a8, XEN a9) = InName;
  840. #define XEN_VARGIFY(OutName, InName) static XEN (*OutName)(XEN a1) = InName;
  841. #endif /* end HAVE_FORTH */
  842. /* ------------------------------ s7 ------------------------------ */
  843. #if HAVE_SCHEME
  844. #define XEN_OK 1
  845. #include "s7.h"
  846. #ifdef __cplusplus
  847. extern "C" {
  848. #endif
  849. extern s7_scheme *s7; /* s7 is a pointer to the current scheme */
  850. #ifdef __cplusplus
  851. }
  852. #endif
  853. #define XEN s7_pointer
  854. #define XEN_FILE_EXTENSION "scm"
  855. #define XEN_LANGUAGE_NAME "s7"
  856. #define XEN_COMMENT_STRING ";"
  857. extern XEN xen_false, xen_true, xen_nil, xen_undefined, xen_zero;
  858. extern size_t xen_s7_number_location, xen_s7_denominator_location;
  859. #define XEN_FALSE xen_false
  860. #define XEN_TRUE xen_true
  861. #define XEN_TRUE_P(Arg) ((Arg) == XEN_TRUE) /* not scheme-wise, but Snd-wise (#t as special arg) */
  862. #define XEN_FALSE_P(Arg) ((Arg) == XEN_FALSE)
  863. #define XEN_BOOLEAN_P(Arg) s7_is_boolean(Arg)
  864. #define C_TO_XEN_BOOLEAN(Arg) ((Arg) ? XEN_TRUE : XEN_FALSE)
  865. #define XEN_TO_C_BOOLEAN(Arg) ((XEN_TRUE_P(Arg)) ? true : false)
  866. #define XEN_NULL_P(Arg) ((Arg) == xen_nil)
  867. #define XEN_BOUND_P(Arg) ((Arg) != xen_undefined)
  868. #define XEN_EMPTY_LIST xen_nil
  869. #define XEN_UNDEFINED xen_undefined
  870. #define XEN_EQ_P(Arg1, Arg2) ((Arg1) == (Arg2))
  871. #define XEN_CONS_P(Arg) s7_cons_p(Arg)
  872. #define XEN_CONS(Arg1, Arg2) s7_cons(s7, Arg1, Arg2)
  873. #define XEN_CONS_2(Arg1, Arg2, Arg3) s7_cons(s7, Arg1, s7_cons(s7, Arg2, Arg3))
  874. #define XEN_PAIR_P(Arg) s7_is_pair(Arg)
  875. #define XEN_CAR(Arg) s7_car(Arg)
  876. #define XEN_CDR(Arg) s7_cdr(Arg)
  877. #define XEN_CADR(Arg) s7_cadr(Arg)
  878. #define XEN_CADDR(Arg) s7_caddr(Arg)
  879. #define XEN_CADDDR(Arg) s7_cadddr(Arg)
  880. #define XEN_CDDR(Arg) s7_cddr(Arg)
  881. #define XEN_CDDDR(Arg) s7_cdddr(Arg)
  882. #define XEN_LIST_P(Arg) s7_is_list(s7, Arg) /* not pair? because we want '() to return #t here */
  883. #define XEN_LIST_LENGTH(Arg) s7_list_length(s7, Arg)
  884. #define XEN_LIST_P_WITH_LENGTH(Arg, Len) ((s7_is_list(s7, Arg)) && ((Len = XEN_LIST_LENGTH(Arg)) >= 0))
  885. #define XEN_LIST_1(a) s7_list(s7, 1, a)
  886. #define XEN_LIST_2(a, b) s7_list(s7, 2, a, b)
  887. #define XEN_LIST_3(a, b, c) s7_list(s7, 3, a, b, c)
  888. #define XEN_LIST_4(a, b, c, d) s7_list(s7, 4, a, b, c, d)
  889. #define XEN_LIST_5(a, b, c, d, e) s7_list(s7, 5, a, b, c, d, e)
  890. #define XEN_LIST_6(a, b, c, d, e, f) s7_list(s7, 6, a, b, c, d, e, f)
  891. #define XEN_LIST_7(a, b, c, d, e, f, g) s7_list(s7, 7, a, b, c, d, e, f, g)
  892. #define XEN_LIST_8(a, b, c, d, e, f, g, h) s7_list(s7, 8, a, b, c, d, e, f, g, h)
  893. #define XEN_LIST_9(a, b, c, d, e, f, g, h, i) s7_list(s7, 9, a, b, c, d, e, f, g, h, i)
  894. #define XEN_LIST_REF(Lst, Num) s7_list_ref(s7, Lst, Num)
  895. #define XEN_LIST_SET(Lst, Num, Val) s7_list_set(s7, Lst, Num, Val)
  896. #define XEN_LIST_REVERSE(Lst) s7_reverse(s7, Lst)
  897. #define XEN_COPY_ARG(Lst) Lst
  898. #define XEN_APPEND(Arg1, Arg2) s7_append(s7, Arg1, Arg2)
  899. #define XEN_ASSOC_REF(Sym, Lst) xen_assoc(s7, Sym, Lst)
  900. #define XEN_ASSOC_SET(Sym, Val, Lst) xen_set_assoc(s7, Sym, Val, Lst)
  901. #define XEN_ASSOC(Sym, Lst) s7_assoc(s7, Sym, Lst)
  902. #define XEN_MEMBER(Sym, Lst) s7_member(s7, Sym, Lst)
  903. #define XEN_STRING_P(Arg) s7_is_string(Arg)
  904. #define XEN_NAME_AS_C_STRING_TO_VALUE(Arg) s7_name_to_value(s7, Arg)
  905. #define XEN_TO_C_STRING(Str) s7_string(Str)
  906. #define C_TO_XEN_STRING(Str) s7_make_string(s7, Str)
  907. #define C_TO_XEN_STRINGN(Str, Len) s7_make_string_with_length(s7, Str, Len)
  908. #define XEN_ZERO xen_zero
  909. #define XEN_INTEGER_P(Arg) s7_is_integer(Arg)
  910. #define C_TO_XEN_INT(Arg) s7_make_integer(s7, Arg)
  911. #define XEN_TO_C_INT(Arg) s7_integer(Arg)
  912. #define XEN_ULONG_P(Arg) s7_is_ulong(Arg)
  913. #define XEN_TO_C_ULONG(Arg) s7_ulong(Arg)
  914. #define C_TO_XEN_ULONG(Arg) s7_make_ulong(s7, (unsigned long)Arg)
  915. #define XEN_ULONG_LONG_P(Arg) s7_is_ulong_long(Arg)
  916. #define XEN_TO_C_ULONG_LONG(Arg) s7_ulong_long(Arg)
  917. #define C_TO_XEN_ULONG_LONG(Arg) s7_make_ulong_long(s7, (unsigned long long)Arg)
  918. #define C_TO_XEN_LONG_LONG(Arg) s7_make_integer(s7, Arg)
  919. #define XEN_TO_C_LONG_LONG(Arg) s7_integer(Arg)
  920. #define XEN_NUMBER_P(Arg) s7_is_real(Arg)
  921. #define XEN_WRAPPED_C_POINTER_P(Arg) s7_is_c_pointer(Arg)
  922. #define XEN_DOUBLE_P(Arg) s7_is_real(Arg)
  923. #define XEN_TO_C_DOUBLE(Arg) ((double)s7_number_to_real(s7, Arg))
  924. #define C_TO_XEN_DOUBLE(Arg) s7_make_real(s7, Arg)
  925. #if HAVE_COMPLEX_NUMBERS
  926. #define XEN_HAVE_COMPLEX_NUMBERS 1
  927. #define XEN_COMPLEX_P(Arg) s7_is_complex(Arg)
  928. #define XEN_TO_C_COMPLEX(a) (s7_real_part(a) + s7_imag_part(a) * _Complex_I)
  929. #define C_TO_XEN_COMPLEX(a) s7_make_complex(s7, creal(a), cimag(a))
  930. #else
  931. #define XEN_HAVE_COMPLEX_NUMBERS 0
  932. #define XEN_COMPLEX_P(Arg) false
  933. #define XEN_TO_C_COMPLEX(a) 0.0
  934. #define C_TO_XEN_COMPLEX(a) XEN_ZERO
  935. #endif
  936. #define XEN_HAVE_RATIOS 1
  937. #define XEN_NUMERATOR(Arg) s7_numerator(Arg)
  938. #define XEN_DENOMINATOR(Arg) s7_denominator(Arg)
  939. #define XEN_RATIONALIZE(Arg1, Arg2) s7_rationalize(s7, XEN_TO_C_DOUBLE(Arg1), XEN_TO_C_DOUBLE(Arg2))
  940. #define XEN_RATIO_P(Arg) s7_is_ratio(Arg)
  941. #define XEN_MAKE_RATIO(Num, Den) s7_make_ratio(s7, XEN_TO_C_INT(Num), XEN_TO_C_INT(Den))
  942. #define XEN_EVAL_C_STRING(Arg) s7_eval_c_string(s7, Arg)
  943. #define XEN_TO_STRING(Obj) s7_object_to_string(s7, Obj, false)
  944. #define XEN_SYMBOL_TO_C_STRING(Arg) s7_symbol_name(Arg)
  945. #define XEN_SYMBOL_P(Arg) s7_is_symbol(Arg)
  946. #define C_STRING_TO_XEN_SYMBOL(Arg) s7_make_symbol(s7, Arg)
  947. #define XEN_DOCUMENTATION_SYMBOL C_STRING_TO_XEN_SYMBOL("documentation")
  948. #define XEN_SET_DOCUMENTATION(Var, Doc)
  949. #define XEN_VECTOR_P(Arg) s7_is_vector(Arg)
  950. #define XEN_VECTOR_LENGTH(Arg) s7_vector_length(Arg)
  951. #define XEN_VECTOR_REF(Vect, Num) s7_vector_ref(s7, Vect, Num)
  952. #define XEN_VECTOR_SET(Vect, Num, Val) s7_vector_set(s7, Vect, Num, Val)
  953. #define XEN_MAKE_VECTOR(Num, Fill) s7_make_and_fill_vector(s7, Num, Fill)
  954. #define XEN_VECTOR_TO_LIST(Vect) s7_vector_to_list(s7, Vect)
  955. #define XEN_VECTOR_RANK(Vect) s7_vector_rank(Vect)
  956. #define XEN_VECTOR_COPY(Vect) s7_vector_copy(s7, Vect)
  957. #define XEN_VECTOR_ELEMENTS(Vect) s7_vector_elements(Vect)
  958. #define XEN_CHAR_P(Arg) s7_is_character(Arg)
  959. #define XEN_TO_C_CHAR(Arg) s7_character(Arg)
  960. #define C_TO_XEN_CHAR(Arg) s7_make_character(s7, Arg)
  961. #define XEN_KEYWORD_P(Obj) s7_is_keyword(Obj)
  962. #define XEN_KEYWORD_EQ_P(k1, k2) ((k1) == (k2))
  963. #define XEN_MAKE_KEYWORD(Arg) s7_make_keyword(s7, Arg)
  964. #define XEN_PROCEDURE_P(Arg) s7_is_procedure(Arg)
  965. #define XEN_LOAD_FILE(File) s7_load(s7, File)
  966. #define XEN_LOAD_PATH s7_load_path(s7)
  967. #define XEN_ADD_TO_LOAD_PATH(Path) s7_add_to_load_path(s7, Path)
  968. #define XEN_ERROR_TYPE(Typ) C_STRING_TO_XEN_SYMBOL(Typ)
  969. #define XEN_ERROR(Type, Info) s7_error(s7, Type, Info)
  970. #define XEN_THROW(Type, Info) s7_error(s7, Type, Info)
  971. #define XEN_PROVIDE(Feature) s7_provide(s7, Feature)
  972. #define XEN_PROTECT_FROM_GC(Arg) s7_gc_protect(s7, Arg)
  973. #define XEN_WRONG_TYPE_ARG_ERROR(Caller, ArgN, Arg, Descr) s7_wrong_type_arg_error(s7, Caller, ArgN, Arg, Descr)
  974. #define XEN_OUT_OF_RANGE_ERROR(Caller, ArgN, Arg, Descr) s7_out_of_range_error(s7, Caller, ArgN, Arg, Descr)
  975. #define XEN_ASSERT_TYPE(Assertion, Arg, Position, Caller, Correct_Type) if (!(Assertion)) XEN_WRONG_TYPE_ARG_ERROR(Caller, Position, Arg, Correct_Type)
  976. #define XEN_NARGIFY_0(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(InName());}
  977. #define XEN_NARGIFY_1(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(InName(XEN_CAR(args)));}
  978. #define XEN_NARGIFY_2(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_2(s7, args, InName));}
  979. #define XEN_NARGIFY_3(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_3(s7, args, InName));}
  980. #define XEN_NARGIFY_4(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_4(s7, args, InName));}
  981. #define XEN_NARGIFY_5(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_5(s7, args, InName));}
  982. #define XEN_NARGIFY_6(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_6(s7, args, InName));}
  983. #define XEN_NARGIFY_7(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_7(s7, args, InName));}
  984. #define XEN_NARGIFY_8(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_8(s7, args, InName));}
  985. #define XEN_NARGIFY_9(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_9(s7, args, InName));}
  986. #define XEN_ARGIFY_1(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_1(s7, args, InName));}
  987. #define XEN_ARGIFY_2(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_2(s7, args, InName));}
  988. #define XEN_ARGIFY_3(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_3(s7, args, InName));}
  989. #define XEN_ARGIFY_4(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_4(s7, args, InName));}
  990. #define XEN_ARGIFY_5(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_5(s7, args, InName));}
  991. #define XEN_ARGIFY_6(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_6(s7, args, InName));}
  992. #define XEN_ARGIFY_7(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_7(s7, args, InName));}
  993. #define XEN_ARGIFY_8(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_8(s7, args, InName));}
  994. #define XEN_ARGIFY_9(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(s7_apply_n_9(s7, args, InName));}
  995. #define XEN_VARGIFY(OutName, InName) static s7_pointer OutName(s7_scheme *sc, s7_pointer args) {return(InName(args));}
  996. #define XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) s7_define_function(s7, Name, Func, ReqArg, OptArg, RstArg, Doc)
  997. #define XEN_DEFINE_SAFE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) s7_define_safe_function(s7, Name, Func, ReqArg, OptArg, RstArg, Doc)
  998. #define XEN_DEFINE_PROCEDURE_STAR(Name, Func, Args, Doc) s7_define_function_star(s7, Name, Func, Args, Doc)
  999. #define XEN_DEFINE_PROCEDURE_WITH_SETTER(Get_Name, Get_Func, Get_Help, Set_Name, Set_Func, Get_Req, Get_Opt, Set_Req, Set_Opt) \
  1000. s7_dilambda(s7, Get_Name, Get_Func, Get_Req, Get_Opt, Set_Func, Set_Req, Set_Opt, Get_Help)
  1001. #define XEN_ARITY(Func) s7_arity(s7, Func)
  1002. #define XEN_REQUIRED_ARGS(Func) XEN_TO_C_INT(XEN_CAR(XEN_ARITY(Func)))
  1003. #define XEN_REQUIRED_ARGS_OK(Func, Args) s7_is_aritable(s7, Func, Args) /* (XEN_REQUIRED_ARGS(Func) == Args) */
  1004. #define XEN_CALL_0(Func, Caller) s7_call_with_location(s7, Func, XEN_EMPTY_LIST, Caller, __FILE__, __LINE__) /* these need a catch */
  1005. #define XEN_CALL_1(Func, Arg1, Caller) s7_call_with_location(s7, Func, XEN_LIST_1(Arg1), Caller, __FILE__, __LINE__)
  1006. #define XEN_CALL_2(Func, Arg1, Arg2, Caller) s7_call_with_location(s7, Func, XEN_LIST_2(Arg1, Arg2), Caller, __FILE__, __LINE__)
  1007. #define XEN_CALL_3(Func, Arg1, Arg2, Arg3, Caller) s7_call_with_location(s7, Func, XEN_LIST_3(Arg1, Arg2, Arg3), Caller, __FILE__, __LINE__)
  1008. #define XEN_CALL_4(Func, Arg1, Arg2, Arg3, Arg4, Caller) s7_call_with_location(s7, Func, XEN_LIST_4(Arg1, Arg2, Arg3, Arg4), Caller, __FILE__, __LINE__)
  1009. #define XEN_CALL_5(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Caller) s7_call_with_location(s7, Func, XEN_LIST_5(Arg1, Arg2, Arg3, Arg4, Arg5), Caller, __FILE__, __LINE__)
  1010. #define XEN_CALL_6(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Caller) s7_call_with_location(s7, Func, XEN_LIST_6(Arg1, Arg2, Arg3, Arg4, Arg5, Arg6), Caller, __FILE__, __LINE__)
  1011. #define XEN_APPLY(Func, Args, Caller) s7_call_with_location(s7, Func, Args, Caller, __FILE__, __LINE__)
  1012. #define XEN_CALL_0_NO_CATCH(Func) s7_call_with_location(s7, Func, XEN_EMPTY_LIST, __func__, __FILE__, __LINE__)
  1013. #define XEN_CALL_1_NO_CATCH(Func, Arg1) s7_call_with_location(s7, Func, XEN_LIST_1(Arg1), __func__, __FILE__, __LINE__)
  1014. #define XEN_CALL_2_NO_CATCH(Func, Arg1, Arg2) s7_call_with_location(s7, Func, XEN_LIST_2(Arg1, Arg2), __func__, __FILE__, __LINE__)
  1015. #define XEN_CALL_3_NO_CATCH(Func, Arg1, Arg2, Arg3) s7_call_with_location(s7, Func, XEN_LIST_3(Arg1, Arg2, Arg3), __func__, __FILE__, __LINE__)
  1016. #define XEN_APPLY_NO_CATCH(Func, Args) s7_call_with_location(s7, Func, Args, __func__, __FILE__, __LINE__)
  1017. typedef XEN (*XEN_CATCH_BODY_TYPE) (void *data);
  1018. #define XEN_DEFINE_CONSTANT(Name, Value, Help) s7_define_constant_with_documentation(s7, Name, s7_make_integer(s7, Value), Help)
  1019. #define XEN_DEFINE(Name, Value) s7_define_variable(s7, Name, Value)
  1020. #define XEN_DEFINED_P(Name) s7_is_defined(s7, Name)
  1021. #define XEN_DEFINE_VARIABLE(Name, Var, Value) Var = s7_define_variable(s7, Name, Value)
  1022. #define XEN_VARIABLE_SET(Var, Val) s7_symbol_set_value(s7, Var, Val)
  1023. #define XEN_VARIABLE_REF(Var) s7_symbol_value(s7, Var)
  1024. #define XEN_NAME_AS_C_STRING_TO_VARIABLE(a) s7_make_symbol(s7, a)
  1025. #define XEN_MARK_OBJECT_TYPE void
  1026. #define XEN_MAKE_OBJECT_TYPE(Name, Print, Free, Equal, Gc_Mark, Apply, Set, Length, Copy, Reverse, Fill) \
  1027. s7_new_type_x(Name, Print, Free, Equal, Gc_Mark, Apply, Set, Length, Copy, Reverse, Fill)
  1028. #define XEN_MAKE_OBJECT_FREE_PROCEDURE(Type, Wrapped_Free, Original_Free) \
  1029. static void Wrapped_Free(void *obj) {Original_Free((Type *)obj);}
  1030. #define XEN_MAKE_OBJECT_PRINT_PROCEDURE(Type, Wrapped_Print, Original_Print) \
  1031. static char *Wrapped_Print(s7_scheme *sc, void *obj) {return(Original_Print((Type *)obj));}
  1032. #define XEN_MAKE_AND_RETURN_OBJECT(Tag, Val, ig1, ig2) return(s7_make_object(s7, Tag, Val))
  1033. #define XEN_MAKE_OBJECT(Tag, Val, ig1, ig2) s7_make_object(s7, Tag, Val)
  1034. #define XEN_OBJECT_REF(Arg) s7_object_value(Arg)
  1035. #define XEN_OBJECT_TYPE int /* tag type */
  1036. #define XEN_OBJECT_TYPE_P(Obj, Tag) (s7_object_type(Obj) == Tag)
  1037. #define XEN_HOOK_P(Arg) ((Arg) != XEN_FALSE)
  1038. #define XEN_DEFINE_HOOK(Name, Descr, Arity, Help) s7_define_constant_with_documentation(s7, Name, s7_eval_c_string(s7, Descr), Help)
  1039. /* "simple hooks are for channel-local hooks (unnamed, accessed through the channel) */
  1040. #define XEN_DEFINE_SIMPLE_HOOK(Descr, Arity) s7_eval_c_string(s7, Descr)
  1041. #define XEN_HOOKED(Hook) s7_is_pair(s7_hook_functions(s7, Hook))
  1042. #define XEN_CLEAR_HOOK(Hook) s7_hook_set_functions(s7, Hook, s7_nil(s7))
  1043. #define XEN_HOOK_PROCEDURES(Hook) s7_hook_functions(s7, Hook)
  1044. #define XEN_ADD_HOOK(Hook, Func, Name, Doc) s7_hook_set_functions(s7, Hook, s7_cons(s7, s7_make_function(s7, Name, Func, 1, 0, false, Doc), s7_hook_functions(s7, Hook)))
  1045. #ifdef __cplusplus
  1046. extern "C" {
  1047. #endif
  1048. s7_scheme *s7_xen_initialize(s7_scheme *sc);
  1049. void xen_s7_set_repl_prompt(const char *new_prompt);
  1050. XEN xen_set_assoc(s7_scheme *sc, s7_pointer key, s7_pointer val, s7_pointer alist);
  1051. XEN xen_assoc(s7_scheme *sc, XEN key, XEN alist);
  1052. #ifdef __cplusplus
  1053. }
  1054. #endif
  1055. #endif
  1056. /* end s7 */
  1057. /* ------------------------------ NO EXTENSION LANGUAGE ------------------------------ */
  1058. #ifndef XEN_OK
  1059. #define XEN int
  1060. #define XEN_FILE_EXTENSION "txt"
  1061. #define XEN_LANGUAGE_NAME "What Language?"
  1062. #define XEN_COMMENT_STRING ";"
  1063. #define XEN_FALSE 0
  1064. #define XEN_TRUE 1
  1065. #define XEN_TRUE_P(a) ((a) == XEN_TRUE)
  1066. #define XEN_FALSE_P(a) ((a) == XEN_FALSE)
  1067. #define XEN_BOOLEAN_P(Arg) 0
  1068. #define C_TO_XEN_BOOLEAN(a) 0
  1069. #define XEN_TO_C_BOOLEAN(a) 0
  1070. #define XEN_NULL_P(a) ((a) == XEN_EMPTY_LIST)
  1071. #define XEN_BOUND_P(Arg) 0
  1072. #define XEN_EMPTY_LIST 0
  1073. #define XEN_UNDEFINED 0
  1074. #define XEN_EQ_P(a, b) 0
  1075. #define XEN_CONS_P(Arg) 0
  1076. #define XEN_CONS(Arg1, Arg2) 0
  1077. #define XEN_CONS_2(Arg1, Arg2, Arg3) 0
  1078. #define XEN_PAIR_P(Arg) 0
  1079. #define XEN_CAR(a) 0
  1080. #define XEN_CADR(a) 0
  1081. #define XEN_CADDR(a) 0
  1082. #define XEN_CADDDR(a) 0
  1083. #define XEN_CDR(a) 0
  1084. #define XEN_CDDR(a) 0
  1085. #define XEN_CDDDR(a) 0
  1086. #define XEN_LIST_P(Arg) 0
  1087. #define XEN_LIST_P_WITH_LENGTH(Arg, Len) 0
  1088. #define XEN_LIST_LENGTH(Arg) 0
  1089. #define XEN_LIST_1(a) 0
  1090. #define XEN_LIST_2(a, b) 0
  1091. #define XEN_LIST_3(a, b, c) 0
  1092. #define XEN_LIST_4(a, b, c, d) 0
  1093. #define XEN_LIST_5(a, b, c, d, e) 0
  1094. #define XEN_LIST_6(a, b, c, d, e, f) 0
  1095. #define XEN_LIST_7(a, b, c, d, e, f, g) 0
  1096. #define XEN_LIST_8(a, b, c, d, e, f, g, h) 0
  1097. #define XEN_LIST_9(a, b, c, d, e, f, g, h, i) 0
  1098. #define XEN_LIST_REF(Lst, Num) 0
  1099. #define XEN_LIST_SET(Lst, Num, Val)
  1100. #define XEN_LIST_REVERSE(Lst) 0
  1101. #define XEN_COPY_ARG(Lst) Lst
  1102. #define XEN_APPEND(X, Y) 0
  1103. #define XEN_STRING_P(Arg) 0
  1104. #define XEN_NAME_AS_C_STRING_TO_VALUE(a) 0
  1105. #define XEN_TO_C_STRING(STR) "(not a string)"
  1106. #define C_TO_XEN_STRING(a) 0
  1107. #define C_TO_XEN_STRINGN(Str, Len) 0
  1108. #define C_STRING_TO_XEN_SYMBOL(a) 0
  1109. #define XEN_ZERO 0
  1110. #define XEN_NUMBER_P(Arg) 0
  1111. #define XEN_DOUBLE_P(Arg) 0
  1112. #define XEN_TO_C_DOUBLE(a) 0.0
  1113. #define C_TO_XEN_DOUBLE(a) 0
  1114. #define XEN_INTEGER_P(Arg) 0
  1115. #define C_TO_XEN_INT(a) a
  1116. #define XEN_TO_C_INT(a) 0
  1117. #define XEN_COMPLEX_P(Arg) 0
  1118. #define XEN_TO_C_COMPLEX(a) 0.0
  1119. #define C_TO_XEN_COMPLEX(a) a
  1120. #define XEN_ULONG_P(Arg) 0
  1121. #define XEN_TO_C_ULONG(a) 0
  1122. #define C_TO_XEN_ULONG(a) 0
  1123. #define C_TO_XEN_LONG_LONG(a) a
  1124. #define XEN_TO_C_LONG_LONG(a) a
  1125. #define XEN_ULONG_LONG_P(Arg) 0
  1126. #define XEN_TO_C_ULONG_LONG(Arg) 0
  1127. #define C_TO_XEN_ULONG_LONG(Arg) 0
  1128. #define XEN_WRAPPED_C_POINTER_P(Arg) 0
  1129. #define XEN_EVAL_C_STRING(Arg) 0
  1130. #define XEN_SYMBOL_TO_C_STRING(a) "(not a symbol)"
  1131. #define XEN_TO_STRING(Obj) "(unknown)"
  1132. #define XEN_PROCEDURE_P(Arg) 0
  1133. #define XEN_ARGIFY_1(OutName, InName) static int OutName(void) {return(-1);}
  1134. #define XEN_ARGIFY_2(OutName, InName) static int OutName(void) {return(-2);}
  1135. #define XEN_ARGIFY_3(OutName, InName) static int OutName(void) {return(-3);}
  1136. #define XEN_ARGIFY_4(OutName, InName) static int OutName(void) {return(-4);}
  1137. #define XEN_ARGIFY_5(OutName, InName) static int OutName(void) {return(-5);}
  1138. #define XEN_ARGIFY_6(OutName, InName) static int OutName(void) {return(-6);}
  1139. #define XEN_ARGIFY_7(OutName, InName) static int OutName(void) {return(-7);}
  1140. #define XEN_ARGIFY_8(OutName, InName) static int OutName(void) {return(-8);}
  1141. #define XEN_ARGIFY_9(OutName, InName) static int OutName(void) {return(-9);}
  1142. #define XEN_NARGIFY_0(OutName, InName) static int OutName(void) {return(0);}
  1143. #define XEN_NARGIFY_1(OutName, InName) static int OutName(void) {return(1);}
  1144. #define XEN_NARGIFY_2(OutName, InName) static int OutName(void) {return(2);}
  1145. #define XEN_NARGIFY_3(OutName, InName) static int OutName(void) {return(3);}
  1146. #define XEN_NARGIFY_4(OutName, InName) static int OutName(void) {return(4);}
  1147. #define XEN_NARGIFY_5(OutName, InName) static int OutName(void) {return(5);}
  1148. #define XEN_NARGIFY_6(OutName, InName) static int OutName(void) {return(6);}
  1149. #define XEN_NARGIFY_7(OutName, InName) static int OutName(void) {return(7);}
  1150. #define XEN_NARGIFY_8(OutName, InName) static int OutName(void) {return(8);}
  1151. #define XEN_NARGIFY_9(OutName, InName) static int OutName(void) {return(9);}
  1152. #define XEN_VARGIFY(OutName, InName) static int OutName(void) {return(-100);}
  1153. #define XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) \
  1154. xen_no_ext_lang_check_args(Name, Func(), ReqArg, OptArg, RstArg)
  1155. #define XEN_DEFINE_PROCEDURE_WITH_SETTER(Get_Name, Get_Func, Get_Help, Set_Name, Set_Func, Get_Req, Get_Opt, Set_Req, Set_Opt) \
  1156. {xen_no_ext_lang_check_args(Get_Name, Get_Func(), Get_Req, Get_Opt, 0); xen_no_ext_lang_check_args(Set_Name, Set_Func(), Set_Req, Set_Opt, 0);}
  1157. #define XEN_DEFINE_SAFE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc) XEN_DEFINE_PROCEDURE(Name, Func, ReqArg, OptArg, RstArg, Doc)
  1158. #define XEN_ARITY(Func) 0
  1159. #define XEN_REQUIRED_ARGS(Func) 0
  1160. #define XEN_REQUIRED_ARGS_OK(Func, Args) false
  1161. #define XEN_CALL_0(Func, Caller) 0
  1162. #define XEN_CALL_1(Func, Arg1, Caller) 0
  1163. #define XEN_CALL_2(Func, Arg1, Arg2, Caller) 0
  1164. #define XEN_CALL_3(Func, Arg1, Arg2, Arg3, Caller) 0
  1165. #define XEN_CALL_4(Func, Arg1, Arg2, Arg3, Arg4, Caller) 0
  1166. #define XEN_CALL_5(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Caller) 0
  1167. #define XEN_CALL_6(Func, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Caller) 0
  1168. #define XEN_APPLY(Func, Args, Caller) 0
  1169. #define XEN_CALL_0_NO_CATCH(Func) 0
  1170. #define XEN_CALL_1_NO_CATCH(Func, Arg1) 0
  1171. #define XEN_CALL_2_NO_CATCH(Func, Arg1, Arg2) 0
  1172. #define XEN_CALL_3_NO_CATCH(Func, Arg1, Arg2, Arg3) 0
  1173. #define XEN_APPLY_NO_CATCH(Func, Args) 0
  1174. #define XEN_DEFINE_CONSTANT(a, b, c)
  1175. #define XEN_DEFINE_VARIABLE(a, b, c)
  1176. #define XEN_DEFINE(Name, Value)
  1177. #define XEN_VARIABLE_SET(a, b)
  1178. #define XEN_VARIABLE_REF(a) 0
  1179. #define XEN_MARK_OBJECT_TYPE XEN
  1180. #define XEN_MAKE_OBJECT_TYPE(Typ, Siz) 0
  1181. #define XEN_MAKE_OBJECT_PRINT_PROCEDURE(Type, Wrapped_Print, Original_Print)
  1182. #define XEN_MAKE_OBJECT_FREE_PROCEDURE(Type, Wrapped_Free, Original_Free)
  1183. #define XEN_MAKE_AND_RETURN_OBJECT(Tag, Val, ig1, ig2) return(0)
  1184. #define XEN_MAKE_OBJECT(Tag, Val, ig1, ig2) 0
  1185. #define XEN_OBJECT_REF(a) 0
  1186. #define XEN_OBJECT_TYPE int
  1187. #define XEN_OBJECT_TYPE_P(OBJ, TAG) 0
  1188. #define XEN_SYMBOL_P(Arg) 0
  1189. #define XEN_HOOK_P(Arg) 0
  1190. #define XEN_HOOKED(a) 0
  1191. #define XEN_DEFINE_HOOK(Name, Descr, Arity, Help) 0
  1192. #define XEN_DEFINE_SIMPLE_HOOK(Descr, Arity) 0
  1193. #define XEN_CLEAR_HOOK(Arg)
  1194. #define XEN_HOOK_PROCEDURES(a) 0
  1195. #define XEN_ADD_HOOK(Hook, Func, Name, Doc)
  1196. #define XEN_VECTOR_P(Arg) 0
  1197. #define XEN_VECTOR_LENGTH(Arg) 0
  1198. #define XEN_VECTOR_REF(Vect, Num) 0
  1199. #define XEN_VECTOR_SET(a, b, c)
  1200. #define XEN_MAKE_VECTOR(Num, Fill) 0
  1201. #define XEN_VECTOR_TO_LIST(Vect) 0
  1202. #define XEN_ASSOC_REF(Sym, Lst) 0
  1203. #define XEN_ASSOC_SET(Sym, Val, Lst) 0
  1204. #define XEN_CHAR_P(Arg) 0
  1205. #define XEN_TO_C_CHAR(Arg) 0
  1206. #define C_TO_XEN_CHAR(Arg) 0
  1207. #define XEN_KEYWORD_P(Obj) 0
  1208. #define XEN_KEYWORD_EQ_P(k1, k2) 0
  1209. #define XEN_MAKE_KEYWORD(Arg) 0
  1210. #define XEN_PROVIDE(Feature)
  1211. #define XEN_DOCUMENTATION_SYMBOL 0
  1212. #define XEN_OBJECT_HELP(Name) 0
  1213. #define XEN_PROTECT_FROM_GC(a) 0
  1214. #define XEN_LOAD_FILE(a) 0
  1215. #define XEN_LOAD_PATH XEN_FALSE
  1216. #define XEN_ADD_TO_LOAD_PATH(Path) XEN_FALSE
  1217. #define XEN_ERROR_TYPE(Typ) XEN_FALSE
  1218. #define XEN_ERROR(Type, Info) fprintf(stderr, "error")
  1219. #define XEN_THROW(Type, Info) fprintf(stderr, "error")
  1220. #define XEN_ASSERT_TYPE(Assertion, Arg, Position, Caller, Correct_Type)
  1221. #define XEN_WRONG_TYPE_ARG_ERROR(Caller, ArgN, Arg, Descr)
  1222. #define XEN_OUT_OF_RANGE_ERROR(Caller, ArgN, Arg, Descr)
  1223. typedef XEN (*XEN_CATCH_BODY_TYPE) (void *data);
  1224. #define XEN_UNPROTECT_FROM_GC(Var) 0
  1225. #ifdef __cplusplus
  1226. extern "C" {
  1227. #endif
  1228. void xen_no_ext_lang_check_args(const char *name, int args, int req_args, int opt_args, int rst_args);
  1229. #ifdef __cplusplus
  1230. }
  1231. #endif
  1232. #endif
  1233. /* end NO EXTENSION LANGUAGE */
  1234. #define XEN_NOT_TRUE_P(a) (!(XEN_TRUE_P(a)))
  1235. #define XEN_NOT_FALSE_P(a) (!(XEN_FALSE_P(a)))
  1236. #define XEN_NOT_NULL_P(a) (!(XEN_NULL_P(a)))
  1237. #define XEN_NOT_BOUND_P(Arg) (!(XEN_BOUND_P(Arg)))
  1238. #if defined(__GNUC__) && (!(defined(__cplusplus)))
  1239. #define XEN_BOOLEAN_IF_BOUND_P(Arg) ({ XEN _xen_h_14_ = Arg; ((XEN_BOOLEAN_P(_xen_h_14_)) || (XEN_NOT_BOUND_P(_xen_h_14_))); })
  1240. #define XEN_INTEGER_IF_BOUND_P(Arg) ({ XEN _xen_h_15_ = Arg; ((XEN_NOT_BOUND_P(_xen_h_15_)) || (XEN_INTEGER_P(_xen_h_15_))); })
  1241. #define XEN_NUMBER_IF_BOUND_P(Arg) ({ XEN _xen_h_16_ = Arg; ((XEN_NOT_BOUND_P(_xen_h_16_)) || (XEN_NUMBER_P(_xen_h_16_))); })
  1242. #define XEN_STRING_IF_BOUND_P(Arg) ({ XEN _xen_h_17_ = Arg; ((XEN_NOT_BOUND_P(_xen_h_17_)) || (XEN_STRING_P(_xen_h_17_))); })
  1243. #define XEN_INTEGER_OR_BOOLEAN_IF_BOUND_P(Arg) ({ XEN _xen_h_18_ = Arg; ((XEN_BOOLEAN_P(_xen_h_18_)) || (XEN_NOT_BOUND_P(_xen_h_18_)) || (XEN_INTEGER_P(_xen_h_18_))); })
  1244. #define XEN_INTEGER_OR_BOOLEAN_P(Arg) ({ XEN _xen_h_21_ = Arg; ((XEN_BOOLEAN_P(_xen_h_21_)) || (XEN_INTEGER_P(_xen_h_21_))); })
  1245. #else
  1246. #define XEN_BOOLEAN_IF_BOUND_P(Arg) ((XEN_BOOLEAN_P(Arg)) || (XEN_NOT_BOUND_P(Arg)))
  1247. #define XEN_INTEGER_IF_BOUND_P(Arg) ((XEN_NOT_BOUND_P(Arg)) || (XEN_INTEGER_P(Arg)))
  1248. #define XEN_NUMBER_IF_BOUND_P(Arg) ((XEN_NOT_BOUND_P(Arg)) || (XEN_NUMBER_P(Arg)))
  1249. #define XEN_STRING_IF_BOUND_P(Arg) ((XEN_NOT_BOUND_P(Arg)) || (XEN_STRING_P(Arg)))
  1250. #define XEN_INTEGER_OR_BOOLEAN_IF_BOUND_P(Arg) ((XEN_BOOLEAN_P(Arg)) || (XEN_NOT_BOUND_P(Arg)) || (XEN_INTEGER_P(Arg)))
  1251. #define XEN_INTEGER_OR_BOOLEAN_P(Arg) ((XEN_BOOLEAN_P(Arg)) || (XEN_INTEGER_P(Arg)))
  1252. #endif
  1253. #if (!HAVE_FORTH)
  1254. #define XEN_LONG_LONG_P(Arg) XEN_INTEGER_P(Arg)
  1255. #else
  1256. #define XEN_LONG_LONG_P(Arg) FTH_LONG_LONG_P(Arg)
  1257. #endif
  1258. #define XEN_LONG_LONG_IF_BOUND_P(Arg) ((XEN_NOT_BOUND_P(Arg)) || (XEN_LONG_LONG_P(Arg)))
  1259. #if (!HAVE_SCHEME)
  1260. #define XEN_AS_STRING(form) XEN_TO_C_STRING(XEN_TO_STRING(form))
  1261. #define XEN_VECTOR_RANK(Vect) 1
  1262. #else
  1263. #define XEN_AS_STRING(form) s7_object_to_c_string(s7, form)
  1264. #endif
  1265. #define XEN_BAD_ARITY_ERROR(Caller, ArgN, Arg, Descr) \
  1266. XEN_ERROR(XEN_ERROR_TYPE("bad-arity"), \
  1267. XEN_LIST_3(C_TO_XEN_STRING(Caller), \
  1268. C_TO_XEN_STRING(Descr), \
  1269. Arg))
  1270. #ifndef XEN_HAVE_RATIOS
  1271. #define XEN_NUMERATOR(Arg) 0
  1272. #define XEN_DENOMINATOR(Arg) 1
  1273. #define XEN_RATIONALIZE(Arg1, Arg2) 1
  1274. #define XEN_RATIO_P(Arg) false
  1275. #define XEN_MAKE_RATIO(Num, Den) 1
  1276. #endif
  1277. #ifndef XEN_DEFINED_P
  1278. #define XEN_DEFINED_P(Name) false
  1279. #endif
  1280. /* (need a way to pass an uninterpreted pointer from C to XEN then back to C) */
  1281. #if HAVE_SCHEME
  1282. #define XEN_WRAP_C_POINTER(a) s7_make_c_pointer(s7, (void *)(a))
  1283. #define XEN_UNWRAP_C_POINTER(a) s7_c_pointer(a)
  1284. #else
  1285. #if (SIZEOF_VOID_P == 4)
  1286. #define XEN_WRAP_C_POINTER(a) ((XEN)(C_TO_XEN_ULONG((unsigned int)a)))
  1287. #define XEN_UNWRAP_C_POINTER(a) XEN_TO_C_ULONG(a)
  1288. #else
  1289. #define XEN_WRAP_C_POINTER(a) C_TO_XEN_ULONG_LONG((unsigned long long int)(a))
  1290. #define XEN_UNWRAP_C_POINTER(a) XEN_TO_C_ULONG_LONG(a)
  1291. #endif
  1292. #endif
  1293. /* Feb-14: the upper case macro names and the old-fashioned _p names are ugly and hard to read -- start replacing them
  1294. */
  1295. #define Xen_is_number(Arg) XEN_NUMBER_P(Arg)
  1296. #define Xen_is_integer(Arg) XEN_INTEGER_P(Arg)
  1297. #define Xen_is_llong(Arg) XEN_LONG_LONG_P(Arg)
  1298. #define Xen_is_keyword(Arg) XEN_KEYWORD_P(Arg)
  1299. #define Xen_is_true(Arg) XEN_TRUE_P(Arg)
  1300. #define Xen_is_false(Arg) XEN_FALSE_P(Arg)
  1301. #define Xen_is_bound(Arg) XEN_BOUND_P(Arg)
  1302. #define Xen_is_boolean(Arg) XEN_BOOLEAN_P(Arg)
  1303. #define Xen_is_null(Arg) XEN_NULL_P(Arg)
  1304. #define Xen_is_eq(Arg1, Arg2) XEN_EQ_P(Arg1, Arg2)
  1305. #define Xen_is_cons(Arg) XEN_CONS_P(Arg)
  1306. #define Xen_is_pair(Arg) XEN_PAIR_P(Arg)
  1307. #define Xen_is_list(Arg) XEN_LIST_P(Arg)
  1308. #define Xen_is_string(Arg) XEN_STRING_P(Arg)
  1309. #define Xen_is_double(Arg) XEN_DOUBLE_P(Arg)
  1310. #define Xen_is_complex(Arg) XEN_COMPLEX_P(Arg)
  1311. #define Xen_is_ulong(Arg) XEN_ULONG_P(Arg)
  1312. #define Xen_is_ullong(Arg) XEN_ULONG_LONG_P(Arg)
  1313. #define Xen_is_wrapped_c_pointer(Arg) XEN_WRAPPED_C_POINTER_P(Arg)
  1314. #define Xen_is_procedure(Arg) XEN_PROCEDURE_P(Arg)
  1315. #define Xen_c_object_is_type(Obj, Tag) XEN_OBJECT_TYPE_P(Obj, Tag)
  1316. #define Xen_is_symbol(Arg) XEN_SYMBOL_P(Arg)
  1317. #define Xen_is_hook(Arg) XEN_HOOK_P(Arg)
  1318. #define Xen_is_vector(Arg) XEN_VECTOR_P(Arg)
  1319. #define Xen_is_char(Arg) XEN_CHAR_P(Arg)
  1320. #define Xen_keyword_is_eq(Arg1, Arg2) XEN_KEYWORD_EQ_P(Arg1, Arg2)
  1321. #define Xen_is_defined(Arg) XEN_DEFINED_P(Arg)
  1322. #define Xen_is_ratio(Arg) XEN_RATIO_P(Arg)
  1323. #define Xen_is_llong_or_unbound(Arg) XEN_LONG_LONG_IF_BOUND_P(Arg)
  1324. #define Xen_is_boolean_or_unbound(Arg) XEN_BOOLEAN_IF_BOUND_P(Arg)
  1325. #define Xen_is_integer_or_unbound(Arg) XEN_INTEGER_IF_BOUND_P(Arg)
  1326. #define Xen_is_number_or_unbound(Arg) XEN_NUMBER_IF_BOUND_P(Arg)
  1327. #define Xen_is_string_or_unbound(Arg) XEN_STRING_IF_BOUND_P(Arg)
  1328. #define Xen_is_integer_boolean_or_unbound(Arg) XEN_INTEGER_OR_BOOLEAN_IF_BOUND_P(Arg)
  1329. #define Xen_is_integer_or_boolean(Arg) XEN_INTEGER_OR_BOOLEAN_P(Arg)
  1330. #define Xen_append(a, b) XEN_APPEND(a, b)
  1331. #define Xen_cadddr(a) XEN_CADDDR(a)
  1332. #define Xen_caddr(a) XEN_CADDR(a)
  1333. #define Xen_cadr(a) XEN_CADR(a)
  1334. #define Xen_car(a) XEN_CAR(a)
  1335. #define Xen_cddr(a) XEN_CDDR(a)
  1336. #define Xen_cdddr(a) XEN_CDDDR(a)
  1337. #define Xen_cdr(a) XEN_CDR(a)
  1338. #define Xen_cons(a, b) XEN_CONS(a, b)
  1339. #define Xen_cons_2(a, b, c) XEN_CONS_2(a, b, c)
  1340. #define Xen_list_1(a) XEN_LIST_1(a)
  1341. #define Xen_list_2(a, b) XEN_LIST_2(a, b)
  1342. #define Xen_list_3(a, b, c) XEN_LIST_3(a, b, c)
  1343. #define Xen_list_4(a, b, c, d) XEN_LIST_4(a, b, c, d)
  1344. #define Xen_list_5(a, b, c, d, e) XEN_LIST_5(a, b, c, d, e)
  1345. #define Xen_list_6(a, b, c, d, e, f) XEN_LIST_6(a, b, c, d, e, f)
  1346. #define Xen_list_7(a, b, c, d, e, f, g) XEN_LIST_7(a, b, c, d, e, f, g)
  1347. #define Xen_list_8(a, b, c, d, e, f, g, h) XEN_LIST_8(a, b, c, d, e, f, g, h)
  1348. #define Xen_list_9(a, b, c, d, e, f, g, h, i) XEN_LIST_9(a, b, c, d, e, f, g, h, i)
  1349. #define Xen_list_length(a) XEN_LIST_LENGTH(a)
  1350. #define Xen_list_ref(a, b) XEN_LIST_REF(a, b)
  1351. #define Xen_list_reverse(a) XEN_LIST_REVERSE(a)
  1352. #define Xen_list_set(a, b, c) XEN_LIST_SET(a, b, c)
  1353. #define Xen_member(a, b) XEN_MEMBER(a, b)
  1354. #define Xen_make_keyword(a) XEN_MAKE_KEYWORD(a)
  1355. #define Xen_make_vector(a, b) XEN_MAKE_VECTOR(a, b)
  1356. #define Xen_throw(a) XEN_THROW(a)
  1357. #define Xen_vector_length(a) XEN_VECTOR_LENGTH(a)
  1358. #define Xen_vector_ref(a, b) XEN_VECTOR_REF(a, b)
  1359. #define Xen_vector_set(a, b, c) XEN_VECTOR_SET(a, b, c)
  1360. #define Xen_vector_to_Xen_list(a) XEN_VECTOR_TO_LIST(a)
  1361. #define C_bool_to_Xen_boolean(a) C_TO_XEN_BOOLEAN(a)
  1362. #define C_char_to_Xen_char(a) C_TO_XEN_CHAR(a)
  1363. #define C_complex_to_Xen_complex(a) C_TO_XEN_COMPLEX(a)
  1364. #define C_double_to_Xen_real(a) C_TO_XEN_DOUBLE(a)
  1365. #define C_int_to_Xen_integer(a) C_TO_XEN_INT(a)
  1366. #define C_llong_to_Xen_llong(a) C_TO_XEN_LONG_LONG(a)
  1367. #define C_string_to_Xen_string(a) C_TO_XEN_STRING(a)
  1368. #define C_string_to_Xen_string_with_length(a, b) C_TO_XEN_STRINGN(a, b)
  1369. #define C_string_to_Xen_symbol(a) C_STRING_TO_XEN_SYMBOL(a)
  1370. #define C_ulong_to_Xen_ulong(a) C_TO_XEN_ULONG(a)
  1371. #define C_ullong_to_Xen_ullong(a) C_TO_XEN_ULONG_LONG(a)
  1372. #define Xen_boolean_to_C_bool(a) XEN_TO_C_BOOLEAN(a)
  1373. #define Xen_char_to_C_char(a) XEN_TO_C_CHAR(a)
  1374. #define Xen_complex_to_C_complex(a) XEN_TO_C_COMPLEX(a)
  1375. #define Xen_real_to_C_double(a) XEN_TO_C_DOUBLE(a)
  1376. #define Xen_integer_to_C_int(a) XEN_TO_C_INT(a)
  1377. #define Xen_llong_to_C_llong(a) XEN_TO_C_LONG_LONG(a)
  1378. #define Xen_string_to_C_string(a) XEN_TO_C_STRING(a)
  1379. #define Xen_symbol_to_C_string(a) XEN_SYMBOL_TO_C_STRING(a)
  1380. #define C_string_to_Xen_value(a) XEN_NAME_AS_C_STRING_TO_VALUE(a)
  1381. #define Xen_ulong_to_C_ulong(a) XEN_TO_C_ULONG(a)
  1382. #define Xen_ullong_to_C_ullong(a) XEN_TO_C_ULONG_LONG(a)
  1383. #define Xen_wrap_C_pointer(a) XEN_WRAP_C_POINTER(a)
  1384. #define Xen_unwrap_C_pointer(a) XEN_UNWRAP_C_POINTER(a)
  1385. #define Xen_numerator(a) XEN_NUMERATOR(a)
  1386. #define Xen_denominator(a) XEN_DENOMINATOR(a)
  1387. #define Xen_rationalize(a, b) XEN_RATIONALIZE(a, b)
  1388. #define Xen_make_ratio(a, b) XEN_MAKE_RATIO(a, b)
  1389. #define Xen_load(a) XEN_LOAD_FILE(a)
  1390. #define Xen_documentation(a) XEN_OBJECT_HELP(a)
  1391. #define Xen_vector_rank(a) XEN_VECTOR_RANK(a)
  1392. #define Xen_wrap_no_args(a, b) XEN_NARGIFY_0(a, b)
  1393. #define Xen_wrap_1_arg(a, b) XEN_NARGIFY_1(a, b)
  1394. #define Xen_wrap_2_args(a, b) XEN_NARGIFY_2(a, b)
  1395. #define Xen_wrap_3_args(a, b) XEN_NARGIFY_3(a, b)
  1396. #define Xen_wrap_4_args(a, b) XEN_NARGIFY_4(a, b)
  1397. #define Xen_wrap_5_args(a, b) XEN_NARGIFY_5(a, b)
  1398. #define Xen_wrap_6_args(a, b) XEN_NARGIFY_6(a, b)
  1399. #define Xen_wrap_7_args(a, b) XEN_NARGIFY_7(a, b)
  1400. #define Xen_wrap_8_args(a, b) XEN_NARGIFY_8(a, b)
  1401. #define Xen_wrap_9_args(a, b) XEN_NARGIFY_9(a, b)
  1402. #define Xen_wrap_1_optional_arg(a, b) XEN_ARGIFY_1(a, b)
  1403. #define Xen_wrap_2_optional_args(a, b) XEN_ARGIFY_2(a, b)
  1404. #define Xen_wrap_3_optional_args(a, b) XEN_ARGIFY_3(a, b)
  1405. #define Xen_wrap_4_optional_args(a, b) XEN_ARGIFY_4(a, b)
  1406. #define Xen_wrap_5_optional_args(a, b) XEN_ARGIFY_5(a, b)
  1407. #define Xen_wrap_6_optional_args(a, b) XEN_ARGIFY_6(a, b)
  1408. #define Xen_wrap_7_optional_args(a, b) XEN_ARGIFY_7(a, b)
  1409. #define Xen_wrap_8_optional_args(a, b) XEN_ARGIFY_8(a, b)
  1410. #define Xen_wrap_9_optional_args(a, b) XEN_ARGIFY_9(a, b)
  1411. #define Xen_wrap_any_args(a, b) XEN_VARGIFY(a, b)
  1412. #define Xen_apply(a, b, c) XEN_APPLY(a, b, c)
  1413. #define Xen_unprotected_apply(a, b) XEN_APPLY_NO_CATCH(a, b)
  1414. #define Xen_eval_C_string(a) XEN_EVAL_C_STRING(a)
  1415. #define Xen_error(a, b) XEN_ERROR(a, b)
  1416. #define Xen_call_with_no_args(a, b) XEN_CALL_0(a, b)
  1417. #define Xen_call_with_1_arg(a, b, c) XEN_CALL_1(a, b, c)
  1418. #define Xen_call_with_2_args(a, b, c, d) XEN_CALL_2(a, b, c, d)
  1419. #define Xen_call_with_3_args(a, b, c, d, e) XEN_CALL_3(a, b, c, d, e)
  1420. #define Xen_call_with_4_args(a, b, c, d, e, f) XEN_CALL_4(a, b, c, d, e, f)
  1421. #define Xen_call_with_5_args(a, b, c, d, e, f, g) XEN_CALL_5(a, b, c, d, e, f, g)
  1422. #define Xen_call_with_6_args(a, b, c, d, e, f, g, h) XEN_CALL_6(a, b, c, d, e, f, g, h)
  1423. #define Xen_unprotected_call_with_no_args(a) XEN_CALL_0_NO_CATCH(a)
  1424. #define Xen_unprotected_call_with_1_arg(a, b) XEN_CALL_1_NO_CATCH(a, b)
  1425. #define Xen_unprotected_call_with_2_args(a, b, c) XEN_CALL_2_NO_CATCH(a, b, c)
  1426. #define Xen_unprotected_call_with_3_args(a, b, c, d) XEN_CALL_3_NO_CATCH(a, b, c, d)
  1427. #define Xen_define(a, b) XEN_DEFINE(a, b)
  1428. #define Xen_define_constant(a, b, c) XEN_DEFINE_CONSTANT(a, b, c)
  1429. #define Xen_define_hook(a, b, c, d) XEN_DEFINE_HOOK(a, b, c, d)
  1430. #define Xen_define_procedure(a, b, c, d, e, f) XEN_DEFINE_PROCEDURE(a, b, c, d, e, f)
  1431. #define Xen_define_procedure_with_setter(a, b, c, d, e, f, g, h, i) XEN_DEFINE_PROCEDURE_WITH_SETTER(a, b, c, d, e, f, g, h, i)
  1432. #define Xen_define_dilambda(a, b, c, d, e, f, g, h, i) XEN_DEFINE_PROCEDURE_WITH_SETTER(a, b, c, d, e, f, g, h, i)
  1433. #define Xen_define_safe_procedure(a, b, c, d, e, f) XEN_DEFINE_SAFE_PROCEDURE(a, b, c, d, e, f)
  1434. #define Xen_define_integer_procedure(a, b, c, d, e, f) XEN_DEFINE_SAFE_PROCEDURE(a, b, c, d, e, f) /*obsolete */
  1435. #define Xen_define_simple_hook(a, b) XEN_DEFINE_SIMPLE_HOOK(a, b)
  1436. #define Xen_define_variable(a, b, c) XEN_DEFINE_VARIABLE(a, b, c)
  1437. #define Xen_out_of_range_error(a, b, c, d) XEN_OUT_OF_RANGE_ERROR(a, b, c, d)
  1438. #define Xen_wrong_type_arg_error(a, b, c, d) XEN_WRONG_TYPE_ARG_ERROR(a, b, c, d)
  1439. #define Xen_bad_arity_error(a, b, c, d) XEN_BAD_ARITY_ERROR(a, b, c, d)
  1440. #define Xen_clear_hook_list(a) XEN_CLEAR_HOOK(a)
  1441. #define Xen_hook_has_list(a) XEN_HOOKED(a)
  1442. #define Xen_hook_list(a) XEN_HOOK_PROCEDURES(a)
  1443. #define Xen_add_to_hook_list(a, b, c, d) XEN_ADD_HOOK(a, b, c, d)
  1444. #define Xen_GC_protect(a) XEN_PROTECT_FROM_GC(a)
  1445. #define Xen_GC_unprotect(a) XEN_UNPROTECT_FROM_GC(a)
  1446. #define Xen_provide_feature(a) XEN_PROVIDE(a)
  1447. #define Xen_arity(a) XEN_ARITY(a)
  1448. #define Xen_add_to_load_path(a) XEN_ADD_TO_LOAD_PATH(a)
  1449. #define Xen_check_type(a, b, c, d, e) XEN_ASSERT_TYPE(a, b, c, d, e)
  1450. #define Xen_make_object(a, b, c, d) XEN_MAKE_OBJECT(a, b, c, d)
  1451. #define Xen_variable_ref(a) XEN_VARIABLE_REF(a)
  1452. #define Xen_variable_set(a, b) XEN_VARIABLE_SET(a, b)
  1453. #define Xen_object_ref(a) XEN_OBJECT_REF(a)
  1454. #define Xen_copy_arg(a) XEN_COPY_ARG(a)
  1455. #define Xen_assoc(a, b) XEN_ASSOC(a, b)
  1456. #define Xen_assoc_ref(a, b) XEN_ASSOC_REF(a, b)
  1457. #define Xen_assoc_set(a, b, c) XEN_ASSOC_SET(a, b, c)
  1458. #define Xen_make_error_type(a) XEN_ERROR_TYPE(a)
  1459. #define Xen_required_args(a) XEN_REQUIRED_ARGS(a)
  1460. #define Xen_is_aritable(a, b) XEN_REQUIRED_ARGS_OK(a, b)
  1461. #define Xen_object_to_C_string(a) XEN_AS_STRING(a)
  1462. #define Xen_wrap_free(a, b, c) XEN_MAKE_OBJECT_FREE_PROCEDURE(a, b, c)
  1463. #define Xen_wrap_print(a, b, c) XEN_MAKE_OBJECT_PRINT_PROCEDURE(a, b, c)
  1464. #define Xen_make_object_type(a, b) XEN_MAKE_OBJECT_TYPE(a, b)
  1465. #define Xen_object_mark_t XEN_MARK_OBJECT_TYPE
  1466. #define Xen_object_type_t XEN_OBJECT_TYPE
  1467. #define Xen_catch_t XEN_CATCH_BODY_TYPE
  1468. #define Xen_comment_mark XEN_COMMENT_STRING
  1469. #define Xen_documentation_symbol XEN_DOCUMENTATION_SYMBOL
  1470. #define Xen_empty_list XEN_EMPTY_LIST
  1471. #define Xen_false XEN_FALSE
  1472. #define Xen_true XEN_TRUE
  1473. #define Xen_undefined XEN_UNDEFINED
  1474. #define Xen_integer_zero XEN_ZERO
  1475. #define Xen_file_extension XEN_FILE_EXTENSION
  1476. #define Xen_language XEN_LANGUAGE_NAME
  1477. #define Xen_load_path XEN_LOAD_PATH
  1478. #define Xen_procedure_cast XEN_PROCEDURE_CAST
  1479. #define Xen XEN
  1480. #if HAVE_SCHEME
  1481. #define Xen_define_typed_procedure(Name, Func, ReqArg, OptArg, RstArg, Doc, Sig) s7_define_typed_function(s7, Name, Func, ReqArg, OptArg, RstArg, Doc, Sig)
  1482. #define Xen_define_unsafe_typed_procedure(Name, Func, ReqArg, OptArg, RstArg, Doc, Sig) s7_define_unsafe_typed_function(s7, Name, Func, ReqArg, OptArg, RstArg, Doc, Sig)
  1483. #define Xen_define_typed_dilambda(Get_Name, Get_Func, Get_Help, Set_Name, Set_Func, Get_Req, Get_Opt, Set_Req, Set_Opt, Get_Sig, Set_Sig) \
  1484. s7_typed_dilambda(s7, Get_Name, Get_Func, Get_Req, Get_Opt, Set_Func, Set_Req, Set_Opt, Get_Help, Get_Sig, Set_Sig)
  1485. #else
  1486. #define Xen_define_typed_procedure(Name, Func, ReqArg, OptArg, RstArg, Doc, Sig) Xen_define_safe_procedure(Name, Func, ReqArg, OptArg, RstArg, Doc)
  1487. #define Xen_define_unsafe_typed_procedure(Name, Func, ReqArg, OptArg, RstArg, Doc, Sig) Xen_define_procedure(Name, Func, ReqArg, OptArg, RstArg, Doc)
  1488. #define Xen_define_typed_dilambda(a, b, c, d, e, f, g, h, i, j, k) XEN_DEFINE_PROCEDURE_WITH_SETTER(a, b, c, d, e, f, g, h, i)
  1489. #endif
  1490. #ifdef __cplusplus
  1491. extern "C" {
  1492. #endif
  1493. char *xen_strdup(const char *str);
  1494. char *xen_version(void);
  1495. void xen_repl(int argc, char **argv);
  1496. void xen_initialize(void);
  1497. void xen_gc_mark(XEN val);
  1498. #ifdef __cplusplus
  1499. }
  1500. #endif
  1501. #endif