]> git.donarmstrong.com Git - lilypond.git/blob - lily/identifier-smob.cc
* lily/paper-score.cc (process): Do not show progress newline.
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
9
10 #include "identifier-smob.hh"
11
12
13 scm_t_bits package_tag;
14
15 static int
16 print_box (SCM b, SCM port, scm_print_state *)
17 {
18   SCM value = SCM_CELL_OBJECT_1 (b);
19
20   scm_puts ("#<packaged object ", port);
21   scm_write (value, port);
22   scm_puts (">", port);
23
24   /* Non-zero means success.  */
25   return 1;
26 }
27
28 /* This defines the primitve `make-box', which returns a new smob of
29    type `box', initialized to `#f'.  */
30 LY_DEFINE (ly_export, "ly:export",
31            1, 0, 0, (SCM arg),
32            "Export a Scheme object to the parser, "
33            "so it is treated as an identifier.")
34 {
35   SCM_RETURN_NEWSMOB (package_tag, arg);
36 }
37
38 SCM
39 unpack_identifier (SCM box)
40 {
41   if (SCM_IMP (box) || SCM_CELL_TYPE (box) != package_tag)
42     return SCM_UNDEFINED;
43   
44   return SCM_CELL_OBJECT_1 (box);
45 }
46
47 static void
48 init_box_type (void)
49 {
50   package_tag = scm_make_smob_type ("box", 0);
51   scm_set_smob_mark (package_tag, scm_markcdr);
52   scm_set_smob_print (package_tag, print_box);
53 }
54
55 ADD_SCM_INIT_FUNC (package, init_box_type);