]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/include/listener.hh
Merge branch 'issue4032'
[lilypond.git] / lily / include / listener.hh
index 0bc937f2b3b7559e212dd14950aad9d7baf7b121..51ad5db821d30885303cb72e9ef787b12720efb9 100644 (file)
@@ -67,6 +67,7 @@ typedef struct
 {
   void (*listen_callback) (void *, SCM);
   void (*mark_callback) (void *);
+  bool (*equal_callback) (void *, void *);
 } Listener_function_table;
 
 class Listener
@@ -81,11 +82,13 @@ public:
   void listen (SCM ev) const;
 
   bool operator == (Listener const &other) const
-  { return target_ == other.target_ && type_ == other.type_; }
+  {
+    return type_ == other.type_
+           && (*type_->equal_callback) ((void *) target_, (void *) other.target_);
+  }
 
   DECLARE_SIMPLE_SMOBS (Listener);
 };
-DECLARE_UNSMOB (Listener, listener);
 
 #define IMPLEMENT_LISTENER(cl, method)                  \
 void                                                    \
@@ -100,12 +103,18 @@ cl :: method ## _mark (void *self)                      \
   cl *s = (cl *)self;                                   \
   scm_gc_mark (s->self_scm ());                         \
 }                                                       \
+bool                                                    \
+cl :: method ## _is_equal (void *a, void *b)            \
+{                                                       \
+  return a == b;                                        \
+}                                                       \
 Listener                                                \
 cl :: method ## _listener () const                      \
 {                                                       \
   static Listener_function_table callbacks;             \
   callbacks.listen_callback = &cl::method ## _callback; \
   callbacks.mark_callback = &cl::method ## _mark;       \
+  callbacks.equal_callback = &cl::method ## _is_equal;  \
   return Listener (this, &callbacks);                   \
 }
 
@@ -115,6 +124,7 @@ cl :: method ## _listener () const                      \
   inline void name (SCM);                               \
   static void name ## _callback (void *self, SCM ev);   \
   static void name ## _mark (void *self);               \
+  static bool name ## _is_equal (void *a, void *b);     \
   Listener name ## _listener () const
 
 #endif /* LISTENER_HH */