DIRECTORY CD, CDCells, CDDirectory, CDExtras, CDInstances, CDProperties, Rope, CDSimpleCells2; CDSimpleCells2Impl: CEDAR PROGRAM IMPORTS CDCells, CDExtras, CDDirectory, CDProperties, Rope EXPORTS CDSimpleCells2 = BEGIN PartialCopy: PUBLIC PROC [ob: CD.Object, design: CD.Design, instances: LIST OF Rope.ROPE_NIL, remove: BOOL_TRUE, prop: ATOM _ $InstanceName, name: Rope.ROPE_NIL] RETURNS [copy: CD.Object_NIL] = BEGIN ExpandToCell: PROC [ob: CD.Object, from: CD.Design] RETURNS [cell: CD.Object] = { cell _ ob; IF ~CDCells.IsCell[cell] THEN { cell _ CDDirectory.ExpandHard[ob, from, NIL]; IF ~CDCells.IsCell[cell] THEN cell _ NIL; } }; ShouldCopy: PROC[i: CD.Instance] RETURNS [copy: BOOL_TRUE] = { ref: REF = CDProperties.GetPropFromInstance[i, prop]; IF ref#NIL THEN { val: Rope.ROPE = CDExtras.ToRope[ref]; FOR rl: LIST OF Rope.ROPE _ instances, rl.rest WHILE rl#NIL DO IF Rope.Equal[val, rl.first] THEN RETURN [copy _ ~remove]; ENDLOOP }; copy _ remove }; cell: CD.Object _ ExpandToCell[ob, design]; --don't care if top level in design; we copy anyway IF cell#NIL THEN { newList: CD.InstanceList _ NIL; cp, newCp: CD.CellPtr; copy _ CDCells.CreateEmptyCell[]; cp _ NARROW[cell.specificRef]; newCp _ NARROW[copy.specificRef]; copy.size _ cell.size; copy.properties _ CDProperties.CopyProps[cell.properties]; newCp^ _ cp^; FOR il: CD.InstanceList _ cp.contents, il.rest WHILE il#NIL DO IF ShouldCopy[il.first] THEN { i: CD.Instance _ NEW[CD.InstanceRep _ il.first^]; i.properties _ CDProperties.CopyProps[i.properties]; newList _ CONS[i, newList]; }; ENDLOOP; newCp.contents _ newList; [] _ CDCells.RepositionCell[copy, NIL]; IF design#NIL THEN [] _ CDDirectory.Include[design, copy, name]; }; END; END. CDSimpleCells2Impl.mesa by Ch. Jacobi, June 10, 1985 12:06:12 pm PDT last edited Ch. Jacobi, August 29, 1985 6:06:10 pm PDT --copy the object; creates a cell --remove TRUE: --all the instances with property prop are and a value in instances are removed --remove FALSE: --only the instances with property prop are and a value in instances are copied --returns cell; however we dont care if cell is in design or not... --accesses parameters of CopyInst --interest rect: by luck, the right thing happens even without coding Κ&˜šœ™Jšœ,™,Jšœ6™6—J˜šΟk ˜ Jšœ˜Jšœ˜Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ ˜ Jšœ˜Jšœ˜—J˜šΟbœœ˜!Jšœ4˜;Jšœ˜—Jšœ˜J˜J˜š Οn œ œœœœœœœ œœœœœœœœ˜ΑJšœ"™"šœ™JšœQ™Q—šœ™JšœQ™Q—Jš˜J˜š Ÿ œœœœ œœ ˜QJšœC™CIcodešœ ˜ šœœ˜Kšœ)œ˜.Kšœœœ˜)K˜—Jšœ˜—J˜š Ÿ œœœ œœœ˜>Jšœ!™!Jšœœ-˜5šœœœ˜Jšœ œ˜&š œœœœœœ˜>Jšœœœ˜:Jš˜—J˜—Jšœ ˜ J˜—J˜Jšœœ$Οc3˜_šœœœ˜Jšœ œœ˜Jšœ œ ˜Jšœ!˜!Jšœœ˜Jšœœ˜!Jšœ˜Jšœ:˜:Jšœ ˜ š œœ%œœ˜>šœœ˜Jšœœ œœ˜1Jšœ4˜4Jšœ œ ˜J˜—Jšœ˜—Jšœ˜J™EJšœ"œ˜'Jšœœœ.˜@Jšœ˜—Jšœ˜J˜—Jšœ˜J˜—…—Ό ψ