From 50452877125358bfad0a3719ee4804d04e1b3d6d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 11 Oct 2025 19:26:11 +0200 Subject: [PATCH] Bugfixes --- src/db/db/gsiDeclDbLibrary.cc | 26 +++++++++++++++++--------- testdata/ruby/dbLibrary.rb | 22 ++++++++++++++++------ 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/db/db/gsiDeclDbLibrary.cc b/src/db/db/gsiDeclDbLibrary.cc index c7c749065..1423d5ee4 100644 --- a/src/db/db/gsiDeclDbLibrary.cc +++ b/src/db/db/gsiDeclDbLibrary.cc @@ -37,14 +37,6 @@ namespace gsi // --------------------------------------------------------------- // db::Library binding -/** - * @brief A basic implementation of the library - */ -static db::Library *new_lib () -{ - return new db::Library (); -} - static db::Library *library_by_name (const std::string &name, const std::string &for_technology) { return db::LibraryManager::instance ().lib_ptr_by_name (name, for_technology); @@ -135,7 +127,10 @@ class LibraryImpl : public db::Library { public: - LibraryImpl () : db::Library () { } + LibraryImpl () : db::Library () + { + // .. nothing yet .. + } virtual std::string reload () { @@ -151,6 +146,15 @@ public: } +static LibraryImpl *new_lib () +{ + return new LibraryImpl (); +} + +/** + * @brief A basic implementation of the library + */ + LibraryClass decl_Library ("db", "LibraryBase", gsi::method ("library_by_name", &library_by_name, gsi::arg ("name"), gsi::arg ("for_technology", std::string (), "unspecific"), "@brief Gets a library by name\n" @@ -289,6 +293,10 @@ LibraryClass decl_Library ("db", "LibraryBase", "@hide" ); +/** + * @brief The reimplementation stub + */ + LibraryClass decl_LibraryImpl (decl_Library, "db", "Library", gsi::constructor ("new", &new_lib, "@brief Creates a new, empty library" diff --git a/testdata/ruby/dbLibrary.rb b/testdata/ruby/dbLibrary.rb index d575fba82..cab65b2e7 100644 --- a/testdata/ruby/dbLibrary.rb +++ b/testdata/ruby/dbLibrary.rb @@ -45,14 +45,17 @@ class DBLibrary_TestClass < TestBase assert_equal(RBA::Library::library_names.member?("RBA-unit-test"), true) assert_equal(RBA::Library::library_by_name("RBA-unit-test").id, lib_id) - # destroy should not do anything as libraries are not to be removed through the destructor - lib._destroy - assert_equal(RBA::Library::library_by_name("RBA-unit-test").id, lib_id) - assert_equal(lib.destroyed?, true) + # The library reference is kept internally + lib = nil + GC.start + GC.start lib = RBA::Library::library_by_name("RBA-unit-test") - assert_equal(lib.destroyed?, false) - lib.delete + assert_equal(lib.name, "RBA-unit-test") + + lib._destroy + assert_equal(lib.destroyed?, true) + assert_equal(RBA::Library::library_by_name("RBA-unit-test"), nil) end @@ -101,6 +104,13 @@ class DBLibrary_TestClass < TestBase lib._destroy assert_equal(lib.destroyed?, true) + end + + def test_4_library_registration + + + + end end