#935 fixed (checking for valid cell index)

This commit is contained in:
Matthias Koefferlein 2021-11-13 01:03:54 +01:00
parent 719eb0bce8
commit 0ca82001ed
2 changed files with 61 additions and 1 deletions

View File

@ -708,8 +708,19 @@ static gsi::layout_locking_iterator1<db::Shapes::shape_iterator> begin_overlappi
return gsi::layout_locking_iterator1<db::Shapes::shape_iterator> (s->layout (), s->begin_overlapping (layer_index, db::CplxTrans (layout->dbu ()).inverted () * box, db::ShapeIterator::All));
}
static db::Instance insert_inst (db::Cell *c, const db::Cell::cell_inst_array_type &inst)
{
if (c->layout () && ! c->layout ()->is_valid_cell_index (inst.object ().cell_index ())) {
throw tl::Exception (tl::to_string (tr ("Cell index is not valid")));
}
return c->insert (inst);
}
static db::Instance insert_inst_with_props (db::Cell *c, const db::Cell::cell_inst_array_type &inst, db::properties_id_type id)
{
if (c->layout () && ! c->layout ()->is_valid_cell_index (inst.object ().cell_index ())) {
throw tl::Exception (tl::to_string (tr ("Cell index is not valid")));
}
if (id) {
return c->insert (db::CellInstArrayWithProperties (inst, id));
} else {
@ -2393,7 +2404,7 @@ Class<db::Cell> decl_Cell ("db", "Cell",
"\n"
"It has been added in version 0.16."
) +
gsi::method ("insert", (db::Instance (db::Cell::*)(const db::Cell::cell_inst_array_type &)) &db::Cell::insert, gsi::arg ("cell_inst_array"),
gsi::method_ext ("insert", &insert_inst, gsi::arg ("cell_inst_array"),
"@brief Inserts a cell instance (array)\n"
"@return An Instance object representing the new instance\n"
"With version 0.16, this method returns an Instance object that represents the new instance.\n"

View File

@ -2024,6 +2024,55 @@ class DBLayout_TestClass < TestBase
end
def test_22
# invalid cell indexes
l = RBA::Layout.new
l.insert_layer_at(0, RBA::LayerInfo.new(1, 0))
c0 = l.cell(l.add_cell("c0"))
c1 = l.cell(l.add_cell("c1"))
assert_equal(c0.cell_index, 0)
assert_equal(c1.cell_index, 1)
tt = RBA::Trans.new
error = 0
begin
c0.insert(RBA::CellInstArray.new(2, tt))
rescue
error = 1
end
assert_equal(error, 1)
error = 0
begin
c0.insert(RBA::CellInstArray.new(2, tt), 17)
rescue
error = 1
end
assert_equal(error, 1)
dtt = RBA::DTrans.new
error = 0
begin
c0.insert(RBA::DCellInstArray.new(2, dtt))
rescue
error = 1
end
assert_equal(error, 1)
error = 0
begin
c0.insert(RBA::DCellInstArray.new(2, dtt), 42)
rescue
error = 1
end
assert_equal(error, 1)
end
# Iterating while flatten
def test_issue200