]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/object.cpp
Fixed a few compile things
[wxWidgets.git] / src / common / object.cpp
index 272e88a21f514df935fe6b40190accfe416371b9..6f378e681076ef0717b1c55b59251776baf9b477 100644 (file)
@@ -38,8 +38,8 @@
 #endif
 
 #if !USE_SHARED_LIBRARY
-wxClassInfo wxObject::classwxObject("wxObject", NULL, NULL, sizeof(wxObject), NULL);
-wxClassInfo *wxClassInfo::first = NULL;
+wxClassInfo wxObject::classwxObject((char *) "wxObject", (char *) NULL, (char *) NULL, (int ) sizeof(wxObject), (wxObjectConstructorFn) NULL);
+wxClassInfo *wxClassInfo::first = (wxClassInfo *) NULL;
 #endif
 
 /*
@@ -48,7 +48,7 @@ wxClassInfo *wxClassInfo::first = NULL;
 
 wxObject::wxObject(void)
 {
-  m_refData = NULL;
+  m_refData = (wxObjectRefData *) NULL;
 }
 
 wxObject::~wxObject(void)
@@ -129,8 +129,8 @@ wxClassInfo::wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz,
   next = first;
   first = this;
 
-  baseInfo1 = NULL;
-  baseInfo2 = NULL;
+  baseInfo1 = (wxClassInfo *) NULL;
+  baseInfo2 = (wxClassInfo *) NULL;
 }
 
 wxObject *wxClassInfo::CreateObject(void)
@@ -138,7 +138,7 @@ wxObject *wxClassInfo::CreateObject(void)
   if (objectConstructor)
     return (wxObject *)(*objectConstructor)();
   else
-    return NULL;
+    return (wxObject *) NULL;
 }
 
 wxClassInfo *wxClassInfo::FindClass(char *c)
@@ -150,7 +150,7 @@ wxClassInfo *wxClassInfo::FindClass(char *c)
       return p;
     p = p->next;
   }
-  return NULL;
+  return (wxClassInfo *) NULL;
 }
 
 // Climb upwards through inheritance hierarchy.
@@ -216,17 +216,71 @@ wxObject *wxCreateDynamicObject(char *name)
       return info->CreateObject();
     info = info->next;
   }
-  return NULL;
+  return (wxObject *) NULL;
 }
 
 #ifdef USE_STORABLE_CLASSES
 
+#include "wx/serbase.h"
+#include "wx/dynlib.h"
+#include "wx/msgdlg.h"
+
 wxObject* wxCreateStoredObject( wxInputStream &stream )
 {
   wxObjectInputStream obj_s(stream);
   return obj_s.LoadObject();
 };
 
+void wxObject::StoreObject( wxObjectOutputStream& stream )
+{
+  wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
+  wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
+  WXSERIAL(wxObject) *serial;
+
+  if (!lib) {
+    wxMessageBox("Can't load wxSerial dynamic library.", "Alert !");
+    return;
+  }
+  serial = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
+
+  if (!serial) {
+    wxString message;
+
+    message.Printf("Can't find the serialization object (%s) for the object %s",
+                   WXSTRINGCAST obj_name,                                                          WXSTRINGCAST GetClassInfo()->GetClassName());
+    wxMessageBox(message, "Alert !");
+    return;
+  }
+
+  serial->SetObject(this);
+  serial->StoreObject(stream);
+
+  delete serial;
+}
+
+void wxObject::LoadObject( wxObjectInputStream& stream )
+{
+  wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
+  wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
+  WXSERIAL(wxObject) *serial =
+                           (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
+
+  if (!serial) {
+    wxString message;
+
+    message.Printf("Can't find the serialization object (%s) for the object %s",
+                   WXSTRINGCAST obj_name,
+                   WXSTRINGCAST GetClassInfo()->GetClassName());
+    wxMessageBox(message, "Alert !");
+    return;
+  }
+
+  serial->SetObject(this);
+  serial->LoadObject(stream);
+
+  delete serial;
+}
+
 #endif
 
 /*
@@ -252,7 +306,7 @@ void wxObject::UnRef(void)
         if (m_refData->m_count == 0)
             delete m_refData;
     }
-    m_refData = NULL;
+    m_refData = (wxObjectRefData *) NULL;
 }
 
 /*