Tidy up a bit.
git-svn-id: svn://localhost/ardour2/branches/3.0@12283 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
a6fdd6c915
commit
4d22a4345a
@ -33,7 +33,7 @@ if len(sys.argv) < 2:
|
||||
|
||||
f = open(sys.argv[1], 'w')
|
||||
|
||||
print >>f,"/** THIS FILE IS AUTOGENERATED by signals.py: CHANGES WILL BE LOST */\n\n"
|
||||
print >>f,"/** THIS FILE IS AUTOGENERATED by signals.py: CHANGES WILL BE LOST */\n"
|
||||
|
||||
# Produce a comma-separated string from a list of substrings,
|
||||
# giving an optional prefix to each substring
|
||||
@ -74,6 +74,10 @@ def signal(f, n, v):
|
||||
else:
|
||||
typename = "typename "
|
||||
|
||||
if v:
|
||||
print >>f, "/** A signal with %d parameters (specialisation for a void return) */" % n
|
||||
else:
|
||||
print >>f, "/** A signal with %d parameters */" % n
|
||||
if v:
|
||||
print >>f,"template <%s>" % comma_separated(An, "typename ")
|
||||
print >>f,"class Signal%d<%s> : public SignalBase" % (n, comma_separated(["void"] + An))
|
||||
@ -96,6 +100,7 @@ def signal(f, n, v):
|
||||
print >>f,"private:"
|
||||
|
||||
print >>f,"""
|
||||
/** The slots that this signal will call on emission */
|
||||
typedef std::map<boost::shared_ptr<Connection>, slot_function_type> Slots;
|
||||
Slots _slots;
|
||||
"""
|
||||
@ -105,11 +110,13 @@ def signal(f, n, v):
|
||||
print >>f,"\t~Signal%d () {" % n
|
||||
|
||||
print >>f,"\t\tboost::mutex::scoped_lock lm (_mutex);"
|
||||
print >>f,"\t\t/* Tell our connection objects that we are going away, so they don't try to call us */"
|
||||
print >>f,"\t\tfor (%sSlots::iterator i = _slots.begin(); i != _slots.end(); ++i) {" % typename
|
||||
|
||||
print >>f,"\t\t\ti->first->signal_going_away ();"
|
||||
print >>f,"\t\t}"
|
||||
print >>f,"\t}"
|
||||
print >>f,""
|
||||
|
||||
if n == 0:
|
||||
p = ""
|
||||
@ -123,7 +130,6 @@ def signal(f, n, v):
|
||||
print >>f,"\t}"
|
||||
|
||||
print >>f,"""
|
||||
|
||||
/** Arrange for @a slot to be executed whenever this signal is emitted.
|
||||
Store the connection that represents this arrangement in @a c.
|
||||
|
||||
@ -195,9 +201,9 @@ def signal(f, n, v):
|
||||
}
|
||||
|
||||
/** See notes for the ScopedConnectionList variant of this function. This
|
||||
* differs in that it stores the connection to the signal in a single
|
||||
* ScopedConnection rather than a ScopedConnectionList.
|
||||
*/
|
||||
* differs in that it stores the connection to the signal in a single
|
||||
* ScopedConnection rather than a ScopedConnectionList.
|
||||
*/
|
||||
|
||||
void connect (ScopedConnection& c,
|
||||
PBD::EventLoop::InvalidationRecord* ir,
|
||||
@ -223,15 +229,23 @@ def signal(f, n, v):
|
||||
else:
|
||||
print >>f,"\ttypename C::result_type operator() (%s)" % comma_separated(Anan)
|
||||
print >>f,"\t{"
|
||||
print >>f,"\t\t/* First, take a copy of our list of slots as it is now */"
|
||||
print >>f,""
|
||||
print >>f,"\t\tSlots s;"
|
||||
print >>f,"\t\t{"
|
||||
print >>f,"\t\t\tboost::mutex::scoped_lock lm (_mutex);"
|
||||
print >>f,"\t\t\ts = _slots;"
|
||||
print >>f,"\t\t}"
|
||||
print >>f,""
|
||||
if not v:
|
||||
print >>f,"\t\tstd::list<R> r;"
|
||||
print >>f,"for (%sSlots::iterator i = s.begin(); i != s.end(); ++i) {" % typename
|
||||
print >>f,"\t\tfor (%sSlots::iterator i = s.begin(); i != s.end(); ++i) {" % typename
|
||||
print >>f,"""
|
||||
/* We may have just called a slot, and this may have resulted in
|
||||
disconnection of other slots from us. The list copy means that
|
||||
this won't cause any problems with invalidated iterators, but we
|
||||
must check to see if the slot we are about to call is still on the list.
|
||||
*/
|
||||
bool still_there = false;
|
||||
{
|
||||
boost::mutex::scoped_lock lm (_mutex);
|
||||
@ -245,7 +259,9 @@ def signal(f, n, v):
|
||||
print >>f,"\t\t\t\tr.push_back ((i->second)(%s));" % comma_separated(an)
|
||||
print >>f,"\t\t\t}"
|
||||
print >>f,"\t\t}"
|
||||
print >>f,""
|
||||
if not v:
|
||||
print >>f,"\t\t/* Call our combiner to do whatever is required to the result values */"
|
||||
print >>f,"\t\tC c;"
|
||||
print >>f,"\t\treturn c (r.begin(), r.end());"
|
||||
print >>f,"\t}"
|
||||
@ -262,7 +278,6 @@ def signal(f, n, v):
|
||||
else:
|
||||
tp = comma_separated(["R"] + An + ["C"])
|
||||
|
||||
print >>f,""
|
||||
print >>f,"private:"
|
||||
print >>f,""
|
||||
print >>f,"\tfriend class Connection;"
|
||||
@ -274,8 +289,7 @@ def signal(f, n, v):
|
||||
boost::mutex::scoped_lock lm (_mutex);
|
||||
_slots[c] = f;
|
||||
return c;
|
||||
}
|
||||
"""
|
||||
}"""
|
||||
|
||||
print >>f,"""
|
||||
void disconnect (boost::shared_ptr<Connection> c)
|
||||
|
Loading…
Reference in New Issue
Block a user