From a729ef1b8b1905cb6c2ec73cc9b54e2e9453a2b3 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Thu, 10 Feb 2011 18:03:14 -0500 Subject: [PATCH] Added internal C function to extract from values object * libguile/values.c (scm_i_extract_values_2): New internal function that extracts two values from a values object. * libguile/values.h: Added prototype. --- libguile/values.c | 18 ++++++++++++++++++ libguile/values.h | 2 ++ 2 files changed, 20 insertions(+), 0 deletions(-) diff --git a/libguile/values.c b/libguile/values.c index 967fcd6..b9fe4cc 100644 --- a/libguile/values.c +++ b/libguile/values.c @@ -35,6 +35,24 @@ SCM scm_values_vtable; +/* OBJ must be a values object containing exactly two values. + scm_i_extract_values_2 puts those two values into *p1 and *p2. */ +void +scm_i_extract_values_2 (SCM obj, SCM *p1, SCM *p2) +{ + SCM values; + + SCM_ASSERT_TYPE (SCM_VALUESP (obj), obj, SCM_ARG1, + "scm_i_extract_values_2", "values"); + values = scm_struct_ref (obj, SCM_INUM0); + if (!scm_is_null_or_nil (SCM_CDDR (values))) + scm_wrong_type_arg_msg + ("scm_i_extract_values_2", SCM_ARG1, obj, + "a values object containing exactly two values"); + *p1 = SCM_CAR (values); + *p2 = SCM_CADR (values); +} + static SCM print_values (SCM obj, SCM pwps) { diff --git a/libguile/values.h b/libguile/values.h index 0750aec..65ad8a1 100644 --- a/libguile/values.h +++ b/libguile/values.h @@ -30,6 +30,8 @@ SCM_API SCM scm_values_vtable; #define SCM_VALUESP(x) (SCM_STRUCTP (x)\ && scm_is_eq (scm_struct_vtable (x), scm_values_vtable)) +SCM_INTERNAL void scm_i_extract_values_2 (SCM obj, SCM *p1, SCM *p2); + SCM_API SCM scm_values (SCM args); SCM_INTERNAL void scm_init_values (void); -- 1.5.6.5