Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2007-09

defining record at runtime

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi,

would it be possible to set up a memory structure according to fpc's aligning rules that will be accepted as a record typed variable? Or does fpc create some informational support items that would miss in this case?

I'm in doubt, since it is normally not possible (AFAIK, tell me if this is wrong) to get structural information about a record type at runtime (no RTTI).

TIA,
Marc

Reply by email

Jonas Maebe
to Marc Santhoff
Marc Santhoff wrote 10 lines
would it be possible to set up a memory structure according to fpc's aligning rules that will be accepted as a record typed variable? Or does fpc create some informational support items that would miss in this case? I'm in doubt, since it is normally not possible (AFAIK, tell me if this is wrong) to get structural information about a record type at runtime (no RTTI).

Initialisation rtti is generated in case the record contains reference counted types. It will be easier to answer your question if you explain what you want to achieve and why.

Jonas

Reply by email

Marc Santhoff
to Jonas Maebe
Jonas Maebe wrote 16 lines
On 25 Sep 2007, at 11:49, Marc Santhoff wrote: > would it be possible to set up a memory structure according to fpc's > aligning rules that will be accepted as a record typed variable? Or > does > fpc create some informational support items that would miss in this > case? > > I'm in doubt, since it is normally not possible (AFAIK, tell me if > this > is wrong) to get structural information about a record type at runtime > (no RTTI). Initialisation rtti is generated in case the record contains reference counted types. It will be easier to answer your question if you explain what you want to achieve and why.

I was a little fast in asking this question. It's about passing around arbitrary anonymous record consisting of atomic types and strings.

But since in the end it all comes down to asking for a records members and field count I have to use additional typing info and doing the memory housekeeping by hand anyways. (If this hasn't changed since fpc 2.0.4)

So forgat about it.

Marc

Reply by email

Leonardo M. Ram�
to Marc Santhoff

An aproximation of what you want to accomplish is the usage of classes (descendants of TPersistent) with published properties accesed using RTTI. The "visible" fields you want to access are these published properties, all other information and methods can't be accessed using RTTI.

TCustomer = class(TPersistent)
private
  FAge: Integer;
  FName: string;
published
  property Age: Integer read FAge write FAge;
  property Name: string read FName write FName;
end;
--- Marc Santhoff wrote 35 lines
Am Dienstag, den 25.09.2007, 11:56 +0200 schrieb Jonas Maebe: > On 25 Sep 2007, at 11:49, Marc Santhoff wrote: > > > would it be possible to set up a memory structure according to fpc's > > aligning rules that will be accepted as a record typed variable? Or > > does > > fpc create some informational support items that would miss in this > > case? > > > > I'm in doubt, since it is normally not possible (AFAIK, tell me if > > this > > is wrong) to get structural information about a record type at runtime > > (no RTTI). > > Initialisation rtti is generated in case the record contains > reference counted types. It will be easier to answer your question if > you explain what you want to achieve and why. I was a little fast in asking this question. It's about passing around arbitrary anonymous record consisting of atomic types and strings. But since in the end it all comes down to asking for a records members and field count I have to use additional typing info and doing the memory housekeeping by hand anyways. (If this hasn't changed since fpc 2.0.4) So forgat about it. Marc _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

____________________________________________________________________________________ Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

Reply by email

Marc Santhoff
to Leonardo M. Ram�
Leonardo M. RamX wrote 6 lines
An aproximation of what you want to accomplish is the usage of classes (descendants of TPersistent) with published properties accesed using RTTI. The "visible" fields you want to access are these published properties, all other information and methods can't be accessed using RTTI.

I know, but since I need flat memory stroage structures this is not an option. And since there are no guarantees about internals I can't use the fact that objects are stored like records + VMT.

I will use this approach at a higher level, I think.

Thanks for pointing out,
Marc

Reply by email