bpcompat-1.0.zip_(re)

Fri, 23 May 1997 14:32:55 +0200 (MET DST)


According to Pierre Phaneuf:
> 
> I just checked out the new bpcompat sources... Did anyone actually *USED*
> the OBJECTS.PAS unit??? More specifically, the TStream Put and Get
> methods? They are obviously broken...

This is a very first release, and the `tStream' object is marked as
"{ !!! not complete !!! }".  Now you know what was meant with the statement
"and some of the routines do not work well" in the announcement.

> Ok, so those are difficult parts, but still... What I need is two things:
> a way to tell what is the real type of an object like the typeof()
> function (didn't check if it was there),

It is there since gpc-970510 (see the announcement).

> and a way to construct an object
> of an type as returned by typeof().

>From the announcement of gpc-970510:

  * `TypeOf' applied to object variables works now, too.  As a GPC extension,
    you can explicitly assign a value to "TypeOf ( MyObj )" if extended syntax
    is ON (*$X+*).

This means that, with (*$X+*), you can explicitly assign a `TypeOf' to
an object.  I implemented this extension just for the purpose to write the
`tStream.Get' method.  (In BP, this is achieved with assembler, but we want
to have it portable for GPC.)
 
> Something that would enable me to do something so that
> new(typeof(TMyObject), Init) creates an instance of TMyObject, calls Init
> and returns a pointer to the newly created object would be just *perfect*.

Please add it to `objects.pas'!  My suggestion:

1) Write a `RegisterType' function, so you can read the `ObjType' out of
   the stream and look up its `VmtLink'.

2) Replace the `New' in `tStream.Get' by a `GetMem' with the Size read off
   the VMT (a Word variable at the very beginning of the VMT).

3) Explicitly assign `VmtLink' to `TypeOf ( the new object )'.

4) Call the object's `Load' constructor.

Please join us in improving GPC!

Greetings,

    Peter

  Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970510] - http://home.pages.de/~gnu-pascal/ [970125]


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es