Sign in Join

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

Mailing lists / lazarus / 2010-05

too many TXMLConfigs! (att: fcl-xml package maintainers)

9 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

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

dmitry boyarintsev

Hello Developers

I'm a bit puzzled there're 2 units in fpc-xml: xmlcfg and xmlconfg

Both of them declare TXMLConfig class. The interfaces of both classes seems to be quite identical.

If one of them is up-kept for backward compatibility, shouldn't it be like:

[code]
unit

  xmlcfg;
uses
  xmlconfig;
type
  TXMLConfig = class(xmlconfig.TXMLConfig);
[/code]
or vice versa?!

LCL also provides its own TXMLConfig at Laz_XMLCfg (with the same interface).

I'm pretty sure that compiler is not smart enough to smart-link away (similar) classes :)
So I guess, there's alway a risk of duplicating code (3 times, by using 3 different TXMLConfigs).

So, what unit should an IDE extension and/or LCL components use?

xmlconf: is used by LazReport
xmlcfg: is used by Grids, XMLPropStorage and the packager (RegisterFCL.pas, but not sure why)
Laz_XMLCfg: is used by LazarusIDE, CodeTools, packager (!!) and fpdoceditor

thanks,
dmitry

Reply by email

Sergei Gorelkin
to dmitry boyarintsev
dmitry boyarintsev wrote
Hello Developers I'm a bit puzzled there're 2 units in fpc-xml: xmlcfg and xmlconfg

xmlconf is the actual one. xmlcfg is unable to properly handle non-ascii data. Maybe it's a good idea to declare it deprecated by now.

Both of them declare TXMLConfig class. The interfaces of both classes seems to be quite identical.

They are mostly identical, so that transition can be generally done simply by replacing the unit name in uses clause.

Show quoted text 13 lines
If one of them is up-kept for backward compatibility, shouldn't it be like: [code] unit xmlcfg; uses xmlconfig; type TXMLConfig = class(xmlconfig.TXMLConfig); [/code] or vice versa?!

To avoid pulling legacy workarounds into new code, abd be able to read the already existing data at the same time, the choice was made to leave the old unit as is and write a new one.

Show quoted text 9 lines
LCL also provides its own TXMLConfig at Laz_XMLCfg (with the same interface). I'm pretty sure that compiler is not smart enough to smart-link away (similar) classes :) So I guess, there's alway a risk of duplicating code (3 times, by using 3 different TXMLConfigs). So, what unit should an IDE extension and/or LCL components use?

Unit that will get compiled into user's programs should use xmlconf. IDE components typically use laz_xmlcfg.

xmlconf: is used by LazReport

- LazReport had faced issues with Unicode in the meantime, so it switched over.

xmlcfg: is used by Grids, XMLPropStorage and the packager (RegisterFCL.pas, but not sure why)

- The rest didn't.

Laz_XMLCfg: is used by LazarusIDE, CodeTools, packager (!!) and fpdoceditor

Regards,
Sergei

Reply by email

patspiper
to dmitry boyarintsev: Hello Developers I'm a bit puzzled there're 2 units in fpc-xml: xmlcfg and xmlconfg Both…
dmitry boyarintsev wrote 5 lines
I'm a bit puzzled there're 2 units in fpc-xml: xmlcfg and xmlconfg Both of them declare TXMLConfig class. The interfaces of both classes seems to be quite identical.

<snip>

LCL also provides its own TXMLConfig at Laz_XMLCfg (with the same interface).

<snip>xmlconf: is used by LazReport

xmlcfg: is used by Grids, XMLPropStorage and the packager (RegisterFCL.pas, but not sure why) Laz_XMLCfg: is used by LazarusIDE, CodeTools, packager (!!) and fpdoceditor

Add to the list TConfigStorage in LazConfigStorage

Reply by email

dmitry boyarintsev
to Felipe Monteiro de Carvalho

Thanks Sergei for the explanation.

Felipe Monteiro de Carvalho wrote
Shouldn't this thread be on fpc-devel?

Yes and no. I was interested about what to use for LCL development. Also "attn" at the subject also denotes to fpc-devel :) and Sergei has answered.

And also, I would recommend removing the obsolete unit completely.

