diff options
author | Andy Wingo <wingo@pobox.com> | 2017-09-22 11:23:00 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2017-09-22 11:35:36 +0200 |
commit | 04f48e94b573eaede0751110c583293cc34cd8f9 (patch) | |
tree | b4062d8108445ccd0ef0adcb14c6cdc96ea41fcf /libguile/struct.c | |
parent | 9ac0544efff1ce5c9e5a4dcf6477cf2794d11ef0 (diff) | |
download | guile-04f48e94b573eaede0751110c583293cc34cd8f9.tar.gz |
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.
Diffstat (limited to 'libguile/struct.c')
-rw-r--r-- | libguile/struct.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libguile/struct.c b/libguile/struct.c index 08451e741..3ebe89064 100644 --- a/libguile/struct.c +++ b/libguile/struct.c @@ -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 |