Well, due to my knowledge of C++ I've managed to fix this - at least it compiles now on my system (SuSE Linux 8.1, gcc 3.2, wxWindows 2.4.1 - by the way, I'm still able to compile M with not the latest wxWindows, is it a feature? :) ). I've deleted (well, commented the bodies) both DECLARE_REF_COUNTER and DEFINE_REF_COUNTER macros, and templatized RefCounter* functions instead. Since I needed to put these functions to the header file, I had to add a #include "modules/Filters.h" to define FilterRule class before RefCounter* specializations. I don't know whether such an approach breaks an internal organization of the source code (this is my first hacking into it) and whether it compiles on all target platforms. For me (and I think, for all who use gcc 3 on Linux or its MinGW counterpart on Windows), it works.
The patch file in unified format is attached (UNIX-eols).
-- Alexey Rusakov aka Ktirf RingRows OOO
Index: include/pointers.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/pointers.h,v
retrieving revision 1.3
diff -u -r1.3 pointers.h
--- include/pointers.h 3 Oct 2003 15:11:21 -0000 1.3
+++ include/pointers.h 11 Oct 2003 22:28:18 -0000
@@ -57,13 +57,13 @@
};
#define DECLARE_REF_COUNTER(ClassName) \
- class ClassName; \
+ /*class ClassName; \
extern void RefCounterIncrement(ClassName *pointer); \
extern void RefCounterDecrement(ClassName *pointer); \
- extern void RefCounterAssign(ClassName *target,ClassName *source);
+ extern void RefCounterAssign(ClassName *target,ClassName *source);*/
#define DEFINE_REF_COUNTER(ClassName) \
- extern void RefCounterIncrement(ClassName *pointer) \
+ /*extern void RefCounterIncrement(ClassName *pointer) \
{ RefCounterIncrement(static_cast<MObjectRC *>(pointer)); } \
extern void RefCounterDecrement(ClassName *pointer) \
{ RefCounterDecrement(static_cast<MObjectRC *>(pointer)); } \
@@ -71,12 +71,35 @@
{ \
RefCounterAssign(static_cast<MObjectRC *>(target), \
static_cast<MObjectRC *>(source)); \
- }
+ }*/
+/*
class MObjectRC;
extern void RefCounterIncrement(MObjectRC *pointer);
extern void RefCounterDecrement(MObjectRC *pointer);
extern void RefCounterAssign(MObjectRC *target,MObjectRC *source);
+*/
+
+template <typename _ClassName>
+void RefCounterIncrement(_ClassName *pointer)
+{
+ if (pointer)
+ pointer->IncRef();
+}
+template <typename _ClassName>
+void RefCounterDecrement(_ClassName *pointer)
+{
+ if (pointer)
+ pointer->DecRef();
+}
+template <typename _ClassName>
+void RefCounterAssign(_ClassName *target, _ClassName *source)
+{
+ if (source)
+ source->IncRef();
+ if (target)
+ target->DecRef();
+}
// Equivalent of auto_ptr, but with private copy constructor and assignment
Index: include/MailFolderCmn.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/MailFolderCmn.h,v
retrieving revision 1.84
diff -u -r1.84 MailFolderCmn.h
--- include/MailFolderCmn.h 3 Oct 2003 17:08:05 -0000 1.84
+++ include/MailFolderCmn.h 11 Oct 2003 22:28:18 -0000
@@ -38,8 +38,7 @@
// trace mask for the mail folder related events
#define TRACE_MF_EVENTS "mfevent"
-class FilterRule;
-DECLARE_REF_COUNTER(FilterRule)
+#include "modules/Filters.h"
/**
MailFolderCmn class, common code shared by all implementations of
Index: src/classes/MObject.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MObject.cpp,v
retrieving revision 1.26
diff -u -r1.26 MObject.cpp
--- src/classes/MObject.cpp 3 Oct 2003 15:11:21 -0000 1.26
+++ src/classes/MObject.cpp 11 Oct 2003 22:28:18 -0000
@@ -152,7 +152,7 @@
// ----------------------------------------------------------------------------
// Reference counting helpers
// ----------------------------------------------------------------------------
-
+/*
extern void RefCounterIncrement(MObjectRC *pointer)
{
if( pointer )
@@ -172,5 +172,5 @@
if( target )
target->DecRef();
}
-
+*/
#endif //DEBUG
