Re: [fpc-pascal] problem with interface (OOP not widget)

2008-03-12 Thread Jonas Maebe


On 12 Mar 2008, at 05:41, Bee wrote:


http://bugs.freepascal.org/view.php?id=10684


Hints? TIA.


I'm currently using a not too elegant workaround to solve this  
problem. With some IFDEFs because the workaround is for FPC only.


There is no support for passing nil as a constant to a procedure of  
object parameter of a cdecl procedure at this time. You can work  
around it by using two overloads (one with a tnotify parameter, one  
without). That should work both in FPC and in Delphi.



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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-03-12 Thread Jonas Maebe


On 12 Mar 2008, at 11:02, Jonas Maebe wrote:


On 12 Mar 2008, at 05:41, Bee wrote:


http://bugs.freepascal.org/view.php?id=10684


Hints? TIA.


I'm currently using a not too elegant workaround to solve this  
problem. With some IFDEFs because the workaround is for FPC only.


There is no support for passing nil as a constant to a procedure of  
object parameter of a cdecl procedure at this time. You can work  
around it by using two overloads (one with a tnotify parameter, one  
without). That should work both in FPC and in Delphi.


Actually, this is more or less the same as what JoshyFun suggested  
earlier.



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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-03-11 Thread Bee

http://bugs.freepascal.org/view.php?id=10684


Hints? TIA.


I'm currently using a not too elegant workaround to solve this problem. 
With some IFDEFs because the workaround is for FPC only.


Nobody seems interested to this bug since there's no response for this 
issue in the mantis. I wonder because IMO it's some kind of basic 
operation for interface. Or aren't there much pascal developers that 
using this technique? Any other better technique for this? TIA.


-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-29 Thread Bee

Did you try such a brute force approach?


Yup, but with no luck. It's very reproducable, see my report at mantis. 
I almost sure that it's about interface things since that it starts the 
problem since the beginning. :(


-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re[2]: [fpc-pascal] problem with interface (OOP not widget)

2008-01-29 Thread JoshyFun
Hello Bee,

Tuesday, January 29, 2008, 7:44:14 AM, you wrote:

 So, may I made a conclusion that this is a bug?

B http://bugs.freepascal.org/view.php?id=10684

B Is there any feasible workaround for this before the bug is fixed? TIA.

I wrote some small changes to your code and the bug only raises when
calling convention is cdecl and optional parameter default value is
set, but mostly related to cdecl and interfaces because as I remove
the cdecl everything seens to compile fine in all situations,
meanwhile removing optional parameter can also rise the bug if I
perform some type conversions brute forced.

To workaround I wrote it in this way, adding a new wrapper function:


function QuerySimple2(const OnChange: TNotifyEvent): ISimple; cdecl;
begin
  Result :=TSimple.Create;
end;

function QuerySimple(const OnChange: TNotifyEvent =nil): ISimple;
begin
  Result :=QuerySimple2(OnChange);
end;


It is not very elegant, I know :)

-- 
Best regards,
 JoshyFunmailto:[EMAIL PROTECTED]

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-29 Thread Giuliano Colla

Bee ha scritto:
Hi Bee, perhaps you could try using {$MODE Delphi} instead of {$MODE 
OBJFPC} since you seem to want Delphi compatibility.


