]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/music-head.ly (texidoc): new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 4 May 2004 23:00:57 +0000 (23:00 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 4 May 2004 23:00:57 +0000 (23:00 +0000)
* 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
lily/identifier-smob.cc
lily/include/ly-smobs.icc
lily/include/smobs.hh
lily/lexer.ll
lily/music-head.cc
lily/parser.yy

index e300c3bd5f611859a4ee826d260963209c962582..63b84bd8bad80a0a6ea7d0e68b425313d0257377 100644 (file)
@@ -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?)
     
index 678cc4a8d076183efeb835a68d3215a62f0a9604..3696cf495464be2df7c3e7ed83a7044ca038d8dd 100644 (file)
@@ -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)
 {
index 7a2f6e7ec2fe77189ceee160f8b8e7923af26f55..2296448400565a454d7833054f1f7236a2ce6dd6 100644 (file)
 
 
 #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);\
 }\
index a31ce06e45ba72caa8601a40cf8e1e8fc9ea79e5..5a5b5ce1811dffa67d23401c4b64d80260840a84 100644 (file)
@@ -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 */
 
index fa31de9c419a0d062a89d1f1c08b7738bb69bac6..506c047dbf0fcd20eee693c89a1c74afb57e5b43 100644 (file)
@@ -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;
index e847b298fdb475dd80f3ea6abca656aa51ae4d1c..0e104eb9ff2714f5a22334686555c04ce9bd1d4f 100644 (file)
@@ -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)
 {
index 4b1868ceab66d1a92c3a1469a08cfb7dfc5a7fe2..14d509f02753945789db98d7e9d553ebd798d104 100644 (file)
@@ -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");