mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-03 16:20:39 +02:00
Deprecate C hooks
* libguile/chooks.c: * libguile/chooks.h: Remove. * libguile/deprecated.h: * libguile/deprecated.c: Add deprecated implementations. * libguile/gc.c: * libguile/gc.h: Arrange to call before/after C hooks if deprecated code is enabled. * libguile/Makefile.am: * libguile.h: Remove chooks.[ch] references.
This commit is contained in:
parent
08296e6022
commit
a6b848dcba
8 changed files with 148 additions and 204 deletions
|
@ -21,6 +21,8 @@
|
|||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define SCM_BUILDING_DEPRECATED_CODE
|
||||
|
||||
#include "deprecation.h"
|
||||
|
@ -765,6 +767,102 @@ scm_i_simple_vector_set_x (SCM v, size_t k, SCM val)
|
|||
|
||||
|
||||
|
||||
scm_t_c_hook scm_before_gc_c_hook = { 0, SCM_C_HOOK_NORMAL, NULL };
|
||||
scm_t_c_hook scm_before_mark_c_hook = { 0, SCM_C_HOOK_NORMAL, NULL };
|
||||
scm_t_c_hook scm_before_sweep_c_hook = { 0, SCM_C_HOOK_NORMAL, NULL };
|
||||
scm_t_c_hook scm_after_sweep_c_hook = { 0, SCM_C_HOOK_NORMAL, NULL };
|
||||
scm_t_c_hook scm_after_gc_c_hook = { 0, SCM_C_HOOK_NORMAL, NULL };
|
||||
|
||||
void
|
||||
scm_c_hook_init (scm_t_c_hook *hook, void *hook_data, scm_t_c_hook_type type)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("C hooks (scm_c_hook_ functions) are deprecated. Implement this yourself.");
|
||||
hook->first = 0;
|
||||
hook->type = type;
|
||||
hook->data = hook_data;
|
||||
}
|
||||
|
||||
void
|
||||
scm_c_hook_add (scm_t_c_hook *hook,
|
||||
scm_t_c_hook_function func,
|
||||
void *fn_data,
|
||||
int appendp)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("C hooks (scm_c_hook_ functions) are deprecated. Implement this yourself.");
|
||||
|
||||
scm_t_c_hook_entry *entry;
|
||||
scm_t_c_hook_entry **loc = &hook->first;
|
||||
|
||||
entry = scm_allocate_sloppy (SCM_I_CURRENT_THREAD,
|
||||
sizeof (scm_t_c_hook_entry));
|
||||
if (appendp)
|
||||
while (*loc)
|
||||
loc = &(*loc)->next;
|
||||
entry->next = *loc;
|
||||
entry->func = func;
|
||||
entry->data = fn_data;
|
||||
*loc = entry;
|
||||
}
|
||||
|
||||
void
|
||||
scm_c_hook_remove (scm_t_c_hook *hook,
|
||||
scm_t_c_hook_function func,
|
||||
void *fn_data)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("C hooks (scm_c_hook_ functions) are deprecated. Implement this yourself.");
|
||||
|
||||
scm_t_c_hook_entry **loc = &hook->first;
|
||||
while (*loc)
|
||||
{
|
||||
if ((*loc)->func == func && (*loc)->data == fn_data)
|
||||
{
|
||||
*loc = (*loc)->next;
|
||||
return;
|
||||
}
|
||||
loc = &(*loc)->next;
|
||||
}
|
||||
fprintf (stderr, "Attempt to remove non-existent hook function\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
void *
|
||||
scm_c_hook_run (scm_t_c_hook *hook, void *data)
|
||||
{
|
||||
scm_c_issue_deprecation_warning
|
||||
("C hooks (scm_c_hook_ functions) are deprecated. Implement this yourself.");
|
||||
|
||||
return scm_i_c_hook_run (hook, data);
|
||||
}
|
||||
|
||||
void *
|
||||
scm_i_c_hook_run (scm_t_c_hook *hook, void *data)
|
||||
{
|
||||
scm_t_c_hook_entry *entry = hook->first;
|
||||
scm_t_c_hook_type type = hook->type;
|
||||
void *res = 0;
|
||||
while (entry)
|
||||
{
|
||||
res = (entry->func) (hook->data, entry->data, data);
|
||||
if (res)
|
||||
{
|
||||
if (type == SCM_C_HOOK_OR)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (type == SCM_C_HOOK_AND)
|
||||
break;
|
||||
}
|
||||
entry = entry->next;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
scm_i_init_deprecated ()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue