home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
oberon-a-1.4ß.lha
/
Oberon-A
/
source
/
amiga
/
Utility.mod
< prev
next >
Wrap
Text File
|
1994-08-08
|
22KB
|
731 lines
(**************************************************************************
$RCSfile: Utility.mod $
Description: Interface to utility.library
Created by: fjc (Frank Copeland)
$Revision: 3.2 $
$Author: fjc $
$Date: 1994/08/08 00:45:05 $
Includes Release 40.15
(C) Copyright 1985-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A interface Copyright © 1994, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
***************************************************************************)
MODULE Utility;
(*
** $C- CaseChk $I- IndexChk $L+ LongAdr $N- NilChk
** $P- PortableCode $R- RangeChk $S- StackChk $T- TypeChk
** $V- OvflChk $Z- ZeroVars
*)
IMPORT E := Exec, SYS := SYSTEM;
(*-- Pointer declarations ---------------------------------------------*)
TYPE
ClockDataPtr * = CPOINTER TO ClockData;
HookPtr * = CPOINTER TO Hook;
TagItemPtr * = CPOINTER TO TagItem;
NamedObjectPtr * = CPOINTER TO NamedObject;
(*-- Library definitions ----------------------------------------------*)
(*
** $VER: date.h 39.1 (20.1.92)
**
** Date conversion routines ClockData definition.
*)
TYPE
ClockData* = RECORD
sec * : E.UWORD;
min * : E.UWORD;
hour * : E.UWORD;
mday * : E.UWORD;
month* : E.UWORD;
year * : E.UWORD;
wday * : E.UWORD;
END; (* ClockData *)
(*
** $VER: hooks.h 39.2 (16.6.93)
**
** callback hooks
*)
TYPE
(* new standard hook structure *)
HookFunc * =
PROCEDURE (hook : HookPtr; object : E.APTR; message : E.APTR) : E.APTR;
AsmHookFunc * = PROCEDURE () : E.APTR;
(*
*** Oberon-A Note ***
Oberon-A does not allow register parameters for normal procedures,
so if you use an AsmHookFunc, you must use SYS.GETREG to access
the parameters. e.g:
PROCEDURE MyHookFunc () : E.APTR
VAR hook : HookPtr; object : E.APTR; message : E.APTR;
BEGIN
SYS.GETREG (8, hook);
SYS.GETREG (10, object);
SYS.GETREG (9, message);
...
END MyHookFunc;
*)
Hook* = RECORD (E.MinNode)
entry * : AsmHookFunc; (* assembler entry point *)
subEntry* : HookFunc; (* often HLL entry point *)
data * : E.APTR; (* owner specific *)
END; (* Hook *)
(*
* Hook calling conventions:
* A0 - pointer to hook data structure itself
* A1 - pointer to parameter structure ("message") typically
* beginning with a longword command code, which makes
* sense in the context in which the hook is being used.
* A2 - Hook specific address data ("object," e.g, GadgetInfo)
*
* Control will be passed to the routine hEntry. For many
* High-Level Languages (HLL), this will be an assembly language
* stub which pushes registers on the stack, does other setup,
* and then calls the function at hSubEntry.
*
* The C standard receiving code is:
* CDispatcher( hook, object, message )
* STRUCT Hook *hook;
* APTR object;
* APTR message;
*
* NOTE that register natural order differs from this convention
* for C parameter order, which is A0,A2,A1.
*
* The assembly language stub for "vanilla" C parameter conventions
* could be:
_hookEntry:
move.l a1,-(sp) ; push message packet pointer
move.l a2,-(sp) ; push object pointer
move.l a0,-(sp) ; push hook pointer
move.l h_SubEntry(a0),a0 ; fetch C entry point ...
jsr (a0) ; ... and call it
lea 12(sp),sp ; fix stack
rts
* with this function as your interface stub, you can write
* a Hook setup function as:
SetupHook( hook, c_function, userdata )
STRUCT Hook *hook;
ULONG ( *c_function)();
VOID *userdata;
{
ULONG ( *hookEntry)();
hook->h_Entry = hookEntry;
hook->h_SubEntry = c_function;
hook->h_Data = userdata;
}
* with Lattice C pragmas, you can put the C function in the
* h_Entry field directly if you declare the function:
ULONG __saveds __asm
CDispatcher( register __a0 STRUCT Hook *hook,
register __a2 VOID *object,
register __a1 ULONG *message );
*
****)
(*
** $VER: tagitem.h 40.1 (19.7.93)
**
** extended specification mechanism
*)
(*****************************************************************************)
(* Tags are a general mechanism of extensible data arrays for parameter
* specification and property inquiry. In practice, tags are used in arrays,
* or chain of arrays.
*
*)
TYPE
Tag * = SYS.LONGWORD;
TagItem* = RECORD
tag* : E.ULONG;
data* : Tag;
END; (* TagItem *)
TagListPtr * = CPOINTER TO ARRAY MAX (INTEGER) OF TagItem;
CONST
(* constants for Tag.tag, control tag values *)
tagDone * = 0; (* terminates array of TagItems. tiData unused *)
tagEnd * = tagDone;
tagIgnore* = 1; (* ignore this item, not end of array *)
tagMore * = 2; (* tiData is pointer to another array of TagItems
* note that this tag terminates the current array
*)
tagSkip * = 3; (* skip this and the next tiData items *)
(* differentiates user tags from control tags *)
tagUser * = 80000000H;
(* If the tagUser bit is set in a tag number, it tells utility.library that
* the tag is not a control tag (like tagDone, tagIgnore, tagMore) and is
* instead an application tag. "USER" means a client of utility.library in
* general, including system code like Intuition or ASL, it has nothing to do
* with user code.
*)
(*****************************************************************************)
(* Tag filter logic specifiers for use with FilterTagItems() *)
tagFilterAND * = 0; (* exclude everything but filter hits *)
tagFilterNOT * = 1; (* exclude only filter hits *)
(*****************************************************************************)
(* Mapping types for use with MapTags() *)
mapRemoveNotFound * = 0; (* remove tags that aren't in mapList *)
mapKeepNotFound * = 1; (* keep tags that aren't in mapList *)
(*****************************************************************************)
(*
** $VER: name.h 39.5 (11.8.93)
**
** Namespace definitions
**)
(*****************************************************************************)
TYPE
(* The named object structure *)
NamedObject * = RECORD
object * : E.APTR; (* Your pointer, for whatever you want *)
END;
CONST
(* Tags for AllocNamedObject() *)
anoNameSpace * = 4000; (* Tag to define namespace *)
anoUserSpace * = 4001; (* tag to define userspace *)
anoPriority * = 4002; (* tag to define priority *)
anoFlags * = 4003; (* tag to define flags *)
(* Flags for tag anoFlags *)
nsNodups * = 0; (* Default allow duplicates *)
nsCase * = 1; (* Default to caseless... *)
(*****************************************************************************)
(*
** $VER: pack.h 39.3 (10.2.93)
**
** Control attributes for Pack/UnpackStructureTags()
*)
(*****************************************************************************)
(* PackTable definition:
*
* The PackTable is a simple array of LONGWORDS that are evaluated by
* PackStructureTags() and UnpackStructureTags().
*
* The table contains compressed information such as the tag offset from
* the base tag. The tag offset has a limited range so the base tag is
* defined in the first longword.
*
* After the first longword, the fields look as follows:
*
* +--------- 1 = signed, 0 = unsigned (for bits, 1=inverted boolean)
* |
* | +------ 00 = Pack/Unpack, 10 = Pack, 01 = Unpack, 11 = special
* | / \
* | | | +-- 00 = Byte, 01 = Word, 10 = Long, 11 = Bit
* | | | / \
* | | | | | /----- For bit operations