mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-04 16:50:25 +02:00
Add new typed struct helpers to get size and unboxed fields
* libguile/struct.h (scm_i_vtable_size): (scm_i_vtable_unboxed_fields): New helpers.
This commit is contained in:
parent
4f25a845cb
commit
38c22e77a0
1 changed files with 14 additions and 2 deletions
|
@ -186,6 +186,18 @@ scm_i_struct_set_raw (struct scm_struct *x, size_t idx, scm_t_bits val)
|
|||
|
||||
/* The SCM_VTABLE_* macros assume that you're passing them a struct which is a
|
||||
valid vtable. */
|
||||
static inline size_t
|
||||
scm_i_vtable_size (struct scm_struct *vtable)
|
||||
{
|
||||
return scm_i_struct_ref_raw (vtable, scm_vtable_index_size);
|
||||
}
|
||||
|
||||
static inline SCM
|
||||
scm_i_vtable_unboxed_fields (struct scm_struct *vtable)
|
||||
{
|
||||
return scm_i_struct_ref_scm (vtable, scm_vtable_index_unboxed_fields);
|
||||
}
|
||||
|
||||
#define SCM_VTABLE_LAYOUT(X) (SCM_STRUCT_SLOT_REF ((X), scm_vtable_index_layout))
|
||||
#define SCM_SET_VTABLE_LAYOUT(X,L) (SCM_STRUCT_SLOT_SET ((X), scm_vtable_index_layout, L))
|
||||
#define SCM_VTABLE_FLAGS(X) (SCM_STRUCT_DATA_REF (X, scm_vtable_index_flags))
|
||||
|
@ -199,8 +211,8 @@ scm_i_struct_set_raw (struct scm_struct *x, size_t idx, scm_t_bits val)
|
|||
#define SCM_SET_VTABLE_INSTANCE_PRINTER(X,P) (SCM_STRUCT_SLOT_SET (X, scm_vtable_index_instance_printer, (P)))
|
||||
#define SCM_VTABLE_NAME(X) (SCM_STRUCT_SLOT_REF (X, scm_vtable_index_name))
|
||||
#define SCM_SET_VTABLE_NAME(X,V) (SCM_STRUCT_SLOT_SET (X, scm_vtable_index_name, V))
|
||||
#define SCM_VTABLE_SIZE(X) (SCM_STRUCT_DATA_REF (X, scm_vtable_index_size))
|
||||
#define SCM_VTABLE_UNBOXED_FIELDS(X) (SCM_STRUCT_SLOT_REF (X, scm_vtable_index_unboxed_fields))
|
||||
#define SCM_VTABLE_SIZE(X) (scm_i_vtable_size (scm_to_struct (X)))
|
||||
#define SCM_VTABLE_UNBOXED_FIELDS(X) (scm_i_vtable_unboxed_fields (scm_to_struct (X)))
|
||||
#define SCM_VTABLE_FIELD_IS_UNBOXED(X,F) (scm_is_true (scm_logbit_p (SCM_I_MAKINUM (F), SCM_VTABLE_UNBOXED_FIELDS (X))))
|
||||
|
||||
#define SCM_STRUCT_VTABLE(X) (SCM_PACK (SCM_CELL_WORD_0 (X) - scm_tc3_struct))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue