Re: [Pyobjc-dev] More on integer values
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2003-02-03 03:35:30
|
On Sunday, Feb 2, 2003, at 21:08 US/Eastern, David Eppstein wrote: > If they're not interchangeable, then maybe it's a bug that calling > into and back from the undo manager is changing my ints into integers? > The point is, I'm passing it arguments that should work, and it's > giving me back ones that don't work. The underlying problem is that the bridge has no way of knowing the signature of the method your are invoking upon prepareWithInvocationTarget_() and, as such, assumes everything passed into that method is an int. -prepareWithInvocationTarget_() basically configures the undo manager to act as a proxy for the next method call-- pushing that call onto a stack for later undo purposes. That is... >>> y = NSUndoManager.alloc().init() >>> y <NSUndoManager: 0x64bea0> >>> y.prepareWithInvocationTarget_(NSMutableArray.array()) <NSUndoManager: 0x64bea0> .... or, when used in context ... >>> a = NSMutableArray.array() >>> uM = NSUndoManager.alloc().init() >>> a.addObject_("foo") >>> uM.prepareWithInvocationTarget_(a).removeObject_("foo") >>> a (foo) >>> uM.undo() >>> a () ... the undo manager effectively captures the invocation of removeObject_() and stores it away until the undo() is invoked. At that point, undo() pops the captured invocation off the undo stack and invokes it. As far as the bridge can tell, removeObject_() is being invoked on the undo manager itself! As such, when the bridge tries to query the undo manager for the signature of the method being invoked, nothing is returned and the bridge falls back to sending across straight object representations of the various parameters. This causes a straight integer parameter to be converted to an (id) on the way to being captured by the undo manager. At least, I think it does. Fixing it may be hard. b.bum |