From 615a0bc06c45a25689cd58eb4d5661eb720fadeb Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 30 Nov 2000 03:26:25 +0000 Subject: [PATCH] *** empty log message *** --- dtool/src/interrogate/interrogateBuilder.cxx | 19 +++++++-- panda/src/cull/cullTraverser.h | 1 + panda/src/gobj/texturePool.I | 24 +++++++++++ panda/src/gobj/texturePool.cxx | 43 ++++++++++++++++++++ panda/src/gobj/texturePool.h | 6 +++ panda/src/loader/modelPool.I | 24 +++++++++++ panda/src/loader/modelPool.cxx | 43 ++++++++++++++++++++ panda/src/loader/modelPool.h | 6 +++ 8 files changed, 162 insertions(+), 4 deletions(-) diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index 80f3c44d81..6f5fb83050 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -2133,11 +2133,20 @@ define_method(CPPInstance *function, InterrogateType &itype, force_publish = true; } + if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { + // A destructor is a special case. If it's public, we export it + // (even if it's not published), but if it's protected or private, + // we don't exported it, and we flag it so we don't try to + // synthesize one later. + if (function->_vis > V_public) { + itype._flags |= InterrogateType::F_private_destructor; + return; + } + force_publish = true; + } + if (!force_publish && function->_vis > min_vis) { // The function is not marked to be exported. - if ((ftype->_flags & CPPFunctionType::F_destructor) != 0) { - itype._flags |= InterrogateType::F_private_destructor; - } return; } @@ -2165,7 +2174,9 @@ define_method(CPPInstance *function, InterrogateType &itype, } if ((function->_storage_class & CPPInstance::SC_inherited_virtual) != 0 && - struct_type->_derivation.size() == 1) { + struct_type->_derivation.size() == 1 && + struct_type->_derivation[0]._vis <= V_public && + !struct_type->_derivation[0]._is_virtual) { // If this function is a virtual function whose first appearance // is in some base class, we don't need to repeat its definition // here, since we're already inheriting it properly. However, we diff --git a/panda/src/cull/cullTraverser.h b/panda/src/cull/cullTraverser.h index 2baa9077f3..8e9ca397c2 100644 --- a/panda/src/cull/cullTraverser.h +++ b/panda/src/cull/cullTraverser.h @@ -52,6 +52,7 @@ public: INLINE void draw_direct(Node *node, const AllAttributesWrapper &initial_state); +PUBLISHED: void output(ostream &out) const; void write(ostream &out, int indent_level = 0) const; diff --git a/panda/src/gobj/texturePool.I b/panda/src/gobj/texturePool.I index ff468bcead..526463eba4 100644 --- a/panda/src/gobj/texturePool.I +++ b/panda/src/gobj/texturePool.I @@ -100,6 +100,30 @@ release_all_textures() { get_ptr()->ns_release_all_textures(); } +//////////////////////////////////////////////////////////////////// +// Function: TexturePool::garbage_collect +// Access: Public, Static +// Description: Releases only those textures in the pool that have a +// reference count of exactly 1; i.e. only those +// textures that are not being used outside of the pool. +// Returns the number of textures released. +//////////////////////////////////////////////////////////////////// +INLINE int TexturePool:: +garbage_collect() { + return get_ptr()->ns_garbage_collect(); +} + +//////////////////////////////////////////////////////////////////// +// Function: TexturePool::list_contents +// Access: Public, Static +// Description: Lists the contents of the texture pool to the +// indicated output stream. +//////////////////////////////////////////////////////////////////// +INLINE void TexturePool:: +list_contents(ostream &out) { + get_ptr()->ns_list_contents(out); +} + //////////////////////////////////////////////////////////////////// // Function: TexturePool::Constructor // Access: Private diff --git a/panda/src/gobj/texturePool.cxx b/panda/src/gobj/texturePool.cxx index c022d840f8..4068ef2854 100644 --- a/panda/src/gobj/texturePool.cxx +++ b/panda/src/gobj/texturePool.cxx @@ -136,6 +136,49 @@ ns_release_all_textures() { _textures.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: TexturePool::ns_garbage_collect +// Access: Private +// Description: The nonstatic implementation of garbage_collect(). +//////////////////////////////////////////////////////////////////// +int TexturePool:: +ns_garbage_collect() { + int num_released = 0; + Textures new_set; + + Textures::iterator ti; + for (ti = _textures.begin(); ti != _textures.end(); ++ti) { + Texture *tex = (*ti).second; + if (tex->get_ref_count() == 1) { + if (gobj_cat.is_debug()) { + gobj_cat.debug() + << "Releasing " << (*ti).first << "\n"; + } + num_released++; + } else { + new_set.insert(new_set.end(), *ti); + } + } + + _textures.swap(new_set); + return num_released; +} + +//////////////////////////////////////////////////////////////////// +// Function: TexturePool::ns_list_contents +// Access: Private +// Description: The nonstatic implementation of list_contents(). +//////////////////////////////////////////////////////////////////// +void TexturePool:: +ns_list_contents(ostream &out) { + out << _textures.size() << " textures:\n"; + Textures::iterator ti; + for (ti = _textures.begin(); ti != _textures.end(); ++ti) { + out << " " << (*ti).first + << " (count = " << (*ti).second->get_ref_count() << ")\n"; + } +} + //////////////////////////////////////////////////////////////////// // Function: TexturePool::get_ptr // Access: Private, Static diff --git a/panda/src/gobj/texturePool.h b/panda/src/gobj/texturePool.h index bdf154d60d..e49d67535f 100644 --- a/panda/src/gobj/texturePool.h +++ b/panda/src/gobj/texturePool.h @@ -36,6 +36,10 @@ PUBLISHED: INLINE static void release_texture(Texture *texture); INLINE static void release_all_textures(); + INLINE static int garbage_collect(); + + INLINE static void list_contents(ostream &out); + private: INLINE TexturePool(); @@ -45,6 +49,8 @@ private: void ns_add_texture(Texture *texture); void ns_release_texture(Texture *texture); void ns_release_all_textures(); + int ns_garbage_collect(); + void ns_list_contents(ostream &out); static TexturePool *get_ptr(); diff --git a/panda/src/loader/modelPool.I b/panda/src/loader/modelPool.I index 6d75701712..d72dc0043a 100644 --- a/panda/src/loader/modelPool.I +++ b/panda/src/loader/modelPool.I @@ -81,6 +81,30 @@ release_all_models() { get_ptr()->ns_release_all_models(); } +//////////////////////////////////////////////////////////////////// +// Function: ModelPool::garbage_collect +// Access: Public, Static +// Description: Releases only those models in the pool that have a +// reference count of exactly 1; i.e. only those +// models that are not being used outside of the pool. +// Returns the number of models released. +//////////////////////////////////////////////////////////////////// +INLINE int ModelPool:: +garbage_collect() { + return get_ptr()->ns_garbage_collect(); +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelPool::list_contents +// Access: Public, Static +// Description: Lists the contents of the model pool to the +// indicated output stream. +//////////////////////////////////////////////////////////////////// +INLINE void ModelPool:: +list_contents(ostream &out) { + get_ptr()->ns_list_contents(out); +} + //////////////////////////////////////////////////////////////////// // Function: ModelPool::Constructor // Access: Private diff --git a/panda/src/loader/modelPool.cxx b/panda/src/loader/modelPool.cxx index 5372239a51..a9fa0b9b10 100644 --- a/panda/src/loader/modelPool.cxx +++ b/panda/src/loader/modelPool.cxx @@ -90,6 +90,49 @@ ns_release_all_models() { _models.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: ModelPool::ns_garbage_collect +// Access: Private +// Description: The nonstatic implementation of garbage_collect(). +//////////////////////////////////////////////////////////////////// +int ModelPool:: +ns_garbage_collect() { + int num_released = 0; + Models new_set; + + Models::iterator ti; + for (ti = _models.begin(); ti != _models.end(); ++ti) { + Node *node = (*ti).second; + if (node->get_ref_count() == 1) { + if (loader_cat.is_debug()) { + loader_cat.debug() + << "Releasing " << (*ti).first << "\n"; + } + num_released++; + } else { + new_set.insert(new_set.end(), *ti); + } + } + + _models.swap(new_set); + return num_released; +} + +//////////////////////////////////////////////////////////////////// +// Function: ModelPool::ns_list_contents +// Access: Private +// Description: The nonstatic implementation of list_contents(). +//////////////////////////////////////////////////////////////////// +void ModelPool:: +ns_list_contents(ostream &out) { + out << _models.size() << " models:\n"; + Models::iterator ti; + for (ti = _models.begin(); ti != _models.end(); ++ti) { + out << " " << (*ti).first + << " (count = " << (*ti).second->get_ref_count() << ")\n"; + } +} + //////////////////////////////////////////////////////////////////// // Function: ModelPool::get_ptr // Access: Private, Static diff --git a/panda/src/loader/modelPool.h b/panda/src/loader/modelPool.h index 84f011d288..e897cf4843 100644 --- a/panda/src/loader/modelPool.h +++ b/panda/src/loader/modelPool.h @@ -42,6 +42,10 @@ PUBLISHED: INLINE static void release_model(const string &filename); INLINE static void release_all_models(); + INLINE static int garbage_collect(); + + INLINE static void list_contents(ostream &out); + private: INLINE ModelPool(); @@ -50,6 +54,8 @@ private: void ns_add_model(const string &filename, Node *model); void ns_release_model(const string &filename); void ns_release_all_models(); + int ns_garbage_collect(); + void ns_list_contents(ostream &out); static ModelPool *get_ptr();