2
0
Эх сурвалжийг харах

* support the "overload" modifier for Objective-C methods
* only check whether the message identifier of an Objective-C method
matches the one from a method with the same name in a parent class
if the parameters match (todo: should be refined to "if the
encoded Objective-C selector names match")

git-svn-id: trunk@22373 -

Jonas Maebe 13 жил өмнө
parent
commit
fe90823b01

+ 1 - 0
.gitattributes

@@ -10980,6 +10980,7 @@ tests/test/tobjc37.pp svneol=native#text/plain
 tests/test/tobjc38.pp svneol=native#text/plain
 tests/test/tobjc39.pp svneol=native#text/plain
 tests/test/tobjc4.pp svneol=native#text/plain
+tests/test/tobjc40.pp svneol=native#text/plain
 tests/test/tobjc4a.pp svneol=native#text/plain
 tests/test/tobjc5.pp svneol=native#text/plain
 tests/test/tobjc5a.pp svneol=native#text/plain

+ 21 - 14
compiler/nobj.pas

@@ -333,22 +333,29 @@ implementation
                           automated header translation tools too complex.
 
                           The same goes for Java. }
-                        if not(oo_is_external in _class.objectoptions) then
-                          if not is_objccategory(_class) then
-                            MessagePos1(pd.fileinfo,parser_e_must_use_override,FullTypeName(tdef(vmtpd.owner.defowner),nil))
-                          else
-                            MessagePos1(pd.fileinfo,parser_e_must_use_reintroduce_objc,FullTypeName(tdef(vmtpd.owner.defowner),nil))
-                        { there may be a lot of these in auto-translated
-                          headers, so only calculate the fulltypename if
-                          the hint will be shown  }
-                        else if CheckVerbosity(V_Hint) then
-                          if not is_objccategory(_class) then
-                            MessagePos1(pd.fileinfo,parser_h_should_use_override,FullTypeName(tdef(vmtpd.owner.defowner),nil))
-                          else
-                            MessagePos1(pd.fileinfo,parser_h_should_use_reintroduce_objc,FullTypeName(tdef(vmtpd.owner.defowner),nil));
+{$ifndef jvm}
+                        if hasequalpara then
+{$endif}
+                          begin
+                            if not(oo_is_external in _class.objectoptions) then
+                              if not is_objccategory(_class) then
+                                MessagePos1(pd.fileinfo,parser_e_must_use_override,FullTypeName(tdef(vmtpd.owner.defowner),nil))
+                              else
+                                MessagePos1(pd.fileinfo,parser_e_must_use_reintroduce_objc,FullTypeName(tdef(vmtpd.owner.defowner),nil))
+                            { there may be a lot of these in auto-translated
+                              headers, so only calculate the fulltypename if
+                              the hint will be shown  }
+                            else if CheckVerbosity(V_Hint) then
+                              if not is_objccategory(_class) then
+                                MessagePos1(pd.fileinfo,parser_h_should_use_override,FullTypeName(tdef(vmtpd.owner.defowner),nil))
+                              else
+                                MessagePos1(pd.fileinfo,parser_h_should_use_reintroduce_objc,FullTypeName(tdef(vmtpd.owner.defowner),nil));
+                          end;
                         { no new entry, but copy the message name if any from
                           the procdef in the parent class }
-                        check_msg_str(vmtpd,pd);
+                        if not is_objc_class_or_protocol(_class) or
+                           hasequalpara then
+                          check_msg_str(vmtpd,pd);
                         if updatevalues then
                           begin
                             { in case of Java, copy the real name from the parent,

+ 1 - 1
compiler/pdecsub.pas

@@ -2259,7 +2259,7 @@ const
       mutexclpo     : []
     ),(
       idtok:_OVERLOAD;
-      pd_flags : [pd_implemen,pd_interface,pd_body,pd_javaclass,pd_intfjava];
+      pd_flags : [pd_implemen,pd_interface,pd_body,pd_javaclass,pd_intfjava,pd_objcclass,pd_objcprot];
       handler  : @pd_overload;
       pocall   : pocall_none;
       pooption : [po_overload];

+ 29 - 0
tests/test/tobjc40.pp

@@ -0,0 +1,29 @@
+{ %target=darwin }
+{ %opt=norun }
+
+{$mode objfpc}
+{$modeswitch objectivec1}
+program Main;
+
+type
+	NSView = objcclass(NSObject)
+		procedure setNeedsDisplay (flag: boolean); message 'setNeedsDisplay:';
+	end;
+
+type
+	NSViewUtilities = objccategory (NSView)
+		procedure setNeedsDisplay; message 'setNeedsDisplay'; overload;
+	end;
+
+procedure NSView.setNeedsDisplay (flag: boolean);
+begin
+end;
+
+procedure NSViewUtilities.setNeedsDisplay;
+begin
+	setNeedsDisplay(true);
+end;
+
+begin
+end.
+