<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Oct 12, 2018 at 10:38 AM David Jenkins <<a href="mailto:david@scootersoftware.com">david@scootersoftware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF">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.<br></div></blockquote><div><br></div><div>I presume this is due to the definition of YES macro in objc, which is 1 (rather than ~NO)</div><div><a href="https://developer.apple.com/documentation/objectivec/objective-c_runtime/boolean_values?language=objchttps://developer.apple.com/documentation/objectivec/bool">https://developer.apple.com/documentation/objectivec/objective-c_runtime/boolean_values?language=objchttps://developer.apple.com/documentation/objectivec/bool</a><br></div><div><br></div><div>so, far the only reliable approach to fix the issue (for the current compiler version) is something like that:</div><div><div><br></div><div>unit cocoa_extra;<br></div><div><br></div><div>type</div><div>  OBJCBOOL = ShortInt;</div><div>...</div><div>  NSMenuFix = objccategory external (NSMenu)</div><div>    function itemAtIndex(index: NSInteger): NSMenuItem; message 'itemAtIndex:';</div><div>    function setEnabled_(aenabled: 

OBJCBOOL ): NSMenuItem; message 'setEnabled:'; // same method, different parameter type</div><div>  end;</div></div><div><br></div><div>class function TCocoaWSMenuItem.SetEnable(const AMenuItem: TMenuItem;<br>   const Enabled: boolean): boolean;<br>begin<br>   Result:=Assigned(AMenuItem) and (AMenuItem.Handle<>0);<br>   if not Result then Exit;<br>   NSMenuItem(AMenuItem.Handle).setEnabled_( Ord(Enabled) ); // totally matches ObjC YES / NO definitions<br>end;  <br></div><div><br></div><div>Not really sure, if it can be properly be solved through the compiler. Because it either would break Boolean (_Bool) or ByteBool.</div><div>OR ByteBool needs to be more strict on it's Ord() value (optionally?)</div><div><br></div><div>thanks,</div><div>Dmitry</div></div></div></div></div></div></div>