123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #include <libguile.h>
- static scm_t_bits scm_tc16_box;
- static SCM
- mark_box (SCM b)
- {
-
- return SCM_CELL_OBJECT_1 (b);
- }
- static int
- print_box (SCM b, SCM port, scm_print_state *pstate)
- {
- SCM value = SCM_CELL_OBJECT_1 (b);
- scm_puts ("#<box ", port);
- scm_write (value, port);
- scm_puts (">", port);
-
- return 1;
- }
- static SCM
- #define FUNC_NAME "make-box"
- make_box (void)
- {
-
- SCM_RETURN_NEWSMOB (scm_tc16_box, SCM_BOOL_F);
- }
- #undef FUNC_NAME
- static SCM
- box_ref (SCM b)
- #define FUNC_NAME "box-ref"
- {
-
- SCM_VALIDATE_SMOB (1, b, box);
-
- return SCM_CELL_OBJECT_1 (b);
- }
- #undef FUNC_NAME
- static SCM
- box_set_x (SCM b, SCM value)
- #define FUNC_NAME "box-set!"
- {
- SCM_VALIDATE_SMOB (1, b, box);
-
- SCM_SET_CELL_OBJECT_1 (b, value);
-
- return SCM_UNSPECIFIED;
- }
- #undef FUNC_NAME
- static void
- init_box_type (void)
- {
- scm_tc16_box = scm_make_smob_type ("box", 0);
- scm_set_smob_mark (scm_tc16_box, mark_box);
- scm_set_smob_print (scm_tc16_box, print_box);
- scm_c_define_gsubr ("make-box", 0, 0, 0, make_box);
- scm_c_define_gsubr ("box-set!", 2, 0, 0, box_set_x);
- scm_c_define_gsubr ("box-ref", 1, 0, 0, box_ref);
- }
- static void
- inner_main (void *closure, int argc, char **argv)
- {
-
- init_box_type ();
-
- scm_shell (argc, argv);
- }
- int
- main (int argc, char **argv)
- {
-
- scm_boot_guile (argc, argv, inner_main, 0);
- return 0;
- }
|