Is there any way to get RTTI hints for a real48 and shortstring variable in a structure where FieldType is nil in TRttiField?

I have discovered what I think is an odd oversight (probably intentional) on the part of the Extended RTTI feature in Delphi.

I would like to dump all the fields in an record type that has about 1500 different fields in it. Yes, seriously.

Some of them are of type real48 and some are shortstring, for those two, it appears that FieldType is nil for these types at runtime:

function TRttiField.GetValue(Instance: Pointer): TValue; 
var
  ft: TRttiType;
begin
  ft := FieldType;
  if ft = nil then
    raise InsufficientRtti; // This fires!
  TValue.Make(PByte(Instance) + Offset, ft.Handle, Result);
end;

If I was willing to assume that all nil-fieldtype fields are in fact real48's, I could simply use the offset and (if the field width is 6) grab a real48 value.

However the second complication is that all shortstring (ie string[30]) types are similarly afflicted.

Has anybody got these two Ancient Pascal Types to work with modern Extended RTTI? Right now I'm using a best-guess approach, and where that fails I am hardcoding rules by name of the field, but if there was some technique I could use that would get me there without having to write a lot of code to extract information from all these old pascal file-of-records that I am modernizing, I would appreciate a better idea.

Answers


Unfortunately Real48 does not have any type info.

You can see that when you try compile this:

program Project1;

begin
  TypeInfo(Real48);
end.

The same goes for the string[n] syntax. But there you could probably fix it by defining your own string types like:

type
  string30 = string[30];

That alone would not include the rtti for the record field so you need to hack/fix the rtti as I showed here: http://stackoverflow.com/a/12687747/587106


Need Your Help

Is having many render partial functions bad?

c# asp.net asp.net-mvc

I am trying to design my render partial. within one render partial i have 30 other render partial functions. I am rendering one item at a time. for example, I am going to put these items in their

Mysql delete query using more than one condition in PHP

php mysql delete-row

I want to delete data from table (PHP + Mysql), with three conditions. I tried both 'AND' and ',' but don't work.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.