[fpc-devel] Use widesting as default?

2010-11-18 Thread Birger Jansen
Hi all,

I'm converting a Delphi 2009 project to FPC. In this project all strings are 
widestrings, which is default for Delphi 2009. However, in FPC all strings are 
still 'normal' strings. Is there a way (compiler switch?) to use widestring as 
default for all strings in FPC?

Kind regards,
  Birger Jansen

(I'm not sure if this message should go here or to Lazarus list since it is not 
entirely clear to me if strings belong to FPC or Lazarus. Forgive me if this is 
the wrong list!)
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: [fpc-devel] Use widesting as default?

2010-11-18 Thread Birger Jansen
 Keep in mind that Delphi 2009's default string type is much more than  
 a regular widestring. Using unicodestring instead in FPC would be  
 more correct, but even then you won't have the same support yet (that  
 first requires the completion of the cpstrnew branch, as Paul  
 indicated).

Thanks for the answer, Paul and Jonas. I'll check how cpstrnew works for me. 
Although I'm not sure if I have enough knowledge to actually contribute 
something in these deeper parts of the FPC-dungeon, I will report my findings.

Kind regards,
  Birger Jansen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: Re: [fpc-devel] Another question about class vars

2010-11-05 Thread Birger Jansen
 Please test r16302.
 
 Best regards,
 Paul Ishenin.

Yes, fixed! Thank you very much.

Kind regards,
  Birger
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: Re: [fpc-devel] fcl-image lacking brush and pen?

2010-11-05 Thread Birger Jansen
-Oorspronkelijk bericht-
Van: Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com
Verzonden: do 04-11-2010 18:11
Aan: FPC developers' list fpc-devel@lists.freepascal.org; 
Onderwerp: Re: [fpc-devel] fcl-image lacking brush and pen?

 I changed the default value of the brush to bsSolid. This should avoid
 some confusion in the long term.

Any chance this will also be changed in TCanvas, which has the same confusing 
issue?

Kind regards,
  Birger
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: Re: Re: [fpc-devel] fcl-image lacking brush and pen?

2010-11-05 Thread Birger Jansen
 TCanvas from the LCL? AFAIK the standard brush style is already bsSolid there.
 
 -- 
 Felipe Monteiro de Carvalho

Sorry, you are right. I looked at the wrong piece of code 
(TCanvas.DoCreateDefaultBrush in canvas.inc).
It seems the problem I'm having with 'empty' rectangles is in some Delphi code 
that is written here.

Kind regards,
  Birger
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] Another question about class vars

2010-11-04 Thread Birger Jansen
Hi all,

I am still a little confused about class vars and the difference there seems to 
be with how this behaves in Delphi. Take the following class:

  TMyClass = class
  private
class var SomeClassVar: Integer;
  public
SomeVar: Integer;
  end;

And two instances of this class: a,b: TMyClass

And let's do this:

  a.SomeClassVar := 10;
  b.SomeClassVar := 20;
  a.SomeVar := 30;
  b.SomeVar := 40; 

I would expect this results:

 a.SomeClassVar= 20
 b.SomeClassVar= 20
 a.SomeVar = 30
 b.SomeVar = 40

But it turns out that for both a and b the value for SomeVar = 40. Which leads 
to the conclusion that SomeVar is also a class var. I would think that because 
of the new section (public) the declaration would default to 'var', but it 
doesn't. SomeVar is also added as a class var.

Changing the class to this...

  TMyClass = class
  private
class var SomeClassVar: Integer;
  public
var SomeVar: Integer;
  end;

(adding var to SomeVar)

...gives the expected result. I know this is probably not a bug, as was 
explained to me in my last post with a question related to class vars. But this 
minuscule difference between Delphi and FPC has a great impact (just spend 4 
hours on tracking an issue down to this).

Any chance that this behaviour can be changed or is it just me who should be 
more carefull with this?

Kind regards,
  Birger
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: Re: [fpc-devel] Another question about class vars

2010-11-04 Thread Birger Jansen
 04.11.2010 18:58, Birger Jansen wrote:
  Any chance that this behaviour can be changed or is it just me who should 
  be 
 more carefull with this?
 You've found a bug. I will fix it later today.

Ok, that's great. I'll check the updates for this issue.

Kind regards,
  Birger
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] Issue with class vars

2010-10-27 Thread Birger Jansen
Hi,

I encountered a possible bug (or at least a compiler error that should be 
clearified) when using class vars in  FPC 2.4.3:

This class definition will compile:

  TTest = class(TObject)
  private
FMyField: string;
class var MyClassVar: Integer;
  published
property MyProperty: string read FMyField write FMyField;
  end; 

When swapping the rows with class var and FMyField it becomes this:

  TTest = class(TObject)
  private
class var MyClassVar: Integer;
FMyField: string;
  published
property MyProperty: string read FMyField write FMyField;
  end;

This breaks the code, but on a strange line: the line property MyProperty (...) 
with Error: Illegal symbol for property access.

Shall I report a bug for this?

Kind regards,
  Birger Jansen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: [fpc-devel] Issue with class vars

2010-10-27 Thread Birger Jansen
The problem is with trunk instead of 2.4.3!

Sorry for the confusion.

-Oorspronkelijk bericht-
Van: Birger Jansen bir...@cnoc.nl
Verzonden: wo 27-10-2010 10:47
Aan: fpc-devel@lists.freepascal.org; 
Onderwerp: [fpc-devel] Issue with class vars

 Hi,
 
 I encountered a possible bug (or at least a compiler error that should be 
 clearified) when using class vars in  FPC 2.4.3:
 
 This class definition will compile:
 
   TTest = class(TObject)
   private
 FMyField: string;
 class var MyClassVar: Integer;
   published
 property MyProperty: string read FMyField write FMyField;
   end; 
 
 When swapping the rows with class var and FMyField it becomes this:
 
   TTest = class(TObject)
   private
 class var MyClassVar: Integer;
 FMyField: string;
   published
 property MyProperty: string read FMyField write FMyField;
   end;
 
 This breaks the code, but on a strange line: the line property MyProperty 
 (...) 
 with Error: Illegal symbol for property access.
 
 Shall I report a bug for this?
 
 Kind regards,
   Birger Jansen
 ___
 fpc-devel maillist  -  fpc-devel@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-devel

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


RE: Re: [fpc-devel] Issue with class vars

2010-10-27 Thread Birger Jansen
You are right, the notation confused me.
Thanks for clearing it out for me with a quick reply!

Kind regards,
  Birger

-Oorspronkelijk bericht-
Van: Paul Ishenin i...@kmiac.ru
Verzonden: wo 27-10-2010 11:05
Aan: FPC developers' list fpc-devel@lists.freepascal.org; 
Onderwerp: Re: [fpc-devel] Issue with class vars

 27.10.2010 16:46, Birger Jansen wrote:
 
  When swapping the rows with class var and FMyField it becomes this:
 
 TTest = class(TObject)
 private
   class var MyClassVar: Integer;
   FMyField: string;
 published
   property MyProperty: string read FMyField write FMyField;
 end;
 
  This breaks the code, but on a strange line: the line property MyProperty 
 (...) with Error: Illegal symbol for property access.
 
 Compiler absolutely correctly reports you that MyProperty can't use 
 FMyField field because it is a class field in this case, not an instance 
 field.
 
 The next code will work again:
 
  TTest = class(TObject)
  private
class var
  MyClassVar: Integer;
var
  FMyField: string;
  published
property MyProperty: string read FMyField write FMyField;
  end;
 
 Best regards,
 Paul Ishenin.
 
 ___
 fpc-devel maillist  -  fpc-devel@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-devel

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


[fpc-devel] TStringGrid behaviour

2010-10-27 Thread Birger Jansen
Hi all,

I have the following code that throws an error in FPC and runs fine in Delphi:

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  MyStringGrid: TStringGrid;
begin
  MyStringGrid := TStringGrid.Create(nil);
  try
