|##########| |#MAGIC #|CLABLJAD |#PROJECT #|"ImportHelp" |#PATHS #|"StdProject" |#FLAGS #|xx---x-xx---xxx----------------- |#USERSW #|-------------------------------- |#USERMASK#|-------------------------------- |#SWITCHES#|xx---xxxxx------ |##########| DEFINITION MODULE Resources; | | 12 Jul 1992 WB added mem parameters for full Exec Memory support. | TYPE ClassPtr = HIDDEN; ContextPtr = HIDDEN; |==============================================================================| | Achtung !!!!! | Diese Prozeduren dürfen nur vom Compiler benutzt werden, sie müssen | dafür an dieser Stelle im Quelltext stehen. PROCEDURE NewContext; PROCEDURE OldContext; PROCEDURE AllocObj(class : ClassPtr;context : ContextPtr):ANYPTR; PROCEDURE FreeObj(obj : ANYPTR); PROCEDURE CloneObj(obj : ANYPTR;context : ContextPtr):ANYPTR; PROCEDURE ChangeObjContext(obj : ANYPTR;context : ContextPtr); |==============================================================================| FROM System IMPORT PROC; FROM Exec IMPORT MemReqs, MemReqSet; CONST NoContext = NIL;|CAST(ContextPtr,NIL); DEFINITION MODULE ResHandles(ResHandlePtr : POINTER TO ResHandle); TYPE ResourcePtr = HIDDEN; ResHandle = RECORD END; Destructor = PROCEDURE(res : ResHandlePtr); PROCEDURE AddResource(res : ResHandlePtr; destruct : Destructor; context : ContextPtr:=NIL); PROCEDURE RemResource(res : ResHandlePtr); PROCEDURE FreeResource(VAR res : ResHandlePtr); PROCEDURE IsResource(res : ResHandlePtr):BOOLEAN; (* PRIVAT !!! *) PROCEDURE FreeResources(res : ResourcePtr); END ResHandles; EXCEPTION NotEnoughMemory : "Not enough memory"; MemoryNotAllocated : "Memory not allocated"; NILDisposed : "Disposed a NIL-Pointer"; ResourceFreedTwice : "Resource freed twice"; ContexFreedTwice : "Context freed twice"; NoOldContext : "No old context accessable"; ActContextFreed : "Actcontext freed"; ResourceNotAllocated : "Resource not allocated"; NilResource : "Passed ResourcePtr is NIL"; VAR ActContext : ContextPtr; | | clear and chip will stay in for a while for compatibility, but will be | ignored if mem # {}. | PROCEDURE Allocate(VAR p : ANYPTR; size : LONGINT; clear, chip : BOOLEAN := FALSE; mem : MemReqSet := MemReqSet:{}; context : ContextPtr := NoContext ); PROCEDURE New( VAR p : ANYPTR; clear, chip : BOOLEAN := FALSE; mem : MemReqSet := MemReqSet:{}; context : ContextPtr:=NoContext ); PROCEDURE Dispose( VAR p : ANYPTR ); PROCEDURE DisposeAll( context : ContextPtr := NoContext ); PROCEDURE Avail( max, chip : BOOLEAN := FALSE; mem : MemReqSet := MemReqSet:{} ): LONGINT; PROCEDURE Create_Context(father : ContextPtr := NoContext):ContextPtr; PROCEDURE Create_Root():ContextPtr; PROCEDURE Delete_Context(VAR context : ContextPtr); END Resources.