mirror of https://github.com/KLayout/klayout.git
WIP: Fixed Spice reader/writer delegate, tests.
This commit is contained in:
parent
a1a0b62a10
commit
717e7ca0ab
|
|
@ -1486,34 +1486,23 @@ public:
|
|||
db::NetlistSpiceWriterDelegate::write_device (dev);
|
||||
}
|
||||
|
||||
void org_write_header () const
|
||||
{
|
||||
db::NetlistSpiceWriterDelegate::write_header ();
|
||||
}
|
||||
|
||||
gsi::Callback cb_write_header;
|
||||
gsi::Callback cb_write_device_intro;
|
||||
gsi::Callback cb_write_device;
|
||||
};
|
||||
|
||||
static void write_header_fb (const db::NetlistSpiceWriterDelegate *delegate)
|
||||
{
|
||||
delegate->write_header ();
|
||||
}
|
||||
|
||||
static void write_device_intro_fb (const db::NetlistSpiceWriterDelegate *delegate, const db::DeviceClass &ccls)
|
||||
{
|
||||
delegate->write_device_intro (ccls);
|
||||
}
|
||||
|
||||
static void write_device_fb (const db::NetlistSpiceWriterDelegate *delegate, const db::Device &cdev)
|
||||
{
|
||||
delegate->write_device (cdev);
|
||||
}
|
||||
|
||||
Class<NetlistSpiceWriterDelegateImpl> db_NetlistSpiceWriterDelegate ("db", "NetlistSpiceWriterDelegate",
|
||||
gsi::method_ext ("write_header", &write_header_fb, "@hide") +
|
||||
gsi::method_ext ("write_device_intro", &write_device_intro_fb, "@hide") +
|
||||
gsi::method_ext ("write_device", &write_device_fb, "@hide") +
|
||||
gsi::method ("write_header", &NetlistSpiceWriterDelegateImpl::org_write_header, "@hide") +
|
||||
gsi::callback ("write_header", &NetlistSpiceWriterDelegateImpl::write_header, &NetlistSpiceWriterDelegateImpl::cb_write_header,
|
||||
"@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::method ("write_device_intro", &NetlistSpiceWriterDelegateImpl::org_write_device_intro, "@hide") +
|
||||
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"
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ module RBA
|
|||
end
|
||||
end
|
||||
|
||||
class MyDelegate < RBA::NetlistSpiceReaderDelegate
|
||||
class MyNetlistSpiceReaderDelegate < RBA::NetlistSpiceReaderDelegate
|
||||
|
||||
def start(netlist)
|
||||
netlist.description = "Read by MyDelegate"
|
||||
|
|
@ -82,7 +82,7 @@ class DBNetlistReaderTests_TestClass < TestBase
|
|||
|
||||
input = File.join($ut_testsrc, "testdata", "algo", "nreader6.cir")
|
||||
|
||||
mydelegate = MyDelegate::new
|
||||
mydelegate = MyNetlistSpiceReaderDelegate::new
|
||||
reader = RBA::NetlistSpiceReader::new(mydelegate)
|
||||
# the delegate is kept by the SPICE writer ..
|
||||
mydelegate = nil
|
||||
|
|
@ -113,7 +113,7 @@ END
|
|||
|
||||
input = File.join($ut_testsrc, "testdata", "algo", "nreader6.cir")
|
||||
|
||||
mydelegate = MyDelegate::new
|
||||
mydelegate = MyNetlistSpiceReaderDelegate::new
|
||||
|
||||
def mydelegate.element(circuit, el, name, model, value, nets, params)
|
||||
self.error("Nothing implemented")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ end
|
|||
|
||||
load("test_prologue.rb")
|
||||
|
||||
class MyDelegate < RBA::NetlistSpiceWriterDelegate
|
||||
class MyNetlistSpiceWriterDelegate < RBA::NetlistSpiceWriterDelegate
|
||||
|
||||
def write_header
|
||||
emit_line("*** My special header")
|
||||
|
|
@ -114,7 +114,7 @@ class DBNetlistWriterTests_TestClass < TestBase
|
|||
|
||||
input = File.join($ut_testsrc, "testdata", "algo", "nwriter_rba2_au.txt")
|
||||
|
||||
mydelegate = MyDelegate::new
|
||||
mydelegate = MyNetlistSpiceWriterDelegate::new
|
||||
writer = RBA::NetlistSpiceWriter::new(mydelegate)
|
||||
# the delegate is kept by the SPICE writer ..
|
||||
mydelegate = nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue