1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-08 13:10:19 +02:00
guile/libguile/values.h
Andy Wingo 224fb82a39 Give reified value objects a proper data type
* libguile/values.h (struct scm_values): New build-time definition.
(scm_to_values):
(scm_from_values):
(scm_values_count):
(scm_values_ref): New helpers.
* libguile/vm.c:
* libguile/values.c:
* libguile/print.c:
* libguile/numbers.c:
* libguile/eval.c: Adapt all callers.
2025-05-30 09:57:08 +02:00

79 lines
1.9 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SCM_VALUES_H
#define SCM_VALUES_H
/* Copyright 2000-2001,2006,2008,2012,2018,2025
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#include "libguile/gc.h"
static inline int
scm_is_values (SCM x)
{
return SCM_HAS_TYP7 (x, scm_tc7_values);
}
#ifdef BUILDING_LIBGUILE
struct scm_values
{
scm_t_bits tag_and_count;
SCM values[];
};
static inline struct scm_values*
scm_to_values (SCM x)
{
if (!scm_is_values (x))
abort ();
return (struct scm_values*) SCM_UNPACK_POINTER (x);
}
static inline SCM
scm_from_values (struct scm_values *values)
{
return SCM_PACK_POINTER (values);
}
static inline size_t
scm_values_count (struct scm_values *x)
{
return x->tag_and_count >> 8;
}
static inline SCM
scm_values_ref (struct scm_values *values, size_t n)
{
return values->values[n];
}
#endif
#define SCM_VALUESP(x) (scm_is_values (x))
SCM_INTERNAL void scm_values_extract_2 (SCM obj, SCM *p1, SCM *p2);
SCM_API SCM scm_values (SCM args);
SCM_API SCM scm_c_values (SCM *base, size_t n);
SCM_API SCM scm_values_2 (SCM a, SCM b);
SCM_API SCM scm_values_3 (SCM a, SCM b, SCM c);
SCM_API size_t scm_c_nvalues (SCM obj);
SCM_API SCM scm_c_value_ref (SCM obj, size_t idx);
SCM_INTERNAL void scm_init_values (void);
#endif /* SCM_VALUES_H */