Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is TPath record from System.IOUtils initialized?

TPath record has class constructor TPath.Create which initialize class vars. But, I can't find any unit where TPath.Create is used / called dispite this all vars has correct values (TPath.PathSeparator, ...).

like image 819
Branko Avatar asked Jan 31 '12 11:01

Branko


1 Answers

Class constructors are called automatically by the initialization code that Delphi produces. Class constructors are called during the initialization section of the unit in which they are declared.

This is described in more detail in the documentation:

A class constructor is a special class method that is not accessible to developers. Calls to class constructors are inserted automatically by the compiler into the initialization section of the unit where the class is defined. Normally, class constructors are used to initialize the static fields of the class or to perform a type of initialization, which is required before the class or any class instance can function properly. Even though the same result can be obtained by placing class initialization code into the initialization section, class constructors have the benefit of helping the compiler decide which classes should be included into the final binary file and which should be removed from it.

You can see that this is so by enabling Debug DCUs and then setting a breakpoint on the code in the class constructor.

like image 136
David Heffernan Avatar answered Nov 11 '22 00:11

David Heffernan