Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-03

System's InitializeArray & FinalizeArray

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Leandro Conde

Hi fpc users!
I'm here again, with another problem :)

Ok, It's not a problem, per se. It's only a doubt, so, I write here to see if you may help me ...

This is the issue:
In Delphi, I've wrote some code in assembler that calls the above mentioned routines from System.pas: _InitializeArray & _FinalizeArray, to allow initialization and finalization of types that requires it, for generic containers which receives only a TypeInfo to indicate the type contained.

the routines' prototype from System.pas are these:
  procedure _InitializeArray(p: Pointer; typeInfo: Pointer; elemCount:
Cardinal);
  procedure _FinalizeArray(p: Pointer; typeInfo: Pointer; elemCount:
Cardinal);

My code looks like this:

procedure TSilTypeinfoDynamicHandler.Initialize(Data: Pointer; Count: Integer);
asm
MOV EAX, TSilTypeinfoHandler[EAX].FTypeInfo
XCHG EDX, EAX
CALL
end;

procedure TSilTypeinfoDynamicHandler.Finalize(Data: Pointer; Count: Integer);
asm
MOV EAX, TSilTypeinfoHandler[EAX].FTypeInfo
XCHG EDX, EAX
CALL
end;

I need to figure out what to do in FPC, which doesn't have the System.InitializeArray and friend.

I've found this (declared in compproc.inc & defined in rtti.inc): fpc_Initialize(Data, TypeInfo)
fpc_finalize (Data, TypeInfo)

Despite some differences (missing elemCount argument), I need to know how to call these and if this is going to work at all ...

Thanks you again!
See ya!
Leo.

Peter Vreman
to Leandro Conde
Show quoted text 48 lines
Hi fpc users! I'm here again, with another problem :) Ok, It's not a problem, per se. It's only a doubt, so, I write here to see if you may help me ... This is the issue: In Delphi, I've wrote some code in assembler that calls the above mentioned routines from System.pas: _InitializeArray & _FinalizeArray, to allow initialization and finalization of types that requires it, for generic containers which receives only a TypeInfo to indicate the type contained. the routines' prototype from System.pas are these: procedure _InitializeArray(p: Pointer; typeInfo: Pointer; elemCount: Cardinal); procedure _FinalizeArray(p: Pointer; typeInfo: Pointer; elemCount: Cardinal); My code looks like this: procedure TSilTypeinfoDynamicHandler.Initialize(Data: Pointer; Count: Integer); asm MOV EAX, TSilTypeinfoHandler[EAX].FTypeInfo XCHG EDX, EAX CALL end; procedure TSilTypeinfoDynamicHandler.Finalize(Data: Pointer; Count: Integer); asm MOV EAX, TSilTypeinfoHandler[EAX].FTypeInfo XCHG EDX, EAX CALL end; I need to figure out what to do in FPC, which doesn't have the System.InitializeArray and friend. I've found this (declared in compproc.inc & defined in rtti.inc): fpc_Initialize(Data, TypeInfo) fpc_finalize (Data, TypeInfo) Despite some differences (missing elemCount argument), I need to know how to call these and if this is going to work at all ...

You need to use Initialize() and Finalize()