diff --git a/src/edt/edt/gsiDeclEdt.cc b/src/edt/edt/gsiDeclEdt.cc index 7f986821c..ea9b3bcda 100644 --- a/src/edt/edt/gsiDeclEdt.cc +++ b/src/edt/edt/gsiDeclEdt.cc @@ -73,6 +73,13 @@ static db::Layout *layout_from_inst_path (const lay::ObjectInstPath *p) return cell ? cell->layout () : 0; } +static db::Cell *cell_from_inst_path (const lay::ObjectInstPath *p) +{ + auto cell_index = p->cell_index_tot (); + db::Layout *layout = layout_from_inst_path (p); + return layout ? &layout->cell (cell_index) : 0; +} + static db::DCplxTrans source_dtrans (const lay::ObjectInstPath *p) { const db::Layout *layout = layout_from_inst_path (p); @@ -203,6 +210,13 @@ gsi::Class decl_ObjectInstPath ("lay", "ObjectInstPath", "This property is set implicitly by setting the top cell and adding elements to the instantiation path.\n" "To obtain the index of the container cell, use \\source.\n" ) + + gsi::method_ext ("cell", &cell_from_inst_path, + "@brief Gets the cell object that the selection applies to.\n" + "\n" + "This is a convenience method that returns a \\Cell objeact instead of a cell index (see \\cell_index).\n" + "\n" + "This method has been introduced in version 0.30.3.\n" + ) + gsi::method_ext ("layout", &layout_from_inst_path, "@brief Gets the Layout object the selected object lives in.\n" "\n" diff --git a/testdata/ruby/edtTest.rb b/testdata/ruby/edtTest.rb index 1346b1576..eaf4b3238 100644 --- a/testdata/ruby/edtTest.rb +++ b/testdata/ruby/edtTest.rb @@ -181,6 +181,8 @@ class EDT_TestClass < TestBase assert_equal(sel.size, 1) assert_equal(sel[0] == p2, true) assert_equal(sel[0].layout.object_id, ly.object_id) + assert_equal(sel[0].cell_index, c2.cell_index) + assert_equal(sel[0].cell.cell_index, c2.cell_index) assert_equal(sel[0].trans.to_s, "r0 *1 10,20") assert_equal(sel[0].dtrans.to_s, "r0 *1 0.01,0.02") assert_equal(sel[0].source_trans.to_s, "r0 *1 10,20")