Recent

Author Topic: LCL Object hierarchy chart  (Read 12399 times)

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: LCL Object hierarchy chart
« Reply #15 on: November 07, 2014, 09:05:58 pm »
For instance, for PasteFromClipboard method of TRichMemo. If I follow Alt+Up and Ctrl+Shift+Down road:

This code:
Code: [Select]
RichMemo1.PasteFromClipboard;

carries to:

Code: [Select]
procedure TCustomRichMemo.PasteFromClipboard; 
begin
  if HandleAllocated then 
    TWSCustomRichMemoClass(WidgetSetClass).PasteFromClipboard(Self);
end;

That line:

Code: [Select]
TWSCustomRichMemoClass(WidgetSetClass).PasteFromClipboard(Self)

carries to:

Code: [Select]
class procedure TWSCustomRichMemo.PasteFromClipboard

which is an empty method. But the paste action is done, I don't know how.

I suppose that it comes (somehow) from TWin32WSCustomRichMemo class, which has the following class procedure:

Code: [Select]
class procedure TWin32WSCustomRichMemo.PasteFromClipboard(const AWinControl: TWinControl); 
begin
  SendMessage(AWinControl.Handle, WM_PASTE, 0,0);
end;

As marcov says (and I believe), so they are linked at runtime.
« Last Edit: November 07, 2014, 09:41:28 pm by typo »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: LCL Object hierarchy chart
« Reply #16 on: November 08, 2014, 01:12:42 pm »
My assumptions seem to be OK, because now I have some methods which result. But I have a class function which does not, I don't know why. Any idea?

The function is from TWin32WSCustomX class. Any limit? Any restriction?
« Last Edit: November 08, 2014, 01:42:54 pm by typo »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2687
Re: LCL Object hierarchy chart
« Reply #17 on: November 12, 2014, 02:56:12 pm »
Afaik the LCL uses a hack to link base LCL classes to the corresponding widgetset.

IOW, not properly done using inheritance, but with casting and/or VMT point manipulation.

Marc tried to explain it once, but I can't remember the exact details anymore

Correct, I'll try to give a simple example (by heart)

Imagine you have a class hierarchy like: TControl -> TWinControl -> TButton
In the widgetset we have the same (abstract) hierarchy: TWSControl -> TWSWinControl -> TWSButton
Each widgetset can "override" a TWSxxx class to implement its functionality: 
  TWSWinControl -> TWSWin32WinControl
  TWSButton -> TWSWin32Button

however with normal inheritance TWSWin32Button is derived from TWSButton/TWSWinControl, but not from TWSWin32WinControl. So the TWSWin32WinControl implementation of  TWSWin32Button is missing.

So at runtime, a virtual class hierarchy is created in memory:  TWSControl -> TWSWinControl -> TWSWin32WinControl -> TWSButton -> TWSWin32Button

//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

sam707

  • Guest
Re: LCL Object hierarchy chart
« Reply #18 on: November 12, 2014, 04:25:12 pm »
;)

http://www.tutorialspoint.com/developers_best_practices/what_is_practice.htm

Quote
Best Practice 1- Keep Reading Existing Software Source Code
Let me ask you few basic questions before we start with one of the most important best practices required for a software developer.

Do you read movie magazines?
Do you read newspapers?
Do you read roadside advertisements?
Do you read junk written here and there?
Do you just read....?
Definitely your answer will be positive but if I ask you one more question in the series:

Do you read Software Source Code?
Only few software developers will have positive answer because reading and understanding an existing software source code is the most boring task. If you are one of them who feels reading software source code is a boring task, then you are missing one of the most important best practices, which a software developer should have in his/her life.

If you want to become a novelist, can you just start writing novels? I would say 100% no!!, you definitely need to read hundreds of novels before you start writing GOOD novels. If you want to become a movie script writer, can you start writing good movie scripts until you have gone through various good movie scripts?, again my answer would be no!!

meaning, if you don't spend hours and hours with gdb your friend, you have no chance to go deep learning

http://www.tutorialspoint.com/pascal/pascal_useful_resources.htm

sam707

  • Guest
Re: LCL Object hierarchy chart
« Reply #19 on: November 12, 2014, 04:37:49 pm »
when hiring someone, I dont ask him for a hierarchy chart poetry lol, i put several questions around some classes and how they interact, method by method. I would then so prefer to hire who wrote the hierarchy digest  :P

a hierarchy chart is a kinda shortcut for the lazy ones who do not want to learn, but want to seem good ;)

... thats for C programmers!! not for Great Pascal programmers. Thats my opinion!

If you need coal for your own programming fire, get a bucket and go for it!
« Last Edit: November 12, 2014, 04:42:21 pm by sam707 »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: LCL Object hierarchy chart
« Reply #20 on: November 12, 2014, 04:48:29 pm »
Afaik the LCL uses a hack to link base LCL classes to the corresponding widgetset.

IOW, not properly done using inheritance, but with casting and/or VMT point manipulation.

Marc tried to explain it once, but I can't remember the exact details anymore
So at runtime, a virtual class hierarchy is created in memory:  TWSControl -> TWSWinControl -> TWSWin32WinControl -> TWSButton -> TWSWin32Button

So this hierarchy exists only for the compiler? Or, on the contrary, this is the actual Lazarus hierachy?

sam707

  • Guest
Re: LCL Object hierarchy chart
« Reply #21 on: November 12, 2014, 04:54:42 pm »
the compiler uses TButton??? I think you have your answer here Mr. typo... you'll find this in lazarus sources, not in fpc sources. fpc is 'command line' compiler, it doesnt care "buttons"
« Last Edit: November 12, 2014, 04:57:40 pm by sam707 »

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: LCL Object hierarchy chart
« Reply #22 on: November 12, 2014, 10:27:11 pm »
I hardly can describe what I felt the first time I came across an empty method of a WSCustomX control. I felt the most ignorant person in the world. Reading source needs that the code be readable, indeed.
« Last Edit: November 12, 2014, 10:38:19 pm by typo »

sam707

  • Guest
Re: LCL Object hierarchy chart
« Reply #23 on: November 12, 2014, 10:44:57 pm »
for sure I agree with you! you need 'many' external knowledge to be able to deep read more or less 'professional' code, that includes 'COM/ActiveX' programming under windows.

and God knows how COM is a gas factory hahaha

but you are very lucky compared to C and C++ programmers because Pascal is truely much more human readable and friendly in its syntax. I learnt plenty of stuffs while I programmed with Qt, then, back to pascal I apply them in a HUMAN way that is direct BEAUTIFUL. C++ ==> obfuscation bias all around, even when unwanted!
« Last Edit: November 12, 2014, 10:51:19 pm by sam707 »

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: LCL Object hierarchy chart
« Reply #24 on: November 13, 2014, 05:06:00 pm »
I hardly can describe what I felt the first time I came across an empty method of a WSCustomX control. I felt the most ignorant person in the world. Reading source needs that the code be readable, indeed.

I completely understand.  For myself, the first time I came across this was by stepping into the code, so I ended up at the right spot.  A few <ctrl> <up>/<down>'s later though, and I was confused, but by then had enough information of where the code ended up, so managed to make a few guesses as to what was going on.  Head scratching though...

But what can you do?  It's documented in the wiki and in the readme...

Oooh.  An IDE helper that knows about the WS logic and offers you jump points based on your choice of widgetset.   I'm *never* going to get time to do that, but there's some smart people here :-)
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

 

TinyPortal © 2005-2018