From ce4dc0896923b1070eb0f27905549c43e2a5706b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 26 Nov 2024 23:15:28 +0100 Subject: [PATCH] Robustness of tests against different hash implementations, documentation update --- src/db/db/gsiDeclDbEdgeNeighborhood.cc | 5 +++- testdata/ruby/dbEdgeNeighborhood.rb | 33 +++++++++++++++----------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/db/db/gsiDeclDbEdgeNeighborhood.cc b/src/db/db/gsiDeclDbEdgeNeighborhood.cc index 7138abc3c..15a9c04ab 100644 --- a/src/db/db/gsiDeclDbEdgeNeighborhood.cc +++ b/src/db/db/gsiDeclDbEdgeNeighborhood.cc @@ -163,7 +163,10 @@ Class decl_EdgeNeighborhoodVisitorImpl (decl_E gsi::callback ("begin_polygon", &EdgeNeighborhoodVisitorImpl::issue_begin_polygon, &EdgeNeighborhoodVisitorImpl::f_begin_polygon, gsi::arg ("layout"), gsi::arg ("cell"), gsi::arg ("polygon"), "@brief Is called for each new polygon\n" "This event announces a new primary polygon. After this event, the edges of the polygon are reported via \\on_edge, " - "followed by a call of \\end_polygon." + "followed by a call of \\end_polygon.\n" + "\n" + "Note, that the polygon object is a temporary reference to a C++ object and it is only valid during the execution of this " + "callback. If you like to keep the polygon object, create a copy of it using the 'dup' method." ) + gsi::callback ("end_polygon", &EdgeNeighborhoodVisitorImpl::issue_end_polygon, &EdgeNeighborhoodVisitorImpl::f_end_polygon, "@brief Is called after the polygon\n" diff --git a/testdata/ruby/dbEdgeNeighborhood.rb b/testdata/ruby/dbEdgeNeighborhood.rb index 3837b4f79..edfeda792 100644 --- a/testdata/ruby/dbEdgeNeighborhood.rb +++ b/testdata/ruby/dbEdgeNeighborhood.rb @@ -26,30 +26,35 @@ class MyVisitor < RBA::EdgeNeighborhoodVisitor def initialize - @log = "" + @log = {} + @current_log = nil end def log - @log + @log.keys.sort { |a,b| a < b ? -1 : (a == b ? 0 : 1) }.collect { |k| @log[k].join("") }.join("") end def begin_polygon(layout, cell, polygon) + polygon = polygon.dup output(polygon) - @log += "Polygon: #{polygon}\n" + @log[polygon] ||= [] + @current_log = @log[polygon] + @current_log << "Polygon: #{polygon}\n" end def end_polygon - @log += "/Polygon\n" + @current_log << "/Polygon\n" + @current_log = nil end def on_edge(layout, cell, edge, neighborhood) - @log += "edge = #{edge}\n" + @current_log << "edge = #{edge}\n" neighborhood.each do |n| x1, x2 = n[0] polygons = n[1] polygons.each do |inp, poly| poly_str = poly.collect { |p| p.to_s }.join("/") - @log += " #{x1},#{x2} -> #{inp}: #{poly_str}\n" + @current_log << " #{x1},#{x2} -> #{inp}: #{poly_str}\n" end end end @@ -68,7 +73,7 @@ def on_edge(layout, cell, edge, neighborhood) polygons.each do |inp, poly| poly.each do |p| bbox = p.bbox - t = self.to_original_trans(edge) + t = RBA::EdgeNeighborhoodVisitor.to_original_trans(edge) ep = RBA::EdgePair::new(edge, t * RBA::Edge::new(bbox.p1, RBA::Point::new(bbox.right, bbox.bottom))) output(ep) end @@ -111,19 +116,19 @@ def test_1 res = prim.complex_op(node) assert_equal(visitor.log, - "Polygon: (0,0;0,1000;1000,1000;1000,0)\n" + - "edge = (0,0;0,1000)\n" + - " 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" + - "edge = (0,1000;1000,1000)\n" + - "edge = (1000,1000;1000,0)\n" + - "edge = (1000,0;0,0)\n" + - "/Polygon\n" + "Polygon: (-1100,0;-1100,1000;-100,1000;-100,0)\n" + "edge = (-1100,0;-1100,1000)\n" + "edge = (-1100,1000;-100,1000)\n" + "edge = (-100,1000;-100,0)\n" + " 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" + "edge = (-100,0;-1100,0)\n" + + "/Polygon\n" + + "Polygon: (0,0;0,1000;1000,1000;1000,0)\n" + + "edge = (0,0;0,1000)\n" + + " 0.0,1000.0 -> 0: (0,100;0,101;1000,101;1000,100)\n" + + "edge = (0,1000;1000,1000)\n" + + "edge = (1000,1000;1000,0)\n" + + "edge = (1000,0;0,0)\n" + "/Polygon\n" )