Problem still persists. :(

-Bee-


FWIW. I've met from time to time a Fatal Internal Error with some number 
 which might match yours, in perfectly clean code, which used to 
compile flawlessly (both when building Lazarus, or building my 
applications). It was happening with pfc 2.0.4, it happens now with fpc 
2.2.0. With a given release of Lazarus it happens quite frequently, with 
the next much less frequently, at random. I didn't report it, because I 
was unable to create a reproducible pattern. In my case, just launching 
again the compilation (one or two times) without touching anything else 
fixed the problem. A variable not properly initialized somewhere in fpc? 
I stopped worrying and when the error pops up I just press F9 again, and 
it works.

Did you try such a brute force approach?

Giuliano

--
Giuliano Colla

Whenever people agree with me, I always feel I must be wrong (O. Wilde)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-28 Thread Bee

So, may I made a conclusion that this is a bug?


http://bugs.freepascal.org/view.php?id=10684

Is there any feasible workaround for this before the bug is fixed? TIA.

-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-28 Thread Bee
Hi Bee, perhaps you could try using {$MODE Delphi} instead of {$MODE 
OBJFPC} since you seem to want Delphi compatibility.


Problem still persists. :(

-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-24 Thread Paul Nicholls
Hi Bee, perhaps you could try using {$MODE Delphi} instead of {$MODE OBJFPC}
since you seem to want Delphi compatibility.

cheers,
Paul

On 23/01/2008, Bee [EMAIL PROTECTED] wrote:

 Hi all,

 I got problem with the code below.

 ---8--- begin code ---8---

 program test_intf_query;

 {$IFDEF FPC}
{$MODE OBJFPC}{$H+}
 {$ENDIF}

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

[fpc-pascal] problem with interface (OOP not widget)

2008-01-23 Thread Bee

Hi all,

I got problem with the code below.

---8--- begin code ---8---

program test_intf_query;

{$IFDEF FPC}
  {$MODE OBJFPC}{$H+}
{$ENDIF}

uses
  Classes;

type
  TPLFieldType = (plftUnknown, plftString, plftSmallint, plftInteger,
plftWord, plftBoolean, plftFloat, plftCurrency, plftBCD, plftDate,
plftTime, plftDateTime, plftBytes, plftVarBytes, plftAutoInc,
plftBlob, plftMemo, plftGraphic, plftFmtMemo, plftParadoxOle,
plftDBaseOle, plftTypedBinary, plftCursor, plftFixedChar,
plftWideString, plftLargeint, plftADT, plftArray, plftReference,
plftDataSet, plftOraBlob, plftOraClob, plftVariant, plftInterface,
plftIDispatch, plftGuid, plftTimeStamp, plftFMTBcd,
plftFixedWideChar, plftWideMemo, plftOraTimeStamp, plftOraInterval);

  ISimple = interface
  ['{24811FF3-4F01-4601-AC5C-22A5B5D46928}']
function ShowSomething: Integer; cdecl;
function GetIsBlob: Boolean; cdecl;
  end;

  TSimple = class(TInterfacedObject, ISimple)
  private
FDataType: TPLFieldType;
  protected
{ ISimple implementation }
function ShowSomething: Integer; cdecl;
function GetIsBlob: Boolean; cdecl;
  end;

{ query ISimple }
function QuerySimple(const OnChange: TNotifyEvent = nil): ISimple;
  cdecl;
begin
  Result := TSimple.Create;
end;

{*** TSimple ***}

function TSimple.ShowSomething: Integer; cdecl;
begin
  Writeln('Message from ISimple');
  Result := 0;
end;

function TSimple.GetIsBlob: Boolean; cdecl;
begin
  Result := FDataType in [
plftBytes, plftVarBytes, plftBlob, plftMemo, plftGraphic,
plftFmtMemo, plftParadoxOle, plftDBaseOle, plftTypedBinary,
plftOraClob, plftOraClob, plftWideMemo
];
end;

{*** main program ***}

var
  FSimple: ISimple;

begin
  FSimple := QuerySimple(nil);
  //FSimple := TSimple.Create;

  FSimple.ShowSomething;
end.

---8--- end code ---8---

FPC failed to compile it. The compiler complained with this message:

test_intf_query.pas(56,26) Error: range check error in set constructor 
or duplicate set element


With wonder, I commented line 56. Then the compiler complained with this 
message:


test_intf_query.pas(66,14) Fatal: Internal error 200408162

Weird. So, I commented line 66 and uncommented line 67 (just to make it 
compilable). It compiled fine. But when it's executed, it ended up with 
AV. Here's the output:


[EMAIL PROTECTED]:~/Programs$ ./test_intf_query
Message from ISimple
An unhandled exception occurred at $0804816C :
EAccessViolation : Access violation
  $0804816C

I'm using FPC 2.2.0, 2.2.1, and 2.3.1 on Ubuntu Gutsy i386. I thought it 
was the problem with FPC for Linux, so I tried it with FPC 2.2.0 on 
Windows (on exact machine). But, same errors persist on all FPC versions. :(


IMHO, the above code (before modifications to make it compilable) should 
be fine. I can't see nothing wrong with it. To make sure, I compiled the 
code using Delphi 7 and Turbo Delphi Explorer. Both Delphi compiled fine 
and the executable output run without problem.


The actual program actually much bigger than the above, it's a part of a 
big framework I've been working on. I cut it and made much simpler to 
isolate the problem. FYI, the framework itself initially written using 
Delphi 7 and works well. Now, I'm trying to port it to FPC.


Hints? TIA.

-Bee-

has Bee.ography at:
http://beeography.wordpress.com
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-23 Thread Bee

You have
  plftOraClob, plftOraClob

2 times the same element. This is not allowed.


Arrggg... what a stupid mistake! How can I didn't notice that?! It 
should be plftOraClob, plftOraBlob (clob and blob)! Thank you, Michael! 
Thank you again for the ultra fast response! :-D


-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-23 Thread Bee
Arrggg... what a stupid mistake! How can I didn't notice that?! It 
should be plftOraClob, plftOraBlob (clob and blob)! Thank you, Michael! 
Thank you again for the ultra fast response! :-D


FYI, the fatal internal error still persist. :)

-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-23 Thread Bee
Arrggg... what a stupid mistake! How can I didn't notice that?! It 
should be plftOraClob, plftOraBlob (clob and blob)! Thank you, Michael! 
Thank you again for the ultra fast response! :-D


I must slipped my fingers and eyes during conversion to FPC. I saw the 
code in Delphi doesn't have the mistake. How did I do that? I feel so 
silly. :-D


-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-23 Thread Michael Van Canneyt


On Wed, 23 Jan 2008, Bee wrote:

 Hi all,
 
 I got problem with the code below.
 
 ---8--- begin code ---8---
 
 program test_intf_query;
 
 {$IFDEF FPC}
   {$MODE OBJFPC}{$H+}
 {$ENDIF}
 
 uses
   Classes;
 
 type
   TPLFieldType = (plftUnknown, plftString, plftSmallint, plftInteger,
 plftWord, plftBoolean, plftFloat, plftCurrency, plftBCD, plftDate,
 plftTime, plftDateTime, plftBytes, plftVarBytes, plftAutoInc,
 plftBlob, plftMemo, plftGraphic, plftFmtMemo, plftParadoxOle,
 plftDBaseOle, plftTypedBinary, plftCursor, plftFixedChar,
 plftWideString, plftLargeint, plftADT, plftArray, plftReference,
 plftDataSet, plftOraBlob, plftOraClob, plftVariant, plftInterface,
 plftIDispatch, plftGuid, plftTimeStamp, plftFMTBcd,
 plftFixedWideChar, plftWideMemo, plftOraTimeStamp, plftOraInterval);
 
   ISimple = interface
   ['{24811FF3-4F01-4601-AC5C-22A5B5D46928}']
 function ShowSomething: Integer; cdecl;
 function GetIsBlob: Boolean; cdecl;
   end;
 
   TSimple = class(TInterfacedObject, ISimple)
   private
 FDataType: TPLFieldType;
   protected
 { ISimple implementation }
 function ShowSomething: Integer; cdecl;
 function GetIsBlob: Boolean; cdecl;
   end;
 
 { query ISimple }
 function QuerySimple(const OnChange: TNotifyEvent = nil): ISimple;
   cdecl;
 begin
   Result := TSimple.Create;
 end;
 
 {*** TSimple ***}
 
 function TSimple.ShowSomething: Integer; cdecl;
 begin
   Writeln('Message from ISimple');
   Result := 0;
 end;
 
 function TSimple.GetIsBlob: Boolean; cdecl;
 begin
   Result := FDataType in [
 plftBytes, plftVarBytes, plftBlob, plftMemo, plftGraphic,
 plftFmtMemo, plftParadoxOle, plftDBaseOle, plftTypedBinary,
 plftOraClob, plftOraClob, plftWideMemo
You have
  plftOraClob, plftOraClob

2 times the same element. This is not allowed.

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


Re: [fpc-pascal] problem with interface (OOP not widget)

2008-01-23 Thread Bee
I'm using FPC 2.2.0, 2.2.1, and 2.3.1 on Ubuntu Gutsy i386. I thought it 
was the problem with FPC for Linux, so I tried it with FPC 2.2.0 on 
Windows (on exact machine). But, same errors persist on all FPC 
versions. :(


If it is a bug of FPC, I'll file it to Mantis ASAP. Just to make sure 
it's not my fault in the first place. :-D


-Bee-

has Bee.ography at:
http://beeography.wordpress.com

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