Open-Source-Software-Entwicklung und Downloads

Browse Subversion Repository

Diff of /trunk/TTProxy/YCL/include/YCL/common.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3226 by maya, Tue Mar 24 09:37:20 2009 UTC revision 3227 by maya, Tue Mar 24 15:10:33 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   * $Id: common.h,v 1.5 2007-08-18 08:52:18 maya Exp $   * $Id: common.h,v 1.5 2007-08-18 08:52:18 maya Exp $
3   */   */
4    
5  #ifndef _YCL_COMMON_H_  #ifndef _YCL_COMMON_H_
6  #define _YCL_COMMON_H_  #define _YCL_COMMON_H_
7    
8  #if _MSC_VER >= 1000  #if _MSC_VER >= 1000
9  #pragma once  #pragma once
10  #endif // _MSC_VER >= 1000  #endif // _MSC_VER >= 1000
11    
12  #ifndef STRICT  #ifndef STRICT
13  #define STRICT  #define STRICT
14  #endif  #endif
15    
16  #include <windows.h>  #include <windows.h>
17  #include <malloc.h>  #include <malloc.h>
18  #include <stdlib.h>  #include <stdlib.h>
19    
20  #ifndef countof  #ifndef countof
21  #define countof(a) (sizeof (a) / sizeof (a)[0])  #define countof(a) (sizeof (a) / sizeof (a)[0])
22  #endif  #endif
23    
24  #ifdef __cplusplus  #ifdef __cplusplus
25  namespace yebisuya {  namespace yebisuya {
26  #endif  #endif
27    
28  HINSTANCE GetInstanceHandle();  HINSTANCE GetInstanceHandle();
29    
30  #ifdef __cplusplus  #ifdef __cplusplus
31  }  }
32  #endif  #endif
33    
34  #ifdef _DEBUG  #ifdef _DEBUG
35  //{  //{
36    
37  inline void OutputDebugStringF(const char* format, ...) {  inline void OutputDebugStringF(const char* format, ...) {
38          char buffer[1025];          char buffer[1025];
39          va_list arglist;          va_list arglist;
40          va_start(arglist, format);          va_start(arglist, format);
41          wvsprintf(buffer, format, arglist);          wvsprintf(buffer, format, arglist);
42          va_end(arglist);          va_end(arglist);
43          OutputDebugString(buffer);          OutputDebugString(buffer);
44  }  }
45    
46  #define YCLTRACE(s)                      OutputDebugString(s)  #define YCLTRACE(s)                      OutputDebugString(s)
47  #define YCLTRACE1(s, a1)                 OutputDebugStringF(s, a1)  #define YCLTRACE1(s, a1)                 OutputDebugStringF(s, a1)
48  #define YCLTRACE2(s, a1, a2)             OutputDebugStringF(s, a1, a2)  #define YCLTRACE2(s, a1, a2)             OutputDebugStringF(s, a1, a2)
49  #define YCLTRACE3(s, a1, a2, a3)         OutputDebugStringF(s, a1, a2, a3)  #define YCLTRACE3(s, a1, a2, a3)         OutputDebugStringF(s, a1, a2, a3)
50  #define YCLTRACE4(s, a1, a2, a3, a4)     OutputDebugStringF(s, a1, a2, a3, a4)  #define YCLTRACE4(s, a1, a2, a3, a4)     OutputDebugStringF(s, a1, a2, a3, a4)
51  #define YCLTRACE5(s, a1, a2, a3, a4, a5) OutputDebugStringF(s, a1, a2, a3, a4, a5)  #define YCLTRACE5(s, a1, a2, a3, a4, a5) OutputDebugStringF(s, a1, a2, a3, a4, a5)
52    
53  inline bool YclAssert(bool condition, const char* message) {  inline bool YclAssert(bool condition, const char* message) {
54          if (!condition) {          if (!condition) {
55                  char buffer[1025];                  char buffer[1025];
56                  wsprintf(buffer, "Assertion Failed!!\n\n"                  wsprintf(buffer, "Assertion Failed!!\n\n"
57                                                   "  %s\n\n"                                                   "  %s\n\n"
58                                                   "if ABORT button pushed then exit this program,\n"                                                   "if ABORT button pushed then exit this program,\n"
59                                                   "if RETRY button pushed then enter debug mode,\n"                                                   "if RETRY button pushed then enter debug mode,\n"
60                                                   "and if IGNORE button pushed then continue program.", message);                                                   "and if IGNORE button pushed then continue program.", message);
61                  switch (MessageBox(NULL, buffer, "YEBISUYA Class Library", MB_ABORTRETRYIGNORE | MB_ICONWARNING)) {                  switch (MessageBox(NULL, buffer, "YEBISUYA Class Library", MB_ABORTRETRYIGNORE | MB_ICONWARNING)) {
62                  case IDABORT:                  case IDABORT:
63                          ExitProcess(-1);                          ExitProcess(-1);
64                          break;                          break;
65                  case IDRETRY:                  case IDRETRY:
66                          return true;                          return true;
67                          break;                          break;
68                  case IDIGNORE:                  case IDIGNORE:
69                          break;                          break;
70                  }                  }
71          }          }
72          return false;          return false;
73  }  }
74    
75  #define YCLASSERT(condition, message) if (YclAssert(condition, message)) {__asm { int 3 }}  #define YCLASSERT(condition, message) if (YclAssert(condition, message)) {__asm { int 3 }}
76  #define YCLVERIFY(condition, message) if (YclAssert(condition, message)) {__asm { int 3 }}  #define YCLVERIFY(condition, message) if (YclAssert(condition, message)) {__asm { int 3 }}
77    
78  #ifdef __cplusplus  #ifdef __cplusplus
79  extern "C" {  extern "C" {
80  #endif//__cplusplus  #endif//__cplusplus
81  void* _malloc_dbg(size_t length, const char* filename, int lineno);  void* _malloc_dbg(size_t length, const char* filename, int lineno);
82  void* _realloc_dbg(void* pointer, size_t length, const char* filename, int lineno);  void* _realloc_dbg(void* pointer, size_t length, const char* filename, int lineno);
83  void* _calloc_dbg(size_t num, size_t size, const char* filename, int lineno);  void* _calloc_dbg(size_t num, size_t size, const char* filename, int lineno);
84  void _free_dbg(void* pointer, const char* filename, int lineno);  void _free_dbg(void* pointer, const char* filename, int lineno);
85  #ifdef __cplusplus  #ifdef __cplusplus
86  }  }
87  #endif//__cplusplus  #endif//__cplusplus
88    
89  #define malloc(l)     _malloc_dbg((l), __FILE__, __LINE__)  #define malloc(l)     _malloc_dbg((l), __FILE__, __LINE__)
90  #define realloc(p, l) _realloc_dbg((p), (l), __FILE__, __LINE__)  #define realloc(p, l) _realloc_dbg((p), (l), __FILE__, __LINE__)
91  #define calloc(c, s)  _calloc_dbg((c), (s), __FILE__, __LINE__)  #define calloc(c, s)  _calloc_dbg((c), (s), __FILE__, __LINE__)
92  #define free(p)       _free_dbg((p), __FILE__, __LINE__)  #define free(p)       _free_dbg((p), __FILE__, __LINE__)
93    
94  //}  //}
95  #else  #else
96  //{  //{
97    
98  #define YCLTRACE(s)  #define YCLTRACE(s)
99  #define YCLTRACE1(s, a1)  #define YCLTRACE1(s, a1)
100  #define YCLTRACE2(s, a1, a2)  #define YCLTRACE2(s, a1, a2)
101  #define YCLTRACE3(s, a1, a2, a3)  #define YCLTRACE3(s, a1, a2, a3)
102  #define YCLTRACE4(s, a1, a2, a3, a4)  #define YCLTRACE4(s, a1, a2, a3, a4)
103  #define YCLTRACE5(s, a1, a2, a3, a4, a5)  #define YCLTRACE5(s, a1, a2, a3, a4, a5)
104    
105  #define YCLASSERT(condition, message)  #define YCLASSERT(condition, message)
106  #define YCLVERIFY(condition, message) (condition)  #define YCLVERIFY(condition, message) (condition)
107    
108  //}  //}
109  #endif  #endif
110    
111  // テンプレート使用時に警告が出るので抑制する  // テンプレート使用時に警告が出るので抑制する
112  #pragma warning(disable: 4786)  #pragma warning(disable: 4786)
113    
114  #endif//_YCL_COMMON_H_  #endif//_YCL_COMMON_H_

Legend:
Removed from v.3226  
changed lines
  Added in v.3227

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26