On Sat, 10 Oct 2015, Sven Barth wrote:
Am 10.10.2015 11:12 schrieb "Michael Van Canneyt" <mich...@freepascal.org>:
On Sat, 10 Oct 2015, Maciej Izak wrote:
I am working on smart pointers for FPC (something more than pure ARC for
classes).
This solution is full compatible with existing code base.
I would like to know what do you think about my conception and work.
First step is almost done -> new record operators:
=== begin code ===
{$MODESWITCH MANAGEMENTOPERATORS}
type // Record with automatic constructor and destructor
TValue = record
class operator Initialize(var aRec: TValue);
class operator Finalize(var aRec: TValue);
class operator Copy(constref aSource: TValue; var aDest: TValue);
end;
=== end code ===
MANAGEMENTOPERATORS are quite simple to implement. MANAGEMENTOPERATORS
were
created initially for fast implementation of TValue in RTTI.pas, but they
inspired me for smart pointers.
This part I understand, it is simple enough. A managed record type ?
I don't think a different type will be needed.
I'm not suggesting it either.
Just looking for a term that concisely describes what it is :)
Just allow those three
operator overloads for normal records and have them be present in the Init
RTTI of the record so that fpc_initialize(), fpc_finalize() and fpc_copy()
can pick them up. This will be needed anyway should such records be placed
in arrays or other records or classes. (Of course from great power comes
great responsibility ;) )
I don't know how this works internally.
Is fpc_initialize called for every record type ? I sincerely hope not.
Does the compiler check the actual RTTI to decide whether fpc_initialize
and friends are called ?
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel