home *** CD-ROM | disk | FTP | other *** search
Modula Implementation | 1990-05-02 | 2.7 KB | 134 lines |
- IMPLEMENTATION MODULE DynamicItem;
-
- (* Product: Incremental Storage Manager
-
- Version: 1.0
-
- Author:
- Daniel B. Hankins
- 143 Montgomery Street
- Poughkeepsie, NY 12601
- dan-hankins@cup.portal.com
-
- Creation Date: 1989
-
- Release Date: November 21, 1989
-
- Notice of Intellectual Property:
- This material is *NOT COPYRIGHTED*. By this notice, I hereby place
- this program and all its parts in the public domain, under the definitions
- and restrictions of United States law.
-
- History of Revisions:
- None yet.
- *)
-
- FROM SYSTEM IMPORT ADDRESS, TSIZE;
-
- IMPORT HandleCollection;
- IMPORT DynItem;
- IMPORT DynItemList;
-
- TYPE
- Object = POINTER TO Handle;
- Handle = DynItem.Object;
-
-
- PROCEDURE New(Size: LONGCARD; InitIt: InitProc; TermIt: TermProc): Object;
- VAR
- DItem: Object;
- ItemHandle: Handle;
- BEGIN
- (* New(Size, InitIt, Item) <-
- DynItem.New(Size, ItemHandle),
- New2(ItemHandle, InitIt, Item).
- New2(ItemHandle, InitIt, Item) <-
- DynItem.Nil(ItemHandle),
- SetValue(Item,NIL).
- New2(ItemHandle, InitIt, Item) <-
- HandleCollection.NewHandle(DItem),
- New3(ItemHandle, DItem, InitIt, Item).
- New3(ItemHandle, DItem, InitIt, Item) <-
- EqualValue(DItem, NIL),
- DynItem.Kill(ItemHandle),
- SetValue(Item, NIL).
- New3(ItemHandle, DItem, InitIt, Item) <-
- SetValue(DItem^, ItemHandle),
- DynItem.SetHandle(DItem^, DItem),
- DynItem.Percolate(DItem^),
- DynItem.Percolate(DItem^),
- DynItem.Init(DItem^, InitIt),
- SetValue(Item, DItem).
- *)
- ItemHandle := DynItem.New(Size, TermIt);
- IF DynItem.Nil(ItemHandle) THEN
- RETURN NIL;
- END;
-
- DItem := HandleCollection.NewHandle();
- IF DItem = NIL THEN
- DynItem.Kill(ItemHandle);
- RETURN NIL;
- END;
-
- DItem^ := ItemHandle;
- DynItem.SetHandle(DItem^, DItem);
- DynItem.Percolate(DItem^);
- DynItem.Percolate(DItem^);
- DynItem.Init(DItem^, InitIt);
-
- RETURN DItem;
- END New;
-
-
- PROCEDURE Ref(Item: Object): Object;
- BEGIN
- DynItem.Ref(Item^);
- RETURN Item;
- END Ref;
-
-
- PROCEDURE Dispose(Item: Object);
- VAR
- List: DynItemList.Object;
- BEGIN
- List := DynItem.GetList(Item^);
- IF DynItem.Dispose(Item^) THEN
- HandleCollection.DisposeHandle(Item);
- END;
- DynItemList.Percolate(List);
- END Dispose;
-
-
- PROCEDURE Access(Item: Object): ADDRESS;
- BEGIN
- RETURN DynItem.Access(Item^);
- END Access;
-
-
- PROCEDURE Set(Item:Object; NewDynItem: ADDRESS);
- BEGIN
- Item^ := DynItem.Object(NewDynItem);
- END Set;
-
-
- PROCEDURE DisposeAll();
- BEGIN
- DynItemList.DisposeAll();
- HandleCollection.DisposeAll();
- END DisposeAll;
-
-
- PROCEDURE NilObject(): Object;
- BEGIN
- RETURN NIL;
- END NilObject;
-
-
- PROCEDURE Nil(Item: Object): BOOLEAN;
- BEGIN
- RETURN (Item = NIL);
- END Nil;
-
- END DynamicItem.
-