#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,240
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.

Online

Board footer

Powered by FluxBB