Re: [Pyobjc-dev] [ pyobjc-Bugs-836247 ] NSWindow.contentRectForFrameRect_styleMask_ not a class meth
Brought to you by:
ronaldoussoren
From: b.bum <bb...@ma...> - 2003-11-07 16:03:20
|
Unless I'm missing something, can't we always tell at the moment of dispatch whether or not a particular method should be resolved in the class or instance context? When objc_msgSend() is invoked, the SEL parameter is resolved internally based on the 'self' parameter -- on the target of invocation. So, once we have an object reference and a selector, our bridged dispatch to the method IMP should "just work" regardless of whether it is a class or instance. The only place that class vs. instance method is problematic would appear to be within the Python subclasses of ObjC objects where there is a need to define both a class and an instance method. I.e. +description vs. -description. Given that +description requires, effectively, a redeclaration through the use of selector(), we could change the name of the method slightly-- and invisibly-- at that time. But that is ugly. Instead, can we handle this at the time of dispatch? I.e. if you do Foo.description to grab a reference to the description method of the Foo class-- which has both +description and -description-- then we should be able to figure out if the class or instance implementation should be invoked at the time of dispatch based on what the target of the invocation is. There are other details that would have to be worked out. But, for the most part, it would seem that this could be done in a largely automatic and transparent fashion. The remaining unknowns are largely arbitrary in nature because they only occur due to the combined interaction of the ObjC and Python runtimes -- we are free to do whatever we want. b.bum |