I must agree that marking the unit as "deprecated" should be enough. It won't break the existing code using the old file, but would also notify maintainers that they should update.

thanks,
dmitry

Reply by email

Hans-Peter Diettrich
to dmitry boyarintsev
Show quoted text 5 lines
> And also, I would recommend removing the obsolete unit completely. I must agree that marking the unit as "deprecated" should be enough. It won't break the existing code using the old file, but would also notify maintainers that they should update.

I'd move such units into a "museum" place, apart from trunk. The museum can be downloaded separately, and an organization into packages may simplifiy the maintenance of legacy code.

DoDi

Reply by email

Marco van de Voort
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 9 lines
dmitry boyarintsev schrieb: > I must agree that marking the unit as "deprecated" should be enough. > It won't break the existing code using the old file, but would also > notify maintainers that they should update. I'd move such units into a "museum" place, apart from trunk. The museum can be downloaded separately, and an organization into packages may simplifiy the maintenance of legacy code.

The rules are like this:

First deprecate them (or clearly say so in the release manifest).

Then do a full release cycle with the sources left in, but not compiled into the releases. (e.g. rtl/linux/oldlinux.pp is now getting that treatment)

Third, remove it, and either throw it away, or move it to some other repository.

Reply by email

Mattias Gaertner
to patspiper: <snip> <snip>xmlconf: is used by LazReport Add to the list TConfigStorage in…
Show quoted text 7 lines
On 05/29/2010 09:35 AM, dmitry boyarintsev wrote: > I'm a bit puzzled there're 2 units in fpc-xml: xmlcfg and xmlconfg > > Both of them declare TXMLConfig class. The interfaces of both classes > seems to be quite identical. <snip> > LCL also provides its own TXMLConfig at Laz_XMLCfg (with the same interface).

Yes. Although there were some recent additions to the laz_xmlcfg that might be interesting for the fcl.

They use different xml units. The laz_ units were copied from the fcl and changed to UTF8 for internal processing for speed reasons. This was some years ago and the FCL units were optimized and extended to parse more stuff. Two weeks ago I copied them again and changed them to UTF8. They are named laz2_ and not yet used, because I discovered an incompatibility for xmlconfig and special characters. This needs to be fixed.

<snip>xmlconf: is used by LazReport > xmlcfg: is used by Grids, XMLPropStorage and the packager > (RegisterFCL.pas, but not sure why) > Laz_XMLCfg: is used by LazarusIDE, CodeTools, packager (!!) and fpdoceditor

Note: The IDE fpdoc editor does not use laz_xmlcfg, but the underlying xml units (laz_dom, laz_xmlread).
The FPDoc editor "lazde" uses the FCL xml.

Add to the list TConfigStorage in LazConfigStorage

That uses the FCL xml.

Mattias

Reply by email

Jesus Reyes
to dmitry boyarintsev: Hello Developers I'm a bit puzzled there're 2 units in fpc-xml: xmlcfg and xmlconfg Both…

--- El s?b 29-may-10, dmitry boyarintsev escribi?:

Show quoted text 13 lines
So, what unit should an IDE extension and/or LCL components use? xmlconf: is used by LazReport xmlcfg: is used by Grids, XMLPropStorage and the packager (RegisterFCL.pas, but not sure why) Laz_XMLCfg: is used by LazarusIDE, CodeTools, packager (!!) and fpdoceditor thanks, dmitry

The grid now uses XMLConf.

For Users that may result affected by this change here are two ways to fix the problem:

1) manually editing the file in a text editor and by search & replace the old UTF8 string by the new correct UTF8 string. ej: 'Espa??ol' (Espa????ol if viewed in ansi editor) -> 'Espa?ol'.

2) Open grids.pas and change the line from

9257:          Cells[i,j]:=UTF8Encode(cfg.GetValue('grid/content/cells/cell'+IntToStr(k)+'/text',''));
to
9257:          Cells[i,j]:=cfg.GetValue('grid/content/cells/cell'+IntToStr(k)+'/text','');

Then recompile LCL and the affected apps, load your files and save them in the new format. After the changes restore line 9257 and recompile LCL and your apps.

Jesus Reyes A.

Reply by email