#1 2019-12-18 20:21:01

emaxx
Member
Registered: 2014-07-03
Posts: 18

TEnumType.SizeInStorageAsSet limited

In our interfaces we are using types kind of "set of TMyEnumeration". Is it possible allow enumerations with more than 32 members in it?

Unfortunatly in such cases an exception is thrown at TInterfaceFactory.Create method.

EInterfaceFactoryException: TInterfaceFactoryRTTI.Create: TMyImplementation set invalid SizeInStorage=0 in IMyInterface.MyMethod method AMyEnum parameter

Some workouround would help:

function TEnumType.SizeInStorageAsSet: Integer;
begin
  case MaxValue of
  0..7:   result := 1;
  8..15:  result := 2;
  16..31: result := 4;
  32..63: result := 8;  // <--- added
  else    result := 0;
  end;
end;

Is there a reason for limiting? We are using Delphi 10.3 Update 1.

Thanks in advance.

Offline

#2 2019-12-18 20:56:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TEnumType.SizeInStorageAsSet limited

IIRC the serialization may use a PtrInt integer for serialization as number.
So I guess your modification may not work as expected for Win32 target.

I will check tomorrow what is the code state about it.

Offline

#3 2024-09-26 09:18:11

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 90

Re: TEnumType.SizeInStorageAsSet limited

Hi,

we also got into trouble because of limitation to 32 members.
Is it ok to expand to 8 ?


thank you

Offline

#4 2024-09-26 12:05:51

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: TEnumType.SizeInStorageAsSet limited

Please try https://synopse.info/fossil/info/d033ec7dee
I guess it is OK: our code seems to use Int64 values, not PtrInt values.

Note that mORMot 2 has no such limitation.
Perhaps time to switch. wink

Offline

Board footer

Powered by FluxBB