Re: [fpc-pascal] Multiple enumerators per class

2011-09-16 Thread Paul Ishenin

16.09.2011 5:37, Mattias Gaertner wrote:

Hi all,

I found the Wiki page about the new for-in loop and found a
misinformation. It stated wrongly that it is not possible to
have multiple enumerators per class. It even gave a proposal
for a new feature that did not add anything new.

I added an example how to add a second enumerator to a class:

http://wiki.freepascal.org/for-in_loop#Multiple_enumerators_for_one_class

IMO the proposal was misleading so I deleted it. I hope this is
ok. If not, I will restore it.
The idea was to have multiple enumerators without creating a dummy class 
for each new.


Best regards,
Paul Ishenin.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Marcos Douglas
On Fri, Sep 16, 2011 at 4:46 AM, Graeme Geldenhuys
 wrote:
> You're original problem is exactly why I said mixing class instances and
> interface instance is looking for trouble. You better know what you are
> doing.
>
> Attached are two examples of your program. One using CORBA interfaces,
> the other using non-reference counting COM style interface. Both work
> under 64-bit FPC 2.4.5 under Linux.

Thanks, but...
The testme.pas has the TNonRefCountedObject class, but it isn't used.
Both has the {$interfaces corba} directive.

Anyway, corba interfaces looks like solve my "problem" but I did more
tests, using corba:
1- If I change the Run procedure (see comments), how I release [f] variable?
procedure Run;
var
  f: IFoo;  // <<< now is an interface
  o: TObj;
begin
  f := TFoo.Create;
  //f.SetInfo('foo');  // do not exists in IFoo, but OK
  o := TObj.Create;
  o.Foo := f;
  writeln(o.Foo.GetInfo);
  o.Free;
  //f.Free  // <<< how I release this?
end;

I.e. this is the inverse of COM interfaces -- inverse of my problem
too -- because I just could instantiate variables of concrete classes
and not variables of type interface.
Maybe the union of both... or Am I saying a nonsense?

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


Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Marcos Douglas
On Fri, Sep 16, 2011 at 5:26 AM, Jonas Maebe  wrote:
>
> That is incorrect. Several things have been fixed regarding the "implements"
> functionality in 2.5.x, but the basics already worked in 2.4.4. The example
> works fine when compiled with 2.4.4

Exactly (I did not see your affirmation before my other mail).

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


Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Marcos Douglas
On Fri, Sep 16, 2011 at 4:02 AM, Graeme Geldenhuys
 wrote:
> On 15/09/2011 17:12, Felipe Monteiro de Carvalho wrote:
>>
>> http://wiki.lazarus.freepascal.org/How_To_Use_Interfaces_to_write_less_code
>
> Should that example not mention that it will not work with any released
> FPC version to date?  That example will only work with the "still to be
> released" 2.6.0 and later. Why Because current released FPC versions
> don't support the 'implements' functionality in classes - it was only
> added in FPC 2.5.1 (old trunk).

I compiled the code using FPC 2.4.3.

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


Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Jonas Maebe


On 16 Sep 2011, at 09:02, Graeme Geldenhuys wrote:

Should that example not mention that it will not work with any  
released

FPC version to date?


No.


That example will only work with the "still to be
released" 2.6.0 and later. Why Because current released FPC versions
don't support the 'implements' functionality in classes - it was only
added in FPC 2.5.1 (old trunk).


That is incorrect. Several things have been fixed regarding the  
"implements" functionality in 2.5.x, but the basics already worked in  
2.4.4. The example works fine when compiled with 2.4.4



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


Re: [fpc-pascal] [Patch] New tests for fcl-db export

2011-09-16 Thread michael . vancanneyt



On Fri, 16 Sep 2011, Reinier Olislagers wrote:


Hi list,

FYI & hopefully implementation:

I've been writing some tests for fcl-db export, that test basic
functionality for:
- CSV export
- DBF export
- SimpleXML export

Please find them in Mantis:
20271   [Patch] SimpleXML export: new test for fcl-db

20268   [Patch] CSV export: new test for fcl-db

20163   [Patch] Dbase export: new test for fcl-db
(reopened, contains fixes suggested by Michael Van Canneyt)


They're all set up in a similar way: create a bufdataset with all the
field types I can cram in, fill them with some rows of extreme and
middle-of-the-road data and try an export.
For e.g. simple xml and csv export, default export formatting settings
as well as custom format settings are tested.

In future, they could be extended a bit (e.g. test reading generated csv
into a stringlist, reading dbf etc).

I do realise these tests could be combined in a big export test, but it
might be an even better idea to incorporate it in the existing
dbtestframework.

However, understanding how to work the db testframework to do the export
tests for a large amount of different data in the datasets is a bit
above the combination of (my skills+my interest in figuring it out), so
in the meanwhile my motto is: a test (or 2) is better than no test.

Also, if somebody would be willing to look at my pet patches:
19759 CSV export doesn't quote memo fields
19937 TSQLExporter does not quote memo fields (or blobs)


I'll have a look at all patches later today.

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


Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Graeme Geldenhuys
You're original problem is exactly why I said mixing class instances and
interface instance is looking for trouble. You better know what you are
doing.

Attached are two examples of your program. One using CORBA interfaces,
the other using non-reference counting COM style interface. Both work
under 64-bit FPC 2.4.5 under Linux.


[tmp]$ ./testme
foo
Done
Heap dump by heaptrc unit
20 memory blocks allocated : 599/616
20 memory blocks freed : 599/616
0 unfreed memory blocks : 0
True heap size : 131072
True free heap : 131072


