Changeset 8
- Timestamp:
- 11/17/06 18:20:45 (2 years ago)
- Files:
-
- trunk/luigi/signalobj.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/luigi/signalobj.d
r7 r8 116 116 * have it.) 117 117 */ 118 slot_key fconnect(DT )(DT f)118 slot_key fconnect(DT,int arg_offset=0)(DT f) 119 119 { 120 120 // make the key … … 124 124 //slot_t f_wrap = SlotAdapter!(slot_t).adapt(f); 125 125 // wrap is safer for now. 126 slot_t f_wrap = SlotAdapter!(slot_t).wrap(f); 126 slot_t f_wrap; 127 f_wrap = SlotAdapter!(slot_t).wrap!(typeof(f),arg_offset)(f); 127 128 128 129 s.connect(f_wrap); … … 130 131 thunkMap[f_key]=f_wrap; 131 132 return f_key; 133 } 134 // this doesn't quite work yet because of DMD bug #540 135 // Name also has to be different from 'fconnect' for what also looks 136 // to be a compiler bug. They should be able to co-exist. 137 template fconnecti(int arg_offset) { 138 slot_key fconnecti(DT)(DT f) 139 { 140 return fconnect!(DT,arg_offset)(f); 141 } 132 142 } 133 143 … … 183 193 static assert( is(slot_ret_t==void), "Expected native slot type to return void." ); 184 194 185 slot_t wrap(WrapSlotT )(WrapSlotT fn) {195 slot_t wrap(WrapSlotT,int arg_offset=0)(WrapSlotT fn) { 186 196 alias WrapSlotT wrap_slot_t; 187 197 alias ReturnType!(fn) wrap_ret_t; 188 198 alias ParameterTypeTuple!(fn) wrap_arg_t; 189 199 190 // This has to be a classfor std.signal's use, currently200 // This has to be a _class_ for std.signal's use, currently 191 201 class Inner { 192 202 wrap_slot_t thunked_slot; 193 203 void slot(slot_arg_t arg) 194 204 { 195 thunked_slot(arg[ 0..wrap_arg_t.length]);205 thunked_slot(arg[arg_offset..wrap_arg_t.length+arg_offset]); 196 206 } 197 207 } 198 208 Inner inner = new Inner; 199 inner.thunked_slot = fn; 209 inner.thunked_slot = fn; 200 210 return &inner.slot; 201 211 } 202 212 203 SigSlotT adapt(WrapSlotT)(WrapSlotT fn)213 slot_t adapt(WrapSlotT)(WrapSlotT fn, int arg_offset=0) 204 214 { 205 215 static if (is(slot_t==WrapSlotT)) { … … 214 224 } 215 225 else { 216 return wrap(fn );226 return wrap(fn,arg_offset); 217 227 } 218 228 } … … 350 360 fsig.fconnect(&func3ldr); 351 361 352 //fsig.fconnect(&func1s, 1); // someday! 362 // Connect, but skip the first arg of the signal 363 // I.e. just subscribe to the string part of the message. 364 // This IFTI limitation is annoying! 365 // fsig.fconnecti!(1)(&func1s); 366 fsig.fconnect!(typeof(&func1s),1)(&func1s); 353 367 354 368 slot_key literal =
