mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-05 01:00:21 +02:00
Excise scm_words from struct.c
* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Update for unboxed-fields representation change. * libguile/struct.c (scm_i_alloc_struct, scm_make_struct_simple): Use scm_allocate_tagged.
This commit is contained in:
parent
91ba12f444
commit
4b2924730e
1 changed files with 13 additions and 9 deletions
|
@ -339,7 +339,11 @@ scm_i_alloc_struct (scm_t_bits vtable_bits, int n_words)
|
|||
{
|
||||
SCM ret;
|
||||
|
||||
ret = scm_words (vtable_bits | scm_tc3_struct, n_words + 1);
|
||||
struct scm_struct *s =
|
||||
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||
sizeof (*s) + n_words * sizeof (SCM));
|
||||
s->tagged_vtable = vtable_bits | scm_tc3_struct;
|
||||
ret = scm_from_struct (s);
|
||||
|
||||
/* vtable_bits can be 0 when making a vtable vtable */
|
||||
if (vtable_bits && SCM_VTABLE_INSTANCE_FINALIZER (SCM_PACK (vtable_bits)))
|
||||
|
@ -444,24 +448,24 @@ SCM_DEFINE (scm_make_struct_simple, "make-struct/simple", 1, 0, 1,
|
|||
"use @code{make-struct/no-tail}.")
|
||||
#define FUNC_NAME s_scm_make_struct_simple
|
||||
{
|
||||
long i, n_init;
|
||||
SCM ret;
|
||||
|
||||
SCM_VALIDATE_VTABLE (1, vtable);
|
||||
n_init = scm_ilength (init);
|
||||
long n_init = scm_ilength (init);
|
||||
if (n_init != SCM_VTABLE_SIZE (vtable))
|
||||
SCM_MISC_ERROR ("Wrong number of initializers.", SCM_EOL);
|
||||
|
||||
ret = scm_words (SCM_UNPACK (vtable) | scm_tc3_struct, n_init + 1);
|
||||
struct scm_struct *s =
|
||||
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||
sizeof (*s) + n_init * sizeof (SCM));
|
||||
s->tagged_vtable = SCM_UNPACK (vtable) | scm_tc3_struct;
|
||||
|
||||
for (i = 0; i < n_init; i++, init = scm_cdr (init))
|
||||
for (long i = 0; i < n_init; i++, init = scm_cdr (init))
|
||||
{
|
||||
SCM_ASSERT (!SCM_VTABLE_FIELD_IS_UNBOXED (vtable, i),
|
||||
vtable, 1, FUNC_NAME);
|
||||
SCM_STRUCT_SLOT_SET (ret, i, scm_car (init));
|
||||
scm_i_struct_set_scm (s, i, scm_car (init));
|
||||
}
|
||||
|
||||
return ret;
|
||||
return scm_from_struct (s);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue