Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Michael Van Canneyt via fpc-devel
On Tue, 16 Aug 2022, Ondrej Pokorny via fpc-devel wrote: Am 16.08.2022 um 13:19 schrieb Michael Van Canneyt via fpc-devel: On Tue, 16 Aug 2022, Ondrej Pokorny via fpc-devel wrote: --- code end Run it in Delphi and FPC and compare the outputs: Delphi output: PropCount: 0 Property info is nu

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Ondrej Pokorny via fpc-devel
Am 16.08.2022 um 13:19 schrieb Michael Van Canneyt via fpc-devel: On Tue, 16 Aug 2022, Ondrej Pokorny via fpc-devel wrote: --- code end Run it in Delphi and FPC and compare the outputs: Delphi output: PropCount: 0 Property info is null FPC output: PropCount: 1 Property name: Fruit Property ki

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Michael Van Canneyt via fpc-devel
On Tue, 16 Aug 2022, Ondrej Pokorny via fpc-devel wrote: --- code end Run it in Delphi and FPC and compare the outputs: Delphi output: PropCount: 0 Property info is null FPC output: PropCount: 1 Property name: Fruit Property kind: tkEnumeration As you can see FPC creates a valid PropInfo

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Ondrej Pokorny via fpc-devel
Am 16.08.2022 um 09:37 schrieb Michael Van Canneyt via fpc-devel: On Tue, 16 Aug 2022, Juha Manninen via fpc-devel wrote: On Thu, Aug 11, 2022 at 9:37 PM Martin Frb via fpc-devel < fpc-devel@lists.freepascal.org> wrote: fpc code is still "unexpected". It takes into account the MinValue type T

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Michael Van Canneyt via fpc-devel
On Tue, 16 Aug 2022, Martin Frb via fpc-devel wrote: On 16/08/2022 09:37, Michael Van Canneyt via fpc-devel wrote: On Tue, 16 Aug 2022, Juha Manninen via fpc-devel wrote: And function GetEnumValue() is buggy. It is not buggy. It does not support enumerateds with gaps, because RTTI does n

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Martin Frb via fpc-devel
On 16/08/2022 09:37, Michael Van Canneyt via fpc-devel wrote: On Tue, 16 Aug 2022, Juha Manninen via fpc-devel wrote: And function GetEnumValue() is buggy. It is not buggy. It does not support enumerateds with gaps, because RTTI does not support enumerateds with gaps. It never has. ...  

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-16 Thread Michael Van Canneyt via fpc-devel
On Tue, 16 Aug 2022, Juha Manninen via fpc-devel wrote: On Thu, Aug 11, 2022 at 9:37 PM Martin Frb via fpc-devel < fpc-devel@lists.freepascal.org> wrote: fpc code is still "unexpected". It takes into account the MinValue type TMyEnum = (a=5, b=7); GetEnumName(pt, 5) // a GetEnumName(pt, 6

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-15 Thread Juha Manninen via fpc-devel
On Thu, Aug 11, 2022 at 9:37 PM Martin Frb via fpc-devel < fpc-devel@lists.freepascal.org> wrote: > fpc code is still "unexpected". > It takes into account the MinValue > > type TMyEnum = (a=5, b=7); > > GetEnumName(pt, 5) // a > GetEnumName(pt, 6) // b // should be 7 > > if it is just the nth nam

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-11 Thread Martin Frb via fpc-devel
On 11/08/2022 18:11, Juha Manninen via fpc-devel wrote: The MaxValue is used in many places for enum and set properties while GetEnumNameCount() is not used anywhere. There are other similar bugs. At least these 2 in propedits.pp look fishy: - procedure TSetPropertyEditor.GetProperties CompType

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-11 Thread Juha Manninen via fpc-devel
On Thu, Aug 11, 2022 at 4:44 PM Martin Frb via fpc-devel < fpc-devel@lists.freepascal.org> wrote: > Because you are not supposed to use MaxValue > Instead use GetEnumNameCount > > for I := MinValue to MinValue + GetEnumNameCount(...) - 1 do begin > > The unit name is returned because the Typ

Re: [fpc-devel] Gaps in a non-contiguous enum

2022-08-11 Thread Martin Frb via fpc-devel
On 11/08/2022 13:38, Juha Manninen via fpc-devel wrote:       // An empty string and the enum's unit name happen in gaps       // of a non-contiguous enum. Why the unit name? A bug in FPC code?   with GetTypeData(EnumType)^ do     for I := MinValue to MaxValue do begin       s := GetEnumName(Enu

[fpc-devel] Gaps in a non-contiguous enum

2022-08-11 Thread Juha Manninen via fpc-devel
I was able to fix issue https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39832 about TEnumPropertyEditor in Lazarus IdeIntf. Explanation: function GetEnumName() in FPC's rtl/objpas/typinfo.pp returns the enum's unit name for one gap in a non-contiguous enum, and an empty string for the o