]> git.saurik.com Git - wxWidgets.git/commitdiff
* Added source file info in utils/serialize/*
authorGuilhem Lavaux <lavaux@easynet.fr>
Wed, 5 Aug 1998 17:12:43 +0000 (17:12 +0000)
committerGuilhem Lavaux <lavaux@easynet.fr>
Wed, 5 Aug 1998 17:12:43 +0000 (17:12 +0000)
* 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

15 files changed:
include/wx/stream.h
samples/thread/test.cpp
src/common/dynlib.cpp
src/common/stream.cpp
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

index 13ee1dce4289e75cbc0190a62e63bd4a17e2dbad..a2f1c0f89bfd6c80356958057daa9ed11eea8123 100644 (file)
@@ -91,8 +91,15 @@ class WXDLLEXPORT wxInputStream {
   wxInputStream& operator>>(wxString& line);
   wxInputStream& operator>>(char& c);
   wxInputStream& operator>>(short& i);
+  wxInputStream& operator>>(int& i);
   wxInputStream& operator>>(long& 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); }
 
  protected:
@@ -136,13 +143,13 @@ class WXDLLEXPORT wxOutputStream {
   wxOutputStream& operator<<(int i);
   wxOutputStream& operator<<(long i);
   wxOutputStream& operator<<(double f);
+  wxOutputStream& operator<<(wxObject& obj);
 
   wxOutputStream& operator<<(float f) { return operator<<((double)f); }
   wxOutputStream& operator<<(unsigned char c) { return operator<<((char)c); }
   wxOutputStream& operator<<(unsigned short i) { return operator<<((short)i); }
   wxOutputStream& operator<<(unsigned int i) { return operator<<((int)i); }
   wxOutputStream& operator<<(unsigned long i) { return operator<<((long)i); }
-
   wxOutputStream& operator<<( __wxOutputManip func) { return func(*this); }
 
  protected:
index 3d7e70edc7549c25b40d9cf011099d59232cdb76..47149b62a742aaa5423c943c56f8e39adfa332b7 100644 (file)
@@ -35,6 +35,8 @@ class MyApp: public wxApp
     bool OnInit(void);
 };
 
+wxMutex text_mutex;
+
 WX_DEFINE_ARRAY(wxThread *,wxArrayThread);
 
 // Define a new frame type
@@ -83,7 +85,9 @@ void *MyThread::Entry()
 
   while (1) {
     TestDestroy();
+    text_mutex.Lock();
     m_frame->m_txtctrl->WriteText(text);
+    text_mutex.UnLock();
     wxSleep(1);
   }
   
index 4f638aac530fc2605c8efa4dc118fb942ba49091..7a76f087f64521dc47e0ecc5787ad2aff921870d 100644 (file)
 #include <dlfcn.h>
 #endif
 
+#ifdef __WINDOWS__
+#include <windows.h>
+#endif
+
 // ---------------------------------------------------------------------------
 // Global variables
 // ---------------------------------------------------------------------------
@@ -59,7 +63,12 @@ wxLibrary::~wxLibrary()
     else
       delete m_liblist;
 
+#ifdef linux
     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)
 {
 #ifdef linux
-  return dlsym(m_handle, symbname.GetData());
+  return dlsym(m_handle, WXSTRINGCAST symbname);
+#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());
 
 #ifdef linux
-  lib_name.Prepend("./lib");
+  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;
index 66538c9ddd1892d1ab7d2a24d5fb81777a6aee5f..44226e57210d7eaedc0a7e513d1251b081f507a0 100644 (file)
@@ -18,6 +18,7 @@
 #include <ctype.h>
 #include <wx/stream.h>
 #include <wx/datstrm.h>
+#include <wx/objstrm.h>
 
 #ifdef __BORLANDC__
 #pragma hdrstop
@@ -270,6 +271,15 @@ wxInputStream& wxInputStream::operator>>(short& i)
   return *this;
 }
 
+wxInputStream& wxInputStream::operator>>(int& i)
+{
+  long l;
+
+  *this >> l;
+  i = (short)l;
+  return *this;
+}
+
 wxInputStream& wxInputStream::operator>>(long& i)
 {
   /* I only implemented a simple integer parser */
@@ -341,6 +351,13 @@ wxInputStream& wxInputStream::operator>>(float& f)
   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 ret_off;
@@ -504,6 +521,13 @@ wxOutputStream& wxOutputStream::operator<<(double f)
   return Write(strfloat, strfloat.Len());
 }
 
+wxOutputStream& wxOutputStream::operator<<(wxObject& obj)
+{
+  wxObjectOutputStream obj_s(*this);
+  obj_s.SaveObject(obj);
+  return *this;
+}
+
 // ----------------------------------------------------------------------------
 // wxFilterInputStream
 // ----------------------------------------------------------------------------
