From 2d334bd88dadca015af6d13485a4a37670fe527d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 11 Dec 2021 01:09:07 +0100 Subject: [PATCH] Some code simplification --- src/pya/pya/pyaModule.cc | 20 +------------------- src/rba/rba/rba.cc | 19 +------------------ 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/pya/pya/pyaModule.cc b/src/pya/pya/pyaModule.cc index 4ff62f83f..19318550b 100644 --- a/src/pya/pya/pyaModule.cc +++ b/src/pya/pya/pyaModule.cc @@ -2387,15 +2387,9 @@ public: void register_extension (const gsi::ClassBase *cls) { if (cls->name ().empty ()) { - // got an extension tl_assert (cls->parent ()); m_extensions_for [cls->parent ()->declaration ()].push_back (cls->declaration ()); - - } else { - - m_links_for [cls->parent ()->declaration ()].push_back (std::make_pair (cls->name (), cls->declaration ())); - } } @@ -2488,24 +2482,13 @@ public: // produce the child classes for (auto cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) { - if (cc->declaration () == cc.operator-> ()) { + if (! cc->name ().empty ()) { PyTypeObject *child_class = make_class (cc.operator-> (), as_static); PythonRef attr ((PyObject *) child_class, false /*borrowed*/); set_type_attr (type, cc->name ().c_str (), attr); } } - // add named extensions - - auto links = m_links_for.find (cls); - if (links != m_links_for.end ()) { - for (auto il = links->second.begin (); il != links->second.end (); ++il) { - PyTypeObject *linked_type = make_class (il->second, false); - PythonRef attr ((PyObject *) linked_type, false /*borrowed*/); - set_type_attr (type, il->first.c_str (), attr); - } - } - // Build the attributes now ... MethodTable *mt = MethodTable::method_table_by_class (cls); @@ -2922,7 +2905,6 @@ private: PythonModule *mp_module; PyObject *m_all_list; std::map > m_extensions_for; - std::map > > m_links_for; }; } diff --git a/src/rba/rba/rba.cc b/src/rba/rba/rba.cc index 89bd04321..ab7d56a09 100644 --- a/src/rba/rba/rba.cc +++ b/src/rba/rba/rba.cc @@ -1537,15 +1537,9 @@ public: void register_extension (const gsi::ClassBase *cls) { if (cls->name ().empty ()) { - // got an extension tl_assert (cls->parent ()); m_extensions_for [cls->parent ()->declaration ()].push_back (cls->declaration ()); - - } else { - - m_links_for [cls->parent ()->declaration ()].push_back (std::make_pair (cls->name (), cls->declaration ())); - } } @@ -1608,7 +1602,7 @@ public: // produce the child classes for (auto cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) { - if (cc->declaration () == cc.operator-> ()) { + if (! cc->name ().empty ()) { if (! is_registered (cc->declaration (), false)) { make_class (cc->declaration (), false, klass, cc->declaration ()); } else { @@ -1618,16 +1612,6 @@ public: } } - // add named extensions - - auto links = m_links_for.find (cls); - if (links != m_links_for.end ()) { - for (auto il = links->second.begin (); il != links->second.end (); ++il) { - VALUE linked_class = make_class (il->second, false); - rb_define_const (klass, il->first.c_str (), linked_class); - } - } - MethodTable *mt = MethodTable::method_table_by_class (cls, true /*force init*/); for (auto m = (cls)->begin_methods (); m != (cls)->end_methods (); ++m) { @@ -1811,7 +1795,6 @@ private: std::vector m_constants; std::map > m_extensions_for; std::set m_extensions; - std::map > > m_links_for; }; }