[tmp]$ ./testme_corba
foo
Done
Heap dump by heaptrc unit
20 memory blocks allocated : 599/616
20 memory blocks freed : 599/616
0 unfreed memory blocks : 0
True heap size : 131072
True free heap : 131072




Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

program testme;

{$mode objfpc}{$H+}
{$interfaces corba}

uses  heaptrc,  Classes,  SysUtils;

type
  IFoo = interface
['{F71A4131-E0A5-48CB-B563-7BBB079D1085}']
function GetInfo: string;
  end;
  
  TNonRefCountedObject = class(TObject, IInterface)
  private
function QueryInterface(const iid : tguid;out obj) : longint;stdcall;
function _AddRef : longint;stdcall;
function _Release : longint;stdcall;
  end;

  TFoo = class(TObject, IFoo)
  private
FInfo: string;
  protected
  public
function GetInfo: string;
procedure SetInfo(const AValue: string);
  end;

function TFoo.GetInfo: string;
begin
  Result := FInfo;
end;

procedure TFoo.SetInfo(const AValue: string);
begin
  FInfo := AValue;
end;

type
  TObj = class(TObject)
  public
Foo: IFoo;
  end;


{ TNonRefCountedObject }

function TNonRefCountedObject.QueryInterface(const iid : tguid;out obj) : longint;stdcall;
begin
  if GetInterface(IID, Obj) then
Result := S_OK
  else
Result := E_NOINTERFACE;
end;

function TNonRefCountedObject._AddRef: longint; stdcall;
begin
  Result := -1;
end;

function TNonRefCountedObject._Release: longint; stdcall;
begin
  Result := -1;
end;



procedure Run;
var
  f: TFoo;  // << type is class, not interface
  o: TObj;
begin
  f := TFoo.Create;
  f.SetInfo('foo');
  o := TObj.Create;
  o.Foo := f;
  writeln(o.Foo.GetInfo);
  o.Free;
  f.Free;
end;

begin
  Run;
  writeln('Done');
end.
program testme_corba;

{$mode objfpc}{$H+}
{$interfaces corba}

uses  heaptrc,  Classes,  SysUtils;

type
  IFoo = interface
['{F71A4131-E0A5-48CB-B563-7BBB079D1085}']
function GetInfo: string;
  end;

  TFoo = class(TObject, IFoo)
  private
FInfo: string;
  protected
  public
function GetInfo: string;
procedure SetInfo(const AValue: string);
  end;

function TFoo.GetInfo: string;
begin
  Result := FInfo;
end;

procedure TFoo.SetInfo(const AValue: string);
begin
  FInfo := AValue;
end;

type
  TObj = class(TObject)
  public
Foo: IFoo;
  end;

procedure Run;
var
  f: TFoo;  // << type is class, not interface
  o: TObj;
begin
  f := TFoo.Create;
  f.SetInfo('foo');
  o := TObj.Create;
  o.Foo := f;
  writeln(o.Foo.GetInfo);
  o.Free;
  f.Free;
end;

begin
  Run;
  writeln('Done');
end.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Graeme Geldenhuys
On 15/09/2011 16:54, Marcos Douglas wrote:
> 
> Well, wrong just because the language is so but not because is ilogical, 
> right?

Unless you are well versed with interfaces, I would not go there. Mixing
object references and interface references (especially if reference
counting is enabled) - you are bound to run into trouble.


> Hm... interesting but what are the advantages?

None of the Windows'ism like COM's IUnknown, or Delphi's IInterface
(alias to IUnknown) on any non-Windows platforms.


> I want my code compiling in Delphi 7 too, so I can have problems with this?

Then stick with Delphi (Windows COM style) interfaces. I don't believe
Delphi support any other style of interface (eg: CORBA, XPCOM etc).


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

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


[fpc-pascal] [Patch] New tests for fcl-db export

2011-09-16 Thread Reinier Olislagers
Hi list,

FYI & hopefully implementation:

I've been writing some tests for fcl-db export, that test basic
functionality for:
- CSV export
- DBF export
- SimpleXML export

Please find them in Mantis:
20271   [Patch] SimpleXML export: new test for fcl-db

20268   [Patch] CSV export: new test for fcl-db

20163   [Patch] Dbase export: new test for fcl-db
(reopened, contains fixes suggested by Michael Van Canneyt)


They're all set up in a similar way: create a bufdataset with all the
field types I can cram in, fill them with some rows of extreme and
middle-of-the-road data and try an export.
For e.g. simple xml and csv export, default export formatting settings
as well as custom format settings are tested.

In future, they could be extended a bit (e.g. test reading generated csv
into a stringlist, reading dbf etc).

I do realise these tests could be combined in a big export test, but it
might be an even better idea to incorporate it in the existing
dbtestframework.

However, understanding how to work the db testframework to do the export
tests for a large amount of different data in the datasets is a bit
above the combination of (my skills+my interest in figuring it out), so
in the meanwhile my motto is: a test (or 2) is better than no test.

Also, if somebody would be willing to look at my pet patches:
19759 CSV export doesn't quote memo fields
19937 TSQLExporter does not quote memo fields (or blobs)

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


Re: [fpc-pascal] Interface, _AddRef, _Release, etc.

2011-09-16 Thread Graeme Geldenhuys
On 15/09/2011 17:12, Felipe Monteiro de Carvalho wrote:
> 
> http://wiki.lazarus.freepascal.org/How_To_Use_Interfaces_to_write_less_code

Should that example not mention that it will not work with any released
FPC version to date?  That example will only work with the "still to be
released" 2.6.0 and later. Why Because current released FPC versions
don't support the 'implements' functionality in classes - it was only
added in FPC 2.5.1 (old trunk).


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

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