[fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Adriaan van Os
I am looking for a way to obtain the class hierarchy of a program in MacPas mode (where there are 
no published properties). TObject has ClassParent, so a list of Class types would be sufficient, I 
think. I can't find however a routine in the RTL to obtain such a list.


Regards,

Adriaan van Os
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Michael Van Canneyt



On Tue, 21 Sep 2010, Adriaan van Os wrote:

I am looking for a way to obtain the class hierarchy of a program in MacPas 
mode (where there are no published properties). TObject has ClassParent, so a 
list of Class types would be sufficient, I think. I can't find however a 
routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Adriaan van Os

Michael Van Canneyt wrote:



On Tue, 21 Sep 2010, Adriaan van Os wrote:

I am looking for a way to obtain the class hierarchy of a program in 
MacPas mode (where there are no published properties). TObject has 
ClassParent, so a list of Class types would be sufficient, I think. I 
can't find however a routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.


Can I add it ? I guess a low-level pointer to a list of VMT's would be sufficient to implement it ? 
That is, for object definitions that do have virtual methods ...


Regards,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Florian Klaempfl
Am 21.09.2010 13:42, schrieb Adriaan van Os:
> Michael Van Canneyt wrote:
>>
>>
>> On Tue, 21 Sep 2010, Adriaan van Os wrote:
>>
>>> I am looking for a way to obtain the class hierarchy of a program in
>>> MacPas mode (where there are no published properties). TObject has
>>> ClassParent, so a list of Class types would be sufficient, I think. I
>>> can't find however a routine in the RTL to obtain such a list.
>>
>> There is no such routine in the RTL, to my knowledge.
> 
> Can I add it ? I guess a low-level pointer to a list of VMT's would be
> sufficient to implement it ? 

Problem is: it breaks smartlinking.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Michael Van Canneyt



On Tue, 21 Sep 2010, Adriaan van Os wrote:


Michael Van Canneyt wrote:



On Tue, 21 Sep 2010, Adriaan van Os wrote:

I am looking for a way to obtain the class hierarchy of a program in 
MacPas mode (where there are no published properties). TObject has 
ClassParent, so a list of Class types would be sufficient, I think. I 
can't find however a routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.


Can I add it ? I guess a low-level pointer to a list of VMT's would be 
sufficient to implement it ? That is, for object definitions that do have 
virtual methods ...


Where do you want to add it ?  What is the method declaration you'd use ?

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Michael Van Canneyt



On Tue, 21 Sep 2010, Florian Klaempfl wrote:


Am 21.09.2010 13:42, schrieb Adriaan van Os:

Michael Van Canneyt wrote:



On Tue, 21 Sep 2010, Adriaan van Os wrote:


I am looking for a way to obtain the class hierarchy of a program in
MacPas mode (where there are no published properties). TObject has
ClassParent, so a list of Class types would be sufficient, I think. I
can't find however a routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.


Can I add it ? I guess a low-level pointer to a list of VMT's would be
sufficient to implement it ?


Problem is: it breaks smartlinking.


Why? It's just walking the ParentClass hierarchy of a given class; which is
what RTTI does anyway ?

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Sven Barth

Am 21.09.2010 13:49, schrieb Michael Van Canneyt:



On Tue, 21 Sep 2010, Florian Klaempfl wrote:


Am 21.09.2010 13:42, schrieb Adriaan van Os:

Michael Van Canneyt wrote:



On Tue, 21 Sep 2010, Adriaan van Os wrote:


I am looking for a way to obtain the class hierarchy of a program in
MacPas mode (where there are no published properties). TObject has
ClassParent, so a list of Class types would be sufficient, I think. I
can't find however a routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.


Can I add it ? I guess a low-level pointer to a list of VMT's would be
sufficient to implement it ?


Problem is: it breaks smartlinking.


Why? It's just walking the ParentClass hierarchy of a given class; which is
what RTTI does anyway ?


If I understood it right he wants the complete hierachy (or the complete 
class tree) which is used in a program. So the opposite of "ClassParent".


Regards,
Sven
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Adriaan van Os

Michael Van Canneyt wrote:


On Tue, 21 Sep 2010, Florian Klaempfl wrote:


Am 21.09.2010 13:42, schrieb Adriaan van Os:

Michael Van Canneyt wrote:



On Tue, 21 Sep 2010, Adriaan van Os wrote:


I am looking for a way to obtain the class hierarchy of a program in
MacPas mode (where there are no published properties). TObject has
ClassParent, so a list of Class types would be sufficient, I think. I
can't find however a routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.


Can I add it ? I guess a low-level pointer to a list of VMT's would be
sufficient to implement it ?


Problem is: it breaks smartlinking.


Yes, I understand that. I looked at the assembly generated for a simple test program and there are 
separate al_globals entries for each vmt and separate al_rtti entries for the vmt rtti. I asssume 
the very reason for the separate entries is smart linking.


Hm, I guess I can look at the data section of the executable but it would be highly dependant of 
the executable binary format.


Is it possible to produce a separate data section/entry that refers to all al_globals and/or all 
al_rtti entries without breaking smart-linking ?



Why? It's just walking the ParentClass hierarchy of a given class; which is
what RTTI does anyway ?


And the other way round (from a class to each subclass).

Regards,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Adriaan van Os

Sven Barth wrote:
If I understood it right he wants the complete hierachy (or the complete 
class tree) which is used in a program. So the opposite of "ClassParent".


Right.

Regards,

Adriaan van Os

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Obtain Class hierarchy (in MacPas mode)

2010-09-21 Thread Michael Van Canneyt



On Tue, 21 Sep 2010, Adriaan van Os wrote:


Michael Van Canneyt wrote:


On Tue, 21 Sep 2010, Florian Klaempfl wrote:


Am 21.09.2010 13:42, schrieb Adriaan van Os:

Michael Van Canneyt wrote:



On Tue, 21 Sep 2010, Adriaan van Os wrote:


I am looking for a way to obtain the class hierarchy of a program in
MacPas mode (where there are no published properties). TObject has
ClassParent, so a list of Class types would be sufficient, I think. I
can't find however a routine in the RTL to obtain such a list.


There is no such routine in the RTL, to my knowledge.


Can I add it ? I guess a low-level pointer to a list of VMT's would be
sufficient to implement it ?


Problem is: it breaks smartlinking.


Yes, I understand that. I looked at the assembly generated for a simple test 
program and there are separate al_globals entries for each vmt and separate 
al_rtti entries for the vmt rtti. I asssume the very reason for the separate 
entries is smart linking.


Hm, I guess I can look at the data section of the executable but it would be 
highly dependant of the executable binary format.


Is it possible to produce a separate data section/entry that refers to all 
al_globals and/or all al_rtti entries without breaking smart-linking ?


Maybe when doing whole-program optimization as implemented by Jonas.
I guess the WPO could be extended to generate the tree you want.

But under 'normal' compilation, I don't think it is possible to do as you
ask without breaking the smartlinking stuff; the tree would of necessity
contain all declared classes of all loaded units.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] TEventLog.FileName location: Change default file location for filename without change unit code.

