X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1bc7510adb4d74edabbefb77fac09bdc49aa776c..588c80dea16b3ab32c7f1f8f15b62eb4450a20a9:/src/common/dynload.cpp diff --git a/src/common/dynload.cpp b/src/common/dynload.cpp index b38dbf6046..562b6ce975 100644 --- a/src/common/dynload.cpp +++ b/src/common/dynload.cpp @@ -10,10 +10,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "dynload.h" -#endif - // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- @@ -58,9 +54,9 @@ public: // TODO: create ms_classes on demand, why always preallocate it? virtual bool OnInit() { - wxPluginLibrary::ms_classes = new wxDLImports(wxKEY_STRING); + wxPluginLibrary::ms_classes = new wxDLImports; wxPluginManager::CreateManifest(); - return TRUE; + return true; } virtual void OnExit() @@ -87,7 +83,7 @@ wxPluginLibrary::wxPluginLibrary(const wxString &libname, int flags) if( m_handle != 0 ) { - UpdateClassInfo(); + UpdateClasses(); RegisterModules(); } else @@ -102,7 +98,7 @@ wxPluginLibrary::~wxPluginLibrary() if( m_handle != 0 ) { UnregisterModules(); - RestoreClassInfo(); + RestoreClasses(); } } @@ -120,77 +116,41 @@ bool wxPluginLibrary::UnrefLib() wxASSERT_MSG( m_objcount == 0, _T("Library unloaded before all objects were destroyed") ); - if ( --m_linkcount == 0 ) + if ( m_linkcount == 0 || --m_linkcount == 0 ) { delete this; - return TRUE; + return true; } - return FALSE; + return false; } // ------------------------ // Private methods // ------------------------ -void wxPluginLibrary::UpdateClassInfo() +void wxPluginLibrary::UpdateClasses() { - wxClassInfo *info; - wxHashTable *t = wxClassInfo::sm_classTable; - - // FIXME: Below is simply a cut and paste specialisation of - // wxClassInfo::InitializeClasses. Once this stabilises, - // the two should probably be merged. - // - // Actually it's becoming questionable whether we should merge - // this info with the main ClassInfo tables since we can nearly - // handle this completely internally now and it does expose - // certain (minimal % user_stupidy) risks. - - for(info = m_after; info != m_before; info = info->m_next) + for (wxClassInfo *info = m_after; info != m_before; info = info->m_next) { - if( info->m_className ) + if( info->GetClassName() ) { - if( t->Get(info->m_className) == 0 ) - t->Put(info->m_className, (wxObject *)info); - // Hash all the class names into a local table too so // we can quickly find the entry they correspond to. - (*ms_classes)[info->m_className] = this; + (*ms_classes)[info->GetClassName()] = this; } } - -#if wxUSE_EXTENDED_RTTI == 0 - for(info = m_after; info != m_before; info = info->m_next) - { - if( info->m_baseClassName1 ) - info->m_baseInfo1 = (wxClassInfo *)t->Get(info->m_baseClassName1); - if( info->m_baseClassName2 ) - info->m_baseInfo2 = (wxClassInfo *)t->Get(info->m_baseClassName2); - } -#endif } -void wxPluginLibrary::RestoreClassInfo() +void wxPluginLibrary::RestoreClasses() { - wxClassInfo *info; + // Check if there is a need to restore classes. + if (!ms_classes) + return; - for(info = m_after; info != m_before; info = info->m_next) + for(wxClassInfo *info = m_after; info != m_before; info = info->m_next) { - wxClassInfo::sm_classTable->Delete(info->m_className); - ms_classes->erase(ms_classes->find(info->m_className)); - } - - if( wxClassInfo::sm_first == m_after ) - wxClassInfo::sm_first = m_before; - else - { - info = wxClassInfo::sm_first; - while( info->m_next && info->m_next != m_after ) info = info->m_next; - - wxASSERT_MSG( info, _T("ClassInfo from wxPluginLibrary not found on purge")); - - info->m_next = m_before; + ms_classes->erase(ms_classes->find(info->GetClassName())); } } @@ -262,7 +222,8 @@ void wxPluginLibrary::UnregisterModules() for ( it = m_wxmodules.begin(); it != m_wxmodules.end(); ++it ) wxModule::UnregisterModule( *it ); - WX_CLEAR_LIST(wxModuleList, m_wxmodules); + // NB: content of the list was deleted by UnregisterModule calls above: + m_wxmodules.clear(); } @@ -351,7 +312,7 @@ bool wxPluginManager::UnloadLibrary(const wxString& libname) wxLogDebug(_T("Attempt to unload library '%s' which is not loaded."), libname.c_str()); - return FALSE; + return false; } wxLogTrace(_T("dll"), _T("UnloadLibrary(%s)"), realname.c_str()); @@ -359,12 +320,12 @@ bool wxPluginManager::UnloadLibrary(const wxString& libname) if ( !entry->UnrefLib() ) { // not really unloaded yet - return FALSE; + return false; } ms_manifest->erase(ms_manifest->find(realname)); - return TRUE; + return true; } // ------------------------ @@ -455,7 +416,7 @@ wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name, bool *success) wxFAIL_MSG( _T("Using a library not loaded with wxDllLoader?") ); if ( success ) - *success = FALSE; + *success = false; return NULL; } @@ -497,7 +458,7 @@ wxLibrary::wxLibrary(wxDllType handle) // Some system may use a local heap for library. get_first = (t_get_first)GetSymbol(_T("wxGetClassFirst")); - // It is a wxWindows DLL. + // It is a wxWidgets DLL. if (get_first) PrepareClasses(get_first()); } @@ -531,7 +492,7 @@ void wxLibrary::PrepareClasses(wxClassInfo *first) info = info->m_next; } -#if wxUSE_EXTENDED_RTTI == 0 +#if !wxUSE_EXTENDED_RTTI // Set base pointers for each wxClassInfo info = first; while (info) @@ -561,13 +522,13 @@ wxLibraries::wxLibraries():m_loaded(wxKEY_STRING) wxLibraries::~wxLibraries() { - wxNode *node = m_loaded.First(); + wxNode *node = m_loaded.GetFirst(); while (node) { - wxLibrary *lib = (wxLibrary *)node->Data(); + wxLibrary *lib = (wxLibrary *)node->GetData(); delete lib; - node = node->Next(); + node = node->GetNext(); } } @@ -578,7 +539,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name) wxNode *node = m_loaded.Find(name.GetData()); if (node != NULL) - return ((wxLibrary *)node->Data()); + return ((wxLibrary *)node->GetData()); // If DLL shares data, this is necessary. old_sm_first = wxClassInfo::sm_first; @@ -586,7 +547,7 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name) wxString libname = ConstructLibraryName(name); - bool success = FALSE; + bool success = false; wxDllType handle = wxDllLoader::LoadLibrary(libname, &success); if(success) { @@ -602,15 +563,15 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name) wxObject *wxLibraries::CreateObject(const wxString& path) { - wxNode *node = m_loaded.First(); + wxNode *node = m_loaded.GetFirst(); wxObject *obj; while (node) { - obj = ((wxLibrary *)node->Data())->CreateObject(path); + obj = ((wxLibrary *)node->GetData())->CreateObject(path); if (obj) return obj; - node = node->Next(); + node = node->GetNext(); } return NULL; }