0
votes

Maybe I am blind, but I can't find in the Free Pascal source file implementations of Classes and some other units like System. Mostly, but not only, I am interested in TObject, TPersistent and TControl code code. I searched both in Lazarus and FP sites on SourceForge. My problem is that the file list is quite large. Google refused to search because of robots.txt.

There is a lclclasses.pas unit, but it is not what I'm looking for - in the uses block it is referring to Classes, but there is no file (I mean I couldn't find it) like "classes.pas".

Here I found the TControl implementation, but that's too far in the hierarchy.

On this page there is an information that the TPersistent is defined in "classesh.inc" and I downloaded sources and it really is in rtl\objpas\classes\classesh.inc, however, it seems that this file is only interface part of the unit.

I tagged this question as "delphi" too, because in fact if there is some open source code for Delphi, I could also accept. If the implementation of this base classes TObject and TPersistent is some kind of built-in feature (the System unit is, I think), I can also take a look at C (or any other language) sources.

Could anybody help me to find implementation of Classes units and the objects defined there?

1
They can be founf in .inc files - David Heffernan
I get it. The files are divided rather by classes not the units. Thank you @DavidHeffernan - Voitcus
I suggest you both: @DavidHeffernan convert that comment in a answer and Voitcus accept it. Is not that obvious for those starting with Lazarus. - Fabricio Araujo
Yes @DavidHeffernan, if you post it as an answer, I will accept it. - Voitcus

1 Answers

2
votes

Because FPC supports so many different platforms, the structure of the RTL code is somewhat complex.

But the platform independent part of the RTL code, which is what you are interested in can be found under the source\rtl\objpas directory.

  • The code for Classes is in include files in source\rtl\objpas\classes. The relevant files are classesh.inc and classes.inc. The former contains the code for the interface section, the latter code for the implementation section.
  • The System unit is highly platform specific. Look for your platform under source\rtl.
  • For SysUtils look under source\rtl\objpas\sysutils.