gsubr.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 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. SCM_API SCM scm_subr_objcode_trampoline (unsigned int nreq,
  24. unsigned int nopt,
  25. unsigned int rest);
  26. /* Subrs
  27. */
  28. /* Max number of args to the C procedure backing a gsubr */
  29. #define SCM_GSUBR_MAX 10
  30. #define SCM_PRIMITIVE_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE (x))
  31. #define SCM_PRIMITIVE_GENERIC_P(x) (SCM_PROGRAM_P (x) && SCM_PROGRAM_IS_PRIMITIVE_GENERIC (x))
  32. #define SCM_SUBRF(x) \
  33. ((SCM (*) (void)) \
  34. SCM_POINTER_VALUE (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 0)))
  35. #define SCM_SUBR_NAME(x) (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 1))
  36. #define SCM_SUBR_GENERIC(x) \
  37. ((SCM *) \
  38. SCM_POINTER_VALUE (SCM_SIMPLE_VECTOR_REF (SCM_PROGRAM_OBJTABLE (x), 2)))
  39. #define SCM_SET_SUBR_GENERIC(x, g) \
  40. (*SCM_SUBR_GENERIC (x) = (g))
  41. SCM_API SCM scm_c_make_gsubr (const char *name,
  42. int req, int opt, int rst, scm_t_subr fcn);
  43. SCM_API SCM scm_c_make_gsubr_with_generic (const char *name,
  44. int req, int opt, int rst,
  45. scm_t_subr fcn, SCM *gf);
  46. SCM_API SCM scm_c_define_gsubr (const char *name,
  47. int req, int opt, int rst, scm_t_subr fcn);
  48. SCM_API SCM scm_c_define_gsubr_with_generic (const char *name,
  49. int req, int opt, int rst,
  50. scm_t_subr fcn, SCM *gf);
  51. SCM_INTERNAL void scm_init_gsubr (void);
  52. #endif /* SCM_GSUBR_H */
  53. /*
  54. Local Variables:
  55. c-file-style: "gnu"
  56. End:
  57. */