X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7a4b9130e341e8ed5192cac76574119fb6664c6c..6f34921d9369a31de14e4b07e4824e2d701710f0:/src/common/dynlib.cpp?ds=inline diff --git a/src/common/dynlib.cpp b/src/common/dynlib.cpp index 4f638aac53..db17f823d4 100644 --- a/src/common/dynlib.cpp +++ b/src/common/dynlib.cpp @@ -22,10 +22,14 @@ // System dependent include // --------------------------------------------------------------------------- -#ifdef linux +#ifdef __UNIX__ #include #endif +#ifdef __WINDOWS__ +#include +#endif + // --------------------------------------------------------------------------- // Global variables // --------------------------------------------------------------------------- @@ -59,7 +63,12 @@ wxLibrary::~wxLibrary() else delete m_liblist; +#ifdef __UNIX__ dlclose(m_handle); +#endif +#ifdef __WINDOWS__ + FreeLibrary((HMODULE)m_handle); +#endif } } @@ -70,9 +79,13 @@ wxObject *wxLibrary::CreateObject(const wxString& name) void *wxLibrary::GetSymbol(const wxString& symbname) { -#ifdef linux - return dlsym(m_handle, symbname.GetData()); +#ifdef __UNIX__ + return dlsym(m_handle, WXSTRINGCAST symbname); +#endif +#ifdef __WINDOWS__ + return GetProcAddress(m_handle, WXSTRINGCAST symbname); #endif + return NULL; } // --------------------------------------------------------------------------- @@ -104,22 +117,25 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name) if ( (node = m_loaded.Find(name.GetData())) ) return ((wxLibrary *)node->Data()); -#ifdef linux +#ifdef __UNIX__ lib_name.Prepend("./lib"); lib_name += ".so"; printf("lib_name = %s\n", WXSTRINGCAST lib_name); - void *handle = dlopen(lib_name.GetData(), RTLD_LAZY); - - printf("handle = %x\n", handle); - lib = new wxLibrary(handle); + void *handle = dlopen(WXSTRINGCAST lib_name, RTLD_LAZY); + if (!handle) + return NULL; #endif #ifdef __WINDOWS__ lib_name += ".dll"; + HMODULE handle = LoadLibrary(lib_name); + if (!handle) + return NULL; #endif + lib = new wxLibrary((void *)handle); m_loaded.Append(name.GetData(), lib); return lib; @@ -150,7 +166,7 @@ wxClassLibrary::wxClassLibrary(void) wxClassLibrary::~wxClassLibrary(void) { - uint i; + size_t i; for (i=0;iclass_info == class_info) { @@ -184,7 +200,7 @@ bool wxClassLibrary::CreateObjects(const wxString& path, wxArrayClassInfo& objs) { wxClassLibInfo *info; - uint i = 0; + size_t i = 0; while (i < m_list.Count()) { info = m_list[i]; @@ -199,7 +215,7 @@ bool wxClassLibrary::FetchInfos(const wxString& path, wxArrayClassLibInfo& infos) { wxClassLibInfo *info; - uint i = 0; + size_t i = 0; while (i < m_list.Count()) { info = m_list[i]; @@ -216,7 +232,7 @@ bool wxClassLibrary::FetchInfos(const wxString& path, wxObject *wxClassLibrary::CreateObject(const wxString& path) { wxClassLibInfo *info; - uint i = 0; + size_t i = 0; while (i < m_list.Count()) { info = m_list[i];