[fpc-devel] Propose: change TComponent.Tag from longint to PtrInt

Jason P Sage jasonpsage at jegas.org
Tue Sep 5 13:46:54 CEST 2006


I have seen this issue come up with my own classes, and I get warnings about
portability from the compiler - the whole 32 to 64 bit warnings. 

The point being is that you can often do some pretty neat things with
pointer math etc. 

Concerning this particular thread - and this discussion about changing
Lazarus just to support it... does seem particular over kill.

One work around you might consider is to make a collection of sorts in
another class where this TAG you are referring to is a unique identifier,
that when passed to this vaporware collection I'm talking about, would
return the actual pointer to the object in question.

Personally - I have this set of classes I developed from the ground up with
some help Michael Van Canneyt like 4 years ago. I was working on a double
linked list that is a class that handles navigation through, crating, and
destroying, classes (linked list items) that works very much like a
recordset e.g. like navigating through ADO (Microsoft ODBC wrapper) in that
you can movefirst, move last, move next, move previous, and various search
things, sorting etc. 

This set of classes has come a long way - but I'm always reminded of the
32/64 bit issue. However the port is simple because only the very core that
does some pointer taboo wizardry is effected - and other objects I manage
with these classes are done with Unique identifiers. 

Example:

SFC: SFC_DL;
SFC:= SFC_DL.Create;
SFC.AddItem SFC_DLITEM.Create;

Writeln('Current Item Unique Identifeir:',SFC.Item.UID, ' or ');
Writeln('Direct: ',SFC_DLITEM(SFC.lpItem).UID);

That gives an integer unique identifier that is portable and managed like
A DBMS autonumber.

Then to attach objects I have as another property of SFC_DLITEM, a pointer:

SFC_DLITEM(SFC.lpItem).PTR:= TMyCustomObject.Create;

Now I can search for its pointer using the UID. Additionally, these classes 
Have ansistring fields like saName, and saDesc, you can search on also:

If SFC_DL.bFoundItem_saName('MyClass Name', false) then ... (false=not case
sensitive)

My point is not to tout my classes - but to suggest that keeping a list of
portable unique identifiers, coupled with pointers, and a method to find
them quickly, might allow you to use the TAG in TComponent as it is, with a
little rework of how you use TAG - but still accomplishing the same thing.

Have a great day people!
Jason P Sage 




More information about the fpc-devel mailing list