objcrtlmacosx.pas 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {
  2. objcrtlmacosx.pas
  3. Copyright (C) 2009 Dmitry Boyarintsev
  4. This unit is implementation for dynamic Objective-C Run-time Library based on run-time version 2.0
  5. headers included with XCode 3.1.2
  6. The original copyright note of is kept on each include file
  7. }
  8. {$IFNDEF FPC_DOTTEDUNITS}
  9. unit objcrtlMacOSX;
  10. {$ENDIF FPC_DOTTEDUNITS}
  11. {$linkframework CoreServices}
  12. {$mode macpas}
  13. interface
  14. {$IFDEF FPC_DOTTEDUNITS}
  15. uses
  16. Api.ObjC.Rtl, Api.ObjC.Rtl10, Api.ObjC.Rtl20;
  17. {$ELSE FPC_DOTTEDUNITS}
  18. uses
  19. objcrtl, objcrtl10, objcrtl20;
  20. {$ENDIF FPC_DOTTEDUNITS}
  21. implementation
  22. type
  23. SInt16 = Integer;
  24. SInt32 = LongInt;
  25. UInt32 = Longword;
  26. FourCharCode = UInt32;
  27. OSErr = SInt16;
  28. OSType = FourCharCode;
  29. const
  30. noErr = 0;
  31. gestaltSystemVersionMinor = FourCharCode('sys2'); { The minor system version number; in 10.4.17 this would be the decimal value 4 }
  32. function Gestalt(selector: OSType; var response: SInt32): OSErr; mwpascal; external name '_Gestalt';
  33. procedure InitObjCRunTime;
  34. var
  35. MacVersion : SInt32;
  36. begin
  37. if (Gestalt(gestaltSystemVersionMinor, MacVersion) = noErr) then begin
  38. if MacVersion >= 5
  39. then InitializeObjcRtl20(DefaultObjCLibName)
  40. else InitializeObjcRtl10(DefaultObjCLibName);
  41. end else
  42. InitializeObjcRtl20(DefaultObjCLibName);
  43. end;
  44. {initialization}
  45. begin
  46. InitObjCRuntime;
  47. end.