From 382386f40b80204f3af9f99204737e8cbbac9d2f Mon Sep 17 00:00:00 2001
From: hanwen <hanwen>
Date: Tue, 4 May 2004 23:00:57 +0000
Subject: [PATCH] * input/regression/music-head.ly (texidoc): new file.

* lily/parser.yy (Generic_prefix_music): allow generic
music-transformation functions.

* lily/music-head.cc (get_music_head_transform): new file.
---
 input/regression/music-head.ly |  2 +-
 lily/identifier-smob.cc        |  9 +--------
 lily/include/ly-smobs.icc      |  2 ++
 lily/include/smobs.hh          |  2 +-
 lily/lexer.ll                  |  2 +-
 lily/music-head.cc             | 17 ++---------------
 lily/parser.yy                 |  4 +++-
 7 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/input/regression/music-head.ly b/input/regression/music-head.ly
index e300c3bd5f..63b84bd8ba 100644
--- a/input/regression/music-head.ly
+++ b/input/regression/music-head.ly
@@ -10,7 +10,7 @@ which can be used to extend music syntax seamlessly."
   (ly:make-music-head
    (lambda (where type)
     (context-spec-music
-     (context-spec-music (make-property-set whichBar type) 'Timing)
+     (context-spec-music (make-property-set 'whichBar type) 'Timing)
      'Score))
    (list string?)
     
diff --git a/lily/identifier-smob.cc b/lily/identifier-smob.cc
index 678cc4a8d0..3696cf4954 100644
--- a/lily/identifier-smob.cc
+++ b/lily/identifier-smob.cc
@@ -8,13 +8,10 @@ source file of the GNU LilyPond music typesetter
 
 */
 #include "identifier-smob.hh"
-/*
-  C&P from example/box.c
- */
+
 
 scm_t_bits package_tag;
 
-/* Print a textual represenation of the smob to a given port.  */
 static int
 print_box (SCM b, SCM port, scm_print_state *)
 {
@@ -34,14 +31,10 @@ print_box (SCM b, SCM port, scm_print_state *)
 LY_DEFINE (package_identifier, "ly:export", 1,0,0, (SCM arg),
 	  "Export a Scheme object to the parser, so it is treated as an identifier.")
 {
-  /* This macro creates the new objects, stores the value `#f' into it
-     and returns it to the caller.  */
   SCM_RETURN_NEWSMOB (package_tag, arg);
 }
 
 
-/* This is the primitive `box-ref' which returns the object stored in
-   the box.  */
 SCM
 unpack_identifier (SCM box)
 {
diff --git a/lily/include/ly-smobs.icc b/lily/include/ly-smobs.icc
index 7a2f6e7ec2..2296448400 100644
--- a/lily/include/ly-smobs.icc
+++ b/lily/include/ly-smobs.icc
@@ -13,9 +13,11 @@
 
 
 #define IMPLEMENT_TYPE_P(CL, FUNCNAME)\
+SCM CL ## _type_p_proc;\
 void init_type_ ## CL ()\
 {\
   SCM subr = scm_c_define_gsubr (FUNCNAME, 1, 0, 0, (Scheme_function_unknown) CL::smob_p);\
+  CL ## _type_p_proc = subr;\
   ly_add_function_documentation (subr, FUNCNAME, "(SCM x)", "Is @var{x} a @code{" #CL "} object?");\
   scm_c_export (FUNCNAME, NULL);\
 }\
diff --git a/lily/include/smobs.hh b/lily/include/smobs.hh
index a31ce06e45..5a5b5ce181 100644
--- a/lily/include/smobs.hh
+++ b/lily/include/smobs.hh
@@ -134,7 +134,7 @@ unsmob_ ## name (SCM s)			\
 return  CL::unsmob (s);				\
 }
 
-#define DECLARE_TYPE_P(CL) extern SCM CL_ ## _type_p_proc
+#define DECLARE_TYPE_P(CL) extern SCM CL ## _type_p_proc
 
 #endif /* SMOBS_HH */
 
diff --git a/lily/lexer.ll b/lily/lexer.ll
index fa31de9c41..506c047dbf 100644
--- a/lily/lexer.ll
+++ b/lily/lexer.ll
@@ -891,7 +891,7 @@ lookup_markup_command (String s)
 int
 music_head_type (SCM func)
 {
-	SCM type= scm_object_property (func, ly_symbol2scm ("music-head-signature"));
+	SCM type= scm_object_property (func, ly_symbol2scm ("music-head-signature-keyword"));
 	if (type == ly_symbol2scm ("scm"))
 	{
 		return MUSIC_HEAD_SCM;
diff --git a/lily/music-head.cc b/lily/music-head.cc
index e847b298fd..0e104eb9ff 100644
--- a/lily/music-head.cc
+++ b/lily/music-head.cc
@@ -8,10 +8,7 @@
 */
 #include "music-head.hh"
 #include "string.hh"
-
-/*
-  C&P from example/box.c
- */
+#include "music.hh"
 
 static scm_t_bits music_head_tag;
 
@@ -30,8 +27,6 @@ print_music_head (SCM b, SCM port, scm_print_state *)
 }
 
 
-/* This defines the primitve `make-music_head', which returns a new smob of
-   type `music_head', initialized to `#f'.  */
 LY_DEFINE (ly_make_music_head, "ly:make-music-head", 2, 0, 0,
 	   (SCM func, SCM signature),
 	  "Make a function to process music, to be used for the "
@@ -39,11 +34,7 @@ LY_DEFINE (ly_make_music_head, "ly:make-music-head", 2, 0, 0,
 	   "Its arguments. @code{signature} is a list containing either "
 	   "@code{ly:music?} predicates or other type predicates.")
 {
-  /* This macro creates the new objects, stores the value `#f' into it
-     and returns it to the caller.  */
   String str = "";
-
-  int k = 0;
   for (SCM s = signature; ly_c_pair_p (s); s = ly_cdr (s))
     {
       if (str != "")
@@ -51,10 +42,8 @@ LY_DEFINE (ly_make_music_head, "ly:make-music-head", 2, 0, 0,
       
       if (ly_car (s) == Music_type_p_proc)
 	str += "music";
-      else if (ly_procedure_p (ly_car (s)))
+      else if (ly_c_procedure_p (ly_car (s)))
 	str += "scm";
-
-      k++;
     }
   
   scm_set_object_property_x (func, ly_symbol2scm ("music-head-signature"),
@@ -73,8 +62,6 @@ is_music_head (SCM music_head)
 }
 
 
-/* This is the primitive `music_head-ref' which returns the object stored in
-   the music_head.  */
 SCM
 get_music_head_transform (SCM music_head)
 {
diff --git a/lily/parser.yy b/lily/parser.yy
index 4b1868ceab..14d509f027 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -958,7 +958,9 @@ Generic_prefix_music:
 		SCM m = scm_call_2 ($1, make_input (THIS->pop_spot ()),
 			$3);
 		if (unsmob_music (m))
-			$$ = unsmob_music (m);
+		{	$$ = unsmob_music (m);
+			scm_gc_protect_object (m);
+		}
 		else
 		{
 			THIS->parser_error ("MUSIC_HEAD should return Music");
-- 
2.39.5