From 57305977a48e4bcc07ef2dda78556b7c216a29a5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 31 Jan 2019 22:23:58 +0100 Subject: [PATCH] Spice writer delegate fix - Changed to const & objects in the Spice writer delegate to non-const & for Ruby/Python reimplementation (as const/non-const ambiguity is an issue for Ruby/Python we cannot efficiently work with const refs) - Updated test data because the previous implementation wasn't using refs but rather copies of device and device class objects. --- src/db/db/gsiDeclDbNetlist.cc | 35 ++++++++++++++++++++++++------- testdata/algo/nwriter_rba2_au.txt | 20 +++++++++--------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/db/db/gsiDeclDbNetlist.cc b/src/db/db/gsiDeclDbNetlist.cc index c572a3543..e3124665c 100644 --- a/src/db/db/gsiDeclDbNetlist.cc +++ b/src/db/db/gsiDeclDbNetlist.cc @@ -1038,25 +1038,44 @@ public: } } - virtual void write_device_intro (const db::DeviceClass &cls) const + virtual void write_device_intro (const db::DeviceClass &ccls) const + { + reimpl_write_device_intro (const_cast (ccls)); + } + + // NOTE: we pass non-const refs to Ruby/Python - everthing else is a bit of a nightmare. + // Still that's not really clean. Just say, the implementation promises not to change the objects. + void reimpl_write_device_intro (db::DeviceClass &cls) const { if (cb_write_device_intro.can_issue ()) { - cb_write_device_intro.issue (&db::NetlistSpiceWriterDelegate::write_device_intro, cls); + cb_write_device_intro.issue (&NetlistSpiceWriterDelegateImpl::org_write_device_intro, const_cast (cls)); } else { - db::NetlistSpiceWriterDelegate::write_device_intro (cls); + org_write_device_intro (cls); } } - virtual void write_device (const db::Device &dev) const + void org_write_device_intro (db::DeviceClass &cls) const + { + db::NetlistSpiceWriterDelegate::write_device_intro (cls); + } + + virtual void write_device (const db::Device &cdev) const + { + reimpl_write_device (const_cast (cdev)); + } + + // NOTE: we pass non-const refs to Ruby/Python - everthing else is a bit of a nightmare. + // Still that's not really clean. Just say, the implementation promises not to change the objects. + void reimpl_write_device (db::Device &dev) const { if (cb_write_device.can_issue ()) { - cb_write_device.issue (&db::NetlistSpiceWriterDelegate::write_device, dev); + cb_write_device.issue (&NetlistSpiceWriterDelegateImpl::org_write_device, dev); } else { org_write_device (dev); } } - virtual void org_write_device (const db::Device &dev) const + void org_write_device (db::Device &dev) const { db::NetlistSpiceWriterDelegate::write_device (dev); } @@ -1076,11 +1095,11 @@ Class db_NetlistSpiceWriterDelegate ("db", "Netl "@brief Writes the text at the beginning of the SPICE netlist\n" "Reimplement this method to insert your own text at the beginning of the file" ) + - gsi::callback ("write_device_intro", &NetlistSpiceWriterDelegateImpl::write_device_intro, &NetlistSpiceWriterDelegateImpl::cb_write_device_intro, gsi::arg ("device_class"), + gsi::callback ("write_device_intro", &NetlistSpiceWriterDelegateImpl::reimpl_write_device_intro, &NetlistSpiceWriterDelegateImpl::cb_write_device_intro, gsi::arg ("device_class"), "@brief Inserts a text for the given device class\n" "Reimplement this method to insert your own text at the beginning of the file for the given device class" ) + - gsi::callback ("write_device", &NetlistSpiceWriterDelegateImpl::write_device, &NetlistSpiceWriterDelegateImpl::cb_write_device, gsi::arg ("device"), + gsi::callback ("write_device", &NetlistSpiceWriterDelegateImpl::reimpl_write_device, &NetlistSpiceWriterDelegateImpl::cb_write_device, gsi::arg ("device"), "@brief Inserts a text for the given device\n" "Reimplement this method to write the given device in the desired way" ) + diff --git a/testdata/algo/nwriter_rba2_au.txt b/testdata/algo/nwriter_rba2_au.txt index 6e4a8506b..492d0d858 100644 --- a/testdata/algo/nwriter_rba2_au.txt +++ b/testdata/algo/nwriter_rba2_au.txt @@ -15,15 +15,15 @@ * net 2 n2 * net 3 n3 * device instance $1 0,0 RCLS -* Before device $0 -* Terminal #1: 0 -* Terminal #2: 0 -R$0 0 0 1.7 -* After device $0 +* Before device $1 +* Terminal #1: 1 +* Terminal #2: 3 +R$1 1 3 1.7 +* After device $1 * device instance $2 0,0 RCLS -* Before device $0 -* Terminal #1: 0 -* Terminal #2: 0 -R$0 0 0 4.2e-05 -* After device $0 +* Before device $2 +* Terminal #1: 3 +* Terminal #2: 2 +R$2 3 2 4.2e-05 +* After device $2 .ENDS C1