On Fri, Oct 12, 2018 at 10:38 AM David Jenkins <da...@scootersoftware.com> wrote:
> 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) https://developer.apple.com/documentation/objectivec/objective-c_runtime/boolean_values?language=objchttps://developer.apple.com/documentation/objectivec/bool so, far the only reliable approach to fix the issue (for the current compiler version) is something like that: unit cocoa_extra; type OBJCBOOL = ShortInt; ... NSMenuFix = objccategory external (NSMenu) function itemAtIndex(index: NSInteger): NSMenuItem; message 'itemAtIndex:'; function setEnabled_(aenabled: OBJCBOOL ): NSMenuItem; message 'setEnabled:'; // same method, different parameter type end; class function TCocoaWSMenuItem.SetEnable(const AMenuItem: TMenuItem; const Enabled: boolean): boolean; begin Result:=Assigned(AMenuItem) and (AMenuItem.Handle<>0); if not Result then Exit; NSMenuItem(AMenuItem.Handle).setEnabled_( Ord(Enabled) ); // totally matches ObjC YES / NO definitions end; 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?) thanks, Dmitry
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel