🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1455

Re: oop in pascal - help needed!

#1455
From: Christopher Eltschka
Date: Wed, 19 Aug 1998 00:00
52 lines
3490 bytes
[Mailed and posted]

Merkosh wrote:
> 
> Hi,
> 
> I want to program an object that allows an easy installation of a keyboard
> interrupt handler. The whole thing should look something like this:
> 
> Type    PKeyboard       = ^TKeyboard;
>         TKeyboard       = Object
>                 Scan    : Byte;
>                 Control : Byte;
> 
>                 Constructor Init(Scan, Control : Byte);
>                 Destructor Done;                Virtual;
>                 Procedure ActionProcedure;      Virtual;
>         End;
> 
> Were Scan is the scancode of the key which has to be pressed to start the
> procedure ActionProcedure and Control is the control key (shift, alt, etc)
> which has to be pressed.
> The following implementation is invalid:
> 
>         Procedure TKeyoard.ActionProcedure; Interrupt;
>         Begin
>         ...
>         End;
> 
> If anybody has a CLUE how something like this can be implemented with
> virtual mehtods or can explain why this is impossible, please contact me:
> <merkosh@iwwn.com.na>

The problem is that interrupt procedures are a very special thing,
and methods are another very special thing. The speciality
of interrupt procedures is that they save the complete register set;
the pseudo arguments which you can give on the definition just
reference the saved registers on stack.
Methods OTOH have a hidden extra parameter, the self parameter.
This parameter tells the method on which object it was invoked.
Now, an interrupt is never invoked on an object, it's invoked
on the system (one could, of course, view the system as an object
with the interrupt table being the virtual method table).
So there's no self parameter on an interrupt, and therefore an
interrupt handler cannot be a method.

However, there's one way you can get your effect anyway:
Maintain a global pointer to the current Keyboard object,
and let the interrupt procedure call your method on that
object. Functions called from interrupt functions may be
just normal functions (except for some limitations due to
non-reentrancy of DOS), including methods.
Technical Details
Message-ID: <35DAD0FB.1E9CCA28@physik.tu-muenchen.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <01bdca19$cb831300$640c1bc4@Merkosh.iwwn.com.na>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 110467,87a99d11cf64563f
X-Google-Attributes: gid110467,public
X-Google-Thread: 10261c,87a99d11cf64563f
X-Google-Attributes: gid10261c,public
X-Google-Thread: 10cc59,87a99d11cf64563f
X-Google-Attributes: gid10cc59,public
X-Google-Thread: 111659,87a99d11cf64563f
X-Google-Attributes: gid111659,public
X-Google-Thread: f8a86,87a99d11cf64563f
X-Google-Attributes: gidf8a86,public
X-Google-Thread: f9e32,87a99d11cf64563f
X-Google-Attributes: gidf9e32,public
X-Google-Thread: 13ed84,87a99d11cf64563f
X-Google-Attributes: gid13ed84,public
X-Google-Thread: 102bfa,87a99d11cf64563f
X-Google-Attributes: gid102bfa,public
From: Christopher Eltschka <celtschk@physik.tu-muenchen.de>
Subject: Re: oop in pascal - help needed!
Date: 1998/08/19
Message-ID: <35DAD0FB.1E9CCA28@physik.tu-muenchen.de>
X-Deja-AN: 382630383
Distribution: world
Content-Transfer-Encoding: 7bit
References: <01bdca19$cb831300$640c1bc4@Merkosh.iwwn.com.na>
To: Merkosh <merkosh@iwwn.com.na>
Content-Type: text/plain; charset=us-ascii
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Mime-Version: 1.0
Newsgroups: alt.msdos.programmer,comp.lang.pascal,comp.lang.pascal.borland,comp.lang.pascal.misc,comp.msdos.programmer,fido.ger.pascal,fido.pascal_ger,fido.pascal-ger,fidonet.pascal