]> git.donarmstrong.com Git - lilypond.git/blob - lily/identifier-smob.cc
Run `make grand-replace'.
[lilypond.git] / lily / identifier-smob.cc
1 /*
2   identifier-smob.cc -- implement glue to pass Scheme expressions off as
3   identifiers.
4
5   source file of the GNU LilyPond music typesetter
6
7   (c) 2002--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 */
9
10 #include "identifier-smob.hh"
11
12 scm_t_bits package_tag;
13
14 static int
15 print_box (SCM b, SCM port, scm_print_state *)
16 {
17   SCM value = SCM_CELL_OBJECT_1 (b);
18
19   scm_puts ("#<packaged object ", port);
20   scm_write (value, port);
21   scm_puts (">", port);
22
23   /* Non-zero means success.  */
24   return 1;
25 }
26
27 /* This defines the primitve `make-box', which returns a new smob of
28    type `box', initialized to `#f'.  */
29 LY_DEFINE (ly_export, "ly:export",
30            1, 0, 0, (SCM arg),
31            "Export a Scheme object to the parser"
32            " so it is treated as an identifier.")
33 {
34   SCM_RETURN_NEWSMOB (package_tag, arg);
35 }
36
37 SCM
38 unpack_identifier (SCM box)
39 {
40   if (SCM_IMP (box) || SCM_CELL_TYPE (box) != package_tag)
41     return SCM_UNDEFINED;
42
43   return SCM_CELL_OBJECT_1 (box);
44 }
45
46 static void
47 init_box_type (void)
48 {
49   package_tag = scm_make_smob_type ("box", 0);
50   scm_set_smob_mark (package_tag, scm_markcdr);
51   scm_set_smob_print (package_tag, print_box);
52 }
53
54 ADD_SCM_INIT_FUNC (package, init_box_type);