Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-16 Thread Stephane Carre

Hello Michael,
In the current stable release (fpc 2.4.4) the unit tests for fpjsonrtti 
fail to compile because unit testcomps is missing.
I believe this is the unit with the test classes used for the destreamer 
tests.

Where can I find this unit ?
Thanks for this !
Regards,
Stephane Carre

On 06/01/2011 00:12, Michael Van Canneyt wrote:

Hello,

For those of you that need JSON support:

I have committed support for streaming published properties 
(properties for which RTTI  is generated) from objects to JSON and 
vice versa, in a unit fpjsonrtti.


Not the full streaming as implemented in the classes system is supported:
- No DefineProperties.
- No methods.
Although it should not be difficult to add support for this.

In contrast, it can stream simple collections and stringlists (with 
ojects attached) in various ways.

There are various events to influence the streaming process.
This should be more than enough to stream objects to and from a 
web-browser.


I have committed an example and a testsuite.
All this is in packages/fcl-json.

Despite the fact that the testsuite runs OK , I'd like to ask those 
for whom it might be useful to test the code and report any errors you 
find to me. Suggestions for improvements are also welcome.


Michael.
___
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


Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Stephane Carre

Hello Michael,
I have not received any e-mail with the testcomps unit.
Can you please make sure you send it to me ?
Thanks for your time !
Regards,
Stephane Carre

On 17/11/2011 09:16, michael.vancann...@wisa.be wrote:



On Wed, 16 Nov 2011, Stephane Carre wrote:


Hello Michael,
In the current stable release (fpc 2.4.4) the unit tests for 
fpjsonrtti fail to compile because unit testcomps is missing.
I believe this is the unit with the test classes used for the 
destreamer tests.

Where can I find this unit ?


I probably forgot to commit it. I will send it to you tonight.

Michael.


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


Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Stephane Carre

Thank you Michael.
I checked before in the fpc source 2.4.4 download available from 
sourceforge, but could not find testcomps anywhere.
The version you attached does not contain TVariantComponent. Is that a 
newer, or older version than the one that should match fpc 2.4.4 ? 
Otherwise I guess I can adapt the missing pieces.

Best regards,
Stephane

On 18/11/2011 13:17, Michael Van Canneyt wrote:


It is attached.

It is committed, but probably not where you expected it :-)

Michael.


On Fri, 18 Nov 2011, Stephane Carre wrote:


Hello Michael,
I have not received any e-mail with the testcomps unit.
Can you please make sure you send it to me ?
Thanks for your time !
Regards,
Stephane Carre

On 17/11/2011 09:16, michael.vancann...@wisa.be wrote:



On Wed, 16 Nov 2011, Stephane Carre wrote:


Hello Michael,
In the current stable release (fpc 2.4.4) the unit tests for 
fpjsonrtti fail to compile because unit testcomps is missing.
I believe this is the unit with the test classes used for the 
destreamer tests.

Where can I find this unit ?


I probably forgot to commit it. I will send it to you tonight.

Michael.


___
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


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

Re: [fpc-pascal] JSON - RTTI streaming.

2011-11-18 Thread Stephane Carre

Hello Michael,
Finally, I also found the original testcomps.pp file in the sources (and 
at the sime time I discovered a limitation of the Windows 7 file search 
tool, which was why I did not find the file before).

As indicated below, the version that comes with the sources is not complete.
I modified testcomps.pp so that the tests fully compile with the stable 
fpc 2.4.4 version.

It is attached here, I hope it helps.
Thank you for this json library !
Best regards,
Stephane

On 18/11/2011 15:30, Stephane Carre wrote:

Thank you Michael.
I checked before in the fpc source 2.4.4 download available from 
sourceforge, but could not find testcomps anywhere.
The version you attached does not contain TVariantComponent. Is that a 
newer, or older version than the one that should match fpc 2.4.4 ? 
Otherwise I guess I can adapt the missing pieces.

Best regards,
Stephane

On 18/11/2011 13:17, Michael Van Canneyt wrote:


It is attached.

It is committed, but probably not where you expected it :-)

Michael.




unit testcomps;

interface

uses classes, sysutils;

Type

  TEmptyPersistent = class(TPersistent);

  TBooleanComponent = class(TComponent)
  private
FBooleanProp: boolean;
  published
property BooleanProp: boolean read FBooleanProp write FBooleanProp;
  end;

  TVariantComponent = class(TComponent)
  private
FVariantProp: variant;
  published
property VariantProp: variant read FVariantProp write FVariantProp;
  end;

  TStringsComponent = class(TComponent)
  private
FStringsProp: TStrings;
  Public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
  Published
Property StringsProp : TStrings Read FStringsProp Write FStringsProp;
  end;

  TEmptyComponent = Class(TComponent)
  end;

  // Simple integer, fits in 1 byte
  TIntegerComponent = Class(TComponent)
  private
FIntProp: Integer;
  Public
Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, fits in 2 bytes
  TIntegerComponent2 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, fits in 3 bytes
  TIntegerComponent3 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp;
  end;

  // Simple integer, Default value. (set)
  TIntegerComponent4 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp default 6;
  end;

  // Simple integer, Default value. (not set)
  TIntegerComponent5 = Class(TComponent)
  private
FIntProp: Integer;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property IntProp : Integer Read FIntProp Write FIntProp default 6;
  end;

  // Simple Int64 property fits in a single byte.
  TInt64Component = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 2 bytes.
  TInt64Component2 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 3 bytes.
  TInt64Component3 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Simple Int64 property fits 4 bytes.
  TInt64Component4 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp;
  end;

  // Int64 property with default, set.
  TInt64Component5 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp default 7;
  end;

  // Int64 property with default, not set.
  TInt64Component6 = Class(TComponent)
  private
FIntProp: Int64;
  Public
 Constructor Create(AOwner : TComponent); override;
  Published
Property Int64Prop : Int64 Read FIntProp Write FIntProp default 7;
  end;

  // String property.
  TStringComponent = Class(TComponent)
  private
F: String;
  Public
Constructor Create(AOwner : TComponent);  override;
  Published
Property StringProp : String Read F Write F;
  end;

  // String property, empty
  TStringComponent2 = Class(TComponent)
  private
F: String;
  Published
Property