1 /* gh.c -- Guile Helper compat functions
2 
3    Copyright (C) 2003 John Harper <jsh@pixelslut.com>
4 
5    $Id$
6 
7    This file is part of librep.
8 
9    librep is free software; you can redistribute it and/or modify it
10    under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2, or (at your option)
12    any later version.
13 
14    librep is distributed in the hope that it will be useful, but
15    WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with librep; see the file COPYING.  If not, write to
21    the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
22 
23 /* The GH interface to guile is deprecated, and this is only a partial
24    implementation, but it may be useful. E.g. it made it easier to get
25    SWIG working with rep.. */
26 
27 #define _GNU_SOURCE
28 
29 #include "rep_gh.h"
30 #include "repint.h"
31 
32 #include <string.h>
33 
34 #define UNIMP							\
35 do {								\
36     static int warned;						\
37     if (!warned)						\
38     {								\
39 	fprintf (stderr, "%s: unimplemented", __FUNCTION__);	\
40 	warned = 1;						\
41     }								\
42 } while (0)
43 
44 #define UNIMP_RET UNIMP; return rep_undefined_value
45 
gh_enter(int argc,char * argv[],void (* c_main_prog)(int,char **))46 void gh_enter(int argc, char *argv[], void (*c_main_prog)(int, char **))
47 {
48     UNIMP;
49 }
50 
gh_repl(int argc,char * argv[])51 void gh_repl(int argc, char *argv[])
52 {
53     UNIMP;
54 }
55 
gh_catch(repv tag,scm_t_catch_body body,void * body_data,scm_t_catch_handler handler,void * handler_data)56 repv gh_catch(repv tag, scm_t_catch_body body, void *body_data,
57 	      scm_t_catch_handler handler, void *handler_data)
58 {
59     UNIMP_RET;
60 }
61 
gh_standard_handler(void * data,repv tag,repv throw_args)62 repv gh_standard_handler(void *data, repv tag, repv throw_args)
63 {
64     UNIMP_RET;
65 }
66 
gh_eval_str(const char * scheme_code)67 repv gh_eval_str(const char *scheme_code)
68 {
69     UNIMP_RET;
70 }
71 
gh_eval_str_with_catch(const char * scheme_code,scm_t_catch_handler handler)72 repv gh_eval_str_with_catch(const char *scheme_code, scm_t_catch_handler handler)
73 {
74     UNIMP_RET;
75 }
76 
gh_eval_str_with_standard_handler(const char * scheme_code)77 repv gh_eval_str_with_standard_handler(const char *scheme_code)
78 {
79     UNIMP_RET;
80 }
81 
gh_eval_str_with_stack_saving_handler(const char * scheme_code)82 repv gh_eval_str_with_stack_saving_handler(const char *scheme_code)
83 {
84     UNIMP_RET;
85 }
86 
gh_eval_file(const char * fname)87 repv gh_eval_file(const char *fname)
88 {
89     UNIMP_RET;
90 }
91 
gh_eval_file_with_catch(const char * scheme_code,scm_t_catch_handler handler)92 repv gh_eval_file_with_catch(const char *scheme_code, scm_t_catch_handler handler)
93 {
94     UNIMP_RET;
95 }
96 
gh_eval_file_with_standard_handler(const char * scheme_code)97 repv gh_eval_file_with_standard_handler(const char *scheme_code)
98 {
99     UNIMP_RET;
100 }
101 
gh_new_procedure(const char * proc_name,repv (* fn)(),int n_required_args,int n_optional_args,int varp)102 repv gh_new_procedure(const char *proc_name, repv (*fn)(),
103 		      int n_required_args, int n_optional_args, int varp)
104 {
105     UNIMP_RET;
106 }
107 
gh_new_procedure0_0(const char * proc_name,repv (* fn)(void))108 repv gh_new_procedure0_0(const char *proc_name, repv (*fn)(void))
109 {
110     return gh_new_procedure (proc_name, fn, 0, 0, 0);
111 }
112 
gh_new_procedure0_1(const char * proc_name,repv (* fn)(repv))113 repv gh_new_procedure0_1(const char *proc_name, repv (*fn)(repv))
114 {
115     return gh_new_procedure (proc_name, fn, 0, 1, 0);
116 }
117 
gh_new_procedure0_2(const char * proc_name,repv (* fn)(repv,repv))118 repv gh_new_procedure0_2(const char *proc_name, repv (*fn)(repv, repv))
119 {
120     return gh_new_procedure (proc_name, fn, 0, 2, 0);
121 }
122 
gh_new_procedure1_0(const char * proc_name,repv (* fn)(repv))123 repv gh_new_procedure1_0(const char *proc_name, repv (*fn)(repv))
124 {
125     return gh_new_procedure (proc_name, fn, 1, 0, 0);
126 }
127 
gh_new_procedure1_1(const char * proc_name,repv (* fn)(repv,repv))128 repv gh_new_procedure1_1(const char *proc_name, repv (*fn)(repv, repv))
129 {
130     return gh_new_procedure (proc_name, fn, 1, 1, 0);
131 }
132 
gh_new_procedure1_2(const char * proc_name,repv (* fn)(repv,repv,repv))133 repv gh_new_procedure1_2(const char *proc_name, repv (*fn)(repv, repv, repv))
134 {
135     return gh_new_procedure (proc_name, fn, 1, 2, 0);
136 }
137 
gh_new_procedure2_0(const char * proc_name,repv (* fn)(repv,repv))138 repv gh_new_procedure2_0(const char *proc_name, repv (*fn)(repv, repv))
139 {
140     return gh_new_procedure (proc_name, fn, 2, 0, 0);
141 }
142 
gh_new_procedure2_1(const char * proc_name,repv (* fn)(repv,repv,repv))143 repv gh_new_procedure2_1(const char *proc_name, repv (*fn)(repv, repv, repv))
144 {
145     return gh_new_procedure (proc_name, fn, 2, 1, 0);
146 }
147 
gh_new_procedure2_2(const char * proc_name,repv (* fn)(repv,repv,repv,repv))148 repv gh_new_procedure2_2(const char *proc_name, repv (*fn)(repv, repv, repv, repv))
149 {
150     return gh_new_procedure (proc_name, fn, 2, 2, 0);
151 }
152 
gh_new_procedure3_0(const char * proc_name,repv (* fn)(repv,repv,repv))153 repv gh_new_procedure3_0(const char *proc_name, repv (*fn)(repv, repv, repv))
154 {
155     return gh_new_procedure (proc_name, fn, 3, 0, 0);
156 }
157 
gh_new_procedure4_0(const char * proc_name,repv (* fn)(repv,repv,repv,repv))158 repv gh_new_procedure4_0(const char *proc_name, repv (*fn)(repv, repv, repv, repv))
159 {
160     return gh_new_procedure (proc_name, fn, 4, 0, 0);
161 }
162 
gh_new_procedure5_0(const char * proc_name,repv (* fn)(repv,repv,repv,repv,repv))163 repv gh_new_procedure5_0(const char *proc_name, repv (*fn)(repv, repv, repv, repv, repv))
164 {
165     return gh_new_procedure (proc_name, fn, 5, 0, 0);
166 }
167 
168 /* C to Scheme conversion */
gh_bool2scm(int x)169 repv gh_bool2scm(int x)
170 {
171     return x ? Qt : Qnil;
172 }
173 
gh_int2scm(int x)174 repv gh_int2scm(int x)
175 {
176     return rep_make_long_int (x);
177 }
178 
gh_ulong2scm(unsigned long x)179 repv gh_ulong2scm(unsigned long x)
180 {
181     return rep_make_long_uint (x);
182 }
183 
gh_long2scm(long x)184 repv gh_long2scm(long x)
185 {
186     return rep_make_long_int (x);
187 }
188 
gh_double2scm(double x)189 repv gh_double2scm(double x)
190 {
191     return rep_make_float (x, rep_FALSE);
192 }
193 
gh_char2scm(char c)194 repv gh_char2scm(char c)
195 {
196     return rep_MAKE_INT (c);
197 }
198 
gh_str2scm(const char * s,size_t len)199 repv gh_str2scm(const char *s, size_t len)
200 {
201     return rep_string_dupn (s, len);
202 }
203 
gh_str02scm(const char * s)204 repv gh_str02scm(const char *s)
205 {
206     return rep_string_dup (s);
207 }
208 
gh_set_substr(char * src,repv dst,long start,size_t len)209 void gh_set_substr(char *src, repv dst, long start, size_t len)
210 {
211     UNIMP;
212 }
213 
gh_symbol2scm(const char * symbol_str)214 repv gh_symbol2scm(const char *symbol_str)
215 {
216     return Fintern (rep_string_dup (symbol_str), Qnil);
217 }
218 
gh_ints2scm(const int * d,long n)219 repv gh_ints2scm(const int *d, long n)
220 {
221     int i;
222     repv vec;
223 
224     vec = rep_make_vector (n);
225     for (i = 0; i < n; i++)
226 	rep_VECTI (vec, i) = rep_make_long_int (d[i]);
227 
228     return vec;
229 }
230 
gh_doubles2scm(const double * d,long n)231 repv gh_doubles2scm(const double *d, long n)
232 {
233     int i;
234     repv vec;
235 
236     vec = rep_make_vector (n);
237     for (i = 0; i < n; i++)
238 	rep_VECTI (vec, i) = rep_make_float (d[i], rep_FALSE);
239 
240     return vec;
241 }
242 
243 /* Scheme to C conversion */
gh_scm2bool(repv obj)244 int gh_scm2bool(repv obj)
245 {
246     return obj != Qnil;
247 }
248 
gh_scm2int(repv obj)249 int gh_scm2int(repv obj)
250 {
251     return rep_get_long_int (obj);
252 }
253 
gh_scm2ulong(repv obj)254 unsigned long gh_scm2ulong(repv obj)
255 {
256     return rep_get_long_uint (obj);
257 }
258 
gh_scm2long(repv obj)259 long gh_scm2long(repv obj)
260 {
261     return rep_get_long_int (obj);
262 }
263 
gh_scm2char(repv obj)264 char gh_scm2char(repv obj)
265 {
266     return rep_INTP (obj) && rep_INT (obj);
267 }
268 
gh_scm2double(repv obj)269 double gh_scm2double(repv obj)
270 {
271     return rep_get_float (obj);
272 }
273 
gh_scm2newstr(repv str,size_t * lenp)274 char *gh_scm2newstr(repv str, size_t *lenp)
275 {
276     char *buf;
277     size_t len;
278 
279     if (!rep_STRINGP (str))
280 	return NULL;
281 
282     len = rep_STRING_LEN (str);
283     buf = malloc (len + 1);
284     memcpy (buf, rep_STR (str), len);
285     buf[len] = 0;
286 
287     if (lenp != NULL)
288 	*lenp = len;
289 
290     return buf;
291 }
292 
gh_get_substr(repv src,char * dst,long start,size_t len)293 void gh_get_substr(repv src, char *dst, long start, size_t len)
294 {
295     if (!rep_STRING (src) || rep_STRING_LEN (src) <= start)
296 	return;
297 
298     len = MIN (len, rep_STRING_LEN (src) - start);
299     memcpy (dst, rep_STR (src) + start, len);
300 }
301 
gh_symbol2newstr(repv sym,size_t * lenp)302 char *gh_symbol2newstr(repv sym, size_t *lenp)
303 {
304     if (!rep_SYMBOLP (sym))
305 	return NULL;
306 
307     return gh_scm2newstr (rep_SYM (sym)->name, lenp);
308 }
309 
gh_scm2chars(repv vector,char * result)310 char *gh_scm2chars(repv vector, char *result)
311 {
312     int len = gh_length (vector), i;
313 
314     if (len == 0)
315 	return result;
316 
317     if (result == NULL)
318 	result = malloc (len * sizeof (result[0]));
319 
320     for (i = 0; i < len; i++)
321 	result[i] = gh_scm2char (Felt (vector, rep_MAKE_INT (i)));
322 
323     return result;
324 }
325 
gh_scm2shorts(repv vector,short * result)326 short *gh_scm2shorts(repv vector, short *result)
327 {
328     int len = gh_length (vector), i;
329 
330     if (len == 0)
331 	return result;
332 
333     if (result == NULL)
334 	result = malloc (len * sizeof (result[0]));
335 
336     for (i = 0; i < len; i++)
337 	result[i] = rep_get_long_int (Felt (vector, rep_MAKE_INT (i)));
338 
339     return result;
340 }
341 
gh_scm2longs(repv vector,long * result)342 long *gh_scm2longs(repv vector, long *result)
343 {
344     int len = gh_length (vector), i;
345 
346     if (len == 0)
347 	return result;
348 
349     if (result == NULL)
350 	result = malloc (len * sizeof (result[0]));
351 
352     for (i = 0; i < len; i++)
353 	result[i] = rep_get_long_int (Felt (vector, rep_MAKE_INT (i)));
354 
355     return result;
356 }
357 
gh_scm2floats(repv vector,float * result)358 float *gh_scm2floats(repv vector, float *result)
359 {
360     int len = gh_length (vector), i;
361 
362     if (len == 0)
363 	return result;
364 
365     if (result == NULL)
366 	result = malloc (len * sizeof (result[0]));
367 
368     for (i = 0; i < len; i++)
369 	result[i] = rep_get_float (Felt (vector, rep_MAKE_INT (i)));
370 
371     return result;
372 }
373 
gh_scm2doubles(repv vector,double * result)374 double *gh_scm2doubles(repv vector, double *result)
375 {
376     int len = gh_length (vector), i;
377 
378     if (len == 0)
379 	return result;
380 
381     if (result == NULL)
382 	result = malloc (len * sizeof (result[0]));
383 
384     for (i = 0; i < len; i++)
385 	result[i] = rep_get_float (Felt (vector, rep_MAKE_INT (i)));
386 
387     return result;
388 }
389 
390 /* type predicates: tell you if an repv object has a given type */
391 
gh_boolean_p(repv val)392 int gh_boolean_p(repv val)
393 {
394     return Qt;
395 }
396 
gh_symbol_p(repv val)397 int gh_symbol_p(repv val)
398 {
399     return rep_SYMBOLP (val);
400 }
401 
gh_char_p(repv val)402 int gh_char_p(repv val)
403 {
404     return rep_INTP (val);
405 }
406 
gh_vector_p(repv val)407 int gh_vector_p(repv val)
408 {
409     return rep_VECTORP (val);
410 }
411 
gh_pair_p(repv val)412 int gh_pair_p(repv val)
413 {
414     return rep_CONSP (val);
415 }
416 
gh_number_p(repv val)417 int gh_number_p(repv val)
418 {
419     return rep_NUMERICP (val);
420 }
421 
gh_string_p(repv val)422 int gh_string_p(repv val)
423 {
424     return rep_STRINGP (val);
425 }
426 
gh_procedure_p(repv val)427 int gh_procedure_p(repv val)
428 {
429     val = Ffunctionp (val);
430     return val && val != Qnil;
431 }
432 
gh_list_p(repv val)433 int gh_list_p(repv val)
434 {
435     return rep_LISTP (val);
436 }
437 
gh_inexact_p(repv val)438 int gh_inexact_p(repv val)
439 {
440     val = Fexactp (val);
441     return val && val == Qnil;
442 }
443 
gh_exact_p(repv val)444 int gh_exact_p(repv val)
445 {
446     val = Fexactp (val);
447     return val && val != Qnil;
448 }
449 
450 
451 /* more predicates */
gh_eq_p(repv x,repv y)452 int gh_eq_p(repv x, repv y)
453 {
454     return x == y;
455 }
456 
gh_eqv_p(repv x,repv y)457 int gh_eqv_p(repv x, repv y)
458 {
459     repv val = Feql (x, y);
460     return val && val != Qnil;
461 }
462 
gh_equal_p(repv x,repv y)463 int gh_equal_p(repv x, repv y)
464 {
465     repv val = Fequal (x, y);
466     return val && val != Qnil;
467 }
468 
gh_string_equal_p(repv s1,repv s2)469 int gh_string_equal_p(repv s1, repv s2)
470 {
471     return rep_STRINGP (s1) && rep_STRINGP (s2) && gh_equal_p (s1, s2);
472 }
473 
gh_null_p(repv l)474 int gh_null_p(repv l)
475 {
476     return l == Qnil;
477 }
478 
479 
480 /* standard Scheme procedures available from C */
481 
gh_not(repv val)482 repv gh_not(repv val)
483 {
484     return val == Qnil ? Qt : Qnil;
485 }
486 
487 
gh_define(const char * name,repv val)488 repv gh_define(const char *name, repv val)
489 {
490     UNIMP_RET;
491 }
492 
493 
494 /* string manipulation routines */
gh_make_string(repv k,repv chr)495 repv gh_make_string(repv k, repv chr)
496 {
497     return Fmake_string (k, chr);
498 }
499 
gh_string_length(repv str)500 repv gh_string_length(repv str)
501 {
502     return Flength (str);
503 }
504 
gh_string_ref(repv str,repv k)505 repv gh_string_ref(repv str, repv k)
506 {
507     return Faref (str, k);
508 }
509 
gh_string_set_x(repv str,repv k,repv chr)510 repv gh_string_set_x(repv str, repv k, repv chr)
511 {
512     return Faset (str, k, chr);
513 }
514 
gh_substring(repv str,repv start,repv end)515 repv gh_substring(repv str, repv start, repv end)
516 {
517     return Fsubstring (str, start, end);
518 }
519 
520 #define APPLY_LIST(lst,fun)		\
521     int n = gh_length (lst), i;		\
522     repv *v = NULL;			\
523     if (n != 0) {			\
524 	v = alloca (sizeof (repv) * n);	\
525 	for (i = 0; i < n; i++)	{	\
526 	    v[i] = rep_CAR (lst);	\
527 	    lst = rep_CDR (lst);	\
528 	}				\
529     }					\
530     return fun (n, v)
531 
gh_string_append(repv args)532 repv gh_string_append(repv args)
533 {
534     APPLY_LIST (args, Fconcat);
535 }
536 
gh_vector(repv ls)537 repv gh_vector(repv ls)
538 {
539     APPLY_LIST (ls, Fvector);
540 }
541 
gh_make_vector(repv length,repv val)542 repv gh_make_vector(repv length, repv val)
543 {
544     return Fmake_vector (length, val);
545 }
546 
gh_vector_set_x(repv vec,repv pos,repv val)547 repv gh_vector_set_x(repv vec, repv pos, repv val)
548 {
549     return Faset (vec, pos, val);
550 }
551 
gh_vector_ref(repv vec,repv pos)552 repv gh_vector_ref(repv vec, repv pos)
553 {
554     return Faref (vec, pos);
555 }
556 
gh_vector_length(repv v)557 unsigned long gh_vector_length (repv v)
558 {
559     return gh_length (v);
560 }
561 
gh_uniform_vector_length(repv v)562 unsigned long gh_uniform_vector_length (repv v)
563 {
564     UNIMP;
565     return 0;
566 }
567 
gh_uniform_vector_ref(repv v,repv ilist)568 repv gh_uniform_vector_ref (repv v, repv ilist)
569 {
570     UNIMP_RET;
571 }
572 
573 #define gh_list_to_vector(ls) gh_vector(ls)
gh_vector_to_list(repv v)574 repv gh_vector_to_list(repv v)
575 {
576     UNIMP_RET;
577 }
578 
579 
gh_lookup(const char * sname)580 repv gh_lookup (const char *sname)
581 {
582     UNIMP_RET;
583 }
584 
gh_module_lookup(repv module,const char * sname)585 repv gh_module_lookup (repv module, const char *sname)
586 {
587     UNIMP_RET;
588 }
589 
gh_cons(repv x,repv y)590 repv gh_cons(repv x, repv y)
591 {
592     return Fcons (x, y);
593 }
594 
gh_list(repv elt,...)595 repv gh_list(repv elt, ...)
596 {
597     repv lst = Qnil;
598     va_list args;
599 
600     va_start (args, elt);
601 
602     while (elt != rep_undefined_value)
603     {
604 	lst = Fcons (elt, lst);
605 	elt = va_arg (args, repv);
606     }
607 
608     va_end (args);
609     return Fnreverse (lst);
610 }
611 
gh_length(repv l)612 unsigned long gh_length(repv l)
613 {
614     repv len = Flength (l);
615     return len && rep_INTP (len) ? rep_INT (len) : 0;
616 }
617 
gh_append(repv args)618 repv gh_append(repv args)
619 {
620     APPLY_LIST (args, Fappend);
621 }
622 
gh_append2(repv l1,repv l2)623 repv gh_append2(repv l1, repv l2)
624 {
625     repv v[2];
626     v[0] = l1;
627     v[1] = l2;
628     return Fappend (2, v);
629 }
630 
gh_append3(repv l1,repv l2,repv l3)631 repv gh_append3(repv l1, repv l2, repv l3)
632 {
633     repv v[3];
634     v[0] = l1;
635     v[1] = l2;
636     v[2] = l3;
637     return Fappend (3, v);
638 }
639 
gh_append4(repv l1,repv l2,repv l3,repv l4)640 repv gh_append4(repv l1, repv l2, repv l3, repv l4)
641 {
642     repv v[4];
643     v[0] = l1;
644     v[1] = l2;
645     v[2] = l3;
646     v[3] = l4;
647     return Fappend (4, v);
648 }
649 
gh_reverse(repv ls)650 repv gh_reverse(repv ls)
651 {
652     return Freverse (ls);
653 }
654 
gh_list_tail(repv ls,repv k)655 repv gh_list_tail(repv ls, repv k)
656 {
657     return Fnthcdr (k, ls);
658 }
659 
gh_list_ref(repv ls,repv k)660 repv gh_list_ref(repv ls, repv k)
661 {
662     return Fnth (k, ls);
663 }
664 
gh_memq(repv x,repv ls)665 repv gh_memq(repv x, repv ls)
666 {
667     return Fmemq (x, ls);
668 }
669 
gh_memv(repv x,repv ls)670 repv gh_memv(repv x, repv ls)
671 {
672     return Fmemql (x, ls);
673 }
674 
gh_member(repv x,repv ls)675 repv gh_member(repv x, repv ls)
676 {
677     return Fmember (x, ls);
678 }
679 
gh_assq(repv x,repv alist)680 repv gh_assq(repv x, repv alist)
681 {
682     return Fassq (x, alist);
683 }
684 
gh_assv(repv x,repv alist)685 repv gh_assv(repv x, repv alist)
686 {
687     UNIMP_RET;
688 }
689 
gh_assoc(repv x,repv alist)690 repv gh_assoc(repv x, repv alist)
691 {
692     return Fassoc (x, alist);
693 }
694 
gh_car(repv x)695 repv gh_car(repv x)
696 {
697     return rep_CONSP (x) ? rep_CAR (x) : rep_undefined_value;
698 }
699 
gh_cdr(repv x)700 repv gh_cdr(repv x)
701 {
702     return rep_CONSP (x) ? rep_CDR (x) : rep_undefined_value;
703 }
704 
gh_caar(repv x)705 repv gh_caar(repv x)
706 {
707     return gh_car (gh_car (x));
708 }
709 
gh_cadr(repv x)710 repv gh_cadr(repv x)
711 {
712     return gh_car (gh_cdr (x));
713 }
714 
gh_cdar(repv x)715 repv gh_cdar(repv x)
716 {
717     return gh_cdr (gh_car (x));
718 }
719 
gh_cddr(repv x)720 repv gh_cddr(repv x)
721 {
722     return gh_cdr (gh_cdr (x));
723 }
724 
gh_caaar(repv x)725 repv gh_caaar(repv x)
726 {
727     return gh_car (gh_car (gh_car (x)));
728 }
729 
gh_caadr(repv x)730 repv gh_caadr(repv x)
731 {
732     return gh_car (gh_car (gh_cdr (x)));
733 }
734 
gh_cadar(repv x)735 repv gh_cadar(repv x)
736 {
737     return gh_car (gh_cdr (gh_car (x)));
738 }
739 
gh_caddr(repv x)740 repv gh_caddr(repv x)
741 {
742     return gh_car (gh_cdr (gh_cdr (x)));
743 }
744 
gh_cdaar(repv x)745 repv gh_cdaar(repv x)
746 {
747     return gh_cdr (gh_car (gh_car (x)));
748 }
749 
gh_cdadr(repv x)750 repv gh_cdadr(repv x)
751 {
752     return gh_cdr (gh_car (gh_cdr (x)));
753 }
754 
gh_cddar(repv x)755 repv gh_cddar(repv x)
756 {
757     return gh_cdr (gh_cdr (gh_car (x)));
758 }
759 
gh_cdddr(repv x)760 repv gh_cdddr(repv x)
761 {
762     return gh_cdr (gh_cdr (gh_cdr (x)));
763 }
764 
765 
gh_set_car_x(repv pair,repv value)766 repv gh_set_car_x(repv pair, repv value)
767 {
768     return Frplaca (pair, value) ? value : rep_undefined_value;
769 }
770 
gh_set_cdr_x(repv pair,repv value)771 repv gh_set_cdr_x(repv pair, repv value)
772 {
773     return Frplacd (pair, value) ? value : rep_undefined_value;
774 }
775 
776 
777 /* Calling Scheme functions from C.  */
778 
gh_apply(repv proc,repv ls)779 repv gh_apply (repv proc, repv ls)
780 {
781     return Ffuncall (Fcons (proc, ls));
782 }
783 
gh_call0(repv proc)784 repv gh_call0 (repv proc)
785 {
786     return rep_call_lisp0 (proc);
787 }
788 
gh_call1(repv proc,repv arg)789 repv gh_call1 (repv proc, repv arg)
790 {
791     return rep_call_lisp1 (proc, arg);
792 }
793 
gh_call2(repv proc,repv arg1,repv arg2)794 repv gh_call2 (repv proc, repv arg1, repv arg2)
795 {
796     return rep_call_lisp2 (proc, arg1, arg2);
797 }
798 
gh_call3(repv proc,repv arg1,repv arg2,repv arg3)799 repv gh_call3 (repv proc, repv arg1, repv arg2, repv arg3)
800 {
801     return rep_call_lisp3 (proc, arg1, arg2, arg3);
802 }
803 
804 
805 /* reading and writing Scheme objects.  */
806 
gh_display(repv x)807 void gh_display (repv x)
808 {
809     UNIMP;
810 }
811 
gh_write(repv x)812 void gh_write (repv x)
813 {
814     UNIMP;
815 }
816 
gh_newline(void)817 void gh_newline (void)
818 {
819     UNIMP;
820 }
821