[consider merging] more consistent behavior of RBA/pya: enum classes are properly made available (was for example RBA::Qt::Qt_Keys instead of RBA::Qt_Keys and pya.Qt.Keys was no fully initialized type object)

This commit is contained in:
Matthias Koefferlein 2023-03-26 14:21:30 +02:00
parent 79ad6b3fae
commit 2e2ba41250
3 changed files with 19 additions and 4 deletions

View File

@ -651,11 +651,26 @@ static void collect_classes (const gsi::ClassBase *cls, std::list<const gsi::Cla
{
unsorted_classes.push_back (cls);
for (tl::weak_collection<gsi::ClassBase>::const_iterator cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
for (auto cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
collect_classes (cc.operator-> (), unsorted_classes);
}
}
static bool all_parts_available (const gsi::ClassBase *cls, const std::set<const gsi::ClassBase *> &taken)
{
if (cls->declaration () && cls->declaration () != cls && taken.find (cls->declaration ()) == taken.end ()) {
return false;
}
for (auto cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
if (! all_parts_available (cc.operator-> (), taken)) {
return false;
}
}
return true;
}
std::list<const gsi::ClassBase *>
ClassBase::classes_in_definition_order (const char *mod_name)
{
@ -687,7 +702,7 @@ ClassBase::classes_in_definition_order (const char *mod_name)
continue;
}
if ((*c)->declaration () && (*c)->declaration () != *c && taken.find ((*c)->declaration ()) == taken.end ()) {
if (! all_parts_available (*c, taken)) {
// can't produce this class yet - it's a reference to another class which is not produced yet.
more_classes.push_back (*c);
continue;

View File

@ -357,7 +357,7 @@ public:
for (auto cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
if (! cc->name ().empty ()) {
PyTypeObject *child_class = make_class (cc.operator-> (), as_static);
PyTypeObject *child_class = make_class (cc->declaration (), as_static);
PythonRef attr ((PyObject *) child_class, false /*borrowed*/);
set_type_attr (type, cc->name ().c_str (), attr);
}

View File

@ -1658,7 +1658,7 @@ public:
for (auto cc = cls->begin_child_classes (); cc != cls->end_child_classes (); ++cc) {
if (! cc->name ().empty ()) {
if (! is_registered (cc->declaration (), false)) {
make_class (cc->declaration (), false, klass, cc->declaration ());
make_class (cc->declaration (), false, klass, cls);
} else {
VALUE child_class = ruby_cls (cc->declaration (), false);
rb_define_const (klass, cc->name ().c_str (), child_class);