Re: [fpc-pascal] Enum property can't be published
> On Sep 27, 2022, at 5:31 PM, Ondrej Pokorny via fpc-pascal > wrote: > > published > property MyEnumOrd: Integer read GetMyEnumOrd write SetEnumOrd; // > gets/sets MyEnum as ordinal value Yeah I guess that work also albeit with some boiler plate. Thanks. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Enum property can't be published
> On Sep 27, 2022, at 5:19 PM, Pierre Muller via fpc-pascal > wrote: > > TDiagnosticSeverity = ( NoError { will be 0}, > Error {will stay equal to 1}, > Warning {will stay equal to 2}, > Information {will stay equal to 3}, > Hint {will stay equal to 4} > ); > > > Not a general solution, but a very simple one in that specific case! I like that actually, thanks. There’s a number of these 1 indexed enums but I think this trick will work in most cases. I know some languages have the convention where you can set just the first index of the first value to set the indexing. That would be a good feature to add to Pascal so we can still publish the enums safely for APIs that have 1 indexing. TDiagnosticSeverity = ( Error = 1, Warning, Information, Hint ); Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Enum property can't be published
Am 27.09.2022 um 11:22 schrieb Hairy Pixels via fpc-pascal: On Sep 27, 2022, at 4:17 PM, Marco van de Voort via fpc-pascal wrote: 3.2.2 compiles without warnings, 3.3.1 (i386-win32 from 17 sept:) ptt.pp(14,44) Warning: This property will not be published Possibly enums with assigned values (which can have gaps) are not safe to publish, and this was only now noted? I must have missed that. What’s a good solution here? It looks like the code needs these enums to be 1 indexed, otherwise they are all in order with no gaps. If I could publish those and just do a +1 first that would work. Publishing enums with gaps didn't work in 3.2.2, even if they compiled. This bug has been fixed. I can think of these 2 solutions: 1.) Add "unused" enum values to the enum: TMyEnum = (meOne = 1, meTwo, meThree, meFive = 5); will become: TMyEnum = (meUnused1, meOne, meTwo, meThree, meUnused2, meFive); 2.) publish their ordinal value public property MyEnum: TMyEnum read FMyEnum write FMyEnum; published property MyEnumOrd: Integer read GetMyEnumOrd write SetEnumOrd; // gets/sets MyEnum as ordinal value Ondrej ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Enum property can't be published
Le 27/09/2022 à 11:22, Hairy Pixels via fpc-pascal a écrit : On Sep 27, 2022, at 4:17 PM, Marco van de Voort via fpc-pascal wrote: 3.2.2 compiles without warnings, 3.3.1 (i386-win32 from 17 sept:) ptt.pp(14,44) Warning: This property will not be published Possibly enums with assigned values (which can have gaps) are not safe to publish, and this was only now noted? I must have missed that. What’s a good solution here? It looks like the code needs these enums to be 1 indexed, otherwise they are all in order with no gaps. If I could publish those and just do a +1 first that would work. Wouldn't adding NoError in front of the enum work for this case? You don't need the explicit values, and their would not change! TDiagnosticSeverity = ( NoError { will be 0}, Error {will stay equal to 1}, Warning {will stay equal to 2}, Information {will stay equal to 3}, Hint {will stay equal to 4} ); Not a general solution, but a very simple one in that specific case! Pierre ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Enum property can't be published
> On Sep 27, 2022, at 4:17 PM, Marco van de Voort via fpc-pascal > wrote: > > 3.2.2 compiles without warnings, 3.3.1 (i386-win32 from 17 sept:) > > ptt.pp(14,44) Warning: This property will not be published > > Possibly enums with assigned values (which can have gaps) are not safe to > publish, and this was only now noted? I must have missed that. What’s a good solution here? It looks like the code needs these enums to be 1 indexed, otherwise they are all in order with no gaps. If I could publish those and just do a +1 first that would work. Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Enum property can't be published
On 27-9-2022 11:14, Hairy Pixels via fpc-pascal wrote: I just tried to build a lazarus project using 3.3.1/ppca64 and I’m getting an error that an enum can’t be published. This was working on 3.2.2/ppcx64 so what changed? === lazbuild ./pasls.lpi --widgetset=cocoa --compiler=/usr/local/lib/fpc/3.3.1/ppca64 --cpu=aarch64 Free Pascal Compiler version 3.3.1 [2022/09/15] for aarch64 Copyright (c) 1993-2022 by Florian Klaempfl and others (1002) Target OS: Darwin for AArch64 === TDiagnosticSeverity = ( Error = 1, Warning = 2, Information = 3, Hint = 4 ); TDiagnostic = class (TCollectionItem) private fSeverity: TDiagnosticSeverity; published property severity: TDiagnosticSeverity read fSeverity write fSeverity; // error: (3134) This kind of property cannot be published 3.2.2 compiles without warnings, 3.3.1 (i386-win32 from 17 sept:) ptt.pp(14,44) Warning: This property will not be published Possibly enums with assigned values (which can have gaps) are not safe to publish, and this was only now noted? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Enum property can't be published
I just tried to build a lazarus project using 3.3.1/ppca64 and I’m getting an error that an enum can’t be published. This was working on 3.2.2/ppcx64 so what changed? === lazbuild ./pasls.lpi --widgetset=cocoa --compiler=/usr/local/lib/fpc/3.3.1/ppca64 --cpu=aarch64 Free Pascal Compiler version 3.3.1 [2022/09/15] for aarch64 Copyright (c) 1993-2022 by Florian Klaempfl and others (1002) Target OS: Darwin for AArch64 === TDiagnosticSeverity = ( Error = 1, Warning = 2, Information = 3, Hint = 4 ); TDiagnostic = class (TCollectionItem) private fSeverity: TDiagnosticSeverity; published property severity: TDiagnosticSeverity read fSeverity write fSeverity; // error: (3134) This kind of property cannot be published Regards, Ryan Joseph ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal