gsubr.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* classes: h_files */
  2. #ifndef SCM_GSUBR_H
  3. #define SCM_GSUBR_H
  4. /* Copyright (C) 1995, 1996, 1998, 2000, 2001, 2006, 2008, 2009,
  5. * 2010, 2011, 2013, 2015 Free Software Foundation, Inc.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 3 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #include "libguile/__scm.h"
  23. /* Subrs
  24. */
  25. /* Max number of args to the C procedure backing a gsubr */
  26. #define SCM_GSUBR_MAX 10
  27. #define SCM_PRIMITIVE_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE (x))
  28. #define SCM_PRIMITIVE_GENERIC_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x))
  29. #define SCM_SUBRF(x) \
  30. ((SCM (*) (void)) \
  31. SCM_POINTER_VALUE (SCM_PROGRAM_FREE_VARIABLE_REF (x, 0)))
  32. #define SCM_SUBR_NAME(x) (SCM_PROGRAM_FREE_VARIABLE_REF (x, 1))
  33. #define SCM_SUBR_GENERIC(x) \
  34. ((SCM *) SCM_POINTER_VALUE (SCM_PROGRAM_FREE_VARIABLE_REF (x, 2)))
  35. #define SCM_SET_SUBR_GENERIC(x, g) \
  36. (*SCM_SUBR_GENERIC (x) = (g))
  37. SCM_INTERNAL int scm_i_primitive_code_p (const scm_t_uint32 *code);
  38. SCM_INTERNAL int scm_i_primitive_arity (SCM subr, int *req, int *opt, int *rest);
  39. SCM_INTERNAL scm_t_uintptr scm_i_primitive_call_ip (SCM subr);
  40. union scm_vm_stack_element;
  41. SCM_INTERNAL SCM scm_apply_subr (union scm_vm_stack_element *sp,
  42. scm_t_ptrdiff nargs);
  43. SCM_API SCM scm_c_make_gsubr (const char *name,
  44. int req, int opt, int rst, scm_t_subr fcn);
  45. SCM_API SCM scm_c_make_gsubr_with_generic (const char *name,
  46. int req, int opt, int rst,
  47. scm_t_subr fcn, SCM *gf);
  48. SCM_API SCM scm_c_define_gsubr (const char *name,
  49. int req, int opt, int rst, scm_t_subr fcn);
  50. SCM_API SCM scm_c_define_gsubr_with_generic (const char *name,
  51. int req, int opt, int rst,
  52. scm_t_subr fcn, SCM *gf);
  53. SCM_INTERNAL void scm_init_gsubr (void);
  54. #endif /* SCM_GSUBR_H */
  55. /*
  56. Local Variables:
  57. c-file-style: "gnu"
  58. End:
  59. */