index dbd55e251001f122861798b60501e0c528082091..8c83acbe021e62db267e870ef00752536151ae81 100644 (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__
 #pragma implementation "sercore.h"
 #endif
index af3d01682487f050689c235c7a594950ec351390..676c04a4497f618bccc19ea4b3c65f25bc618adc 100644 (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__
 #define __SERCORE_H__
 
index 59aabe8f7fe06cb93293fde03542d8b12d08366e..022f940d76d427acad2324b09e9710f95ffbb4bb 100644 (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__
 #pragma implementation "serctrl.h"
 #endif
index 1f922cf4b605735055d2c3b5ad8f401e335a5140..d2eeb8244993d988e44c2fc6f6d7d35762a73e8a 100644 (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__
 #define __SERCTRL_H__
 
index ce8c34d1fbe7e6d69b5d7fc1871fc57751d32b0c..da6d92785abb263d14260789d7d0e40ca1740883 100644 (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__
 #pragma implementation "serext.h"
 #endif
index f1d36fbbc6c7915d49d600fed0ee9e9767fceb19..5856e50edd94a9f023a88fde38579b94d0710b56 100644 (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__
 #define __SEREXT_H__
 
index a73423430318ecf067a31d05879830698a47b31f..e76c555ffcb0ea5cd382d51bcb248543e115da7b 100644 (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__
 #pragma implementation "sergdi.h"
 #endif
index 1ab04142b29b970e895991c99cb053fc23d6426c..98a3957ac0ae7e77d481ed1ba24115f8cf4c2cf6 100644 (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__
 #define __SERGDI_H__
 
index 0e2a730220892c8bc8c3a62749194066c0db8037..95194106fc5cd3bff03b77475033a2acec70b555 100644 (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/serbase.h>
 
index 52914a0d89d72c6f0fc74348bbdb20d1e1ccb810..e9143391f3fa94c45293dc4c686aa99a29270ea9 100644 (file)
@@ -3,9 +3,9 @@
 // Purpose:     Serialization: wxWindow classes
 // Author:      Guilhem Lavaux
 // Modified by:
-// Created:     11/07/98
+// Created:     July 1998
 // RCS-ID:      $Id$
-// Copyright:   (c) Guilhem Lavaux
+// Copyright:   (c) 1998 Guilhem Lavaux
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
@@ -20,6 +20,7 @@
 #include <wx/objstrm.h>
 #include <wx/utils.h>
 #include <wx/frame.h>
+#include <wx/panel.h>
 #include <wx/serbase.h>
 #include "serwnd.h"
 
@@ -27,13 +28,12 @@ IMPLEMENT_SERIAL_CLASS(wxWindow, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxLayoutConstraints, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxFrame, wxWindow)
+IMPLEMENT_SERIAL_CLASS(wxPanel, wxWindow)
 //IMPLEMENT_SERIAL_CLASS(wxDialog, wxWindow)
 IMPLEMENT_SERIAL_CLASS(wxMenuBar, wxWindow)
 IMPLEMENT_SERIAL_CLASS(wxMenuItem, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxMenu, wxObject)
 
-// IMPLEMENT_ALIAS_SERIAL_CLASS(wxPanel, wxWindow)
-
 void WXSERIAL(wxWindow)::StoreObject(wxObjectOutputStream& s)
 {
   wxWindow *win_object = (wxWindow *)Object();
@@ -322,3 +322,16 @@ void WXSERIAL(wxMenuItem)::LoadObject(wxObjectInputStream& s)
   item->Check( data_s.Read8() );
   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);
+}
index b195ec300ab136d50688248449cf982aab1e675a..943374c3f7df58c765ab41a98f9b7f338fefe29e 100644 (file)
@@ -5,7 +5,7 @@
 // Modified by:
 // Created:     July 1998
 // RCS-ID:      $Id$
-// Copyright:   (c) Guilhem Lavaux
+// Copyright:   (c) 1998 Guilhem Lavaux
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
@@ -41,7 +41,7 @@ class WXSERIAL(wxWindow) : public WXSERIAL(wxObject)
 DECLARE_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject)
 DECLARE_SERIAL_CLASS(wxLayoutConstraints, wxObject)
 DECLARE_SERIAL_CLASS(wxFrame, wxWindow)
-//DECLARE_SERIAL_CLASS(wxPanel, wxWindow)
+DECLARE_SERIAL_CLASS(wxPanel, wxWindow)
 //DECLARE_SERIAL_CLASS(wxDialog, wxWindow)
 DECLARE_SERIAL_CLASS(wxMenuBar, wxWindow)
 DECLARE_SERIAL_CLASS(wxMenuItem, wxObject)