gh_funcs.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* Copyright (C) 1995,1996,1997,1998, 2000, 2001, 2006, 2008 Free Software Foundation, Inc.
  2. * This library is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU Lesser General Public
  4. * License as published by the Free Software Foundation; either
  5. * version 2.1 of the License, or (at your option) any later version.
  6. *
  7. * This library is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. * Lesser General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Lesser General Public
  13. * License along with this library; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. #ifdef HAVE_CONFIG_H
  17. # include <config.h>
  18. #endif
  19. /* Defining Scheme functions implemented by C functions --- subrs. */
  20. #include "libguile/gh.h"
  21. #if SCM_ENABLE_DEPRECATED
  22. /* allows you to define new scheme primitives written in C */
  23. SCM
  24. gh_new_procedure (const char *proc_name, SCM (*fn) (),
  25. int n_required_args, int n_optional_args, int varp)
  26. {
  27. return scm_c_define_gsubr (proc_name, n_required_args, n_optional_args,
  28. varp, fn);
  29. }
  30. SCM
  31. gh_new_procedure0_0 (const char *proc_name, SCM (*fn) ())
  32. {
  33. return gh_new_procedure (proc_name, fn, 0, 0, 0);
  34. }
  35. SCM
  36. gh_new_procedure0_1 (const char *proc_name, SCM (*fn) ())
  37. {
  38. return gh_new_procedure (proc_name, fn, 0, 1, 0);
  39. }
  40. SCM
  41. gh_new_procedure0_2 (const char *proc_name, SCM (*fn) ())
  42. {
  43. return gh_new_procedure (proc_name, fn, 0, 2, 0);
  44. }
  45. SCM
  46. gh_new_procedure1_0 (const char *proc_name, SCM (*fn) ())
  47. {
  48. return gh_new_procedure (proc_name, fn, 1, 0, 0);
  49. }
  50. SCM
  51. gh_new_procedure1_1 (const char *proc_name, SCM (*fn) ())
  52. {
  53. return gh_new_procedure (proc_name, fn, 1, 1, 0);
  54. }
  55. SCM
  56. gh_new_procedure1_2 (const char *proc_name, SCM (*fn) ())
  57. {
  58. return gh_new_procedure (proc_name, fn, 1, 2, 0);
  59. }
  60. SCM
  61. gh_new_procedure2_0 (const char *proc_name, SCM (*fn) ())
  62. {
  63. return gh_new_procedure (proc_name, fn, 2, 0, 0);
  64. }
  65. SCM
  66. gh_new_procedure2_1 (const char *proc_name, SCM (*fn) ())
  67. {
  68. return gh_new_procedure (proc_name, fn, 2, 1, 0);
  69. }
  70. SCM
  71. gh_new_procedure2_2 (const char *proc_name, SCM (*fn) ())
  72. {
  73. return gh_new_procedure (proc_name, fn, 2, 2, 0);
  74. }
  75. SCM
  76. gh_new_procedure3_0 (const char *proc_name, SCM (*fn) ())
  77. {
  78. return gh_new_procedure (proc_name, fn, 3, 0, 0);
  79. }
  80. SCM
  81. gh_new_procedure4_0 (const char *proc_name, SCM (*fn) ())
  82. {
  83. return gh_new_procedure (proc_name, fn, 4, 0, 0);
  84. }
  85. SCM
  86. gh_new_procedure5_0 (const char *proc_name, SCM (*fn) ())
  87. {
  88. return gh_new_procedure (proc_name, fn, 5, 0, 0);
  89. }
  90. /* some (possibly most) Scheme functions available from C */
  91. SCM
  92. gh_define (const char *name, SCM val)
  93. {
  94. scm_c_define (name, val);
  95. return SCM_UNSPECIFIED;
  96. }
  97. /* Calling Scheme functions from C. */
  98. SCM
  99. gh_apply (SCM proc, SCM args)
  100. {
  101. return scm_apply (proc, args, SCM_EOL);
  102. }
  103. SCM
  104. gh_call0 (SCM proc)
  105. {
  106. return scm_apply (proc, SCM_EOL, SCM_EOL);
  107. }
  108. SCM
  109. gh_call1 (SCM proc, SCM arg)
  110. {
  111. return scm_apply (proc, arg, scm_listofnull);
  112. }
  113. SCM
  114. gh_call2 (SCM proc, SCM arg1, SCM arg2)
  115. {
  116. return scm_apply (proc, arg1, scm_cons (arg2, scm_listofnull));
  117. }
  118. SCM
  119. gh_call3 (SCM proc, SCM arg1, SCM arg2, SCM arg3)
  120. {
  121. return scm_apply (proc, arg1, scm_cons2 (arg2, arg3, scm_listofnull));
  122. }
  123. #endif /* SCM_ENABLE_DEPRECATED */
  124. /*
  125. Local Variables:
  126. c-file-style: "gnu"
  127. End:
  128. */