mirror of https://github.com/KLayout/klayout.git
Some code simplification
This commit is contained in:
parent
8dbc31a41f
commit
2d334bd88d
|
|
@ -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<const gsi::ClassBase *, std::vector<const gsi::ClassBase *> > m_extensions_for;
|
||||
std::map<const gsi::ClassBase *, std::vector<std::pair<std::string, const gsi::ClassBase *> > > m_links_for;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <RubyConstDescriptor> m_constants;
|
||||
std::map<const gsi::ClassBase *, std::vector<const gsi::ClassBase *> > m_extensions_for;
|
||||
std::set<const gsi::ClassBase *> m_extensions;
|
||||
std::map<const gsi::ClassBase *, std::vector<std::pair<std::string, const gsi::ClassBase *> > > m_links_for;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue