38 lines
1.4 KiB
C
38 lines
1.4 KiB
C
#include <stdio.h>
|
|
#include "../runtime/gyehoek.h"
|
|
#include "../runtime/weak-set.h"
|
|
|
|
static int
|
|
symbol_lookup_predicate_fn (SCM sym, void *closure) {
|
|
SCM other = SCM_PACK_POINTER (closure);
|
|
return 1;
|
|
}
|
|
|
|
int main () {
|
|
/* const char s[] = "wormy"; */
|
|
/* const SCM str = scm_from_utf8_string (s, sizeof(s)); */
|
|
/* const unsigned long hash = scm_c_hash (str); */
|
|
/* printf ("%ld\n", hash); */
|
|
|
|
SCM set = scm_c_make_weak_set (31);
|
|
SCM str = scm_from_cstring ("my-symbol");
|
|
SCM sym = scm_make_symbol (str, scm_c_hash (str));
|
|
scm_c_weak_set_insert (set, scm_c_hash (str),
|
|
SCM_PACK (SCM_MAKE_SMALL_INT (123)),
|
|
symbol_lookup_predicate_fn,
|
|
SCM_UNPACK_POINTER (sym));
|
|
printf ("%ld\n", weak_set_count (set));
|
|
scm_c_weak_set_insert (set, scm_c_hash (str),
|
|
SCM_PACK (SCM_MAKE_SMALL_INT (123)),
|
|
symbol_lookup_predicate_fn,
|
|
SCM_UNPACK_POINTER (sym));
|
|
printf ("%ld\n", weak_set_count (set));
|
|
SCM str2 = scm_from_cstring ("my-symbol2");
|
|
SCM sym2 = scm_make_symbol (str2, scm_c_hash (str2));
|
|
scm_c_weak_set_insert (set, scm_c_hash (str2),
|
|
SCM_PACK (SCM_MAKE_SMALL_INT (456)),
|
|
symbol_lookup_predicate_fn,
|
|
SCM_UNPACK_POINTER (sym2));
|
|
printf ("%ld\n", weak_set_count (set));
|
|
}
|