* Added source file info in utils/serialize/*

* Added Windows support in dynlib.cpp (not tested)
* Added some operator in wxStream
* Added a mutex in thread sample (more later)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@441 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux 1998-08-05 17:12:43 +00:00
parent e1a6fc11e2
commit 123a7fddb8
15 changed files with 180 additions and 13 deletions

View File

@ -91,8 +91,15 @@ class WXDLLEXPORT wxInputStream {
wxInputStream& operator>>(wxString& line); wxInputStream& operator>>(wxString& line);
wxInputStream& operator>>(char& c); wxInputStream& operator>>(char& c);
wxInputStream& operator>>(short& i); wxInputStream& operator>>(short& i);
wxInputStream& operator>>(int& i);
wxInputStream& operator>>(long& i); wxInputStream& operator>>(long& i);
wxInputStream& operator>>(float& i); wxInputStream& operator>>(float& i);
wxInputStream& operator>>(wxObject *& obj);
wxInputStream& operator>>(unsigned char& c) { return operator>>((char&)c); }
wxInputStream& operator>>(unsigned short& i) { return operator>>((short&)i); }
wxInputStream& operator>>(unsigned int& i) { return operator>>((int&)i); }
wxInputStream& operator>>(unsigned long& i) { return operator>>((long&)i); }
wxInputStream& operator>>( __wxInputManip func) { return func(*this); } wxInputStream& operator>>( __wxInputManip func) { return func(*this); }
protected: protected:
@ -136,13 +143,13 @@ class WXDLLEXPORT wxOutputStream {
wxOutputStream& operator<<(int i); wxOutputStream& operator<<(int i);
wxOutputStream& operator<<(long i); wxOutputStream& operator<<(long i);
wxOutputStream& operator<<(double f); wxOutputStream& operator<<(double f);
wxOutputStream& operator<<(wxObject& obj);
wxOutputStream& operator<<(float f) { return operator<<((double)f); } wxOutputStream& operator<<(float f) { return operator<<((double)f); }
wxOutputStream& operator<<(unsigned char c) { return operator<<((char)c); } wxOutputStream& operator<<(unsigned char c) { return operator<<((char)c); }
wxOutputStream& operator<<(unsigned short i) { return operator<<((short)i); } wxOutputStream& operator<<(unsigned short i) { return operator<<((short)i); }
wxOutputStream& operator<<(unsigned int i) { return operator<<((int)i); } wxOutputStream& operator<<(unsigned int i) { return operator<<((int)i); }
wxOutputStream& operator<<(unsigned long i) { return operator<<((long)i); } wxOutputStream& operator<<(unsigned long i) { return operator<<((long)i); }
wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); } wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
protected: protected:

View File

@ -35,6 +35,8 @@ class MyApp: public wxApp
bool OnInit(void); bool OnInit(void);
}; };
wxMutex text_mutex;
WX_DEFINE_ARRAY(wxThread *,wxArrayThread); WX_DEFINE_ARRAY(wxThread *,wxArrayThread);
// Define a new frame type // Define a new frame type
@ -83,7 +85,9 @@ void *MyThread::Entry()
while (1) { while (1) {
TestDestroy(); TestDestroy();
text_mutex.Lock();
m_frame->m_txtctrl->WriteText(text); m_frame->m_txtctrl->WriteText(text);
text_mutex.UnLock();
wxSleep(1); wxSleep(1);
} }

View File

@ -26,6 +26,10 @@
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
#ifdef __WINDOWS__
#include <windows.h>
#endif
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Global variables // Global variables
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -59,7 +63,12 @@ wxLibrary::~wxLibrary()
else else
delete m_liblist; delete m_liblist;
#ifdef linux
dlclose(m_handle); dlclose(m_handle);
#endif
#ifdef __WINDOWS__
FreeLibrary((HMODULE)m_handle);
#endif
} }
} }
@ -71,8 +80,12 @@ wxObject *wxLibrary::CreateObject(const wxString& name)
void *wxLibrary::GetSymbol(const wxString& symbname) void *wxLibrary::GetSymbol(const wxString& symbname)
{ {
#ifdef linux #ifdef linux
return dlsym(m_handle, symbname.GetData()); return dlsym(m_handle, WXSTRINGCAST symbname);
#endif #endif
#ifdef __WINDOWS__
return GetProcAddress(m_handle, WXSTRINGCAST symbname);
#endif
return NULL;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -105,21 +118,24 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
return ((wxLibrary *)node->Data()); return ((wxLibrary *)node->Data());
#ifdef linux #ifdef linux
lib_name.Prepend("./lib"); lib_name.Prepend("lib");
lib_name += ".so"; lib_name += ".so";
printf("lib_name = %s\n", WXSTRINGCAST lib_name); printf("lib_name = %s\n", WXSTRINGCAST lib_name);
void *handle = dlopen(lib_name.GetData(), RTLD_LAZY); void *handle = dlopen(WXSTRINGCAST lib_name, RTLD_LAZY);
printf("handle = %x\n", handle);
lib = new wxLibrary(handle);
if (!handle)
return NULL;
#endif #endif
#ifdef __WINDOWS__ #ifdef __WINDOWS__
lib_name += ".dll"; lib_name += ".dll";
HMODULE handle = LoadLibrary(lib_name);
if (!handle)
return NULL;
#endif #endif
lib = new wxLibrary((void *)handle);
m_loaded.Append(name.GetData(), lib); m_loaded.Append(name.GetData(), lib);
return lib; return lib;

View File

@ -18,6 +18,7 @@
#include <ctype.h> #include <ctype.h>
#include <wx/stream.h> #include <wx/stream.h>
#include <wx/datstrm.h> #include <wx/datstrm.h>
#include <wx/objstrm.h>
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
@ -270,6 +271,15 @@ wxInputStream& wxInputStream::operator>>(short& i)
return *this; return *this;
} }
wxInputStream& wxInputStream::operator>>(int& i)
{
long l;
*this >> l;
i = (short)l;
return *this;
}
wxInputStream& wxInputStream::operator>>(long& i) wxInputStream& wxInputStream::operator>>(long& i)
{ {
/* I only implemented a simple integer parser */ /* I only implemented a simple integer parser */
@ -341,6 +351,13 @@ wxInputStream& wxInputStream::operator>>(float& f)
return *this; return *this;
} }
wxInputStream& wxInputStream::operator>>(wxObject *& obj)
{
wxObjectInputStream obj_s(*this);
obj = obj_s.LoadObject();
return *this;
}
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode) off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
{ {
off_t ret_off; off_t ret_off;
@ -504,6 +521,13 @@ wxOutputStream& wxOutputStream::operator<<(double f)
return Write(strfloat, strfloat.Len()); return Write(strfloat, strfloat.Len());
} }
wxOutputStream& wxOutputStream::operator<<(wxObject& obj)
{
wxObjectOutputStream obj_s(*this);
obj_s.SaveObject(obj);
return *this;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFilterInputStream // wxFilterInputStream
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sercore.cpp
// Purpose: Serialization: core classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "sercore.h" #pragma implementation "sercore.h"
#endif #endif

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sercore.h
// Purpose: Serialization: core classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __SERCORE_H__ #ifndef __SERCORE_H__
#define __SERCORE_H__ #define __SERCORE_H__

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: serctrl.cpp
// Purpose: Serialization: control classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "serctrl.h" #pragma implementation "serctrl.h"
#endif #endif

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: serctrl.h
// Purpose: Serialization: control classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __SERCTRL_H__ #ifndef __SERCTRL_H__
#define __SERCTRL_H__ #define __SERCTRL_H__

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: serext.cpp
// Purpose: Serialization: Other classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "serext.h" #pragma implementation "serext.h"
#endif #endif

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: serext.cpp
// Purpose: Serialization: Other classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __SEREXT_H__ #ifndef __SEREXT_H__
#define __SEREXT_H__ #define __SEREXT_H__

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sergdi.cpp
// Purpose: Serialization: GDI classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "sergdi.h" #pragma implementation "sergdi.h"
#endif #endif

View File

@ -1,3 +1,14 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sergdi.h
// Purpose: Serialization: GDI classes
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __SERGDI_H__ #ifndef __SERGDI_H__
#define __SERGDI_H__ #define __SERGDI_H__

View File

@ -1,3 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: sermain.cpp
// Purpose: Serialization: main
// Author: Guilhem Lavaux
// Modified by:
// Created: July 1998
// RCS-ID: $Id$
// Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "serbase.h"
#endif
#include <wx/dynlib.h> #include <wx/dynlib.h>
#include <wx/serbase.h> #include <wx/serbase.h>

View File

@ -3,9 +3,9 @@
// Purpose: Serialization: wxWindow classes // Purpose: Serialization: wxWindow classes
// Author: Guilhem Lavaux // Author: Guilhem Lavaux
// Modified by: // Modified by:
// Created: 11/07/98 // Created: July 1998
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Guilhem Lavaux // Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -20,6 +20,7 @@
#include <wx/objstrm.h> #include <wx/objstrm.h>
#include <wx/utils.h> #include <wx/utils.h>
#include <wx/frame.h> #include <wx/frame.h>
#include <wx/panel.h>
#include <wx/serbase.h> #include <wx/serbase.h>
#include "serwnd.h" #include "serwnd.h"
@ -27,13 +28,12 @@ IMPLEMENT_SERIAL_CLASS(wxWindow, wxObject)
IMPLEMENT_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject) IMPLEMENT_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject)
IMPLEMENT_SERIAL_CLASS(wxLayoutConstraints, wxObject) IMPLEMENT_SERIAL_CLASS(wxLayoutConstraints, wxObject)
IMPLEMENT_SERIAL_CLASS(wxFrame, wxWindow) IMPLEMENT_SERIAL_CLASS(wxFrame, wxWindow)
IMPLEMENT_SERIAL_CLASS(wxPanel, wxWindow)
//IMPLEMENT_SERIAL_CLASS(wxDialog, wxWindow) //IMPLEMENT_SERIAL_CLASS(wxDialog, wxWindow)
IMPLEMENT_SERIAL_CLASS(wxMenuBar, wxWindow) IMPLEMENT_SERIAL_CLASS(wxMenuBar, wxWindow)
IMPLEMENT_SERIAL_CLASS(wxMenuItem, wxObject) IMPLEMENT_SERIAL_CLASS(wxMenuItem, wxObject)
IMPLEMENT_SERIAL_CLASS(wxMenu, wxObject) IMPLEMENT_SERIAL_CLASS(wxMenu, wxObject)
// IMPLEMENT_ALIAS_SERIAL_CLASS(wxPanel, wxWindow)
void WXSERIAL(wxWindow)::StoreObject(wxObjectOutputStream& s) void WXSERIAL(wxWindow)::StoreObject(wxObjectOutputStream& s)
{ {
wxWindow *win_object = (wxWindow *)Object(); wxWindow *win_object = (wxWindow *)Object();
@ -322,3 +322,16 @@ void WXSERIAL(wxMenuItem)::LoadObject(wxObjectInputStream& s)
item->Check( data_s.Read8() ); item->Check( data_s.Read8() );
item->SetSubMenu( (wxMenu *)s.GetChild(0) ); item->SetSubMenu( (wxMenu *)s.GetChild(0) );
} }
void WXSERIAL(wxPanel)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxWindow)::StoreObject(s);
}
void WXSERIAL(wxPanel)::LoadObject(wxObjectInputStream& s)
{
WXSERIAL(wxWindow)::LoadObject(s);
((wxPanel *)Object())->Create(m_parent, m_id, wxPoint(m_x, m_y),
wxSize(m_w, m_h), m_style, m_name);
}

View File

@ -5,7 +5,7 @@
// Modified by: // Modified by:
// Created: July 1998 // Created: July 1998
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Guilhem Lavaux // Copyright: (c) 1998 Guilhem Lavaux
// Licence: wxWindows license // Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -41,7 +41,7 @@ class WXSERIAL(wxWindow) : public WXSERIAL(wxObject)
DECLARE_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject) DECLARE_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject)
DECLARE_SERIAL_CLASS(wxLayoutConstraints, wxObject) DECLARE_SERIAL_CLASS(wxLayoutConstraints, wxObject)
DECLARE_SERIAL_CLASS(wxFrame, wxWindow) DECLARE_SERIAL_CLASS(wxFrame, wxWindow)
//DECLARE_SERIAL_CLASS(wxPanel, wxWindow) DECLARE_SERIAL_CLASS(wxPanel, wxWindow)
//DECLARE_SERIAL_CLASS(wxDialog, wxWindow) //DECLARE_SERIAL_CLASS(wxDialog, wxWindow)
DECLARE_SERIAL_CLASS(wxMenuBar, wxWindow) DECLARE_SERIAL_CLASS(wxMenuBar, wxWindow)
DECLARE_SERIAL_CLASS(wxMenuItem, wxObject) DECLARE_SERIAL_CLASS(wxMenuItem, wxObject)