Implements listener equality compatible with instanced Scheme engravers.
Also permits \remove to take Scheme argument.
if (ly_symbol2scm ("consists") == tag)
l1 = scm_cons (arg, l1);
else if (ly_symbol2scm ("remove") == tag
if (ly_symbol2scm ("consists") == tag)
l1 = scm_cons (arg, l1);
else if (ly_symbol2scm ("remove") == tag
- && get_translator (arg))
+ && (scm_is_pair (arg)
+ || ly_is_procedure (arg)
+ || get_translator (arg)))
l1 = scm_delete_x (arg, l1);
}
l1 = scm_delete_x (arg, l1);
}
{
void (*listen_callback) (void *, SCM);
void (*mark_callback) (void *);
{
void (*listen_callback) (void *, SCM);
void (*mark_callback) (void *);
+ bool (*equal_callback) (void *, void *);
} Listener_function_table;
class Listener
} Listener_function_table;
class Listener
void listen (SCM ev) const;
bool operator == (Listener const &other) const
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_SIMPLE_SMOBS (Listener);
};
cl *s = (cl *)self; \
scm_gc_mark (s->self_scm ()); \
} \
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; \
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); \
}
return Listener (this, &callbacks); \
}
inline void name (SCM); \
static void name ## _callback (void *self, SCM ev); \
static void name ## _mark (void *self); \
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 */
Listener name ## _listener () const
#endif /* LISTENER_HH */
| context_def_mod STRING {
$$ = scm_list_2 ($1, $2);
}
| context_def_mod STRING {
$$ = scm_list_2 ($1, $2);
}
- | context_def_mod embedded_scm {
- if (ly_symbol2scm ("consists") != $1)
- {
- $$ = SCM_EOL;
- parser->parser_error (@1, _ ("only \\consists takes non-string argument."));
- }
- else
- {
- $$ = scm_list_2 ($1, $2);
- }
+ | context_def_mod embedded_scm
+ {
+ if (!scm_is_string ($2)
+ && ly_symbol2scm ("consists") != $1
+ && ly_symbol2scm ("remove") != $1)
+ {
+ $$ = SCM_EOL;
+ parser->parser_error (@1, _ ("only \\consists and \\remove take non-string argument."));
+ }
+ else
+ {
+ $$ = scm_list_2 ($1, $2);
+ }
scm_gc_mark ((SCM)target);
}
scm_gc_mark ((SCM)target);
}
+static
+bool equal_listen_closure (void *a, void *b)
+{
+ SCM target_a = (SCM) a;
+ SCM target_b = (SCM) b;
+
+ return ly_is_equal (target_a, target_b);
+}
+
Listener_function_table listen_closure
=
{
Listener_function_table listen_closure
=
{
- call_listen_closure, mark_listen_closure
+ call_listen_closure, mark_listen_closure, equal_listen_closure