mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
Slightly improve comments and style in `struct.c'.
* libguile/struct.c (scm_i_struct_inherit_vtable_magic): Comment. Punctuate comments within the body, have them follow GCS. (scm_make_vtable_vtable): Clarify comments.
This commit is contained in:
parent
01e74380f6
commit
696ac4dfcc
1 changed files with 14 additions and 14 deletions
|
@ -208,6 +208,8 @@ set_vtable_layout_flags (SCM vtable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Have OBJ, a newly created vtable, inherit flags from VTABLE. VTABLE is a
|
||||||
|
vtable-vtable and OBJ is an instance of VTABLE. */
|
||||||
void
|
void
|
||||||
scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj)
|
scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj)
|
||||||
#define FUNC_NAME "%inherit-vtable-magic"
|
#define FUNC_NAME "%inherit-vtable-magic"
|
||||||
|
@ -218,19 +220,18 @@ scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj)
|
||||||
Both of these questions also imply a certain layout of the structure. So
|
Both of these questions also imply a certain layout of the structure. So
|
||||||
instead of checking the layout at runtime, what we do is pre-verify the
|
instead of checking the layout at runtime, what we do is pre-verify the
|
||||||
layout -- so that at runtime we can just check the applicable flag and
|
layout -- so that at runtime we can just check the applicable flag and
|
||||||
dispatch directly to the Scheme procedure in slot 0.
|
dispatch directly to the Scheme procedure in slot 0. */
|
||||||
*/
|
|
||||||
SCM olayout;
|
SCM olayout;
|
||||||
|
|
||||||
/* verify that obj is a valid vtable */
|
/* Verify that OBJ is a valid vtable. */
|
||||||
if (scm_is_false (scm_symbol_p (SCM_VTABLE_LAYOUT (obj))))
|
if (scm_is_false (scm_symbol_p (SCM_VTABLE_LAYOUT (obj))))
|
||||||
scm_misc_error (FUNC_NAME, "invalid layout for new vtable",
|
scm_misc_error (FUNC_NAME, "invalid layout for new vtable",
|
||||||
scm_list_1 (SCM_VTABLE_LAYOUT (obj)));
|
scm_list_1 (SCM_VTABLE_LAYOUT (obj)));
|
||||||
|
|
||||||
set_vtable_layout_flags (obj);
|
set_vtable_layout_flags (obj);
|
||||||
|
|
||||||
/* if obj's vtable is compatible with the required vtable (class) layout, it
|
/* If OBJ's vtable is compatible with the required vtable (class) layout, it
|
||||||
is a metaclass */
|
is a metaclass. */
|
||||||
olayout = scm_symbol_to_string (SCM_VTABLE_LAYOUT (obj));
|
olayout = scm_symbol_to_string (SCM_VTABLE_LAYOUT (obj));
|
||||||
if (scm_is_true (scm_leq_p (scm_string_length (required_vtable_fields),
|
if (scm_is_true (scm_leq_p (scm_string_length (required_vtable_fields),
|
||||||
scm_string_length (olayout)))
|
scm_string_length (olayout)))
|
||||||
|
@ -241,8 +242,8 @@ scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj)
|
||||||
scm_string_length (required_vtable_fields))))
|
scm_string_length (required_vtable_fields))))
|
||||||
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_VTABLE);
|
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_VTABLE);
|
||||||
|
|
||||||
/* finally if obj is an applicable class, verify that its vtable is
|
/* Finally, if OBJ is an applicable class, verify that its vtable is
|
||||||
compatible with the required applicable layout */
|
compatible with the required applicable layout. */
|
||||||
if (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SETTER_VTABLE))
|
if (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SETTER_VTABLE))
|
||||||
{
|
{
|
||||||
if (scm_is_false (scm_string_eq (olayout, required_applicable_with_setter_fields,
|
if (scm_is_false (scm_string_eq (olayout, required_applicable_with_setter_fields,
|
||||||
|
@ -576,11 +577,8 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1,
|
||||||
"@end lisp")
|
"@end lisp")
|
||||||
#define FUNC_NAME s_scm_make_vtable_vtable
|
#define FUNC_NAME s_scm_make_vtable_vtable
|
||||||
{
|
{
|
||||||
SCM fields;
|
SCM fields, layout, obj;
|
||||||
SCM layout;
|
size_t basic_size, n_tail, i, n_init;
|
||||||
size_t basic_size;
|
|
||||||
size_t n_tail, i, n_init;
|
|
||||||
SCM obj;
|
|
||||||
long ilen;
|
long ilen;
|
||||||
scm_t_bits *v;
|
scm_t_bits *v;
|
||||||
|
|
||||||
|
@ -611,11 +609,13 @@ SCM_DEFINE (scm_make_vtable_vtable, "make-vtable-vtable", 2, 0, 1,
|
||||||
|
|
||||||
SCM_CRITICAL_SECTION_START;
|
SCM_CRITICAL_SECTION_START;
|
||||||
obj = scm_i_alloc_struct (NULL, basic_size + n_tail);
|
obj = scm_i_alloc_struct (NULL, basic_size + n_tail);
|
||||||
/* magic magic magic */
|
/* Make it so that the vtable of OBJ is itself. */
|
||||||
SCM_SET_CELL_WORD_0 (obj, (scm_t_bits)SCM_STRUCT_DATA (obj) | scm_tc3_struct);
|
SCM_SET_CELL_WORD_0 (obj, (scm_t_bits) SCM_STRUCT_DATA (obj) | scm_tc3_struct);
|
||||||
SCM_CRITICAL_SECTION_END;
|
SCM_CRITICAL_SECTION_END;
|
||||||
|
|
||||||
scm_struct_init (obj, layout, n_tail, n_init, v);
|
scm_struct_init (obj, layout, n_tail, n_init, v);
|
||||||
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_VTABLE);
|
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_VTABLE);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue