Added new dynamic loading classes. (which handle proper
wxRTTI and wxModule initialisation and unloading) Removed serialisation code from wxObject and elsewhere. Added USER_EXPORTED hash and list macros. Added *_PLUGGABLE_CLASS defines for exporting dynamic wxObjects from dlls. ---------------------------------------------------------------------- Modified Files: Makefile.in configure configure.in setup.h.in debian/changelog distrib/msw/tmake/filelist.txt include/wx/defs.h include/wx/docview.h include/wx/dynlib.h include/wx/fileconf.h include/wx/hash.h include/wx/list.h include/wx/module.h include/wx/object.h include/wx/resource.h include/wx/stream.h include/wx/gtk/setup0.h include/wx/msw/setup0.h src/files.lst src/wxBase.dsp src/wxUniv.dsp src/wxWindows.dsp src/common/dynlib.cpp src/common/filename.cpp src/common/module.cpp src/common/object.cpp src/common/stream.cpp src/gtk/files.lst src/mac/files.lst src/mgl/files.lst src/mgl/makefile.wat src/motif/files.lst src/msw/dialup.cpp src/msw/files.lst src/msw/helpchm.cpp src/msw/makefile.b32 src/msw/makefile.bcc src/msw/makefile.dos src/msw/makefile.g95 src/msw/makefile.sc src/msw/makefile.vc src/msw/makefile.wat src/os2/files.lst src/univ/files.lst Added Files: include/wx/dynload.h src/common/dynload.cpp Removed Files: include/wx/objstrm.h include/wx/serbase.h src/common/objstrm.cpp src/common/serbase.cpp utils/serialize/.cvsignore utils/serialize/makefile.b32 utils/serialize/sercore.cpp utils/serialize/sercore.h utils/serialize/serctrl.cpp utils/serialize/serctrl.h utils/serialize/serext.cpp utils/serialize/serext.h utils/serialize/sergdi.cpp utils/serialize/sergdi.h utils/serialize/sermain.cpp utils/serialize/serwnd.cpp utils/serialize/serwnd.h ---------------------------------------------------------------------- git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13088 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -180,6 +180,23 @@ typedef short int WXTYPE;
|
||||
// because -1 is a valid (and largely used) value for window id.
|
||||
typedef int wxWindowID;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// other feature tests
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Every ride down a slippery slope begins with a single step..
|
||||
//
|
||||
// Yes, using nested classes is indeed against our coding standards in
|
||||
// general, but there are places where you can use them to advantage
|
||||
// without totally breaking ports that cannot use them. If you do, then
|
||||
// wrap it in this guard, but such cases should still be relatively rare.
|
||||
|
||||
#ifndef __WIN16__
|
||||
#define wxUSE_NESTED_CLASSES 1
|
||||
#else
|
||||
#define wxUSE_NESTED_CLASSES 0
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// portable calling conventions macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -96,11 +96,6 @@ public:
|
||||
virtual wxInputStream& LoadObject(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
// need this to keep from hiding the virtual from wxObject
|
||||
virtual void LoadObject(wxObjectInputStream& stream) { wxObject::LoadObject(stream); };
|
||||
#endif
|
||||
|
||||
// Called by wxWindows
|
||||
virtual bool OnSaveDocument(const wxString& filename);
|
||||
virtual bool OnOpenDocument(const wxString& filename);
|
||||
|
@@ -18,7 +18,11 @@
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#if wxUSE_DYNLIB_CLASS
|
||||
#if wxUSE_DYNAMIC_LOADER
|
||||
|
||||
#include "wx/dynload.h" // Use the new (version of) wxDynamicLibrary instead
|
||||
|
||||
#elif wxUSE_DYNLIB_CLASS
|
||||
|
||||
#include "wx/string.h"
|
||||
#include "wx/list.h"
|
||||
@@ -85,7 +89,7 @@ public:
|
||||
if success pointer is not NULL, it will be filled with TRUE if everything
|
||||
went ok and FALSE otherwise
|
||||
*/
|
||||
static wxDllType LoadLibrary(const wxString& libname, bool *success = NULL);
|
||||
static wxDllType LoadLibrary(const wxString& libname, bool *success = 0);
|
||||
|
||||
/*
|
||||
This function unloads the shared library previously loaded with
|
||||
@@ -109,14 +113,15 @@ public:
|
||||
|
||||
Returns the pointer to the symbol or NULL on error.
|
||||
*/
|
||||
static void * GetSymbol(wxDllType dllHandle, const wxString &name);
|
||||
static void *GetSymbol(wxDllType dllHandle, const wxString &name, bool success = 0);
|
||||
|
||||
// return the standard DLL extension (with leading dot) for this platform
|
||||
static wxString GetDllExt();
|
||||
static const wxString &GetDllExt() { return ms_dllext; }
|
||||
|
||||
private:
|
||||
// forbid construction of objects
|
||||
wxDllLoader();
|
||||
static const wxString ms_dllext;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
207
include/wx/dynload.h
Normal file
207
include/wx/dynload.h
Normal file
@@ -0,0 +1,207 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dynload.h
|
||||
// Purpose: Dynamic loading framework
|
||||
// Author: Ron Lee, David Falkinder, Vadim Zeitlin and a cast of 1000's
|
||||
// (derived in part from dynlib.cpp (c) 1998 Guilhem Lavaux)
|
||||
// Modified by:
|
||||
// Created: 03/12/01
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2001 Ron Lee <ron@debian.org>
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_DYNAMICLOADER_H__
|
||||
#define _WX_DYNAMICLOADER_H__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dynload.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DYNAMIC_LOADER
|
||||
|
||||
#include "wx/hash.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
|
||||
// Ugh, I'd much rather this was typesafe, but no time
|
||||
// to rewrite wxHashTable right now..
|
||||
|
||||
typedef wxHashTable wxDLManifest;
|
||||
typedef wxHashTable wxDLImports;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// conditional compilation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Note: WXPM/EMX has to be tested first, since we want to use
|
||||
// native version, even if configure detected presence of DLOPEN.
|
||||
|
||||
#if defined(__WXPM__) || defined(__EMX__)
|
||||
#define INCL_DOS
|
||||
#include <os2.h>
|
||||
typedef HMODULE wxDllType;
|
||||
#elif defined(HAVE_DLOPEN)
|
||||
#include <dlfcn.h>
|
||||
typedef void *wxDllType;
|
||||
#elif defined(HAVE_SHL_LOAD)
|
||||
#include <dl.h>
|
||||
typedef shl_t wxDllType;
|
||||
#elif defined(__WINDOWS__)
|
||||
#include <windows.h> // needed to get HMODULE
|
||||
typedef HMODULE wxDllType;
|
||||
#elif defined(__DARWIN__)
|
||||
typedef void *wxDllType;
|
||||
#elif defined(__WXMAC__)
|
||||
typedef CFragConnectionID wxDllType;
|
||||
#else
|
||||
#error "wxLibrary can't be compiled on this platform, sorry."
|
||||
#endif
|
||||
|
||||
// LoadLibrary is defined in windows.h as LoadLibraryA, but wxDllLoader
|
||||
// method should be called LoadLibrary, not LoadLibraryA or LoadLibraryW!
|
||||
|
||||
#if defined(__WIN32__) && defined(LoadLibrary)
|
||||
# include "wx/msw/winundef.h"
|
||||
#endif
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDllLoader
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
// Cross platform wrapper for dlopen and friends.
|
||||
// There are no instances of this class, it simply
|
||||
// serves as a namespace for its static member functions.
|
||||
|
||||
class WXDLLEXPORT wxDllLoader
|
||||
{
|
||||
public:
|
||||
|
||||
// libname may be either the full path to the file or just the filename
|
||||
// in which case the library is searched for in all standard locations.
|
||||
// The platform specific library extension is automatically appended.
|
||||
|
||||
static wxDllType Load(const wxString& name);
|
||||
|
||||
// The same as Load, except 'name' is searched for without modification.
|
||||
|
||||
static wxDllType LoadLibrary(const wxString& name);
|
||||
static void UnloadLibrary(wxDllType dll);
|
||||
|
||||
// return a valid handle for the main program itself or NULL if
|
||||
// back linking is not supported by the current platform (e.g. Win32)
|
||||
|
||||
static wxDllType GetProgramHandle();
|
||||
|
||||
// resolve a symbol in a loaded DLL, such as a variable or function
|
||||
// name. dllHandle is a handle previously returned by LoadLibrary(),
|
||||
// symbol is the (possibly mangled) name of the symbol.
|
||||
// (use extern "C" to export unmangled names)
|
||||
//
|
||||
// Since it is perfectly valid for the returned symbol to actually be
|
||||
// NULL, that is not always indication of an error. Pass and test the
|
||||
// parameter 'success' for a true indication of success or failure to
|
||||
// load the symbol.
|
||||
//
|
||||
// Returns a pointer to the symbol on success.
|
||||
|
||||
static void *GetSymbol(wxDllType dllHandle, const wxString &name, bool *success = 0);
|
||||
|
||||
// return the platform standard DLL extension (with leading dot)
|
||||
|
||||
static const wxString &GetDllExt() { return ms_dllext; }
|
||||
|
||||
private:
|
||||
|
||||
wxDllLoader(); // forbid construction of objects
|
||||
static const wxString ms_dllext; // Platform specific shared lib suffix.
|
||||
};
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxDynamicLibrary
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class wxDLManifestEntry
|
||||
{
|
||||
public:
|
||||
|
||||
static wxDLImports ms_classes; // Static hash of all imported classes.
|
||||
|
||||
wxDLManifestEntry( const wxString &libname );
|
||||
~wxDLManifestEntry();
|
||||
|
||||
wxDLManifestEntry *Ref() { ++m_count; return this; }
|
||||
bool Unref() { return (m_count-- < 2) ? (delete this, TRUE) : FALSE; }
|
||||
|
||||
bool IsLoaded() const { return m_count > 0; }
|
||||
|
||||
wxDllType GetLinkHandle() const { return m_handle; }
|
||||
wxDllType GetProgramHandle() const { return wxDllLoader::GetProgramHandle(); }
|
||||
void *GetSymbol(const wxString &symbol, bool *success = 0)
|
||||
{
|
||||
return wxDllLoader::GetSymbol( m_handle, symbol, success );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Order of these three *is* important, do not change it
|
||||
|
||||
wxClassInfo *m_before; // sm_first before loading this lib
|
||||
wxDllType m_handle; // Handle from dlopen.
|
||||
wxClassInfo *m_after; // ..and after.
|
||||
|
||||
size_t m_count; // Ref count of Link and Create calls.
|
||||
wxModuleList m_wxmodules; // any wxModules that we initialised.
|
||||
|
||||
void UpdateClassInfo(); // Update the wxClassInfo table
|
||||
void RestoreClassInfo(); // Restore the original wxClassInfo state.
|
||||
void RegisterModules(); // Init any wxModules in the lib.
|
||||
void UnregisterModules(); // Cleanup any wxModules we installed.
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDLManifestEntry)
|
||||
};
|
||||
|
||||
|
||||
class WXDLLEXPORT wxDynamicLibrary
|
||||
{
|
||||
public:
|
||||
|
||||
// Static accessors.
|
||||
|
||||
static wxDLManifestEntry *Link(const wxString &libname);
|
||||
static bool Unlink(const wxString &libname);
|
||||
|
||||
// Instance methods.
|
||||
|
||||
wxDynamicLibrary(const wxString &libname);
|
||||
~wxDynamicLibrary();
|
||||
|
||||
bool IsLoaded() const { return m_entry && m_entry->IsLoaded(); }
|
||||
void *GetSymbol(const wxString &symbol, bool *success = 0)
|
||||
{
|
||||
return m_entry->GetSymbol( symbol, success );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static wxDLManifest ms_manifest; // Static hash of loaded libs.
|
||||
wxDLManifestEntry *m_entry; // Cache our entry in the manifest.
|
||||
|
||||
// We could allow this class to be copied if we really
|
||||
// wanted to, but not without modification.
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxDynamicLibrary)
|
||||
};
|
||||
|
||||
|
||||
#endif // wxUSE_DYNAMIC_LOADER
|
||||
#endif // _WX_DYNAMICLOADER_H__
|
||||
|
||||
// vi:sts=4:sw=4:et
|
@@ -95,6 +95,7 @@
|
||||
class WXDLLEXPORT wxFileConfigGroup;
|
||||
class WXDLLEXPORT wxFileConfigEntry;
|
||||
class WXDLLEXPORT wxFileConfigLineList;
|
||||
class WXDLLEXPORT wxInputStream;
|
||||
|
||||
class WXDLLEXPORT wxFileConfig : public wxConfigBase
|
||||
{
|
||||
|
@@ -332,10 +332,6 @@
|
||||
* Use streams
|
||||
*/
|
||||
#define wxUSE_STREAMS 1
|
||||
/*
|
||||
* Use class serialization
|
||||
*/
|
||||
#define wxUSE_SERIAL 1
|
||||
/*
|
||||
* Use sockets
|
||||
*/
|
||||
@@ -345,10 +341,6 @@
|
||||
* streams implementation.
|
||||
*/
|
||||
#define wxUSE_STD_IOSTREAM 0
|
||||
/*
|
||||
* wxLibrary class
|
||||
*/
|
||||
#define wxUSE_DYNLIB_CLASS 1
|
||||
|
||||
/*
|
||||
* Use font metric files in GetTextExtent for wxPostScriptDC
|
||||
@@ -418,9 +410,9 @@
|
||||
*/
|
||||
#define wxUSE_SPLINES 1
|
||||
/*
|
||||
* Use wxLibrary class
|
||||
* Use wxObjectLoader class
|
||||
*/
|
||||
#define wxUSE_DYNLIB_CLASS 1
|
||||
#define wxUSE_DYNAMIC_LOADER 1
|
||||
|
||||
/*
|
||||
* Use the mdi architecture
|
||||
|
@@ -332,10 +332,6 @@
|
||||
* Use streams
|
||||
*/
|
||||
#define wxUSE_STREAMS 1
|
||||
/*
|
||||
* Use class serialization
|
||||
*/
|
||||
#define wxUSE_SERIAL 1
|
||||
/*
|
||||
* Use sockets
|
||||
*/
|
||||
@@ -345,10 +341,6 @@
|
||||
* streams implementation.
|
||||
*/
|
||||
#define wxUSE_STD_IOSTREAM 0
|
||||
/*
|
||||
* wxLibrary class
|
||||
*/
|
||||
#define wxUSE_DYNLIB_CLASS 1
|
||||
|
||||
/*
|
||||
* Use font metric files in GetTextExtent for wxPostScriptDC
|
||||
@@ -418,9 +410,9 @@
|
||||
*/
|
||||
#define wxUSE_SPLINES 1
|
||||
/*
|
||||
* Use wxLibrary class
|
||||
* Use wxObjectLoader class
|
||||
*/
|
||||
#define wxUSE_DYNLIB_CLASS 1
|
||||
#define wxUSE_DYNAMIC_LOADER 1
|
||||
|
||||
/*
|
||||
* Use the mdi architecture
|
||||
|
@@ -297,5 +297,8 @@ private:
|
||||
#define WX_DECLARE_EXPORTED_HASH(el, list, hash) \
|
||||
_WX_DECLARE_HASH(el, list, hash, class WXDLLEXPORT)
|
||||
|
||||
#define WX_DECLARE_USER_EXPORTED_HASH(el, list, hash, usergoo) \
|
||||
_WX_DECLARE_HASH(el, list, hash, class usergoo)
|
||||
|
||||
#endif
|
||||
// _WX_HASH_H__
|
||||
|
@@ -461,10 +461,18 @@ private:
|
||||
typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \
|
||||
WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node, class WXDLLEXPORT)
|
||||
|
||||
#define WX_DECLARE_USER_EXPORTED_LIST(elementtype, listname, usergoo) \
|
||||
typedef elementtype _WX_LIST_ITEM_TYPE_##listname; \
|
||||
WX_DECLARE_LIST_2(elementtype, listname, wx##listname##Node, class usergoo)
|
||||
|
||||
// this macro must be inserted in your program after
|
||||
// #include <wx/listimpl.cpp>
|
||||
#define WX_DEFINE_LIST(name) "don't forget to include listimpl.cpp!"
|
||||
|
||||
#define WX_DEFINE_EXPORTED_LIST(name) WX_DEFINE_LIST(name)
|
||||
#define WX_DEFINE_USER_EXPORTED_LIST(name) WX_DEFINE_LIST(name)
|
||||
|
||||
|
||||
// =============================================================================
|
||||
// now we can define classes 100% compatible with the old ones
|
||||
// =============================================================================
|
||||
|
@@ -32,15 +32,20 @@ public:
|
||||
wxModule() {}
|
||||
virtual ~wxModule() {}
|
||||
|
||||
// if module init routine returns FALSE application will fail to startup
|
||||
// if module init routine returns FALSE application
|
||||
// will fail to startup
|
||||
|
||||
bool Init() { return OnInit(); }
|
||||
void Exit() { OnExit(); }
|
||||
|
||||
// Override both of these
|
||||
// Override both of these
|
||||
// called on program startup
|
||||
|
||||
virtual bool OnInit() = 0;
|
||||
// called just before program termination, but only if OnInit()
|
||||
|
||||
// called just before program termination, but only if OnInit()
|
||||
// succeeded
|
||||
|
||||
virtual void OnExit() = 0;
|
||||
|
||||
static void RegisterModule(wxModule* module);
|
||||
@@ -48,6 +53,10 @@ public:
|
||||
static bool InitializeModules();
|
||||
static void CleanUpModules();
|
||||
|
||||
// used by wxObjectLoader when unloading shared libs's
|
||||
|
||||
static void UnregisterModule(wxModule* module);
|
||||
|
||||
protected:
|
||||
static wxModuleList m_modules;
|
||||
|
||||
|
@@ -240,9 +240,6 @@
|
||||
// Use standard C++ streams if 1. If 0, use wxWin streams implementation.
|
||||
#define wxUSE_STD_IOSTREAM 0
|
||||
|
||||
// Use serialization (requires utils/serialize)
|
||||
#define wxUSE_SERIAL 0
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// non GUI features selection
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -345,14 +342,14 @@
|
||||
|
||||
// If wxUSE_DIALUP_MANAGER is 1, compile in wxDialUpManager class which allows
|
||||
// to connect/disconnect from the network and be notified whenever the dial-up
|
||||
// network connection is established/terminated. Requires wxUSE_DYNLIB_CLASS.
|
||||
// network connection is established/terminated. Requires wxUSE_DYNAMIC_LOADER.
|
||||
//
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_DIALUP_MANAGER 1
|
||||
|
||||
// Compile in wxLibrary class for run-time DLL loading and function calling.
|
||||
// Compile in classes for run-time DLL loading and function calling.
|
||||
// Required by wxUSE_DIALUP_MANAGER.
|
||||
//
|
||||
// This setting is for Win32 only
|
||||
@@ -360,7 +357,7 @@
|
||||
// Default is 1.
|
||||
//
|
||||
// Recommended setting: 1
|
||||
#define wxUSE_DYNLIB_CLASS 1
|
||||
#define wxUSE_DYNAMIC_LOADER 1
|
||||
|
||||
// Set to 1 to use socket classes
|
||||
#define wxUSE_SOCKETS 1
|
||||
|
@@ -2,10 +2,11 @@
|
||||
// Name: object.h
|
||||
// Purpose: wxObject class, plus run-time type information macros
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Modified by: Ron Lee
|
||||
// Created: 01/02/97
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart and Markus Holzem
|
||||
// Copyright: (c) 1997 Julian Smart and Markus Holzem
|
||||
// (c) 2001 Ron Lee <ron@debian.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -16,6 +17,10 @@
|
||||
#pragma interface "object.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/memory.h"
|
||||
|
||||
@@ -23,135 +28,230 @@ class WXDLLEXPORT wxObject;
|
||||
|
||||
#if wxUSE_DYNAMIC_CLASSES
|
||||
|
||||
// #ifdef __GNUWIN32__
|
||||
// ----------------------------------------------------------------------------
|
||||
// conditional compilation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef GetClassName
|
||||
#undef GetClassName
|
||||
#endif
|
||||
#ifdef GetClassInfo
|
||||
#undef GetClassInfo
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
class WXDLLEXPORT wxClassInfo;
|
||||
class WXDLLEXPORT wxInputStream;
|
||||
class WXDLLEXPORT wxOutputStream;
|
||||
class WXDLLEXPORT wxObjectInputStream;
|
||||
class WXDLLEXPORT wxObjectOutputStream;
|
||||
class WXDLLEXPORT wxHashTable;
|
||||
class WXDLLEXPORT wxObject_Serialize;
|
||||
|
||||
#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
|
||||
#include "wx/ioswrap.h"
|
||||
#include "wx/ioswrap.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dynamic object system declarations
|
||||
*/
|
||||
|
||||
typedef wxObject * (*wxObjectConstructorFn) (void);
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxClassInfo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
typedef wxObject *(*wxObjectConstructorFn)(void);
|
||||
|
||||
class WXDLLEXPORT wxClassInfo
|
||||
{
|
||||
public:
|
||||
wxClassInfo(const wxChar *cName,
|
||||
const wxChar *baseName1,
|
||||
const wxChar *baseName2,
|
||||
int sz,
|
||||
wxObjectConstructorFn fn);
|
||||
wxClassInfo::wxClassInfo(const wxChar *className,
|
||||
const wxChar *baseName1,
|
||||
const wxChar *baseName2,
|
||||
int size,
|
||||
wxObjectConstructorFn ctor)
|
||||
: m_className(className)
|
||||
, m_baseClassName1(baseName1)
|
||||
, m_baseClassName2(baseName2)
|
||||
, m_objectSize(size)
|
||||
, m_objectConstructor(ctor)
|
||||
, m_baseInfo1(0)
|
||||
, m_baseInfo2(0)
|
||||
, m_next(sm_first)
|
||||
{ sm_first = this; }
|
||||
|
||||
wxObject *CreateObject(void);
|
||||
wxObject *CreateObject() { return m_objectConstructor ? (*m_objectConstructor)() : 0; }
|
||||
|
||||
const wxChar *GetClassName() const { return m_className; }
|
||||
const wxChar *GetBaseClassName1() const { return m_baseClassName1; }
|
||||
const wxChar *GetBaseClassName2() const { return m_baseClassName2; }
|
||||
const wxClassInfo* GetBaseClass1() const { return m_baseInfo1; }
|
||||
const wxClassInfo* GetBaseClass2() const { return m_baseInfo2; }
|
||||
int GetSize() const { return m_objectSize; }
|
||||
wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
|
||||
static const wxClassInfo* GetFirst() { return sm_first; }
|
||||
const wxClassInfo* GetNext() const { return m_next; }
|
||||
bool IsKindOf(const wxClassInfo *info) const;
|
||||
const wxChar *GetClassName() const { return m_className; }
|
||||
const wxChar *GetBaseClassName1() const { return m_baseClassName1; }
|
||||
const wxChar *GetBaseClassName2() const { return m_baseClassName2; }
|
||||
const wxClassInfo *GetBaseClass1() const { return m_baseInfo1; }
|
||||
const wxClassInfo *GetBaseClass2() const { return m_baseInfo2; }
|
||||
int GetSize() const { return m_objectSize; }
|
||||
|
||||
static wxClassInfo *FindClass(const wxChar *c);
|
||||
wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
|
||||
static const wxClassInfo *GetFirst() { return sm_first; }
|
||||
const wxClassInfo *GetNext() const { return m_next; }
|
||||
static wxClassInfo *FindClass(const wxChar *className);
|
||||
|
||||
// Climb upwards through inheritance hierarchy.
|
||||
// Dual inheritance is catered for.
|
||||
|
||||
// Initializes parent pointers and hash table for fast searching.
|
||||
static void InitializeClasses();
|
||||
bool IsKindOf(const wxClassInfo *info) const
|
||||
{
|
||||
return info != 0 &&
|
||||
( info == this ||
|
||||
( m_baseInfo1 && m_baseInfo1->IsKindOf(info) ) ||
|
||||
( m_baseInfo2 && m_baseInfo2->IsKindOf(info) ) );
|
||||
}
|
||||
|
||||
// Cleans up hash table used for fast searching.
|
||||
static void CleanUpClasses();
|
||||
// Initializes parent pointers and hash table for fast searching.
|
||||
|
||||
static void InitializeClasses();
|
||||
|
||||
// Cleans up hash table used for fast searching.
|
||||
|
||||
static void CleanUpClasses();
|
||||
|
||||
public:
|
||||
const wxChar* m_className;
|
||||
const wxChar* m_baseClassName1;
|
||||
const wxChar* m_baseClassName2;
|
||||
int m_objectSize;
|
||||
wxObjectConstructorFn m_objectConstructor;
|
||||
const wxChar *m_className;
|
||||
const wxChar *m_baseClassName1;
|
||||
const wxChar *m_baseClassName2;
|
||||
int m_objectSize;
|
||||
wxObjectConstructorFn m_objectConstructor;
|
||||
|
||||
// Pointers to base wxClassInfos: set in InitializeClasses
|
||||
const wxClassInfo* m_baseInfo1;
|
||||
const wxClassInfo* m_baseInfo2;
|
||||
// Pointers to base wxClassInfos: set in InitializeClasses
|
||||
|
||||
// class info object live in a linked list: pointers to its head and the
|
||||
// next element in it
|
||||
static wxClassInfo* sm_first;
|
||||
wxClassInfo* m_next;
|
||||
const wxClassInfo *m_baseInfo1;
|
||||
const wxClassInfo *m_baseInfo2;
|
||||
|
||||
static wxHashTable* sm_classTable;
|
||||
// class info object live in a linked list:
|
||||
// pointers to its head and the next element in it
|
||||
|
||||
static wxClassInfo *sm_first;
|
||||
wxClassInfo *m_next;
|
||||
|
||||
static wxHashTable *sm_classTable;
|
||||
};
|
||||
|
||||
WXDLLEXPORT wxObject* wxCreateDynamicObject(const wxChar *name);
|
||||
WXDLLEXPORT wxObject *wxCreateDynamicObject(const wxChar *name);
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
WXDLLEXPORT wxObject* wxCreateStoredObject( wxInputStream& stream );
|
||||
#endif
|
||||
|
||||
#define DECLARE_DYNAMIC_CLASS(name) \
|
||||
public:\
|
||||
static wxClassInfo sm_class##name;\
|
||||
wxClassInfo *GetClassInfo() const \
|
||||
// ----------------------------------------------------------------------------
|
||||
// Dynamic class macros
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#define DECLARE_DYNAMIC_CLASS(name) \
|
||||
public: \
|
||||
static wxClassInfo sm_class##name; \
|
||||
virtual wxClassInfo *GetClassInfo() const \
|
||||
{ return &name::sm_class##name; }
|
||||
|
||||
#define DECLARE_ABSTRACT_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
|
||||
#define DECLARE_CLASS(name) DECLARE_DYNAMIC_CLASS(name)
|
||||
|
||||
//////
|
||||
////// for concrete classes
|
||||
//////
|
||||
// -----------------------------------
|
||||
// for concrete classes
|
||||
// -----------------------------------
|
||||
|
||||
// Single inheritance with one base class
|
||||
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
|
||||
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
|
||||
{ return new name; }\
|
||||
wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename), (wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name);
|
||||
// Single inheritance with one base class
|
||||
|
||||
// Multiple inheritance with two base classes
|
||||
#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
|
||||
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
|
||||
{ return new name; }\
|
||||
wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename1), (wxChar *) wxT(#basename2), (int) sizeof(name), (wxObjectConstructorFn) wxConstructorFor##name);
|
||||
#define IMPLEMENT_DYNAMIC_CLASS(name, basename) \
|
||||
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name() \
|
||||
{ return new name; } \
|
||||
wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename), \
|
||||
0, (int) sizeof(name), \
|
||||
(wxObjectConstructorFn) wxConstructorFor##name);
|
||||
|
||||
//////
|
||||
////// for abstract classes
|
||||
//////
|
||||
// Multiple inheritance with two base classes
|
||||
|
||||
// Single inheritance with one base class
|
||||
#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
|
||||
wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename), \
|
||||
(wxChar *) NULL, (int) sizeof(name), (wxObjectConstructorFn) NULL);
|
||||
#define IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) \
|
||||
wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name() \
|
||||
{ return new name; } \
|
||||
wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
|
||||
wxT(#basename2), (int) sizeof(name), \
|
||||
(wxObjectConstructorFn) wxConstructorFor##name);
|
||||
|
||||
// Multiple inheritance with two base classes
|
||||
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
|
||||
wxClassInfo name::sm_class##name((wxChar *) wxT(#name), (wxChar *) wxT(#basename1), \
|
||||
(wxChar *) wxT(#basename2), (int) sizeof(name), (wxObjectConstructorFn) NULL);
|
||||
// -----------------------------------
|
||||
// for abstract classes
|
||||
// -----------------------------------
|
||||
|
||||
// Single inheritance with one base class
|
||||
|
||||
#define IMPLEMENT_ABSTRACT_CLASS(name, basename) \
|
||||
wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename), \
|
||||
0, (int) sizeof(name), (wxObjectConstructorFn) 0);
|
||||
|
||||
// Multiple inheritance with two base classes
|
||||
|
||||
#define IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) \
|
||||
wxClassInfo name::sm_class##name(wxT(#name), wxT(#basename1), \
|
||||
wxT(#basename2), (int) sizeof(name), \
|
||||
(wxObjectConstructorFn) 0);
|
||||
|
||||
#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
|
||||
#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
|
||||
|
||||
// -----------------------------------
|
||||
// for pluggable classes
|
||||
// -----------------------------------
|
||||
|
||||
// NOTE: this should probably be the very first statement
|
||||
// in the class declaration so wxPluginSentinel is
|
||||
// the first member initialised and the last destroyed.
|
||||
|
||||
// _DECLARE_DL_SENTINEL(name) wxPluginSentinel m_pluginsentinel;
|
||||
|
||||
#if wxUSE_NESTED_CLASSES
|
||||
|
||||
#if 0
|
||||
#define _DECLARE_DL_SENTINEL(name) \
|
||||
wxPluginSentinel m_pluginsentinel;
|
||||
|
||||
#else
|
||||
|
||||
#define _DECLARE_DL_SENTINEL(name) \
|
||||
class name##PluginSentinel { \
|
||||
private: \
|
||||
static const wxString sm_className; \
|
||||
public: \
|
||||
name##PluginSentinel(); \
|
||||
~##name##PluginSentinel(); \
|
||||
}; \
|
||||
name##PluginSentinel m_pluginsentinel;
|
||||
#endif
|
||||
|
||||
#define _IMPLEMENT_DL_SENTINEL(name) \
|
||||
const wxString name::name##PluginSentinel::sm_className(#name); \
|
||||
name::name##PluginSentinel::name##PluginSentinel() { \
|
||||
wxDLManifestEntry *e = (wxDLManifestEntry*) wxDLManifestEntry::ms_classes.Get(#name); \
|
||||
if( e != 0 ) { e->Ref(); } \
|
||||
} \
|
||||
name::name##PluginSentinel::~##name##PluginSentinel() { \
|
||||
wxDLManifestEntry *e = (wxDLManifestEntry*) wxDLManifestEntry::ms_classes.Get(#name); \
|
||||
if( e != 0 ) { wxCHECK_RET( !e->Unref(), _T("premature library unlinking") ); } \
|
||||
}
|
||||
#else
|
||||
|
||||
#define _DECLARE_DL_SENTINEL(name)
|
||||
#define _IMPLEMENT_DL_SENTINEL(name)
|
||||
|
||||
#endif // wxUSE_NESTED_CLASSES
|
||||
|
||||
#define DECLARE_PLUGGABLE_CLASS(name) \
|
||||
DECLARE_DYNAMIC_CLASS(name) _DECLARE_DL_SENTINEL(name)
|
||||
|
||||
#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name) \
|
||||
DECLARE_ABSTRACT_CLASS(name) _DECLARE_DL_SENTINEL(name)
|
||||
|
||||
#define IMPLEMENT_PLUGGABLE_CLASS(name, basename) \
|
||||
IMPLEMENT_DYNAMIC_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name)
|
||||
#define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2) \
|
||||
IMPLEMENT_DYNAMIC_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name)
|
||||
|
||||
#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename) \
|
||||
IMPLEMENT_ABSTRACT_CLASS(name, basename) _IMPLEMENT_DL_SENTINEL(name)
|
||||
#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2) \
|
||||
IMPLEMENT_ABSTRACT_CLASS2(name, basename1, basename2) _IMPLEMENT_DL_SENTINEL(name)
|
||||
|
||||
|
||||
#define CLASSINFO(name) (&name::sm_class##name)
|
||||
|
||||
#else // !wxUSE_DYNAMIC_CLASSES
|
||||
|
||||
// No dynamic class system: so stub out the macros
|
||||
// No dynamic class system: so stub out the macros
|
||||
|
||||
#define DECLARE_DYNAMIC_CLASS(name)
|
||||
#define DECLARE_ABSTRACT_CLASS(name)
|
||||
#define DECLARE_CLASS(name)
|
||||
@@ -162,137 +262,144 @@ wxObject* WXDLLEXPORT_CTORFN wxConstructorFor##name(void) \
|
||||
#define IMPLEMENT_CLASS IMPLEMENT_ABSTRACT_CLASS
|
||||
#define IMPLEMENT_CLASS2 IMPLEMENT_ABSTRACT_CLASS2
|
||||
|
||||
#endif // wxUSE_DYNAMIC_CLASSES/!wxUSE_DYNAMIC_CLASSES
|
||||
#define DECLARE_PLUGGABLE_CLASS(name)
|
||||
#define DECLARE_ABSTRACT_PLUGGABLE_CLASS(name)
|
||||
#define IMPLEMENT_PLUGGABLE_CLASS(name, basename)
|
||||
#define IMPLEMENT_PLUGGABLE_CLASS2(name, basename1, basename2)
|
||||
#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS(name, basename)
|
||||
#define IMPLEMENT_ABSTRACT_PLUGGABLE_CLASS2(name, basename1, basename2)
|
||||
|
||||
#endif // wxUSE_DYNAMIC_CLASSES
|
||||
|
||||
|
||||
#define wxIS_KIND_OF(obj, className) obj->IsKindOf(&className::sm_class##className)
|
||||
|
||||
// Just seems a bit nicer-looking (pretend it's not a macro)
|
||||
// Just seems a bit nicer-looking (pretend it's not a macro)
|
||||
|
||||
#define wxIsKindOf(obj, className) obj->IsKindOf(&className::sm_class##className)
|
||||
|
||||
// to be replaced by dynamic_cast<> in the future
|
||||
#define wxDynamicCast(obj, className) \
|
||||
(className *) wxCheckDynamicCast((wxObject*)(obj), &className::sm_class##className)
|
||||
// to be replaced by dynamic_cast<> in the future
|
||||
|
||||
#define wxDynamicCast(obj, className) \
|
||||
(className *) wxCheckDynamicCast((wxObject*)(obj), &className::sm_class##className)
|
||||
|
||||
// The 'this' pointer is always true, so use this version
|
||||
// to cast the this pointer and avoid compiler warnings.
|
||||
|
||||
// The 'this' pointer is always true, so use this version to cast the this
|
||||
// pointer and avoid compiler warnings.
|
||||
#define wxDynamicCastThis(className) \
|
||||
(IsKindOf(&className::sm_class##className) \
|
||||
? (className *)(this) \
|
||||
: (className *)0)
|
||||
(IsKindOf(&className::sm_class##className) ? (className *)(this) : (className *)0)
|
||||
|
||||
#define wxConstCast(obj, className) ((className *)(obj))
|
||||
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
inline void wxCheckCast(void *ptr)
|
||||
{
|
||||
wxASSERT_MSG( ptr, _T("wxStaticCast() used incorrectly") );
|
||||
}
|
||||
inline void wxCheckCast(void *ptr)
|
||||
{
|
||||
wxASSERT_MSG( ptr, _T("wxStaticCast() used incorrectly") );
|
||||
}
|
||||
#define wxStaticCast(obj, className) \
|
||||
(wxCheckCast(wxDynamicCast(obj, className)), ((className *)(obj)))
|
||||
|
||||
#define wxStaticCast(obj, className) \
|
||||
(wxCheckCast(wxDynamicCast(obj, className)), ((className *)(obj)))
|
||||
#else // !__WXDEBUG__
|
||||
#define wxStaticCast(obj, className) ((className *)(obj))
|
||||
|
||||
#else // !Debug
|
||||
#define wxStaticCast(obj, className) ((className *)(obj))
|
||||
#endif // Debug/!Debug
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
// Unfortunately Borland seems to need this include.
|
||||
#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
|
||||
#ifdef __BORLANDC__
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
// Unfortunately Borland seems to need this include.
|
||||
|
||||
#if wxUSE_STD_IOSTREAM \
|
||||
&& (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT) \
|
||||
&& defined(__BORLANDC__)
|
||||
#if wxUSE_IOSTREAMH
|
||||
#include <iostream.h>
|
||||
#else
|
||||
#include <iostream>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxObject
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxObjectRefData;
|
||||
|
||||
class WXDLLEXPORT wxObject
|
||||
{
|
||||
public:
|
||||
DECLARE_ABSTRACT_CLASS(wxObject)
|
||||
|
||||
// This is equivalent to using the macro DECLARE_ABSTRACT_CLASS
|
||||
static wxClassInfo sm_classwxObject;
|
||||
public:
|
||||
wxObject() : m_refData(0) {}
|
||||
virtual ~wxObject() { UnRef(); }
|
||||
|
||||
wxObject(void);
|
||||
virtual ~wxObject(void);
|
||||
|
||||
virtual wxClassInfo *GetClassInfo(void) const { return &sm_classwxObject; }
|
||||
|
||||
bool IsKindOf(wxClassInfo *info) const;
|
||||
bool IsKindOf(wxClassInfo *info) const;
|
||||
|
||||
#if defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING
|
||||
void * operator new (size_t size, wxChar * fileName = NULL, int lineNum = 0);
|
||||
# if defined(__VISAGECPP__)
|
||||
# if __DEBUG_ALLOC__
|
||||
void operator delete (void * buf,const char * _fname, size_t _line);
|
||||
# endif //__DEBUG_ALLOC__
|
||||
# else // Everybody else
|
||||
void operator delete (void * buf);
|
||||
# endif // end of VISAGECPP
|
||||
void *operator new (size_t size, wxChar *fileName = 0, int lineNum = 0);
|
||||
|
||||
// VC++ 6.0
|
||||
# if defined(__VISUALC__) && (__VISUALC__ >= 1200)
|
||||
#ifndef __VISAGECPP__
|
||||
void operator delete (void * buf);
|
||||
#elif __DEBUG_ALLOC__
|
||||
void operator delete (void *buf, const char *_fname, size_t _line);
|
||||
#endif
|
||||
|
||||
// VC++ 6.0
|
||||
|
||||
#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
|
||||
void operator delete(void *buf, wxChar*, int);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Causes problems for VC++
|
||||
# if wxUSE_ARRAY_MEMORY_OPERATORS && !defined(__VISUALC__) && !defined( __MWERKS__)
|
||||
void * operator new[] (size_t size, wxChar * fileName = NULL, int lineNum = 0);
|
||||
void operator delete[] (void * buf);
|
||||
# endif
|
||||
|
||||
# ifdef __MWERKS__
|
||||
void * operator new[] (size_t size, wxChar * fileName , int lineNum = 0);
|
||||
void * operator new[] (size_t size) { return operator new[] ( size , NULL , 0 ) ; }
|
||||
void operator delete[] (void * buf);
|
||||
# endif
|
||||
#if wxUSE_ARRAY_MEMORY_OPERATORS && !defined(__VISUALC__) && !defined( __MWERKS__)
|
||||
void *operator new[] (size_t size, wxChar *fileName = 0, int lineNum = 0);
|
||||
void operator delete[] (void *buf);
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
void *operator new[] (size_t size, wxChar *fileName , int lineNum = 0);
|
||||
void *operator new[] (size_t size) { return operator new[] ( size, 0, 0 ) ; }
|
||||
void operator delete[] (void *buf);
|
||||
#endif
|
||||
|
||||
#endif // Debug & memory tracing
|
||||
|
||||
|
||||
#if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
|
||||
virtual void Dump(wxSTD ostream& str);
|
||||
virtual void Dump(wxSTD ostream& str);
|
||||
#endif
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
virtual void StoreObject( wxObjectOutputStream &stream );
|
||||
virtual void LoadObject( wxObjectInputStream &stream );
|
||||
#endif
|
||||
// make a 'clone' of the object
|
||||
|
||||
void Ref(const wxObject& clone);
|
||||
|
||||
// make a 'clone' of the object
|
||||
void Ref(const wxObject& clone);
|
||||
// destroy a reference
|
||||
|
||||
void UnRef();
|
||||
|
||||
// destroy a reference
|
||||
void UnRef(void);
|
||||
|
||||
inline wxObjectRefData *GetRefData(void) const { return m_refData; }
|
||||
inline void SetRefData(wxObjectRefData *data) { m_refData = data; }
|
||||
inline wxObjectRefData *GetRefData() const { return m_refData; }
|
||||
inline void SetRefData(wxObjectRefData *data) { m_refData = data; }
|
||||
|
||||
protected:
|
||||
wxObjectRefData* m_refData;
|
||||
#if wxUSE_SERIAL
|
||||
wxObject_Serialize* m_serialObj;
|
||||
#endif
|
||||
wxObjectRefData *m_refData;
|
||||
};
|
||||
|
||||
/*
|
||||
* wxObjectData
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxObjectRefData {
|
||||
|
||||
class WXDLLEXPORT wxObjectRefData
|
||||
{
|
||||
friend class wxObject;
|
||||
|
||||
public:
|
||||
wxObjectRefData(void);
|
||||
virtual ~wxObjectRefData(void);
|
||||
wxObjectRefData() : m_count(1) {}
|
||||
virtual ~wxObjectRefData() {}
|
||||
|
||||
inline int GetRefCount(void) const { return m_count; }
|
||||
inline int GetRefCount() const { return m_count; }
|
||||
private:
|
||||
int m_count;
|
||||
};
|
||||
|
||||
|
||||
inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
|
||||
{
|
||||
return obj && obj->GetClassInfo()->IsKindOf(classInfo) ? obj : 0;
|
||||
@@ -306,15 +413,14 @@ inline wxObject *wxCheckDynamicCast(wxObject *obj, wxClassInfo *classInfo)
|
||||
#define WXDEBUG_NEW new
|
||||
#endif
|
||||
|
||||
// Redefine new to be the debugging version. This doesn't
|
||||
// work with all compilers, in which case you need to
|
||||
// use WXDEBUG_NEW explicitly if you wish to use the debugging version.
|
||||
// Redefine new to be the debugging version. This doesn't
|
||||
// work with all compilers, in which case you need to
|
||||
// use WXDEBUG_NEW explicitly if you wish to use the debugging version.
|
||||
|
||||
#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
|
||||
#define new new(__TFILE__,__LINE__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_OBJECTH__
|
||||
|
||||
#endif // _WX_OBJECTH__
|
||||
|
||||
// vi:sts=4:sw=4:et
|
||||
|
@@ -1,90 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: objstrm.h
|
||||
// Purpose: wxObjectStream classes
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: 16/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Guilhem Lavaux
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef _WX_WXOBJSTRM_H__
|
||||
#define _WX_WXOBJSTRM_H__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_STREAMS && wxUSE_SERIAL
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/stream.h"
|
||||
|
||||
class wxObjectStreamInfo : public wxObject {
|
||||
public:
|
||||
wxString object_name;
|
||||
int n_children, children_removed;
|
||||
wxList children;
|
||||
wxObjectStreamInfo *parent;
|
||||
wxObject *object;
|
||||
bool duplicate, recall;
|
||||
};
|
||||
|
||||
class wxObjectOutputStream : public wxFilterOutputStream {
|
||||
public:
|
||||
wxObjectOutputStream(wxOutputStream& s);
|
||||
|
||||
void AddChild(wxObject *obj);
|
||||
bool SaveObject(wxObject& obj);
|
||||
|
||||
bool FirstStage() const { return m_stage == 0; }
|
||||
|
||||
wxString GetObjectName(wxObject *obj);
|
||||
|
||||
protected:
|
||||
void WriteObjectDef(wxObjectStreamInfo& info);
|
||||
void ProcessObjectDef(wxObjectStreamInfo *info);
|
||||
void ProcessObjectData(wxObjectStreamInfo *info);
|
||||
|
||||
protected:
|
||||
int m_stage;
|
||||
bool m_saving;
|
||||
wxObjectStreamInfo *m_current_info;
|
||||
wxList m_saved_objs;
|
||||
};
|
||||
|
||||
class wxObjectInputStream : public wxFilterInputStream {
|
||||
public:
|
||||
wxObjectInputStream(wxInputStream& s);
|
||||
|
||||
bool SecondCall() const { return m_secondcall; }
|
||||
void Recall(bool on = TRUE) { m_current_info->recall = on; }
|
||||
|
||||
wxObject *GetChild(int no) const;
|
||||
wxObject *GetChild();
|
||||
int NumberOfChildren() const { return m_current_info->n_children; }
|
||||
void RemoveChildren(int nb);
|
||||
wxObject *GetParent() const;
|
||||
wxObject *LoadObject();
|
||||
|
||||
wxObject *SolveName(const wxString& objName) const;
|
||||
|
||||
protected:
|
||||
bool ReadObjectDef(wxObjectStreamInfo *info);
|
||||
wxObjectStreamInfo *ProcessObjectDef(wxObjectStreamInfo *info);
|
||||
void ProcessObjectData(wxObjectStreamInfo *info);
|
||||
|
||||
protected:
|
||||
bool m_secondcall;
|
||||
wxObjectStreamInfo *m_current_info;
|
||||
wxList m_solver;
|
||||
};
|
||||
|
||||
#endif
|
||||
// wxUSE_STREAMS && wxUSE_SERIAL
|
||||
|
||||
#endif
|
||||
// _WX_WXOBJSTRM_H__
|
@@ -52,6 +52,8 @@
|
||||
#undef FindResource
|
||||
#endif
|
||||
|
||||
class WXDLLEXPORT wxInputStream;
|
||||
|
||||
/*
|
||||
* Internal format for control/panel item
|
||||
*/
|
||||
@@ -153,7 +155,7 @@ class WXDLLEXPORT wxResourceTable: public wxHashTable
|
||||
virtual bool DeleteResource(const wxString& name);
|
||||
|
||||
virtual bool ParseResourceFile(const wxString& filename);
|
||||
virtual bool ParseResourceFile( wxInputStream *is ) ;
|
||||
virtual bool ParseResourceFile(wxInputStream *is);
|
||||
virtual bool ParseResourceData(const wxString& data);
|
||||
virtual bool SaveResource(const wxString& filename);
|
||||
|
||||
|
@@ -1,67 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: serbase.h
|
||||
// Purpose: Serialization plug-ins
|
||||
// Author: Guilhem Lavaux
|
||||
// Modified by:
|
||||
// Created: July 1998
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Guilhem Lavaux
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifndef _WX_WX_SERBASEH_H__
|
||||
#define _WX_WX_SERBASEH_H__
|
||||
|
||||
#include "wx/setup.h"
|
||||
#include "wx/dynlib.h"
|
||||
|
||||
#define WXSERIAL(classname) classname##_Serialize
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
class wxObject_Serialize : public wxObject {
|
||||
DECLARE_DYNAMIC_CLASS(wxObject_Serialize)
|
||||
public:
|
||||
wxObject_Serialize() {}
|
||||
virtual ~wxObject_Serialize() {}
|
||||
|
||||
void SetObject(wxObject *obj) { m_object = obj; }
|
||||
wxObject *Object() { return m_object; }
|
||||
|
||||
protected:
|
||||
wxObject *m_object;
|
||||
};
|
||||
#endif
|
||||
// wxUSE_SERIAL
|
||||
|
||||
|
||||
#define DECLARE_SERIAL_CLASS(classname, parent) \
|
||||
class WXSERIAL(classname) : public WXSERIAL(parent) { \
|
||||
DECLARE_DYNAMIC_CLASS(classname##_Serialize) \
|
||||
public: \
|
||||
WXSERIAL(classname)() { } \
|
||||
virtual ~WXSERIAL(classname)() { } \
|
||||
\
|
||||
virtual void StoreObject(wxObjectOutputStream& stream); \
|
||||
virtual void LoadObject(wxObjectInputStream& stream); \
|
||||
};
|
||||
|
||||
#define DECLARE_ALIAS_SERIAL_CLASS(classname, parent) \
|
||||
class WXSERIAL(classname) : public WXSERIAL(parent) { \
|
||||
DECLARE_DYNAMIC_CLASS(classname##_Serialize) \
|
||||
public: \
|
||||
WXSERIAL(classname)() { } \
|
||||
virtual ~WXSERIAL(classname)() { } \
|
||||
};
|
||||
|
||||
#define IMPLEMENT_SERIAL_CLASS(classname, parent) \
|
||||
IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize)
|
||||
|
||||
#define IMPLEMENT_ALIAS_SERIAL_CLASS(classname, parent) \
|
||||
IMPLEMENT_DYNAMIC_CLASS(classname##_Serialize, parent##_Serialize)
|
||||
|
||||
#if wxUSE_SERIAL
|
||||
DECLARE_SERIAL_CLASS(wxList, wxObject)
|
||||
DECLARE_SERIAL_CLASS(wxHashTable, wxObject)
|
||||
#endif
|
||||
// wxUSE_SERIAL
|
||||
|
||||
#endif
|
@@ -122,9 +122,6 @@ public:
|
||||
|
||||
// Operators
|
||||
wxInputStream& operator>>(wxOutputStream& out) { return Read(out); }
|
||||
#if wxUSE_SERIAL
|
||||
wxInputStream& operator>>(wxObject *& obj);
|
||||
#endif
|
||||
wxInputStream& operator>>( __wxInputManip func) { return func(*this); }
|
||||
|
||||
protected:
|
||||
@@ -161,9 +158,6 @@ public:
|
||||
virtual void Sync();
|
||||
|
||||
wxOutputStream& operator<<(wxInputStream& out) { return Write(out); }
|
||||
#if wxUSE_SERIAL
|
||||
wxOutputStream& operator<<(wxObject& obj);
|
||||
#endif
|
||||
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
|
||||
|
||||
protected:
|
||||
|
Reference in New Issue
Block a user