Jelajahi Sumber

* don't automatically set the parent class of objcclasses without a
designated parent to NSObject, because you can have multiple root classes
(e.g., NSProxy is also an Objective-C root class in Cocoa). Instead,
give a hint when an Objective-C class is declared without any parent
(because it can very well be a mistake, given that Pascal classes all
do automatically inherit form TObject).

git-svn-id: branches/objc@13177 -

Jonas Maebe 16 tahun lalu
induk
melakukan
ba2c2cd449
4 mengubah file dengan 17 tambahan dan 13 penghapusan
  1. 1 0
      .gitattributes
  2. 1 2
      compiler/pdecobj.pas
  3. 0 11
      compiler/symdef.pas
  4. 15 0
      tests/test/tobjc3.pp

+ 1 - 0
.gitattributes

@@ -7917,6 +7917,7 @@ tests/test/tmsg4.pp svneol=native#text/plain
 tests/test/tmt1.pp svneol=native#text/plain
 tests/test/tobjc1.pp svneol=native#text/plain
 tests/test/tobjc2.pp svneol=native#text/plain
+tests/test/tobjc3.pp svneol=native#text/plain
 tests/test/tobject1.pp svneol=native#text/plain
 tests/test/tobject2.pp svneol=native#text/plain
 tests/test/tobject3.pp svneol=native#text/plain

+ 1 - 2
compiler/pdecobj.pas

@@ -299,8 +299,7 @@ implementation
                 if current_objectdef<>interface_iunknown then
                   childof:=interface_iunknown;
               odt_objcclass:
-                if current_objectdef<>objcclass_nsobject then
-                  childof:=objcclass_nsobject;
+                CGMessage(parser_h_no_objc_parent);
             end;
           end;
 

+ 0 - 11
compiler/symdef.pas

@@ -667,7 +667,6 @@ interface
        objc_superclasstype,
        objc_idtype,
        objc_seltype         : tpointerdef;
-       objcclass_nsobject   : tobjectdef;
 
     const
 {$ifdef i386}
@@ -3715,12 +3714,6 @@ implementation
         else
           ImplementedInterfaces:=nil;
         writing_class_record_dbginfo:=false;
-
-       { make NSObject immediately known in the same unit }
-       if (childof=nil) and
-           (objecttype=odt_objcclass) and
-           (objrealname^='NSObject') then
-          objcclass_nsobject:=self;
      end;
 
 
@@ -3797,10 +3790,6 @@ implementation
             (objecttype=odt_interfacecom) and
             (objname^='IUNKNOWN') then
            interface_iunknown:=self;
-         if (childof=nil) and
-            (objecttype=odt_objcclass) and
-            (objrealname^='NSObject') then
-           objcclass_nsobject:=self;
          writing_class_record_dbginfo:=false;
        end;
 

+ 15 - 0
tests/test/tobjc3.pp

@@ -0,0 +1,15 @@
+{ %fail }
+{ %opt=-vh -Seh }
+{ %target=darwin }
+{ %cpu=powerpc,i386 }
+
+{$modeswitch objectivec1}
+
+type
+  { should produce a hint that ta does not automatically derive from any
+    other class  }
+  ta = objcclass
+  end; external;
+
+begin
+end.