[fpc-devel] OSX: Setting up parameters to objc_msgSend()
skalogryz.lists at gmail.com
Fri Oct 12 17:09:59 CEST 2018
On Fri, Oct 12, 2018 at 10:38 AM David Jenkins <david at scootersoftware.com>
> The movsbl %dl, %edx is good. Unfortunately the value of %edx is
> 0xffffffff not 0x00000001. This is the same result I saw when I changed it
> to LongBool.
I presume this is due to the definition of YES macro in objc, which is 1
(rather than ~NO)
so, far the only reliable approach to fix the issue (for the current
compiler version) is something like that:
OBJCBOOL = ShortInt;
NSMenuFix = objccategory external (NSMenu)
function itemAtIndex(index: NSInteger): NSMenuItem; message
function setEnabled_(aenabled: OBJCBOOL ): NSMenuItem; message
'setEnabled:'; // same method, different parameter type
class function TCocoaWSMenuItem.SetEnable(const AMenuItem: TMenuItem;
const Enabled: boolean): boolean;
Result:=Assigned(AMenuItem) and (AMenuItem.Handle<>0);
if not Result then Exit;
NSMenuItem(AMenuItem.Handle).setEnabled_( Ord(Enabled) ); // totally
matches ObjC YES / NO definitions
Not really sure, if it can be properly be solved through the compiler.
Because it either would break Boolean (_Bool) or ByteBool.
OR ByteBool needs to be more strict on it's Ord() value (optionally?)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fpc-devel