Stop using object array for wxDynamicLibraryDetailsArray
Use a simple wxBaseArray of wxDynamicLibraryDetails objects. Also document this container.
This commit is contained in:
parent
16842b2b2f
commit
78ae3f0b16
5 changed files with 25 additions and 23 deletions
|
|
@ -202,9 +202,7 @@ private:
|
|||
friend class wxDynamicLibraryDetailsCreator;
|
||||
};
|
||||
|
||||
WX_DECLARE_USER_EXPORTED_OBJARRAY(wxDynamicLibraryDetails,
|
||||
wxDynamicLibraryDetailsArray,
|
||||
WXDLLIMPEXP_BASE);
|
||||
using wxDynamicLibraryDetailsArray = wxBaseArray<wxDynamicLibraryDetails>;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxDynamicLibrary: represents a handle to a DLL/shared object
|
||||
|
|
|
|||
|
|
@ -56,6 +56,14 @@ public:
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
A vector of wxDynamicLibraryDetails.
|
||||
|
||||
This class is actually a legacy container (see @ref overview_container for
|
||||
more details), but it can, and should be, handled as just a vector of
|
||||
wxDynamicLibraryDetails objects in the application code.
|
||||
*/
|
||||
using wxDynamicLibraryDetailsArray = std::vector<wxDynamicLibraryDetails>;
|
||||
|
||||
/**
|
||||
Dynamic library category used with wxDynamicLibrary::CanonicalizeName().
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@
|
|||
#include "wx/filename.h" // for SplitPath()
|
||||
#include "wx/platinfo.h"
|
||||
|
||||
#include "wx/arrimpl.cpp"
|
||||
|
||||
WX_DEFINE_USER_EXPORTED_OBJARRAY(wxDynamicLibraryDetailsArray)
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
|
|
|||
|
|
@ -97,26 +97,26 @@ wxDynamicLibraryDetailsCreator::EnumModulesProc(const wxChar* name,
|
|||
{
|
||||
EnumModulesProcParams *params = (EnumModulesProcParams *)data;
|
||||
|
||||
wxDynamicLibraryDetails *details = new wxDynamicLibraryDetails;
|
||||
wxDynamicLibraryDetails details;
|
||||
|
||||
// fill in simple properties
|
||||
details->m_name = name;
|
||||
details->m_address = wxUIntToPtr(base);
|
||||
details->m_length = size;
|
||||
details.m_name = name;
|
||||
details.m_address = wxUIntToPtr(base);
|
||||
details.m_length = size;
|
||||
|
||||
// to get the version, we first need the full path
|
||||
const HMODULE hmod = wxDynamicLibrary::MSWGetModuleHandle
|
||||
(
|
||||
details->m_name,
|
||||
details->m_address
|
||||
details.m_name,
|
||||
details.m_address
|
||||
);
|
||||
if ( hmod )
|
||||
{
|
||||
wxString fullname = wxGetFullModuleName(hmod);
|
||||
if ( !fullname.empty() )
|
||||
{
|
||||
details->m_path = fullname;
|
||||
details->m_version = GetFileVersion(fullname);
|
||||
details.m_path = fullname;
|
||||
details.m_version = GetFileVersion(fullname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,14 +131,14 @@ class wxDynamicLibraryDetailsCreator
|
|||
{
|
||||
public:
|
||||
// create a new wxDynamicLibraryDetails from the given data
|
||||
static wxDynamicLibraryDetails *
|
||||
static wxDynamicLibraryDetails
|
||||
New(void *start, void *end, const wxString& path)
|
||||
{
|
||||
wxDynamicLibraryDetails *details = new wxDynamicLibraryDetails;
|
||||
details->m_path = path;
|
||||
details->m_name = path.AfterLast(wxT('/'));
|
||||
details->m_address = start;
|
||||
details->m_length = (char *)end - (char *)start;
|
||||
wxDynamicLibraryDetails details;
|
||||
details.m_path = path;
|
||||
details.m_name = path.AfterLast(wxT('/'));
|
||||
details.m_address = start;
|
||||
details.m_length = (char *)end - (char *)start;
|
||||
|
||||
// try to extract the library version from its name
|
||||
const size_t posExt = path.rfind(wxT(".so"));
|
||||
|
|
@ -147,7 +147,7 @@ public:
|
|||
if ( path.c_str()[posExt + 3] == wxT('.') )
|
||||
{
|
||||
// assume "libfoo.so.x.y.z" case
|
||||
details->m_version.assign(path, posExt + 4, wxString::npos);
|
||||
details.m_version.assign(path, posExt + 4, wxString::npos);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -156,7 +156,7 @@ public:
|
|||
{
|
||||
// assume "libbar-x.y.z.so" case
|
||||
posDash++;
|
||||
details->m_version.assign(path, posDash, posExt - posDash);
|
||||
details.m_version.assign(path, posDash, posExt - posDash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue