[cig-commits] r5618 - in long/3D/Gale/trunk/src/StGermain: .
Base/Foundation/src
walter at geodynamics.org
walter at geodynamics.org
Fri Dec 22 06:05:47 PST 2006
Author: walter
Date: 2006-12-22 06:05:46 -0800 (Fri, 22 Dec 2006)
New Revision: 5618
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.c
long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.h
long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/shortcuts.h
Log:
r3206 at earth (orig r3904): LukeHodkinson | 2006-12-13 16:52:06 -0800
* Adding a macro to help in creating virtual functions.
* Adding optional reference counting to the foundation
class.
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3901
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:3196
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/branches/decomp3d/StGermain:3904
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3899
Modified: long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.c 2006-12-22 13:41:56 UTC (rev 5617)
+++ long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.c 2006-12-22 14:05:46 UTC (rev 5618)
@@ -85,6 +85,7 @@
/* General and Virtual info should already be set */
/* Stg_Class info */
+ self->nRefs = 1;
}
void Stg_Class_Delete( void* _class ) {
@@ -214,3 +215,21 @@
return Stg_Class_GetTypeMacro( self );
}
+
+
+void Stg_Class_AddRef( void* _class ) {
+ Stg_Class* self = (Stg_Class*)_class;
+
+ assert( self );
+
+ self->nRefs++;
+}
+
+void Stg_Class_RemoveRef( void* _class ) {
+ Stg_Class* self = (Stg_Class*)_class;
+
+ assert( self );
+
+ if( !(--self->nRefs) )
+ Stg_Class_Delete( self );
+}
Modified: long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.h 2006-12-22 13:41:56 UTC (rev 5617)
+++ long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/Class.h 2006-12-22 14:05:46 UTC (rev 5618)
@@ -59,6 +59,7 @@
SizeT _sizeOfSelf; /**< Size of the final class type */ \
Bool _deleteSelf; /**< True it is to be deallocated in Delete */ \
Type type; /**< Global const char* to string of class' name */ \
+ unsigned nRefs; /* Reference counting. */ \
\
/* Virtual info */ \
Stg_Class_DeleteFunction* _delete; /**< Virtual function for deleting a class. */ \
@@ -137,6 +138,9 @@
/** Get the class type */
#define Stg_Class_GetType Stg_Class_GetTypeMacro
#endif
+
+ void Stg_Class_AddRef( void* _class );
+ void Stg_Class_RemoveRef( void* _class );
/* Private member functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Modified: long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/shortcuts.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/shortcuts.h 2006-12-22 13:41:56 UTC (rev 5617)
+++ long/3D/Gale/trunk/src/StGermain/Base/Foundation/src/shortcuts.h 2006-12-22 14:05:46 UTC (rev 5618)
@@ -50,6 +50,15 @@
#endif
+#ifndef NDEBUG
+#define VirtualCall( method, ... ) \
+ (assert( self ), (self)->method( __VA_ARGS__ )
+#else
+#define VirtualCall( method, ... ) \
+ (self)->method( __VA_ARGS )
+#endif
+
+
#define AllocArray( type, size ) \
((size) ? Memory_Alloc_Array_Unnamed( type, size ) : NULL)
More information about the cig-commits
mailing list