mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
Fix for typedefs to external types in interrogate
This commit is contained in:
parent
acc2a310d0
commit
64144955a0
@ -1235,11 +1235,13 @@ void InterfaceMakerPythonNative::
|
||||
write_sub_module(ostream &out, Object *obj) {
|
||||
//Object * obj = _objects[_embeded_index] ;
|
||||
string class_name = make_safe_name(obj->_itype.get_scoped_name());
|
||||
string class_ptr;
|
||||
out << " // Module init upcall for " << obj->_itype.get_scoped_name() << "\n";
|
||||
|
||||
if (!obj->_itype.is_typedef()) {
|
||||
out << " // " << *(obj->_itype._cpptype) << "\n";
|
||||
out << " Dtool_PyModuleClassInit_" << class_name << "(module);\n";
|
||||
class_ptr = "&Dtool_" + class_name;
|
||||
|
||||
} else {
|
||||
// Unwrap typedefs.
|
||||
@ -1258,22 +1260,29 @@ write_sub_module(ostream &out, Object *obj) {
|
||||
|
||||
if (!isExportThisRun(wrapped_itype._cpptype)) {
|
||||
_external_imports.insert(TypeManager::resolve_type(wrapped_itype._cpptype));
|
||||
|
||||
class_ptr = "Dtool_Ptr_" + class_name;
|
||||
out << " assert(" << class_ptr << " != NULL);\n";
|
||||
} else {
|
||||
class_ptr = "&Dtool_" + class_name;
|
||||
}
|
||||
}
|
||||
|
||||
std::string export_class_name = classNameFromCppName(obj->_itype.get_name(), false);
|
||||
std::string export_class_name2 = classNameFromCppName(obj->_itype.get_name(), true);
|
||||
|
||||
class_ptr = "(PyObject *)" + class_ptr;
|
||||
|
||||
// Note: PyModule_AddObject steals a reference, so we have to call Py_INCREF
|
||||
// for every but the first time we add it to the module.
|
||||
if (obj->_itype.is_typedef()) {
|
||||
out << " Py_INCREF((PyObject *)&Dtool_" << class_name << ");\n";
|
||||
out << " Py_INCREF(" << class_ptr << ");\n";
|
||||
}
|
||||
|
||||
out << " PyModule_AddObject(module, \"" << export_class_name << "\", (PyObject *)&Dtool_" << class_name << ");\n";
|
||||
out << " PyModule_AddObject(module, \"" << export_class_name << "\", " << class_ptr << ");\n";
|
||||
if (export_class_name != export_class_name2) {
|
||||
out << " Py_INCREF((PyObject *)&Dtool_" << class_name << ");\n";
|
||||
out << " PyModule_AddObject(module, \"" << export_class_name2 << "\", (PyObject *)&Dtool_" << class_name << ");\n";
|
||||
out << " Py_INCREF(Dtool_Ptr_" << class_name << ");\n";
|
||||
out << " PyModule_AddObject(module, \"" << export_class_name2 << "\", " << class_ptr << ");\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user