Explorar o código

objc: use compile-time macOS version checks

Use "modern" APIs for calling inherited messages when targeting Mac OS X 10.6
or later
Jonas Maebe %!s(int64=2) %!d(string=hai) anos
pai
achega
df3a0af7e0
Modificáronse 2 ficheiros con 15 adicións e 15 borrados
  1. 8 8
      compiler/ncal.pas
  2. 7 7
      compiler/objcutil.pas

+ 8 - 8
compiler/ncal.pas

@@ -2764,10 +2764,10 @@ implementation
           begin
           begin
             if not(cnf_inherited in callnodeflags) then
             if not(cnf_inherited in callnodeflags) then
               msgsendname:='OBJC_MSGSEND_STRET'
               msgsendname:='OBJC_MSGSEND_STRET'
-{$if defined(onlymacosx10_6) or defined(arm) }
-            else if (target_info.system in systems_objc_nfabi) then
+            else if (target_info.system in systems_objc_nfabi) and
+                    (not MacOSXVersionMin.isvalid or
+                     (MacOSXVersionMin.relationto(10,6,0)>=0)) then
               msgsendname:='OBJC_MSGSENDSUPER2_STRET'
               msgsendname:='OBJC_MSGSENDSUPER2_STRET'
-{$endif onlymacosx10_6 or arm}
             else
             else
               msgsendname:='OBJC_MSGSENDSUPER_STRET'
               msgsendname:='OBJC_MSGSENDSUPER_STRET'
           end
           end
@@ -2781,12 +2781,12 @@ implementation
         { default }
         { default }
         else
         else
 {$endif aarch64}
 {$endif aarch64}
-             if not(cnf_inherited in callnodeflags) then
-          msgsendname:='OBJC_MSGSEND'
-{$if defined(onlymacosx10_6) or defined(arm) or defined(aarch64)}
-        else if (target_info.system in systems_objc_nfabi) then
+          if not(cnf_inherited in callnodeflags) then
+            msgsendname:='OBJC_MSGSEND'
+        else if (target_info.system in systems_objc_nfabi) and
+                (not MacOSXVersionMin.isvalid or
+                 (MacOSXVersionMin.relationto(10,6,0)>=0)) then
           msgsendname:='OBJC_MSGSENDSUPER2'
           msgsendname:='OBJC_MSGSENDSUPER2'
-{$endif onlymacosx10_6 or arm}
         else
         else
           msgsendname:='OBJC_MSGSENDSUPER';
           msgsendname:='OBJC_MSGSENDSUPER';
 
 

+ 7 - 7
compiler/objcutil.pas

@@ -52,7 +52,7 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      globtype,
+      globtype,globals,versioncmp,
       cutils,
       cutils,
       pass_1,
       pass_1,
       verbose,systems,
       verbose,systems,
@@ -153,13 +153,13 @@ end;
                 { in case we are in a category method, we need the metaclass of the
                 { in case we are in a category method, we need the metaclass of the
                   superclass class extended by this category (= metaclass of superclass of superclass)
                   superclass class extended by this category (= metaclass of superclass of superclass)
                   for the fragile abi, and the metaclass of the superclass for the non-fragile ABI }
                   for the fragile abi, and the metaclass of the superclass for the non-fragile ABI }
-{$if defined(onlymacosx10_6) or defined(arm) or defined(aarch64)}
                 { NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
                 { NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
                     (but also on all iPhone SDK revisions we support) }
                     (but also on all iPhone SDK revisions we support) }
-                if (target_info.system in systems_objc_nfabi) then
+                if (target_info.system in systems_objc_nfabi) and
+                   (not MacOSXVersionMin.isvalid or
+                    (MacOSXVersionMin.relationto(10,6,0)>=0)) then
                   result:=cloadvmtaddrnode.create(ctypenode.create(tobjectdef(tclassrefdef(def).pointeddef).childof))
                   result:=cloadvmtaddrnode.create(ctypenode.create(tobjectdef(tclassrefdef(def).pointeddef).childof))
                 else
                 else
-{$endif onlymacosx10_6 or arm aarch64}
                   result:=cloadvmtaddrnode.create(ctypenode.create(tobjectdef(tclassrefdef(def).pointeddef).childof.childof));
                   result:=cloadvmtaddrnode.create(ctypenode.create(tobjectdef(tclassrefdef(def).pointeddef).childof.childof));
                 tloadvmtaddrnode(result).forcall:=true;
                 tloadvmtaddrnode(result).forcall:=true;
                 result:=cloadvmtaddrnode.create(result);
                 result:=cloadvmtaddrnode.create(result);
@@ -183,14 +183,14 @@ end;
             tloadvmtaddrnode(result).forcall:=true;
             tloadvmtaddrnode(result).forcall:=true;
           end;
           end;
 
 
-{$if defined(onlymacosx10_6) or defined(arm) or defined(aarch64)}
         { For the non-fragile ABI, the superclass send2 method itself loads the
         { For the non-fragile ABI, the superclass send2 method itself loads the
           superclass. For the fragile ABI, we have to do this ourselves.
           superclass. For the fragile ABI, we have to do this ourselves.
 
 
           NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
           NOTE: those send2 methods are only available on Mac OS X 10.6 and later!
             (but also on all iPhone SDK revisions we support) }
             (but also on all iPhone SDK revisions we support) }
-        if not(target_info.system in systems_objc_nfabi) then
-{$endif onlymacosx10_6 or arm or aarch64}
+        if not(target_info.system in systems_objc_nfabi) or
+           (MacOSXVersionMin.isvalid and
+            (MacOSXVersionMin.relationto(10,6,0)<0)) then
           result:=objcloadbasefield(result,'SUPERCLASS');
           result:=objcloadbasefield(result,'SUPERCLASS');
         typecheckpass(result);
         typecheckpass(result);
       end;
       end;