Вниз
Скачать: CL | DM;

Propose small change to _Tobj to the Dacha man ;)   Найти похожие ветки 

← →
Thaddy   (2005-08-05 01:47) [0]

This is an architectural matter.

What are your thoughts about this possible change to _Tobj (The basic object for Tobj and therefore Tcontrol):
I propose to make the *first* field an untyped pointer, so that you can assign other objects or data to it, just like CustomObj and CustomData.
The advantage is, that you can typecast a full Tobj descendant to the type that holds the pointer:

type
 PPMyObject = ^PMyObject;
 PMyObject = ^TMyObject;
 TMyObject = object(Tobj)
 ....
 end;

Now if the *first* field in _Tobj were a pointer, we could assign a structure to it, say, PWaveFormatEx and we could typecast the whole object as PPWaveFormatEx. Actually simulating interfaces and /or "friend" in C++
You can already do this with simple objects, but you loose the power of the destructor/free. (Add2Autofree, etc)
Right Now the first field is FRefCount. Ithink my proposal would not break the code, only Frefcount and fTag need to be switched?
Or am I missing something?


← →
Thaddy   (2005-08-05 02:01) [1]

And the typecast would be:


var

 WaveFormat:TWaveFormatEx; // or any other record or object

 MyObject:PMyobject;
begin
 MyObject:=NewMyObject;
 MyObject.Tag:=Cardinal(@WaveFormat);// Assumes the above!
 PPWaveFormatEx(MyObject).nSamplesPerSec:=44100;
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.041 c
3-1138958029
Ega23
2006-02-03 12:13
2006.03.26
Создание View - поясните


2-1141894640
nap<>
2006-03-09 11:57
2006.03.26
Про формы :)


4-1136740034
Microsom
2006-01-08 20:07
2006.03.26
Delphi &amp; ADSI (ActiveDirectory)


15-1141036082
Loginov Dmitry
2006-02-27 13:28
2006.03.26
Про сайт...


15-1141472956
ipashkov
2006-03-04 14:49
2006.03.26
Глюки с Delphi IDE под Windows Server 2003




   Наверх