mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Deprecate struct "self" slots
* libguile/print.h (SCM_PRINT_STATE_LAYOUT): Use a normal slot instead of a self slot. * libguile/print.c (make_print_state): Initialize "handle" slot manually. * libguile/struct.c (issue_deprecation_warning_for_self_slots): New helper, called when making vtables to issue deprecation warnings for "self" slots. Avoids warning for the "self" slot that's part of the fixed vtable slots. (scm_i_struct_inherit_vtable_magic): Call issue_deprecation_warning_for_self_slots. * doc/ref/api-data.texi (Vtables, Structure Basics): Remove references to self slots. * NEWS: Add entry.
This commit is contained in:
parent
9ac0544eff
commit
04f48e94b5
5 changed files with 38 additions and 15 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "libguile/_scm.h"
|
||||
#include "libguile/async.h"
|
||||
#include "libguile/chars.h"
|
||||
#include "libguile/deprecation.h"
|
||||
#include "libguile/eval.h"
|
||||
#include "libguile/alist.h"
|
||||
#include "libguile/hashtab.h"
|
||||
|
@ -229,6 +230,23 @@ scm_is_valid_vtable_layout (SCM layout)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
issue_deprecation_warning_for_self_slots (SCM vtable)
|
||||
{
|
||||
SCM olayout;
|
||||
size_t idx, first_user_slot = 0;
|
||||
|
||||
olayout = scm_symbol_to_string (SCM_VTABLE_LAYOUT (vtable));
|
||||
if (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_VTABLE))
|
||||
first_user_slot = scm_vtable_offset_user;
|
||||
|
||||
for (idx = first_user_slot * 2; idx < scm_c_string_length (olayout); idx += 2)
|
||||
if (scm_is_eq (scm_c_string_ref (olayout, idx), SCM_MAKE_CHAR ('s')))
|
||||
scm_c_issue_deprecation_warning
|
||||
("Vtables with \"self\" slots are deprecated. Initialize these "
|
||||
"fields manually.");
|
||||
}
|
||||
|
||||
/* Have OBJ, a newly created vtable, inherit flags from VTABLE. VTABLE is a
|
||||
vtable-vtable and OBJ is an instance of VTABLE. */
|
||||
void
|
||||
|
@ -288,6 +306,8 @@ scm_i_struct_inherit_vtable_magic (SCM vtable, SCM obj)
|
|||
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_APPLICABLE);
|
||||
}
|
||||
|
||||
issue_deprecation_warning_for_self_slots (obj);
|
||||
|
||||
SCM_SET_VTABLE_FLAGS (obj, SCM_VTABLE_FLAG_VALIDATED);
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue