123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- {
- $Id$
- This file is part of the Free Pascal run time library.
- Copyright (c) 1999-2000 by xxxx
- member of the Free Pascal development team
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- { Run-Time type information routines - processor dependent part }
- {$ifndef FPC_SYSTEM_HAS_FPC_INITIALIZE}
- Procedure Initialize (Data,TypeInfo : pointer);[Public,Alias : 'FPC_INITIALIZE'];
- { this definition is sometimes (depending on switches)
- already defined or not so define it locally to avoid problems PM }
- Type
- Pbyte = ^Byte;
- Var Temp : PByte;
- I : longint;
- Size,Count : longint;
- TInfo : Pointer;
- begin
- Temp:=PByte(TypeInfo);
- case temp^ of
- tkAstring,tkWstring : PPchar(Data)^:=Nil;
- tkArray :
- begin
- temp:=Temp+1;
- I:=temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PArrayRec(Temp)^.Size; // get element size
- Count:=PArrayRec(Temp)^.Count; // get element Count
- TInfo:=PArrayRec(Temp)^.Info; // Get element info
- For I:=0 to Count-1 do
- Initialize (Data+(I*size),TInfo);
- end;
- tkrecord :
- begin
- Temp:=Temp+1;
- I:=Temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PRecRec(Temp)^.Size; // get record size; not needed.
- Count:=PRecRec(Temp)^.Count; // get element Count
- For I:=1 to count Do
- With PRecRec(Temp)^.elements[I] do
- Initialize (Data+Offset,Info);
- end;
- end;
- end;
- {$endif}
- {$ifndef FPC_SYSTEM_HAS_FPC_FINALIZE}
- Procedure Finalize (Data,TypeInfo: Pointer);[Public,Alias : 'FPC_FINALIZE'];
- { this definition is sometimes (depending on switches)
- already defined or not so define it locally to avoid problems PM }
- Type
- Pbyte = ^Byte;
- Var Temp : PByte;
- I : longint;
- Size,Count : longint;
- TInfo : Pointer;
- begin
- Temp:=PByte(TypeInfo);
- case temp^ of
- tkAstring,tkWstring : AnsiStr_Decr_Ref(Data);
- tkArray :
- begin
- Temp:=Temp+1;
- I:=temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PArrayRec(Temp)^.Size; // get element size
- Count:=PArrayRec(Temp)^.Count; // get element Count
- TInfo:=PArrayRec(Temp)^.Info; // Get element info
- For I:=0 to Count-1 do
- Finalize (Data+(I*size),TInfo);
- end;
- tkrecord :
- begin
- Temp:=Temp+1;
- I:=Temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PRecRec(Temp)^.Size; // get record size; not needed.
- Count:=PRecRec(Temp)^.Count; // get element Count
- For I:=1 to count do
- With PRecRec(Temp)^.elements[I] do
- Finalize (Data+Offset,Info);
- end;
- end;
- end;
- {$endif}
- {$ifndef FPC_SYSTEM_HAS_FPC_ADDREF}
- Procedure Addref (Data,TypeInfo : Pointer); [Public,alias : 'FPC_ADDREF'];
- { this definition is sometimes (depending on switches)
- already defined or not so define it locally to avoid problems PM }
- Type
- Pbyte = ^Byte;
- Var Temp : PByte;
- I : longint;
- Size,Count : longint;
- TInfo : Pointer;
- begin
- Temp:=PByte(TypeInfo);
- case temp^ of
- tkAstring,tkWstring : AnsiStr_Incr_Ref(Data);
- tkArray :
- begin
- Temp:=Temp+1;
- I:=temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PArrayRec(Temp)^.Size; // get element size
- Count:=PArrayRec(Temp)^.Count; // get element Count
- TInfo:=PArrayRec(Temp)^.Info; // Get element info
- For I:=0 to Count-1 do
- AddRef (Data+(I*size),TInfo);
- end;
- tkrecord :
- begin
- Temp:=Temp+1;
- I:=Temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PRecRec(Temp)^.Size; // get record size; not needed.
- Count:=PRecRec(Temp)^.Count; // get element Count
- For I:=1 to count do
- With PRecRec(Temp)^.elements[I] do
- AddRef (Data+Offset,Info);
- end;
- end;
- end;
- {$endif}
- {$ifndef FPC_SYSTEM_HAS_FPC_DECREF}
- Procedure DecRef (Data, TypeInfo : Pointer);[Public,alias : 'FPC_DECREF'];
- { this definition is sometimes (depending on switches)
- already defined or not so define it locally to avoid problems PM }
- Type
- Pbyte = ^Byte;
- Var Temp : PByte;
- I : longint;
- Size,Count : longint;
- TInfo : Pointer;
- begin
- Temp:=PByte(TypeInfo);
- case temp^ of
- tkAstring,tkWstring : AnsiStr_Decr_Ref(Data);
- tkArray :
- begin
- Temp:=Temp+1;
- I:=temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PArrayRec(Temp)^.Size; // get element size
- Count:=PArrayRec(Temp)^.Count; // get element Count
- TInfo:=PArrayRec(Temp)^.Info; // Get element info
- For I:=0 to Count-1 do
- DecRef (Data+(I*size),TInfo);
- end;
- tkrecord :
- begin
- Temp:=Temp+1;
- I:=Temp^;
- temp:=temp+(I+1); // skip name string;
- Size:=PRecRec(Temp)^.Size; // get record size; not needed.
- Count:=PRecRec(Temp)^.Count; // get element Count
- For I:=1 to count do
- With PRecRec(Temp)^.elements[I] do
- DecRef (Data+Offset,Info);
- end;
- end;
- end;
- {$endif}
- {$ifndef FPC_SYSTEM_HAS_FPC_FINALIZEARRAY}
- procedure FinalizeArray(data,typeinfo : pointer;count,size : longint); [Public,Alias:'FPC_FINALIZEARRAY'];
- var
- i : longint;
- begin
- for i:=0 to count-1 do
- int_finalize(data+size*i,typeinfo);
- end;
- {$endif}
- {
- $Log$
- Revision 1.2 2001-04-23 18:25:44 peter
- * m68k updates
- }
|