Recent

Author Topic: Lazarus Cocoa build failed in Mac OS Mojave 10.14  (Read 1358 times)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2030
    • havefunsoft.com
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #15 on: December 05, 2018, 08:00:58 pm »
This does not seem trivial to fix, since LclObjCBoolean is defined in CocoaPrivate, but required in the interface of CocoaUtils, causing a circular unit reference.
how come? custom changes?

Furthermore, Cocoa_Extra already has an 8 bit ObjCBool. Two different boolean types in two different units with different prefixes do not look like a good idea.
ObjCBool is hidden by {$ifdef BOOLFIX}
cocoadefines.inc needs to be updated to undefine BOOLFIX for any FPC version past 3.0.4.
For 3.0.4 ObjCBool is not a duplication, but rather
LCLObjCBoolean - has intent to be cross FPC version compatible
ObjCBool - has intent to be binary correct for ObjC call for fpc 3.0.4
Ultimately both are present to address the same problem, but in different spotss.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

CCRDude

  • Sr. Member
  • ****
  • Posts: 431
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #16 on: December 05, 2018, 08:14:50 pm »
No custom changes, fresh checkouts.

I simply saw that NSResponderHotKeys is responsible for the errors seen by josh and myself, and that one is in CocoaUtils. I saw that LCLObjCBoolean is defined in CocoaPrivate, but I cannot add CocoaPrivate to the uses part of CocoaUtils, since CocoaPrivate already uses CocoaUtils.

0. I gave it a few more tries, and moved the LCLObjCBoolean definition to Cocoa_Extra. That avoids the circular reference, and allows to compile, with the following problems coming up:
1. In CocoaDatePicker, there's still TCocoaDatePicker.acceptsFirstResponder with the wrong type in interface and implementation.
2. In CocoaWSMenus, TCocoaMenuItem, you changed boolean to LCLObjCBoolean only in the interface, not the implementation.
3. In cocoaprinters_h.inc, TCocoaPrinterView, the update from boolean to LCLObjCBoolean was still missing for knowsPageRange and isFlipped.

With those changes, I was able to cross-compile to Darwin/Cocoa and the output works fine on High Sierra.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2030
    • havefunsoft.com
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #17 on: December 05, 2018, 08:17:58 pm »
I simply saw that NSResponderHotKeys is responsible for the errors seen by josh and myself, and that one is in CocoaUtils. I saw that LCLObjCBoolean is defined in CocoaPrivate, but I cannot add CocoaPrivate to the uses part of CocoaUtils, since CocoaPrivate already uses CocoaUtils.
NSResponderHotKeys is a procedure. It doesn't need LCLObjCBoolean

Code: Diff  [Select]
  1. Index: cocoawindows.pas
  2. ===================================================================
  3. --- cocoawindows.pas    (revision 59729)
  4. +++ cocoawindows.pas    (working copy)
  5. @@ -389,6 +389,7 @@
  6.    resp : NSResponder;
  7.    wn   : NSWindow;
  8.    view : NSTextView;
  9. +  r    : Boolean;
  10.  begin
  11.    Result := false;
  12.    // only respond to key, if focused
  13. @@ -400,7 +401,8 @@
  14.  
  15.    if (not resp.lclIsEnabled) then Exit;
  16.  
  17. -  NSResponderHotKeys(self, event, Result, resp);
  18. +  NSResponderHotKeys(self, event, r, resp);
  19. +  Result := r;
  20.    if not Result then
  21.      Result:=inherited performKeyEquivalent(event);
  22.  end;

Please provide a patch for points 1 through 3 and I'll apply them tonight!
« Last Edit: December 05, 2018, 08:31:08 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

CCRDude

  • Sr. Member
  • ****
  • Posts: 431
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #18 on: December 05, 2018, 08:21:41 pm »
NSResponderHotKeys is a procedure that takes, as its third parameter, a "var handled: boolean".

But TCocoaWindowContent.performKeyEquivalent passes it's Result, which is a LCLObjCBoolean, as third parameter to NSResponderHotKeys.

I felt it safer to adjust the var parameter of the procedure, than to typecast the boolean forth and back.

CCRDude

  • Sr. Member
  • ****
  • Posts: 431
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #19 on: December 05, 2018, 08:23:55 pm »
I now see your edit, but don't understand it. Since the problem is that NSResponderHotKeys expects a boolean, what help would it do to pass a variable "r" of the same type as the non-functioning result, LCLObjCBoolean? And what exactly means "Result := rsbool", should this be "Result := r", with an "r: boolean" instead of an "r: LCLOBjCBoolean"?

Whether this is solved by the helper var, or changing the parameter type, the other three issues reported by me above are independent of this.
« Last Edit: December 05, 2018, 08:25:32 pm by CCRDude »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2030
    • havefunsoft.com
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #20 on: December 05, 2018, 08:25:42 pm »
should this be "Result := r", with an "r: boolean" instead of an "r: LCLOBjCBoolean"?
yes it should, i updated the patch

Whether this is solved by the helper var, or changing the parameter type, the other three issues reported by me above are independent of this.
These are two different approaches, because change in parameter type requires to move the type declaration.

Long term: NSResponderHotKeys  needs to be moved to cocoawindows.pas
« Last Edit: December 05, 2018, 08:27:19 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

josh

  • Hero Member
  • *****
  • Posts: 647
Re: Lazarus Cocoa build failed in Mac OS Mojave 10.14
« Reply #21 on: December 05, 2018, 10:36:33 pm »
Just this minute finish attempt at a fresh install of cocoa 64, and it fails with same error as before.

Unfortunately I have not been able to compile anything on Cocoa for the past 2 months natively on High Sierra, and now I can't cross compile to cocoa 64 from carbon 32.

Would be a good x-mas present to get the Cocoa 64 working again; just to see the improvements over the past  2 months.
« Last Edit: December 05, 2018, 11:10:47 pm by josh »
Development Installation Lazarus 1.3, FPC 2.7.1,Windows 7/8 32/64, OSX, *nix

Test Environment Lazarus & FPC Trunk on Windows and OSX (Cocoa Mainly on OSX). Testing also Crosscompile windows to OSX.. 
Any posts made from 2015 will be based on Lazarus Trunk.