Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-12

Generated names in specialized classes are weird in Free Pascal

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog

Hello,

Recently I've made a class to generate error log for codes in Delphi and Free Pascal. It works capturing the class name where the problem occurred, adding the date/time concatenated with the error message. It's working perfectly in Delphi.

The problem is in Free Pascal and in your approach to save the name of specialized classes. They are very weird names and a little intuitive. For example:

TFoo$1$crcB96581A6

Assuming the small code below is my log generator, see the output generated by Delphi code:

program Project1;
{$APPTYPE CONSOLE}
uses
  System.SysUtils;
type
  TTest = class(TObject)
  end;
  TFoo<T> = class(TObject)
  public
    class procedure Log(AClass: System.TClass);
  end;
  TBar1 = TFoo<TTest>; // short declaration
  TBar2 = class(TFoo<TTest>) // full declaration
  end;
  class procedure TFoo<T>.Log(AClass: System.TClass);
  begin
    System.WriteLn('[', System.SysUtils.FormatDateTime('hh:nn:ss.zzz',
      System.SysUtils.Now), ']: ', AClass.ClassName);
  end;
begin
  TFoo<TTest>.Log(TBar1);
  TFoo<TTest>.Log(TBar2.ClassParent);
  System.ReadLn;
end.

Output:

[06:27:08.545]: TFoo<Project1.TTest>
[06:27:08.546]: TFoo<Project1.TTest>

Now, see the same output for a Free Pascal code:

program Project1;
{$mode delphi}
uses
  SysUtils;
type
  TTest = class(TObject)
  end;
  TFoo<T> = class(TObject)
  public
    class procedure Log(AClass: System.TClass);
  end;
  TBar1 = TFoo<TTest>; // short declaration
  TBar2 = class(TFoo<TTest>) // full declaration
  end;
  class procedure TFoo<T>.Log(AClass: System.TClass);
  begin
    System.WriteLn('[', SysUtils.FormatDateTime('hh:nn:ss.zzz',
      SysUtils.Now), ']: ', AClass.ClassName);
  end;
begin
  TFoo<TTest>.Log(TBar1);
  TFoo<TTest>.Log(TBar2.ClassParent);
  System.ReadLn;
end.

Output:

[06:27:08.545]: TFoo$1$crcB96581A6
[06:27:08.545]: TFoo$1$crcB96581A6

It is very weird this generated class names. The Free Pascal will continue to use these weird names or there are plans to improve this in future versions? With names like that is almost impossible to create automated error logs structures with Free Pascal.

Thank you!

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Sven Barth
to silvioprog
"silvioprog" wrote
It is very weird this generated class names. The Free Pascal will

continue to use these weird names or there are plans to improve this in future versions? With names like that is almost impossible to create automated error logs structures with Free Pascal.

Please update to most current trunk version.

Regards,
Sven

Reply by email

silvioprog
to Sven Barth
Sven Barth wrote 11 lines
Am 23.12.2014 15:53 schrieb "silvioprog" : > It is very weird this generated class names. The Free Pascal will continue to use these weird names or there are plans to improve this in future versions? With names like that is almost impossible to create automated error logs structures with Free Pascal. Please update to most current trunk version. Regards, Sven

Hm... my revision is: (*). (from GIT)

The output:

[14:07:46.689]: TFoo$1$crcB96581A6
[14:07:46.690]: TFoo$1$crcB96581A6

(*):

SHA 05f1c39d
by pierre, 23/12/2014 13:12
parent 667edc8b

go32v2 must also define NO_THREADING, as threads are not supported on this target

git-svn-id:
3ad0048d-3df7-0310-abae-a5850022a9f2

on branches master, origin/master
branches master, origin/master

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

silvioprog
to silvioprog

And:

C:\repository\git\freepascal\bin\i386-win32>fpc -iDV 2014/12/23 2.7.1

...

begin
  WriteLn({$I %FPCDATE%});
end.

Out: 2014/12/23

silvioprog wrote 36 lines
On Tue, Dec 23, 2014 at 1:22 PM, Sven Barth wrote: > Am 23.12.2014 15:53 schrieb "silvioprog" : > > It is very weird this generated class names. The Free Pascal will > continue to use these weird names or there are plans to improve this in > future versions? With names like that is almost impossible to create > automated error logs structures with Free Pascal. > > Please update to most current trunk version. > > Regards, > Sven > Hm... my revision is: (*). (from GIT) The output: [14:07:46.689]: TFoo$1$crcB96581A6 [14:07:46.690]: TFoo$1$crcB96581A6 (*): SHA 05f1c39d by pierre, 23/12/2014 13:12 parent 667edc8b go32v2 must also define NO_THREADING, as threads are not supported on this target git-svn-id: 3ad0048d-3df7-0310-abae-a5850022a9f2 on branches master, origin/master branches master, origin/master
Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Sven Barth
to silvioprog: On Tue, Dec 23, 2014 at 1:22 PM, Sven Barth Hm... my revision is: (*). (from GIT) The…
"silvioprog" wrote 14 lines
Hm... my revision is: (*). (from GIT) The output: [14:07:46.689]: TFoo$1$crcB96581A6 [14:07:46.690]: TFoo$1$crcB96581A6 (*): SHA 05f1c39d by pierre, 23/12/2014 13:12 parent 667edc8b go32v2 must also define NO_THREADING, as threads are not supported on

this target

git-svn-id:

3ad0048d-3df7-0310-abae-a5850022a9f2

on branches master, origin/master branches master, origin/master

There was still an error, because of a last minute change by me. Please try revision 29328 from half an hour ago.

Regards,
Sven

Reply by email

silvioprog
to Sven Barth
Sven Barth wrote 29 lines
Am 23.12.2014 18:11 schrieb "silvioprog" : > Hm... my revision is: (*). (from GIT) > > The output: > > [14:07:46.689]: TFoo$1$crcB96581A6 > [14:07:46.690]: TFoo$1$crcB96581A6 > > (*): > > SHA 05f1c39d > by pierre, 23/12/2014 13:12 > parent 667edc8b > > go32v2 must also define NO_THREADING, as threads are not supported on this target > > git-svn-id: 3ad0048d-3df7-0310-abae-a5850022a9f2 > > on branches master, origin/master > branches master, origin/master There was still an error, because of a last minute change by me. Please try revision 29328 from half an hour ago. Regards, Sven

Now it works like a charm, thanks alot buddy! (y)

Silvio Clécio My public projects - github.com/silvioprog

Reply by email