]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #1355.
authorNeil Puttock <n.puttock@gmail.com>
Sun, 24 Oct 2010 23:10:29 +0000 (00:10 +0100)
committerNeil Puttock <n.puttock@gmail.com>
Sun, 24 Oct 2010 23:10:56 +0000 (00:10 +0100)
A derived smob cannot use the macro IMPLEMENT_TYPE_P () to export
its type predicate, since this relies on the IMPLEMENT_SMOBS ()
macro to initialize the class's smob tag and predicate function
(smob_p ()): IMPLEMENT_SMOBS () is reserved for use in base classes.
In the case of Stream_event, this results in both ly:stream-event?
and ASSERT_SMOB (Stream_event, ...) failing to distinguish
stream events from other Probs.

* lily/function-documentation.cc (init_func_doc):

  add type predicate documentation for Stream_event

* lily/include/stream-event.hh:

  remove declaration for Stream_event predicate

* lily/stream-event-scheme.cc:

  implement ly:stream-event? manually
  use LY_ASSERT_TYPE () instead of LY_ASSERT_SMOB ()

* lily/stream-event.cc:

  remove macro implementation of ly:stream-event?

lily/function-documentation.cc
lily/include/stream-event.hh
lily/stream-event-scheme.cc
lily/stream-event.cc

index cbb6035038c9ebde2fa070a5f7f2439fe94cc212..f190f0e2b8eb1bf0b08c9901b1ef152ec33216f8 100644 (file)
@@ -69,7 +69,7 @@ LY_DEFINE (ly_get_all_function_documentation, "ly:get-all-function-documentation
 
 #include <map>
 
-map<void *, string>  type_names;
+map<void *, string> type_names;
   
 void
 ly_add_type_predicate (void *ptr,
@@ -91,14 +91,15 @@ predicate_to_typename (void *ptr)
 }
 
 /* type predicates. */
-#include "spanner.hh"
+#include "global-context.hh"
+#include "input.hh"
 #include "item.hh"
 #include "music.hh"
 #include "music-function.hh"
-#include "performance.hh"
 #include "paper-score.hh"
-#include "global-context.hh"
-#include "input.hh"
+#include "performance.hh"
+#include "spanner.hh"
+#include "stream-event.hh"
 
 void
 init_func_doc ()
@@ -128,6 +129,7 @@ init_func_doc ()
   ly_add_type_predicate ((void*) &unsmob_item, "Item");
   ly_add_type_predicate ((void*) &unsmob_music, "Music");
   ly_add_type_predicate ((void*) &unsmob_spanner, "Spanner");
+  ly_add_type_predicate ((void*) &unsmob_stream_event, "Stream_event");
 }
 
 ADD_SCM_INIT_FUNC (func_doc, init_func_doc);
index b41d2566c4f96ab52f45f8716c907e4bbb899d2c..f6e5477fbde382afab9f3425fd2e0c0abe6cecc6 100644 (file)
@@ -46,7 +46,6 @@ public:
 #define in_event_class(class_name) internal_in_event_class (ly_symbol2scm (class_name))
 
 Stream_event *unsmob_stream_event (SCM);
-DECLARE_TYPE_P (Stream_event);
 SCM ly_event_deep_copy (SCM);
 
 #endif /* STREAM_EVENT_HH */
index 3d569960ed381adbe57220d8e8bb3b5fa8d88388..4315e9f6c55fd45b3b162113c4542765d3d95435 100644 (file)
 
 #include "stream-event.hh"
 
+LY_DEFINE (ly_stream_event_p, "ly:stream-event?",
+          1, 0, 0, (SCM obj),
+          "Is @code{@var{obj}} a @code{Stream_event} object?")
+{
+  return scm_from_bool (unsmob_stream_event (obj));
+}
+
 LY_DEFINE (ly_make_stream_event, "ly:make-stream-event",
           1, 1, 0, (SCM cl, SCM proplist),
           "Create a stream event of class @var{cl} with the given"
@@ -41,7 +48,7 @@ LY_DEFINE (ly_event_property, "ly:event-property",
           "Get the property @var{sym} of stream event @var{mus}."
           "  If @var{sym} is undefined, return @code{'()}.")
 {
-  LY_ASSERT_SMOB (Stream_event, sev, 1);
+  LY_ASSERT_TYPE (unsmob_stream_event, sev, 1);
   LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
 
   Stream_event *e = unsmob_stream_event (sev);
@@ -53,7 +60,7 @@ LY_DEFINE (ly_event_set_property_x, "ly:event-set-property!",
            3, 0, 0, (SCM ev, SCM sym, SCM val),
            "Set property @var{sym} in event @var{ev} to @var{val}.")
 {
-  LY_ASSERT_SMOB (Stream_event, ev, 1);
+  LY_ASSERT_TYPE (unsmob_stream_event, ev, 1);
   LY_ASSERT_TYPE (ly_is_symbol, sym, 2);
   
   return ly_prob_set_property_x (ev, sym, val);
index 6392e3c718585d2b01611d105fdf5998f01e5f2c..4a846d841cd9d665cb867a37278e700f2cd0dcc8 100644 (file)
@@ -73,8 +73,6 @@ Stream_event::internal_in_event_class (SCM class_name)
   return scm_c_memq (class_name, cl) != SCM_BOOL_F;
 }
 
-IMPLEMENT_TYPE_P (Stream_event, "ly:stream-event?");
-
 MAKE_SCHEME_CALLBACK (Stream_event, undump, 1);
 MAKE_SCHEME_CALLBACK (Stream_event, dump, 1);