Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "KOL";
Текущий архив: 2006.03.26;
Скачать: [xml.tar.bz2];

Вниз

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 вся ветка

Форум: "KOL";
Текущий архив: 2006.03.26;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.039 c
2-1141710863
dimm86
2006-03-07 08:54
2006.03.26
designEditors


2-1142240964
mrAndersen
2006-03-13 12:09
2006.03.26
Как добавить *.gif файл на форму?


15-1141105932
Ega23
2006-02-28 08:52
2006.03.26
С Днём рождения! 28 февраля


15-1141060496
I am
2006-02-27 20:14
2006.03.26
Оптимальный вариант проверки подлинности


2-1142312072
Гога
2006-03-14 07:54
2006.03.26
ООП





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский