|
@@ -186,9 +186,13 @@ interface
|
|
|
destructor destroy; override;
|
|
|
procedure check_forwards; virtual;
|
|
|
function find_procdef_bytype(pt:tproctypeoption): tprocdef;
|
|
|
- function GetSymtable(t:tGetSymtable):TSymtable;override;
|
|
|
+ function GetSymtable(t:tGetSymtable):TSymtable;override;
|
|
|
function is_packed:boolean;
|
|
|
function RttiName: string;
|
|
|
+ { enumerator support }
|
|
|
+ function search_enumerator_get: tprocdef; virtual;
|
|
|
+ function search_enumerator_move: tprocdef; virtual;
|
|
|
+ function search_enumerator_current: tsym; virtual;
|
|
|
end;
|
|
|
|
|
|
trecorddef = class(tabstractrecorddef)
|
|
@@ -315,9 +319,9 @@ interface
|
|
|
{ dispinterface support }
|
|
|
function get_next_dispid: longint;
|
|
|
{ enumerator support }
|
|
|
- function search_enumerator_get: tprocdef;
|
|
|
- function search_enumerator_move: tprocdef;
|
|
|
- function search_enumerator_current: tsym;
|
|
|
+ function search_enumerator_get: tprocdef; override;
|
|
|
+ function search_enumerator_move: tprocdef; override;
|
|
|
+ function search_enumerator_current: tsym; override;
|
|
|
{ WPO }
|
|
|
procedure register_created_object_type;override;
|
|
|
procedure register_maybe_created_object_type;
|
|
@@ -2681,6 +2685,101 @@ implementation
|
|
|
until tmp=nil;
|
|
|
end;
|
|
|
|
|
|
+ function tabstractrecorddef.search_enumerator_get: tprocdef;
|
|
|
+ var
|
|
|
+ sym : tsym;
|
|
|
+ i : integer;
|
|
|
+ pd : tprocdef;
|
|
|
+ hashedid : THashedIDString;
|
|
|
+ begin
|
|
|
+ result:=nil;
|
|
|
+ hashedid.id:='GETENUMERATOR';
|
|
|
+ sym:=tsym(symtable.FindWithHash(hashedid));
|
|
|
+ if assigned(sym) and (sym.typ=procsym) then
|
|
|
+ begin
|
|
|
+ for i := 0 to Tprocsym(sym).ProcdefList.Count - 1 do
|
|
|
+ begin
|
|
|
+ pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
|
|
|
+ if (pd.proctypeoption = potype_function) and
|
|
|
+ (is_class_or_interface_or_object(pd.returndef) or is_record(pd.returndef)) and
|
|
|
+ (pd.visibility >= vis_public) then
|
|
|
+ begin
|
|
|
+ result:=pd;
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+ function tabstractrecorddef.search_enumerator_move: tprocdef;
|
|
|
+ var
|
|
|
+ sym : tsym;
|
|
|
+ i : integer;
|
|
|
+ pd : tprocdef;
|
|
|
+ hashedid : THashedIDString;
|
|
|
+ begin
|
|
|
+ result:=nil;
|
|
|
+ // first search for po_enumerator_movenext method modifier
|
|
|
+ // then search for public function MoveNext: Boolean
|
|
|
+ for i:=0 to symtable.SymList.Count-1 do
|
|
|
+ begin
|
|
|
+ sym:=TSym(symtable.SymList[i]);
|
|
|
+ if (sym.typ=procsym) then
|
|
|
+ begin
|
|
|
+ pd:=Tprocsym(sym).find_procdef_byoptions([po_enumerator_movenext]);
|
|
|
+ if assigned(pd) then
|
|
|
+ begin
|
|
|
+ result:=pd;
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ hashedid.id:='MOVENEXT';
|
|
|
+ sym:=tsym(symtable.FindWithHash(hashedid));
|
|
|
+ if assigned(sym) and (sym.typ=procsym) then
|
|
|
+ begin
|
|
|
+ for i:=0 to Tprocsym(sym).ProcdefList.Count-1 do
|
|
|
+ begin
|
|
|
+ pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
|
|
|
+ if (pd.proctypeoption = potype_function) and
|
|
|
+ is_boolean(pd.returndef) and
|
|
|
+ (pd.minparacount = 0) and
|
|
|
+ (pd.visibility >= vis_public) then
|
|
|
+ begin
|
|
|
+ result:=pd;
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+
|
|
|
+ function tabstractrecorddef.search_enumerator_current: tsym;
|
|
|
+ var
|
|
|
+ sym: tsym;
|
|
|
+ i: integer;
|
|
|
+ hashedid : THashedIDString;
|
|
|
+ begin
|
|
|
+ result:=nil;
|
|
|
+ // first search for ppo_enumerator_current property modifier
|
|
|
+ // then search for public property Current
|
|
|
+ for i:=0 to symtable.SymList.Count-1 do
|
|
|
+ begin
|
|
|
+ sym:=TSym(symtable.SymList[i]);
|
|
|
+ if (sym.typ=propertysym) and (ppo_enumerator_current in tpropertysym(sym).propoptions) then
|
|
|
+ begin
|
|
|
+ result:=sym;
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
+ hashedid.id:='CURRENT';
|
|
|
+ sym:=tsym(symtable.FindWithHash(hashedid));
|
|
|
+ if assigned(sym) and (sym.typ=propertysym) and
|
|
|
+ (sym.visibility >= vis_public) and not tpropertysym(sym).propaccesslist[palt_read].empty then
|
|
|
+ begin
|
|
|
+ result:=sym;
|
|
|
+ exit;
|
|
|
+ end;
|
|
|
+ end;
|
|
|
|
|
|
{***************************************************************************
|
|
|
trecorddef
|
|
@@ -4834,7 +4933,7 @@ implementation
|
|
|
begin
|
|
|
pd := tprocdef(Tprocsym(sym).ProcdefList[i]);
|
|
|
if (pd.proctypeoption = potype_function) and
|
|
|
- is_class_or_interface_or_object(pd.returndef) and
|
|
|
+ (is_class_or_interface_or_object(pd.returndef) or is_record(pd.returndef)) and
|
|
|
(pd.visibility >= vis_public) then
|
|
|
begin
|
|
|
result:=pd;
|