7 #define OBJC_MEMORY_CHECK
\r
10 #include <windows.h>
\r
12 #include <pthread.h>
\r
15 #include <Raym/Runtime.h>
\r
17 #define SET_METHOD(P1, P2) \
\r
28 #define RELEASE(P1) \
\r
35 #define isKindOfClass(CLS, OBJ) \
\r
36 (strcmp(#CLS, (OBJ)->className()) == 0)
\r
41 #define OBJC_LOCK_CREATE InitializeCriticalSection(&_cs)
\r
42 #define OBJC_LOCK_DESTROY DeleteCriticalSection(&_cs)
\r
44 #define OBJC_LOCK(OBJ) \
\r
45 DebugLog4("ECS_B:[0x%08X:0x%08X] %s() at %d\n", (unsigned int)(OBJ), GetCurrentThreadId(), __FUNCTION__, __LINE__); \
\r
46 EnterCriticalSection(&(OBJ)->_cs); \
\r
47 DebugLog4("ECS_A:[0x%08X:0x%08X] %s() at %d\n", (unsigned int)(OBJ), GetCurrentThreadId(), __FUNCTION__, __LINE__);
\r
49 #define OBJC_UNLOCK(OBJ) \
\r
50 DebugLog4("LCS_B:[0x%08X:0x%08X] %s() at %d\n", (unsigned int)(OBJ), GetCurrentThreadId(), __FUNCTION__, __LINE__); \
\r
51 LeaveCriticalSection(&(OBJ)->_cs); \
\r
52 DebugLog4("LCS_A:[0x%08X:0x%08X] %s() at %d\n", (unsigned int)(OBJ), GetCurrentThreadId(), __FUNCTION__, __LINE__);
\r
55 #define DEFINE_STATIC_MUTEX(variable) \
\r
56 class STATIC_MUTEX_variable \
\r
59 CRITICAL_SECTION _cs; \
\r
62 STATIC_MUTEX_variable() \
\r
64 InitializeCriticalSection(&_cs); \
\r
66 ~STATIC_MUTEX_variable() \
\r
68 DeleteCriticalSection(&_cs); \
\r
72 EnterCriticalSection(&_cs); \
\r
76 LeaveCriticalSection(&_cs); \
\r
79 static STATIC_MUTEX_variable variable;
\r
83 #define OBJC_LOCK_CREATE { \
\r
84 pthread_mutexattr_t attr; \
\r
85 pthread_mutexattr_init(&attr); \
\r
86 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); \
\r
87 pthread_mutex_init(&_lock, &attr); \
\r
89 #define OBJC_LOCK_DESTROY pthread_mutex_destroy(&_lock)
\r
90 #define OBJC_LOCK pthread_mutex_lock(&_lock)
\r
91 #define OBJC_UNLOCK pthread_mutex_unlock(&_lock)
\r
98 #ifdef OBJC_MEMORY_CHECK
\r
99 extern int global_objc_count_;
\r
100 extern int global_objc_init_count_;
\r
101 extern int global_objc_retain_count_;
\r
102 extern int global_objc_autorelease_count_;
\r
103 extern int global_objc_release_count_;
\r
106 typedef unsigned int uint;
\r
107 typedef unsigned char uchar;
\r
118 CRITICAL_SECTION _cs;
\r
120 pthread_mutex_t _lock;
\r
126 static Object *alloc();
\r
131 Object *autorelease();
\r
132 Object *autorelease(bool rootPool);
\r
135 virtual String *description();
\r
137 // virtual const char *className() = 0;
\r
138 virtual const char *className();
\r
140 friend void OBJC_LOCK(Object *);
\r
141 friend void OBJC_UNLOCK(Object *);
\r
144 inline void OBJC_LOCK(Object *obj)
\r
147 EnterCriticalSection(&(obj->_cs));
\r
152 inline void OBJC_UNLOCK(Object *obj)
\r
155 LeaveCriticalSection(&(obj->_cs));
\r