<> <> <> <> DIRECTORY BasicTime, CD, Rope, SymTab; CDImports: CEDAR DEFINITIONS = BEGIN <> <<>> <> <> <<>> IsImport: PROC [ob: CD.Object] RETURNS [BOOL] = INLINE { RETURN [ISTYPE[ob.specific, ImportSpecific] AND ob.class=importsClass] }; importsClass: READONLY CD.ObjectClass; --refered record readonly too ImportSpecific: TYPE = REF ImportRep; ImportRep: TYPE = RECORD [ --consider all fields READONLY boundOb: CD.Object _ NIL, -- NIL if not yet bound boundDesign: CD.Design _ NIL, ir: CD.Rect _ [0, 0, -1, -1], objectName: Rope.ROPE _ NIL, designName: Rope.ROPE _ NIL ]; BoolOrInteractive: TYPE = {true, false, interactive}; <<>> <<>> <<--creation and caching of imports>> <<-- Designs have a cache for imported designs and imported objects>> <<-- Caching is done by checking the cache without enumerating instances >> FetchImport: PROC [into: CD.Design, objectName, importeeName: Rope.ROPE] RETURNS [ob: CD.Object]; <<--Returns an import object if object found in cache or NIL if none found.>> CreateImportFromCache: PROC [into: CD.Design, objectName, importeeName: Rope.ROPE, load: BOOL_FALSE] RETURNS [ob: CD.Object]; <<--Creates an import object; NIL if not done.>> <<--load: load and cache design first if not already cached.>> <<--If object not cached, requires design importeeName to be loaded (to know size of ob)>> <<--Might return a cached object. Returned object is included in cache.>> CreateImportWithoutSource: PROC [into: CD.Design, objectName, importeeName: Rope.ROPE, ir, bbox: CD.Rect, exact: BoolOrInteractive_false] RETURNS [ob: CD.Object]; <<--Creates an import object; NIL if not done.>> <<--Design importeeName need not be loaded nor will it be loaded.>> <<--exact: in case a cached object is found but data is wrong a new object is created. >> <<--Might return a cached object. Returned object is included in cache.>> CreateImportWithSource: PROC [into: CD.Design, objectName: Rope.ROPE, source: CD.Design, exact: BOOL_FALSE] RETURNS [ob: CD.Object]; <<--Creates an import object; NIL if not done.>> <<--exact: in case a cached object is found but source is wrong a new object is created >> <<--Design might or might not be included in cache. Returned object is included in cache.>> <<--operation with imports>> HasUnloadedImports: PROC [design: CD.Design_NIL, object: CD.Object_NIL, recurse: BOOL_TRUE] RETURNS [yes: BOOL_FALSE, where: LIST OF CD.Object_NIL]; <<-- Checks both, whether design or object has unloaded imports.>> <<-- recurse: check whether imports depend on unloaded imports recursively>> <<-- yes: whether some unloaded import is found>> <<-- where: nesting where some unloaded import is found; #NIL if ~yes>> MergeInImports: PROC [into: CD.Design, importeeName: Rope.ROPE]; <<--Includes all the imported and loaded objects from design importeeName (including >> <<--their transitive closure; but not indirect imports) into the design "into".>> LocalCopy: PROC [into: CD.Design, import: CD.Object] RETURNS [CD.Object]; <<--Makes a local copy of an import object; Children are copied over or replaced by imports.>> <<--import is an import object from any source imported into into>> <<--[Repeated LocalCopy might produce less good caching than calling MergeInImports]>> LoadAndBindAll: PROC [into: CD.Design, allowConflicts: BoolOrInteractive_true, forceBind: BOOL_FALSE] RETURNS [done: BOOL]; <<--Binds and caches all imported objects in into. >> <<--allowConflicts: If conflicts are disabled, objects with size conflict will not be bound. >> <<--forceBind: If objects are already bound, but to different source: Re-bind it.>> <<--Takes designs from cache, unless not found then read file.>> <<--Procedure talks to TerminalIO.>> LoadAndBindDesign: PROC [into: CD.Design, importeeName: Rope.ROPE, allowConflicts: BoolOrInteractive_true, forceBind: BOOL_FALSE, useCache: BOOL_FALSE, fileName: Rope.ROPE_NIL, forceFile: BOOL_FALSE] RETURNS [done: BOOL]; <<--Binds and caches all imported objects from design importeeName in into. >> <<--allowConflicts: If conflicts are disabled, objects with size conflict will not be bound.>> <<--forceBind: If objects are already bound, but to different source: Re-bind it.>> <<--useCache: Take design from cache instead of reading in file.>> <<--fileName: Optional; used in case a file is accessed.>> <<--forceFile: Loads new file into design cache, even if already cached.>> <<--done: On a coarse design basis; does not mean each object is bound.>> <<--Procedure talks to TerminalIO.>> ReBindObject: PROC [design: CD.Design, ob: CD.Object, importee: CD.Design, allowSizeConflicts: BoolOrInteractive _ true] RETURNS [ok: BOOL]; <<--Redo binding of an import object>> <<--design: design where import object ob is included>> <<--importee: design from where remote object shall be used>> <<--Cache is not involved.>> OccursInDrawing: PROC [x: CD.Object, in: CD.Object] RETURNS [BOOL]; <<--Recursivity test>> <<--Check whether drawing of "in" would draw "x">> <<>> <> <> CacheList: TYPE = PRIVATE REF CacheListRec; CacheListRec: TYPE = RECORD [list: LIST OF Cache]; -- READONLY to clients <<--describes all the caching for imports of a design>> Cache: TYPE = PRIVATE REF CacheRec; CacheRec: TYPE = RECORD[ -- READONLY to clients importeeName: Rope.ROPE _ NIL, importee: CD.Design _ NIL, objects: SymTab.Ref _ NIL, --objects do not need to be included in importee ! data: REF _ NIL ]; GetCacheList: PRIVATE PROC [design: CD.Design] RETURNS [CacheList]; <<-- Returns the caches considered for imports into design.>> <<-- Consider the list and its entries READONLY.>> GetCache: PRIVATE PROC [into: CD.Design, importeeName: Rope.ROPE, createIfNotFound: BoolOrInteractive_false] RETURNS [Cache]; <<-- Returns a cache for a particular import.>> <<-- Consider the returned record READONLY>> <<-- NIL if not found and not created.>> DoCacheDesign: PRIVATE PROC [into: CD.Design, importee: CD.Design]; <<-- Caches a design.>> <<-- importee must be readonly.>> FindCachedDesign: PRIVATE PROC [designName: Rope.ROPE, fileName: Rope.ROPE_NIL, createdTime: BasicTime.GMT _ BasicTime.nullGMT, checkUnloadedImps: BOOL_FALSE] RETURNS [found: CD.Design_NIL]; <<-- Tries hard to find a cached design and returns it, or NIL if not found.>> <<-- Expect the cached design to be readonly.>> <<-- fileName: checks that cached design really comes from this file.>> <<-- checkUnloadedImps: returns cached design only if it has no indirect unloaded imports.>> END.