+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+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
+ // name without appending the usual dll
+ // filename extension.
+
+ // this flag is obsolete, don't use
+ wxDL_NOSHARE = 0x00000010, // load new DLL, don't reuse already loaded
+ // (only for wxPluginManager)
+
+ wxDL_QUIET = 0x00000020, // don't log an error if failed to load
+
+ // this flag is dangerous, for internal use of wxMSW only, don't use at all
+ // and especially don't use directly, use wxLoadedDLL instead if you really
+ // do need it
+ wxDL_GET_LOADED = 0x00000040, // Win32 only: return handle of already
+ // loaded DLL or NULL otherwise; Unload()
+ // should not be called so don't forget to
+ // Detach() if you use this function
+
+ wxDL_DEFAULT = wxDL_NOW // default flags correspond to Win32
+};
+
+enum wxDynamicLibraryCategory
+{
+ wxDL_LIBRARY, // standard library
+ wxDL_MODULE // loadable module/plugin
+};
+
+enum wxPluginCategory
+{
+ wxDL_PLUGIN_GUI, // plugin that uses GUI classes
+ wxDL_PLUGIN_BASE // wxBase-only plugin
+};
+
+// ----------------------------------------------------------------------------
+// macros
+// ----------------------------------------------------------------------------
+
+// when loading a function from a DLL you always have to cast the returned
+// "void *" pointer to the correct type and, even more annoyingly, you have to
+// repeat this type twice if you want to declare and define a function pointer
+// all in one line
+//
+// this macro makes this slightly less painful by allowing you to specify the
+// type only once, as the first parameter, and creating a variable of this type
+// called "pfn<name>" initialized with the "name" from the "dynlib"
+#define wxDYNLIB_FUNCTION(type, name, dynlib) \
+ type pfn ## name = (type)(dynlib).GetSymbol(wxT(#name))
+
+
+// a more convenient function replacing wxDYNLIB_FUNCTION above
+//
+// it uses the convention that the type of the function is its name suffixed
+// with "_t" but it doesn't define a variable but just assigns the loaded value
+// to it and also allows to pass it the prefix to be used instead of hardcoding
+// "pfn" (the prefix can be "m_" or "gs_pfn" or whatever)
+//
+// notice that this function doesn't generate error messages if the symbol
+// couldn't be loaded, the caller should generate the appropriate message
+#define wxDL_INIT_FUNC(pfx, name, dynlib) \
+ pfx ## name = (name ## _t)(dynlib).RawGetSymbol(#name)
+
+#ifdef __WXMSW__
+
+// same as wxDL_INIT_FUNC() but appends 'A' or 'W' to the function name, see
+// wxDynamicLibrary::GetSymbolAorW()
+#define wxDL_INIT_FUNC_AW(pfx, name, dynlib) \
+ pfx ## name = (name ## _t)(dynlib).GetSymbolAorW(#name)
+
+#endif // __WXMSW__
+
+// the following macros can be used to redirect a whole library to a class and
+// check at run-time if the library is present and contains all required
+// methods
+//
+// notice that they are supposed to be used inside a class which has "m_ok"
+// member variable indicating if the library had been successfully loaded
+
+// helper macros constructing the name of the variable storing the function
+// pointer and the name of its type from the function name
+#define wxDL_METHOD_NAME(name) m_pfn ## name
+#define wxDL_METHOD_TYPE(name) name ## _t
+
+// parameters are:
+// - rettype: return type of the function, e.g. "int"
+// - name: name of the function, e.g. "foo"
+// - args: function signature in parentheses, e.g. "(int x, int y)"
+// - argnames: the names of the parameters in parentheses, e.g. "(x, y)"
+// - defret: the value to return if the library wasn't successfully loaded
+#define wxDL_METHOD_DEFINE( rettype, name, args, argnames, defret ) \
+ typedef rettype (* wxDL_METHOD_TYPE(name)) args ; \
+ wxDL_METHOD_TYPE(name) wxDL_METHOD_NAME(name); \
+ rettype name args \
+ { return m_ok ? wxDL_METHOD_NAME(name) argnames : defret; }
+
+#define wxDL_VOIDMETHOD_DEFINE( name, args, argnames ) \
+ typedef void (* wxDL_METHOD_TYPE(name)) args ; \
+ wxDL_METHOD_TYPE(name) wxDL_METHOD_NAME(name); \
+ void name args \
+ { if ( m_ok ) wxDL_METHOD_NAME(name) argnames ; }
+
+#define wxDL_METHOD_LOAD(lib, name) \
+ wxDL_METHOD_NAME(name) = \
+ (wxDL_METHOD_TYPE(name)) lib.GetSymbol(#name, &m_ok); \
+ if ( !m_ok ) return false
+
+// ----------------------------------------------------------------------------
+// wxDynamicLibraryDetails: contains details about a loaded wxDynamicLibrary
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxDynamicLibraryDetails
+{
+public:
+ // ctor, normally never used as these objects are only created by
+ // wxDynamicLibrary::ListLoaded()
+ wxDynamicLibraryDetails() { m_address = NULL; m_length = 0; }