MyStringGrid.RowCount := 0;
MyStringGrid.RowHeights[0] := 1;
  finally
MyStringGrid.Free;
  end;
end;

Delphi checks if the grid has at least 
In FPC there is no check on RowCount before the height is set, resulting in a 
List index(0) out of bounds exception. Although it is correct, it is annoying 
:-)

It can be fixed by adding something like this to the beginning of 
TCustomGrid.Setrowheights:

  if ARow = FRows.Count then EXIT;

Shall I file a report for this?

Kind regards,
  Birger Jansen
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] TStringGrid behaviour

2010-10-27 Thread Birger Jansen
Van: Thaddy tha...@thaddy.com
 First: It is not a good idea to create the stringgrid without a parent... or 
 any visual control. Annoying :) and potentionally dangereous.

True, dirty example code.

 Second: As you remarked, the behaviour is correct. Why being annoyed about 
 making a programming mistake?

I thought the Free Pascal project wanted to be compatible with Delphi where it 
is possible. I stumbled upon this issue while converting a Delphi project and 
thought it might be something to fix for the sake of compatibility.

@Graeme: sorry.

Kind regards,
  Birger
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


RE: Re: [fpc-devel] Fatal: Internal error 200111022

2010-10-20 Thread Birger Jansen
Hi Michael,

Yes, TSub.Count should be used. I agree that it is dirty and confusing. Best 
would be to only have it work in Delphi mode.

Kind regards,
  Birger


-Oorspronkelijk bericht-
Van: Michael Van Canneyt mich...@freepascal.org
Verzonden: wo 20-10-2010 13:22
Aan: FPC developers' list fpc-devel@lists.freepascal.org; 
Onderwerp: Re: [fpc-devel] Fatal: Internal error 200111022

 
 Hello,
 
 Which 'Count' should the compiler select ? I suspect TSub.Count ?
 
 I think we should prohibit this dubious construct in ObjFC mode.
 (but try to be delphi compatible in Delphi mode)
 
 Michael.
 
 On Wed, 20 Oct 2010, Birger Jansen wrote:
 
  I'm not sure if this is the correct way to report this, please correct me 
  if 
 I should report in another way.
 
  I found an old conversation between Leonardo and Florian about the Fatail 
 internal error 200111022. The thread concluded that they could not reproduce 
 the error.
 
  I got this error while converting a large project from Delphi to FPC. It 
 turns out that a base class has a property Count, and a derived class has a 
 function with the same name Count. This will compile, untill you call the 
 property or function Count.
 
  I created an example that should explain it. Uncomment the marked line to 
  get 
 the fatal internal error:
 
  program project1;
 
  {$mode objfpc}{$H+}
 
  uses
   {$IFDEF UNIX}{$IFDEF UseCThreads}
   cthreads,
   {$ENDIF}{$ENDIF}
   Classes;
 
  type
 
   TBase = class
   private
 function GetCount: Integer;
   public
 property Count: Integer read GetCount;
   end;
 
   TSub = class(TBase)
   public
 function Count: Integer; overload;
   end;
 
  function TSub.Count: Integer;
  begin
   Result := 0;
  end;
 
  { TBase }
 
  function TBase.GetCount: Integer;
  begin
   Result := 0;
  end;
 
  var
   MySub: TSub;
   i : Integer;
  begin
   MySub := TSub.Create;
  // uncomment the next line for Fatal Internal error 200111022:
  //  for i := 0 to MySub.Count do begin end;
  end.
  ___
  fpc-devel maillist  -  fpc-devel@lists.freepascal.org
  http://lists.freepascal.org/mailman/listinfo/fpc-devel
 
 ___
 fpc-devel maillist  -  fpc-devel@lists.freepascal.org
 http://lists.freepascal.org/mailman/listinfo/fpc-devel

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


[fpc-devel] Fatal: Internal error 200111022

2010-10-20 Thread Birger Jansen
 Can you please enter a bug-report for this, and simply mention these facts ?

Done: http://bugs.freepascal.org/view.php?id=17675
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel