# pragma interface "dynlib.h"
#endif
-#include "wx/setup.h"
+#include "wx/defs.h"
#if wxUSE_DYNLIB_CLASS
#include "wx/string.h"
#include "wx/dynarray.h"
-// FIXME: can this go in private.h or something too??
#if defined(__WXPM__) || defined(__EMX__)
-#define INCL_DOS
-#include <os2.h>
+#include "wx/os2/private.h"
#endif
#ifdef __WXMSW__
#include "wx/msw/private.h"
#endif
+#if defined(HAVE_DLERROR) && !defined(__EMX__)
+ #define wxHAVE_DYNLIB_ERROR
+#endif
+
class WXDLLIMPEXP_BASE wxDynamicLibraryDetailsCreator;
// ----------------------------------------------------------------------------
enum wxDLFlags
{
wxDL_LAZY = 0x00000001, // resolve undefined symbols at first use
+ // (only works on some Unix versions)
wxDL_NOW = 0x00000002, // resolve undefined symbols on load
+ // (default, always the case under Win32)
wxDL_GLOBAL = 0x00000004, // export extern symbols to subsequently
// loaded libs.
- wxDL_VERBATIM = 0x00000008, // Attempt to load the supplied library
+ wxDL_VERBATIM = 0x00000008, // attempt to load the supplied library
// name without appending the usual dll
// filename extension.
-
wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded
+ // (only for wxPluginManager)
- // FIXME: why? (VZ)
-#ifdef __osf__
- wxDL_DEFAULT = wxDL_LAZY
-#else
- wxDL_DEFAULT = wxDL_LAZY | wxDL_GLOBAL
-#endif
+ wxDL_DEFAULT = wxDL_NOW // default flags correspond to Win32
};
enum wxDynamicLibraryCategory
// raw function for loading dynamic libs: always behaves as if
// wxDL_VERBATIM were specified and doesn't log error message if the
// library couldn't be loaded but simply returns NULL
- static wxDllType RawLoad(const wxString& libname);
-
+ static wxDllType RawLoad(const wxString& libname, int flags = wxDL_DEFAULT);
+
// detach the library object from its handle, i.e. prevent the object from
// unloading the library in its dtor -- the caller is now responsible for
// doing this
static void *RawGetSymbol(wxDllType handle, const wxString& name);
void *RawGetSymbol(const wxString& name) const
{
+#if defined (__WXPM__) || defined(__EMX__)
+ return GetSymbol(name);
+#else
return RawGetSymbol(m_handle, name);
+#endif
+ }
+
+#ifdef __WXMSW__
+ // this function is useful for loading functions from the standard Windows
+ // DLLs: such functions have an 'A' (in ANSI build) or 'W' (in Unicode, or
+ // wide character build) suffix if they take string parameters
+ static void *RawGetSymbolAorW(wxDllType handle, const wxString& name)
+ {
+ return RawGetSymbol
+ (
+ handle,
+ name +
+#if wxUSE_UNICODE
+ L'W'
+#else
+ 'A'
+#endif
+ );
}
+ void *GetSymbolAorW(const wxString& name) const
+ {
+ return RawGetSymbolAorW(m_handle, name);
+ }
+#endif // __WXMSW__
+
// return all modules/shared libraries in the address space of this process
//
- // returns an empty array if not implemented or an error occured
+ // returns an empty array if not implemented or an error occurred
static wxDynamicLibraryDetailsArray ListLoaded();
// return platform-specific name of dynamic library with proper extension
// common part of GetSymbol() and HasSymbol()
void *DoGetSymbol(const wxString& name, bool *success = 0) const;
+#ifdef wxHAVE_DYNLIB_ERROR
+ // log the error after a dlxxx() function failure
+ static void Error();
+#endif // wxHAVE_DYNLIB_ERROR
+
// platform specific shared lib suffix.
static const wxChar *ms_dllext;