Browse Source

+ tobject.methodaddress und tobject.methodname durchsucht nun auch
die Elternklassen

florian 26 years ago
parent
commit
fcd9a97bcb
1 changed files with 35 additions and 19 deletions
  1. 35 19
      rtl/inc/objpas.inc

+ 35 - 19
rtl/inc/objpas.inc

@@ -132,18 +132,24 @@
         var
            methodtable : pmethodnametable;
            i : dword;
+           c : tclass;
 
         begin
-           methodtable:=pmethodnametable((Pointer(Self)+vmtMethodTable)^);
-           if assigned(methodtable) then
+           c:=self;
+           while assigned(c) do
              begin
-                for i:=1 to methodtable^.count do
-                  if methodtable^.entries[i].name^=name then
-                    begin
-                       MethodAddress:=methodtable^.entries[i].addr;
-                       exit;
-                    end;                  
-             end;
+                methodtable:=pmethodnametable((Pointer(c)+vmtMethodTable)^);
+                if assigned(methodtable) then
+                  begin
+                     for i:=1 to methodtable^.count do
+                       if methodtable^.entries[i].name^=name then
+                         begin
+                            MethodAddress:=methodtable^.entries[i].addr;
+                            exit;
+                         end;
+                  end;
+                c:=c.ClassParent;
+             end;                                                                                                                                                                                                                                              
            MethodAddress:=nil;
         end;
 
@@ -152,21 +158,27 @@
         var
            methodtable : pmethodnametable;
            i : dword;
+           c : tclass;
 
         begin
-           methodtable:=pmethodnametable((Pointer(Self)+vmtMethodTable)^);
-           if assigned(methodtable) then
+           c:=self;
+           while assigned(c) do
              begin
-                for i:=1 to methodtable^.count do
-                  if methodtable^.entries[i].addr=address then
-                    begin
-                       MethodName:=methodtable^.entries[i].name^;
-                       exit;
-                    end;                  
+                methodtable:=pmethodnametable((Pointer(c)+vmtMethodTable)^);
+                if assigned(methodtable) then
+                  begin
+                     for i:=1 to methodtable^.count do
+                       if methodtable^.entries[i].addr=address then
+                         begin
+                            MethodName:=methodtable^.entries[i].name^;
+                            exit;
+                         end;
+                  end;
+                c:=c.ClassParent;
              end;
            MethodName:='';
         end;
-           
+
       function TObject.FieldAddress(const name : shortstring) : pointer;
 
         begin
@@ -393,7 +405,11 @@
 
 {
   $Log$
-  Revision 1.9  1999-09-12 08:01:00  florian
+  Revision 1.10  1999-09-12 14:53:26  florian
+    + tobject.methodaddress und tobject.methodname durchsucht nun auch
+      die Elternklassen
+
+  Revision 1.9  1999/09/12 08:01:00  florian
     + implementation of TObject.MethodName and TObject.MethodAddress (not
       in the compiler yet)