Debian Codegraph @

src/c/multival.d

raw
1 /* -*- Mode: C; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /* vim: set filetype=c tabstop=2 shiftwidth=2 expandtab: */
3
4 /*
5 * multival.d -- multiple values
6 *
7 * Copyright (c) 1984 Taiichi Yuasa and Masami Hagiya
8 * Copyright (c) 1990 Giuseppe Attardi
9 *
10 * See file 'LICENSE' for the copyright details.
11 *
12 */
13
14 #include <ecl/ecl.h>
15 #include <ecl/internal.h>
16
17 @(defun values (&rest args)
18 cl_object output;
19 @
20 unlikely_if (narg > ECL_MULTIPLE_VALUES_LIMIT)
21 FEerror("Too many values in VALUES",0);
22 the_env->nvalues = narg;
23 output = ECL_NIL;
24 if (narg) {
25 int i = 0;
26 do {
27 the_env->values[i] = ecl_va_arg(args);
28 } while (++i < narg);
29 output = the_env->values[0];
30 }
31 return output;
32 @)
33
34 cl_object
35 cl_values_list(cl_object list)
36 {
37 cl_env_ptr the_env = ecl_process_env();
38 int i;
39 the_env->values[0] = ECL_NIL;
40 for (i = 0; !Null(list); list=ECL_CONS_CDR(list)) {
41 unlikely_if (!LISTP(list))
42 FEtype_error_list(list);
43 unlikely_if (i == ECL_MULTIPLE_VALUES_LIMIT)
44 FEerror("Too many values in VALUES-LIST",0);
45 the_env->values[i++] = ECL_CONS_CAR(list);
46 }
47 the_env->nvalues = i;
48 return the_env->values[0];
49 }