Mercurial > projects > qtd
comparison qt/d2/qt/Signal.d @ 190:a1b48a630f73
D2 support, simple stuff works now
author | eldar |
---|---|
date | Sun, 12 Jul 2009 20:51:37 +0000 |
parents | 7dd099050621 |
children | 7e589f525254 |
comparison
equal
deleted
inserted
replaced
189:37b419197d4b | 190:a1b48a630f73 |
---|---|
86 | 86 |
87 struct Fn | 87 struct Fn |
88 { | 88 { |
89 void* funcptr; | 89 void* funcptr; |
90 | 90 |
91 static typeof(*this) opCall(R, A...)(R function(A) fn) | 91 static typeof(this) opCall(R, A...)(R function(A) fn) |
92 { | 92 { |
93 typeof(*this) r; | 93 typeof(this) r; |
94 r.funcptr = fn; | 94 r.funcptr = fn; |
95 return r; | 95 return r; |
96 } | 96 } |
97 | 97 |
98 template call(R) | 98 template call(R) |
119 struct Dg | 119 struct Dg |
120 { | 120 { |
121 void* context; | 121 void* context; |
122 void* funcptr; | 122 void* funcptr; |
123 | 123 |
124 static typeof(*this) opCall(R, A...)(R delegate(A) dg) | 124 static typeof(this) opCall(R, A...)(R delegate(A) dg) |
125 { | 125 { |
126 typeof(*this) r; | 126 typeof(this) r; |
127 r.context = dg.ptr; | 127 r.context = dg.ptr; |
128 r.funcptr = dg.funcptr; | 128 r.funcptr = dg.funcptr; |
129 return r; | 129 return r; |
130 } | 130 } |
131 | 131 |
690 } | 690 } |
691 | 691 |
692 // Adjusts signal arguments and calls the slot. S - slot signature, A - signal arguments | 692 // Adjusts signal arguments and calls the slot. S - slot signature, A - signal arguments |
693 private void invokeSlot(S, Receiver, A...)(Receiver r, A args) | 693 private void invokeSlot(S, Receiver, A...)(Receiver r, A args) |
694 { | 694 { |
695 r.get!(S)()(args[0..ParameterTupleOf!(S).length]); | 695 r.get!(S)()(args[0..ParameterTypeTuple!(S).length]); |
696 } | 696 } |
697 | 697 |
698 void blockSignals() | 698 void blockSignals() |
699 { | 699 { |
700 synchronized(this) | 700 synchronized(this) |
767 } | 767 } |
768 } | 768 } |
769 | 769 |
770 template CheckSlot(Slot, A...) | 770 template CheckSlot(Slot, A...) |
771 { | 771 { |
772 static assert(ParameterTupleOf!(Slot).length <= A.length, "Slot " ~ ParameterTypeTuple!(Slot).stringof ~ | 772 static assert(ParameterTypeTuple!(Slot).length <= A.length, "Slot " ~ ParameterTypeTuple!(Slot).stringof ~ |
773 " has more prameters than signal " ~ A.stringof); | 773 " has more prameters than signal " ~ A.stringof); |
774 alias CheckSlotImpl!(Slot, 0, A) check; | 774 alias CheckSlotImpl!(Slot, 0, A) check; |
775 } | 775 } |
776 | 776 |
777 template CheckSlotImpl(Slot, int i, A...) | 777 template CheckSlotImpl(Slot, int i, A...) |
778 { | 778 { |
779 alias ParameterTupleOf!(Slot) SlotArgs; | 779 alias ParameterTypeTuple!(Slot) SlotArgs; |
780 static if (i < SlotArgs.length) | 780 static if (i < SlotArgs.length) |
781 { | 781 { |
782 static assert (is(SlotArgs[i] : A[i]), "Argument " ~ ToString!(i) ~ | 782 static assert (is(SlotArgs[i] : A[i]), "Argument " ~ ToString!(i) ~ |
783 ":" ~ A[i].stringof ~ " of signal " ~ A.stringof ~ " is not implicitly convertible to parameter " | 783 ":" ~ A[i].stringof ~ " of signal " ~ A.stringof ~ " is not implicitly convertible to parameter " |
784 | 784 |