[Oberon] FPGA - OberonV4 Dialogs

Skulski, Wojciech skulski at pas.rochester.edu
Fri Dec 14 03:14:51 CET 2018


Tomas:

  Andreas released the Oberon-2 compiler. Porting Dialogs to his compiler should be now significantly easier than porting to Oberon-07.

Wojtek
________________________________________
From: Oberon [oberon-bounces at lists.inf.ethz.ch] on behalf of Tomas Kral [thomas.kral at email.cz]
Sent: Thursday, December 13, 2018 5:30 PM
To: oberon at lists.inf.ethz.ch
Subject: Re: [Oberon] FPGA - OberonV4 Dialogs

On Thu, 13 Dec 2018 23:11:56 +0100
Jörg Straube <joerg.straube at iaeth.ch> wrote:

> „m.draw := Draw“ should be after NEW(m) in the two main bodies and
> deleted from both New()s

Thank you, corrected. Added some fields so I may not use `Texts', no
need to modify PO2013 `Texts' and `TextFrames'. Unlike the original
Dialogs.

MODULE DLog; (* TK 13.12.2018 Dialogs - simple coding for RISC *)
  IMPORT In, Out, Modules;

  TYPE
    Object* = POINTER TO ObjDesc;
    Methods* = POINTER TO MethodDesc;
    Rect* = POINTER TO RectDesc;

    ObjDesc* = RECORD
      do*: Methods;
      r*: Rect; (*bounding rectangle*)
      next: Object;
      id*: INTEGER
    END;

    RectDesc = RECORD x, y, w, h: INTEGER;
    END;

    MethodDesc* = RECORD
      draw*: PROCEDURE (o: Object);
    END;

  VAR first: Object; cnt: INTEGER;

  PROCEDURE Load*;
    VAR name: Modules.ModuleName; module: Modules.Module; New: PROCEDURE;
  BEGIN In.Open; In.Name(name);
    WHILE In.Done DO
      Out.String(name); Out.String(" loading ");
      Modules.Load(name, module);
      New := Modules.ThisCommand(module, "New");
      IF Modules.res = 0 THEN New() END ;
      In.Name(name); Out.Ln
    END;
  END Load;

  PROCEDURE LinkObj*(o: Object);
  BEGIN o.next := first; first := o;
    INC(cnt); o.id := cnt
  END LinkObj;

  PROCEDURE Update*;
    VAR o: Object;
  BEGIN o := first;
    WHILE o # NIL DO o.do.draw(o); o := o.next END
  END Update;

BEGIN first := NIL; cnt := 0
END DLog.

DLog.Load DText DButton DButton DText DText ~ Objects from stream now, TODO from persistent file
DLog.Update


MODULE DText;
  IMPORT DLog, Out;

  TYPE
    Text = ARRAY 32 OF CHAR;

    Item = POINTER TO ItemDesc;
    ItemDesc = RECORD(DLog.ObjDesc)
      static: BOOLEAN;
      name: Text;
    END;

  VAR t: Item; m: DLog.Methods;

  PROCEDURE Draw(o: DLog.Object);
  BEGIN Out.String("Drawing text"); Out.Int(o.id, 2); Out.Ln
  END Draw;

  PROCEDURE New*;
  BEGIN NEW(t); DLog.LinkObj(t); t.do := m
  END New;

BEGIN NEW(m); m.draw := Draw
END DText.


MODULE DButton;
  IMPORT DLog, Out;

  CONST oval = 0; oblique = 1;

  TYPE
    Item = POINTER TO ItemDesc;
    ItemDesc = RECORD(DLog.ObjDesc)
      shape: INTEGER;
    END;

  VAR t: Item; m: DLog.Methods;

  PROCEDURE Draw(o: DLog.Object);
  BEGIN Out.String("Drawing button"); Out.Int(o.id, 2); Out.Ln
  END Draw;

  PROCEDURE New*;
  BEGIN NEW(t); DLog.LinkObj(t); t.do := m
  END New;

BEGIN NEW(m); m.draw := Draw
END DButton.


--
Tomas Kral <thomas.kral at email.cz>
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.inf.ethz.ch_mailman_listinfo_oberon&d=DwIGaQ&c=kbmfwr1Yojg42sGEpaQh5ofMHBeTl9EI2eaqQZhHbOU&r=uUiA_zLpwaGJIlq-_BM9w1wVOuyqPwHi3XzJRa-ybV0&m=AZINTDgIhqfeheIrEMML8BqJiaIjk-X1Mp24vvADKXI&s=uiG0fg7osSRnhTSCSqWrvs8u2WRc5wdPtzkLNhh4PhM&e=


More information about the Oberon mailing list