2010-09-21 Thread phoebus phoebus
Hi,

I'm using FPC 2.2.4 with Lazarus.

The unit eventlog is great for logging events. SO i use it.
 
My question is how to change the default location for the filename for Linxu 
ssytem which is harcoded in the code.
The documentation for TEventLog.FileName wrote:
" FileName is the name of the log file used to log messages (...). The file is 
then located in the "/tmp" directory on unix-like systems, or in the 
application 
directory for Dos/Windows like systems
 
Line 56 to 60 from eventlog.inc (fpc\2.2.4\source\packages\fcl-base\src\unix)
    Function TEventLog.DefaultFileName : String;
    begin
  Result:='/tmp/'+ChangeFileExt(ExtractFileName(Paramstr(0)),'.log');
    end;
I can of course change the function code like Windows to have the log in the 
same directory thtat the application.:
Line 18 to 22 from eventlog.inc (fpc\2.2.4\source\packages\fcl-base\src\windows)
    Function TEventLog.DefaultFileName : String;
    begin
  Result:=ChangeFileExt(Paramstr(0),'.log');
    end;

Could you indicate a nice solution to indicate log file location in using the 
unit eventlog without change fpc code?
 
FYI: this is the code i use:
    program project1;
    {$mode objfpc}{$H+}
    uses  Sysutils, eventlog,
  {$IFDEF UNIX}  BaseUnix,{$IFDEF UseCThreads}
    cthreads,
  {$ENDIF}{$ENDIF}
    Classes
  { you can add units after this };
    {$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}
 var
  A : TEventLog;
    begin
  A := TEventLog.Create(nil);
  A.LogType := ltFile;
  A.FileName := 'log';
  A.Active := True;
  A.Info('Program started.');
  A.Info('Info from A.');
  A.Warning('Info from A.');
  A.Error('Info from A.');
  A.Debug('Info from A.');
  A.Info('Program stopped.');
  FreeAndNil(A);
 end.
 
Thanks for your advice.
Regards,
Phoebus



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TEventLog.FileName location: Change default file location for filename without change unit code.

2010-09-21 Thread Michael Van Canneyt



On Tue, 21 Sep 2010, phoebus phoebus wrote:


