<html><head><meta name="qrichtext" content="1" /></head><body style="font-size:10pt;font-family:Sans Serif">
<p>Am Donnerstag, 8. Dezember 2005 21:58 schrieb <span style="color:#ff0000">Richard</span> <span style="color:#ff0000">Dale</span>:</p>
<p><span style="color:#008000">> On Thursday 08 December 2005 19:32, Arno Rehn wrote:</span></p>
<p><span style="color:#007000">> > Am Mittwoch, 7. Dezember 2005 17:43 schrieb Richard Dale:</span></p>
<p><span style="color:#006000">> > > On Wednesday 07 December 2005 15:36, Arno Rehn wrote:</span></p>
<p><span style="color:#008000">> > > > Hi,</span></p>
<p><span style="color:#008000">> > > ></span></p>
<p><span style="color:#008000">> > > > I experimented a bit and created a more complex Hello-World sample</span></p>
<p><span style="color:#008000">> > > > app. I wanted to connect the "clicked()" signal of a button to the</span></p>
<p><span style="color:#008000">> > > > "quit()" slot of QApplication. Got a SIGSEGV.</span></p>
<p><span style="color:#008000">> > > > I looked into the Qt.cpp of qtruby and it seems as signals and slots</span></p>
<p><span style="color:#008000">> > > > are a bit difficult.</span></p>
<p><span style="color:#006000">> > ></span></p>
<p><span style="color:#006000">> > > QtRuby dynamically constructs QMetaObjects, rather than it being done</span></p>
<p><span style="color:#006000">> > > at compile time by the moc pre-processor. But the actual runtime is</span></p>
<p><span style="color:#006000">> > > identical. We need a way of denoting which methods are slots in C#, and</span></p>
<p><span style="color:#006000">> > > I assume we can use 'attributes' (or are they called 'annotations' I've</span></p>
<p><span style="color:#006000">> > > forgotten). Maybe you could have a look at how we might mark slots, and</span></p>
<p><span style="color:#006000">> > > then the runtime side should be very similar to QtRuby. We don't have</span></p>
<p><span style="color:#006000">> > > to invent anything much new apart from that.</span></p>
<p><span style="color:#007000">> ></span></p>
<p><span style="color:#007000">> > OK, I found out how to mark Signals/Slots with Attributes. I attached an</span></p>
<p><span style="color:#007000">> > example.</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> That looks good. In Qt4 there is a macro 'Q_SLOTS' to use instead of the</span></p>
<p><span style="color:#008000">> 'slots' moc keyword because of a clash with the Boost library. So maybe</span></p>
<p><span style="color:#008000">> slots could be marked like this, to look more like that macro:</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">>       [Q_SLOT()]</span></p>
<p><span style="color:#008000">>       public void mySlot()</span></p>
<p><span style="color:#008000">>       {</span></p>
<p><span style="color:#008000">>       }</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> Maybe signals need to map onto delegates, rather than ordinary methods.</span></p>
<p><span style="color:#ff0000">Would</span> <span style="color:#ff0000">be</span> a <span style="color:#ff0000">good</span> <span style="color:#ff0000">idea</span>. <span style="color:#ff0000">Maybe</span> <span style="color:#ff0000">signals</span> <span style="color:#ff0000">need</span> <span style="color:#ff0000">to</span> be <span style="color:#ff0000">delegates</span>, <span style="color:#ff0000">which</span> are <span style="color:#ff0000">set</span> <span style="color:#ff0000">by the programmer or </span> '<span style="color:#ff0000">QObject</span>.<span style="color:#ff0000">Connect</span>()'. <span style="color:#ff0000">Could</span> <span style="color:#ff0000">look</span> <span style="color:#ff0000">like</span> <span style="color:#ff0000">this</span>:</p>
<p></p>
<p><span style="color:#ff0000">   publi</span>c<span style="color:#ff0000"> clas</span>s<span style="color:#ff0000"> QApplicatio</span>n : ...</p>
<p>       {</p>
<p>               delegate void LastWindowClosedHandler();</p>
<p>               </p>
<p>               [Q_SIGNAL()]</p>
<p>               LastWindowClosedHandler LastWindowClosed;</p>
<p>               </p>
<p>               ...</p>
<p>       }</p>
<p></p>
<p>Now we could just say 'LastWindowClosed' is set by the programmer. This would keep the delegate-system of Mono/.NET. Additionally it would be possible to create a 'QObject.Connect(...)' which dynamically connects 'LastWindowClosed' to another method.</p>
<p>But I don't know how to check whether the underlying C++-instance triggered the signal. Then it would be quite easy to call the appropiate delegate.</p>
<p></p>
<p><span style="color:#008000">> At the moment an interface is generated containing the type signatures of</span></p>
<p><span style="color:#008000">> signals like this:</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">>       public interface IQApplicationSignals {</span></p>
<p><span style="color:#008000">>               void LastWindowClosed();</span></p>
<p><span style="color:#008000">>               void AboutToQuit();</span></p>
<p><span style="color:#008000">>               void GuiThreadAwake();</span></p>
<p><span style="color:#008000">>       }</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> And I was thinking of having a QObject.Emit() method which returned a</span></p>
<p><span style="color:#008000">> transparent proxy, so you could invoke a signal with like this:</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> (LastWindowClosed) myInstance.Emit()</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> And it would be forwarded to SignalInvocation.Invoke(), in a similar manner</span></p>
<p><span style="color:#008000">> to how ordinary method calls get diverted to SmokeInvocation.Invoke() at</span></p>
<p><span style="color:#008000">> the moment.</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> But slots are easiest to get working first though, and marking them with</span></p>
<p><span style="color:#008000">> attributes like you've done looks pretty good to me.</span></p>
<p><span style="color:#008000">></span></p>
<p><span style="color:#008000">> -- Richard</span></p>
<p><span style="color:#008000">> _______________________________________________</span></p>
<p><span style="color:#008000">> Kde-bindings mailing list</span></p>
<p><span style="color:#008000">> Kde-bindings@kde.org</span></p>
<p><span style="color:#008000">> https://mail.kde.org/mailman/listinfo/kde-bindings</span></p>
<p></p>
<p>-- </p>
<p><span style="color:#ff0000">MfG</span></p>
<p>Arno <span style="color:#ff0000">Rehn</span></p>
<p><span style="color:#ff0000">arno</span>@<span style="color:#ff0000">arnorehn</span>.de</p>
</body></html>