diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 81069c4df8..e7836a2a33 100755 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -1142,9 +1142,6 @@ write_module_class(ostream &out, Object *obj) { } } - bool is_runtime_typed = IsPandaTypedObject(obj->_itype._cpptype->as_struct_type()); - - InterrogateDatabase *idb = InterrogateDatabase::get_ptr(); std::string ClassName = make_safe_name(obj->_itype.get_scoped_name()); @@ -1532,6 +1529,10 @@ write_module_class(ostream &out, Object *obj) { } + bool is_runtime_typed = IsPandaTypedObject(obj->_itype._cpptype->as_struct_type()); + if (HasAGetClassTypeFunction(obj->_itype)) { + is_runtime_typed = true; + } if(is_runtime_typed) out << " RegisterRuntimeClass(&Dtool_"<get_function(func_index); + if (ifunc.get_name() == "get_class_type") { + if (ifunc._instances != (InterrogateFunction::Instances *)NULL) { + InterrogateFunction::Instances::const_iterator ii; + for (ii = ifunc._instances->begin();ii != ifunc._instances->end();++ii) { + CPPInstance *cppinst = (*ii).second; + CPPFunctionType *cppfunc = cppinst->_type->as_function_type(); + + if (cppfunc != NULL && cppfunc->_return_type != NULL && + cppfunc->_parameters != NULL) { + CPPType *ret_type = TypeManager::unwrap(cppfunc->_return_type); + if (TypeManager::is_struct(ret_type) && + ret_type->get_simple_name() == "TypeHandle") { + if(cppfunc->_parameters->_parameters.size() == 0) { + return true; + } + } + } + + } + } + } + } + return false; +} + //////////////////////////////////////////////////////////////////// // Function: InterfaceMakerPythonNative::NeedsAStrFunction // Access: Private diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.h b/dtool/src/interrogate/interfaceMakerPythonNative.h index 5960da3706..897ae50656 100755 --- a/dtool/src/interrogate/interfaceMakerPythonNative.h +++ b/dtool/src/interrogate/interfaceMakerPythonNative.h @@ -108,6 +108,7 @@ public: bool IsPandaTypedObject(CPPStructType * inclass) { return DoesInheritFromIsClass(inclass,"TypedObject"); }; void WriteReturnInstance(ostream &out, int indent_level, std::string &return_expr, std::string &ows_memory_flag,const std::string &class_name, CPPType *ctype, bool inplace, const std::string &const_flag); bool HasAGetKeyFunction(const InterrogateType &itype_class); + bool HasAGetClassTypeFunction(const InterrogateType &itype_class); int NeedsAStrFunction(const InterrogateType &itype_class); int NeedsAReprFunction(const InterrogateType &itype_class); diff --git a/dtool/src/interrogatedb/py_panda.cxx b/dtool/src/interrogatedb/py_panda.cxx index a924f5ad29..93c30a98d8 100644 --- a/dtool/src/interrogatedb/py_panda.cxx +++ b/dtool/src/interrogatedb/py_panda.cxx @@ -196,7 +196,7 @@ PyObject * DTool_CreatePyInstanceTyped(void * local_this_in, Dtool_PyTypedObject // if we get this far .. just wrap the thing in the known type ?? // better than aborting...I guess.... ///////////////////////////////////////////////////// - Dtool_PyInstDef * self = (Dtool_PyInstDef *) known_class_type.As_PyTypeObject().tp_new(&known_class_type.As_PyTypeObject(), NULL,NULL); + Dtool_PyInstDef * self = (Dtool_PyInstDef *) known_class_type.As_PyTypeObject().tp_new(&known_class_type.As_PyTypeObject(), NULL,NULL); if(self != NULL) { self->_ptr_to_object = local_this_in;