فهرست منبع

Add possibility to query the hidden field of a class that represents the reference count

symdef.pas, tobjectdef:
  + new method "refcount_field" which returns the (potentially inherited) field that holds the reference count or Nil if the class isn't reference counted

git-svn-id: branches/svenbarth/arc@28808 -
svenbarth 10 سال پیش
والد
کامیت
878483ad50
1فایلهای تغییر یافته به همراه17 افزوده شده و 0 حذف شده
  1. 17 0
      compiler/symdef.pas

+ 17 - 0
compiler/symdef.pas

@@ -431,6 +431,7 @@ interface
           procedure set_parent(c : tobjectdef);
           function find_destructor: tprocdef;
           function implements_any_interfaces: boolean;
+          function refcount_field:tsym;
           { dispinterface support }
           function get_next_dispid: longint;
           { enumerator support }
@@ -6367,6 +6368,22 @@ implementation
           (assigned(childof) and childof.implements_any_interfaces);
       end;
 
+
+     function tobjectdef.refcount_field:tsym;
+       var
+         srsymtable : tsymtable;
+       begin
+         if not (oo_is_reference_counted in objectoptions) then
+           result:=nil
+         else
+           begin
+             { search without the '$' prefix! }
+             if not searchsym_in_class(self,self,'refcount',result,srsymtable,[]) then
+               result:=nil;
+           end;
+       end;
+
+
     function tobjectdef.size : asizeint;
       begin
         if objecttype in [odt_class,odt_interfacecom,odt_interfacecorba,odt_dispinterface,odt_objcclass,odt_objcprotocol,odt_helper,odt_javaclass,odt_interfacejava] then