41 lines · 1.4 KB · Text
RawDownload
= devpointer: I/O interface for the pointer device     include "draw.m";   # for Draw->Pointer    include "devpointer.m";    ptr := load Devpointer Devpointer->PATH;     init:      fn();    reader:    fn(file: string, posn: chan of ref Draw->Pointer,                  pid: chan of (int, string));    bytes2ptr: fn(buf: array of byte)    : ref Draw->Pointer;    ptr2bytes: fn(ptr: ref Draw->Pointer): array of byte; Devpointer  reads messages from pointer devices with the samedata format as /dev/pointer, converting them to Pointer adts. Init must be called before any other operation of the module. Reader should be spawned by the caller.  It opens the pointerdevice  specified  by  file,  and  sends a value (id, err) onchannel pid.  On success, id is the process ID of the spawnedprocess and err is nil; on an error, err is a diagnostic, andid is undefined.  If the file was opened successfully, readercontinually  reads  the pointer device and sends Pointer adtsover the channel posn.  If file is nil, the default device is/dev/pointer. Bytes2ptr  converts  the  array of bytes buf to a Pointer andreturns a reference to it.  Buf  should  consist  of  exactlyDevpointer->Size  bytes  and  be  in  the  format returned by/dev/pointer. Ptr2bytes provides the inverse transformation  of  bytes2ptr:it  packs the data into an array of bytes of appropriate for‐mat, which it returns. == files/dev/pointer == see ALSOdraw-intro(2), draw-pointer(2)