[fpc-devel] Creating new classes at runtime

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Nov 12 20:26:52 CET 2004


I don't know, if this is the right list, but the topic is quite fpc specific and needs some compiler gurus:

The Lazarus IDE needs to create new classes at runtime. For example when loading/creating a descendent of TDataModule named TMyDataModule, it needs a unique TMyDataModule = class(TDataModule) complete with vmt, method table (empty), field table (empty), typeinfo (no properties), and .. ?
At the moment lazarus only supports TDataModule and TForm, so I was able to just define the two and copy. But for inheriting I need 'real' custom classes.

Creating the empty method table, field table and new typeinfo seems to be easy. But I found some fields, which I don't know:
In objpash.inc there is
    const
       vmtInstanceSize         = 0;
       vmtParent               = sizeof(ptrint)*2;

The fields behind vmtParent are easy (at least I think so). But what about the 8 bytes (i386) behind vmtInstanceSize and in front of vmtParent?
They seem to be a negative number and a pointer? What are they are good for?

And: Is this solution portable or will I get into trouble?


Mattias




More information about the fpc-devel mailing list