Hi,

I'm using FPC 2.2.4 with Lazarus.

The unit eventlog is great for logging events. SO i use it.
 
My question is how to change the default location for the filename for Linxu 
ssytem which is harcoded in the code.

The documentation for TEventLog.FileName wrote:
" FileName is the name of the log file used to log messages (...). The file is 
then located in the "/tmp" directory on unix-like systems, or in the application 
directory for Dos/Windows like systems

 
Line 56 to 60 from eventlog.inc (fpc\2.2.4\source\packages\fcl-base\src\unix)
    Function TEventLog.DefaultFileName : String;
    begin
  Result:='/tmp/'+ChangeFileExt(ExtractFileName(Paramstr(0)),'.log');
    end;
I can of course change the function code like Windows to have the log in the 
same directory thtat the application.:

Line 18 to 22 from eventlog.inc (fpc\2.2.4\source\packages\fcl-base\src\windows)
    Function TEventLog.DefaultFileName : String;
    begin
  Result:=ChangeFileExt(Paramstr(0),'.log');
    end;

Could you indicate a nice solution to indicate log file location in using the 
unit eventlog without change fpc code?


You can just set the filename property, with full path:
/my/path/mylog.txt

It will be created in the path you specify, as you can see in ActivateFileLog.

Procedure TEventLog.ActivateFileLog;

begin
  If (FFileName='') then
FFileName:=DefaultFileName;
  // This will raise an exception if the file cannot be opened for writing !
  FStream:=TFileStream.Create(FFileName,fmCreate or fmShareDenyWrite);
end;

The default is just that, the default. If you specify a filename, then that
is used. What more do you need ?

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

[fpc-pascal] code optimization

2010-09-21 Thread stefan077
Hi all,
 
I am currently trying to get the fastest possible code from fpc on a  modern 
CPU (Intel Xeon) under Windows XP. I use the compiler options:
 
fpc -Mdelphi -O3 -OpPENTIUMM -Cfsse2 -Cr- -Co- -CO- -Ci- myprogram.dpr
 
Are there any better settings I should use? Compiling exactly the same  program 
with Delphi7 results in 50% faster code. I understand that fpc  does not 
support the most recent CPUs, but neither does DELPHI 7. So  what optimizations 
are done by Delphi 7 that are not done by fpc and why  is this the case?
 
 Stefan
___
Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] TEventLog.FileName location: Change default file location for filename without change unit code.

2010-09-21 Thread DaWorm
On Tue, Sep 21, 2010 at 9:39 AM, Michael Van Canneyt  wrote:

> begin
>>   Result:=ChangeFileExt(Paramstr(0),'.log');
>> end;
>>
> Function TEventLog.DefaultFileName : String;
>

On Windows, this can be problematic.  Win7 for sure, usually Vista, and any
version of Windows that has had its security tightened won't let you write
files into the application folder.

Jeff.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re : [fpc-pascal] TEventLog.FileName location: Change default file location for filename without change unit code.

2010-09-21 Thread phoebus phoebus
Hi,

Thanks Michael for the update.

>>  The default is just that, the default. If you specify a filename, then that 
>> is 
>>used.
Yes, that's right. 

Thanks also jeff for the advise on Windows platform.

Regards,
Frphoebus


  ___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] code optimization

2010-09-21 Thread Adrian Veith
 Hi Stefan,

is this a benchmark program or a complex program you are talking about.
If it is a benchmark, then it would be interesting to see the code,
because from my experience I doubt that Delphi produces better code than
fpc (in general it is the other way round). If it is a complex program,
then you need to analyze carefully which part of the program consumes
the most time and why. A number of 50% is in anyway unrealistic (this is
something you get if you compare inlined code against uninlined) ,
because the differences you get from code optimization are in a range
from +/-10% normally - unless you have found a real performance
bottleneck. And sometimes (most of) it is only an unoptimized library code.

Adrian.

On 21.09.2010 16:39, stefan...@web.de wrote:
> Hi all,
>  
> I am currently trying to get the fastest possible code from fpc on a  modern 
> CPU (Intel Xeon) under Windows XP. I use the compiler options:
>  
> fpc -Mdelphi -O3 -OpPENTIUMM -Cfsse2 -Cr- -Co- -CO- -Ci- myprogram.dpr
>  
> Are there any better settings I should use? Compiling exactly the same  
> program with Delphi7 results in 50% faster code. I understand that fpc  does 
> not support the most recent CPUs, but neither does DELPHI 7. So  what 
> optimizations are done by Delphi 7 that are not done by fpc and why  is this 
> the case?
>  
>  Stefan
> ___
> Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
> Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02
> ___
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal