~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to libs/appleutility/CADebugMacros.h

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-8gsftrku6jnzhd7v
Tags: upstream-3.4~dfsg
ImportĀ upstreamĀ versionĀ 3.4~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*      Copyright:      ļæ½ Copyright 2005 Apple Computer, Inc. All rights reserved.
 
2
 
 
3
        Disclaimer:     IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
 
4
                        ("Apple") in consideration of your agreement to the following terms, and your
 
5
                        use, installation, modification or redistribution of this Apple software
 
6
                        constitutes acceptance of these terms.  If you do not agree with these terms,
 
7
                        please do not use, install, modify or redistribute this Apple software.
 
8
 
 
9
                        In consideration of your agreement to abide by the following terms, and subject
 
10
                        to these terms, Apple grants you a personal, non-exclusive license, under Appleļæ½s
 
11
                        copyrights in this original Apple software (the "Apple Software"), to use,
 
12
                        reproduce, modify and redistribute the Apple Software, with or without
 
13
                        modifications, in source and/or binary forms; provided that if you redistribute
 
14
                        the Apple Software in its entirety and without modifications, you must retain
 
15
                        this notice and the following text and disclaimers in all such redistributions of
 
16
                        the Apple Software.  Neither the name, trademarks, service marks or logos of
 
17
                        Apple Computer, Inc. may be used to endorse or promote products derived from the
 
18
                        Apple Software without specific prior written permission from Apple.  Except as
 
19
                        expressly stated in this notice, no other rights or licenses, express or implied,
 
20
                        are granted by Apple herein, including but not limited to any patent rights that
 
21
                        may be infringed by your derivative works or by other works in which the Apple
 
22
                        Software may be incorporated.
 
23
 
 
24
                        The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
 
25
                        WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
 
26
                        WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
27
                        PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
 
28
                        COMBINATION WITH YOUR PRODUCTS.
 
29
 
 
30
                        IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
 
31
                        CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 
32
                        GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
33
                        ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
 
34
                        OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
 
35
                        (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
 
36
                        ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
37
*/
 
38
/*=============================================================================
 
39
        CADebugMacros.h
 
40
 
 
41
=============================================================================*/
 
42
#if !defined(__CADebugMacros_h__)
 
43
#define __CADebugMacros_h__
 
44
 
 
45
//=============================================================================
 
46
//      CADebugMacros
 
47
//=============================================================================
 
48
 
 
49
//#define       CoreAudio_StopOnFailure                 1
 
50
//#define       CoreAudio_TimeStampMessages             1
 
51
//#define       CoreAudio_ThreadStampMessages   1
 
52
//#define       CoreAudio_FlushDebugMessages    1
 
53
 
 
54
#define CA4CCToCString(the4CC)  { ((char*)&the4CC)[0], ((char*)&the4CC)[1], ((char*)&the4CC)[2], ((char*)&the4CC)[3], 0 }
 
55
 
 
56
#pragma mark    Basic Definitions
 
57
 
 
58
#if     DEBUG || CoreAudio_Debug
 
59
        
 
60
        // can be used to break into debugger immediately, also see CADebugger
 
61
        #define BusError()              (*(long *)0 = 0)
 
62
        
 
63
        //      basic debugging print routines
 
64
        #if     TARGET_OS_MAC && !TARGET_API_MAC_CARBON
 
65
                extern pascal void DebugStr(const unsigned char* debuggerMsg);
 
66
                #define DebugMessage(msg)       DebugStr("\p"msg)
 
67
                #define DebugMessageN1(msg, N1)
 
68
                #define DebugMessageN2(msg, N1, N2)
 
69
                #define DebugMessageN3(msg, N1, N2, N3)
 
70
        #else
 
71
                #include "CADebugPrintf.h"
 
72
                
 
73
                #if     (CoreAudio_FlushDebugMessages && !CoreAudio_UseSysLog) || defined(CoreAudio_UseSideFile)
 
74
                        #define FlushRtn        ;fflush(DebugPrintfFile)
 
75
                #else
 
76
                        #define FlushRtn
 
77
                #endif
 
78
                
 
79
                #if             CoreAudio_ThreadStampMessages
 
80
                        #include <pthread.h>
 
81
                        #include "CAHostTimeBase.h"
 
82
                        #define DebugMessage(msg)                                                                               DebugPrintfRtn(DebugPrintfFile, "%p %.4f: %s"DebugPrintfLineEnding, pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn
 
83
                        #define DebugMessageN1(msg, N1)                                                                 DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn
 
84
                        #define DebugMessageN2(msg, N1, N2)                                                             DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn
 
85
                        #define DebugMessageN3(msg, N1, N2, N3)                                                 DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn
 
86
                        #define DebugMessageN4(msg, N1, N2, N3, N4)                                             DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn
 
87
                        #define DebugMessageN5(msg, N1, N2, N3, N4, N5)                                 DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn
 
88
                        #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)                             DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn
 
89
                        #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)                 DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn
 
90
                        #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)             DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
 
91
                        #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
 
92
                #elif   CoreAudio_TimeStampMessages
 
93
                        #include "CAHostTimeBase.h"
 
94
                        #define DebugMessage(msg)                                                                               DebugPrintfRtn(DebugPrintfFile, "%.4f: %s"DebugPrintfLineEnding, pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn
 
95
                        #define DebugMessageN1(msg, N1)                                                                 DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn
 
96
                        #define DebugMessageN2(msg, N1, N2)                                                             DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn
 
97
                        #define DebugMessageN3(msg, N1, N2, N3)                                                 DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn
 
98
                        #define DebugMessageN4(msg, N1, N2, N3, N4)                                             DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn
 
99
                        #define DebugMessageN5(msg, N1, N2, N3, N4, N5)                                 DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn
 
100
                        #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)                             DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn
 
101
                        #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)                 DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn
 
102
                        #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)             DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
 
103
                        #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg DebugPrintfLineEnding, ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
 
104
                #else
 
105
                        #define DebugMessage(msg)                                                                               DebugPrintfRtn(DebugPrintfFile, "%s"DebugPrintfLineEnding, msg) FlushRtn
 
106
                        #define DebugMessageN1(msg, N1)                                                                 DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1) FlushRtn
 
107
                        #define DebugMessageN2(msg, N1, N2)                                                             DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2) FlushRtn
 
108
                        #define DebugMessageN3(msg, N1, N2, N3)                                                 DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3) FlushRtn
 
109
                        #define DebugMessageN4(msg, N1, N2, N3, N4)                                             DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3, N4) FlushRtn
 
110
                        #define DebugMessageN5(msg, N1, N2, N3, N4, N5)                                 DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3, N4, N5) FlushRtn
 
111
                        #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)                             DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6) FlushRtn
 
112
                        #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)                 DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7) FlushRtn
 
113
                        #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)             DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
 
114
                        #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFile, msg DebugPrintfLineEnding, N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
 
115
                #endif
 
116
        #endif
 
117
        void    DebugPrint(const char *fmt, ...);       // can be used like printf
 
118
        #define DEBUGPRINT(msg) DebugPrint msg          // have to double-parenthesize arglist (see Debugging.h)
 
119
        #if VERBOSE
 
120
                #define vprint(msg) DEBUGPRINT(msg)
 
121
        #else
 
122
                #define vprint(msg)
 
123
        #endif
 
124
        
 
125
        #if     CoreAudio_StopOnFailure
 
126
                #include "CADebugger.h"
 
127
                #define STOP    CADebuggerStop()
 
128
        #else
 
129
                #define STOP
 
130
        #endif
 
131
 
 
132
#else
 
133
        #define DebugMessage(msg)
 
134
        #define DebugMessageN1(msg, N1)
 
135
        #define DebugMessageN2(msg, N1, N2)
 
136
        #define DebugMessageN3(msg, N1, N2, N3)
 
137
        #define DebugMessageN4(msg, N1, N2, N3, N4)
 
138
        #define DebugMessageN5(msg, N1, N2, N3, N4, N5)
 
139
        #define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)
 
140
        #define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)
 
141
        #define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)
 
142
        #define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9)
 
143
        #define DEBUGPRINT(msg)
 
144
        #define vprint(msg)
 
145
        #define STOP
 
146
#endif
 
147
 
 
148
void    LogError(const char *fmt, ...);                 // writes to syslog (and stderr if debugging)
 
149
void    LogWarning(const char *fmt, ...);               // writes to syslog (and stderr if debugging)
 
150
 
 
151
#if     DEBUG || CoreAudio_Debug
 
152
 
 
153
#pragma mark    Debug Macros
 
154
 
 
155
#define Assert(inCondition, inMessage)                                                                                                  \
 
156
                        if(!(inCondition))                                                                                                                      \
 
157
                        {                                                                                                                                                       \
 
158
                                DebugMessage(inMessage);                                                                                                \
 
159
                                STOP;                                                                                                                                   \
 
160
                        }
 
161
 
 
162
#define AssertNoError(inError, inMessage)                                                                                               \
 
163
                        {                                                                                                                                                       \
 
164
                                SInt32 __Err = (inError);                                                                                               \
 
165
                                if(__Err != 0)                                                                                                                  \
 
166
                                {                                                                                                                                               \
 
167
                                        char __4CC[5] = CA4CCToCString(__Err);                                                          \
 
168
                                        DebugMessageN2(inMessage ", Error: %ld (%s)", __Err, __4CC);            \
 
169
                                        STOP;                                                                                                                           \
 
170
                                }                                                                                                                                               \
 
171
                        }
 
172
 
 
173
#define AssertNoKernelError(inError, inMessage)                                                                                 \
 
174
                        {                                                                                                                                                       \
 
175
                                unsigned int __Err = (unsigned int)(inError);                                                   \
 
176
                                if(__Err != 0)                                                                                                                  \
 
177
                                {                                                                                                                                               \
 
178
                                        DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
 
179
                                        STOP;                                                                                                                           \
 
180
                                }                                                                                                                                               \
 
181
                        }
 
182
 
 
183
#define FailIf(inCondition, inHandler, inMessage)                                                                               \
 
184
                        if(inCondition)                                                                                                                         \
 
185
                        {                                                                                                                                                       \
 
186
                                DebugMessage(inMessage);                                                                                                \
 
187
                                STOP;                                                                                                                                   \
 
188
                                goto inHandler;                                                                                                                 \
 
189
                        }
 
190
 
 
191
#define FailWithAction(inCondition, inAction, inHandler, inMessage)                                             \
 
192
                        if(inCondition)                                                                                                                         \
 
193
                        {                                                                                                                                                       \
 
194
                                DebugMessage(inMessage);                                                                                                \
 
195
                                STOP;                                                                                                                                   \
 
196
                                { inAction; }                                                                                                                   \
 
197
                                goto inHandler;                                                                                                                 \
 
198
                        }
 
199
 
 
200
#define FailIfNULL(inPointer, inAction, inHandler, inMessage)                                                   \
 
201
                        if((inPointer) == NULL)                                                                                                         \
 
202
                        {                                                                                                                                                       \
 
203
                                DebugMessage(inMessage);                                                                                                \
 
204
                                STOP;                                                                                                                                   \
 
205
                                { inAction; }                                                                                                                   \
 
206
                                goto inHandler;                                                                                                                 \
 
207
                        }
 
208
 
 
209
#define FailIfKernelError(inKernelError, inException, inMessage)                                                \
 
210
                        {                                                                                                                                                       \
 
211
                                kern_return_t __Err = (inKernelError);                                                                  \
 
212
                                if(__Err != 0)                                                                                                                  \
 
213
                                {                                                                                                                                               \
 
214
                                        DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
 
215
                                        STOP;                                                                                                                           \
 
216
                                        { inAction; }                                                                                                           \
 
217
                                        goto inHandler;                                                                                                         \
 
218
                                }                                                                                                                                               \
 
219
                        }
 
220
 
 
221
#define FailIfError(inError, inException, inMessage)                                                                    \
 
222
                        {                                                                                                                                                       \
 
223
                                SInt32 __Err = (inError);                                                                                               \
 
224
                                if(__Err != 0)                                                                                                                  \
 
225
                                {                                                                                                                                               \
 
226
                                        char __4CC[5] = CA4CCToCString(__Err);                                                          \
 
227
                                        DebugMessageN2(inMessage ", Error: %ld (%s)", __Err, __4CC);            \
 
228
                                        STOP;                                                                                                                           \
 
229
                                        { inAction; }                                                                                                           \
 
230
                                        goto inHandler;                                                                                                         \
 
231
                                }                                                                                                                                               \
 
232
                        }
 
233
 
 
234
#if defined(__cplusplus)
 
235
 
 
236
#define Throw(inException)  STOP; throw (inException)
 
237
 
 
238
#define ThrowIf(inCondition, inException, inMessage)                                                                    \
 
239
                        if(inCondition)                                                                                                                         \
 
240
                        {                                                                                                                                                       \
 
241
                                DebugMessage(inMessage);                                                                                                \
 
242
                                Throw(inException);                                                                                                             \
 
243
                        }
 
244
 
 
245
#define ThrowIfNULL(inPointer, inException, inMessage)                                                                  \
 
246
                        if((inPointer) == NULL)                                                                                                         \
 
247
                        {                                                                                                                                                       \
 
248
                                DebugMessage(inMessage);                                                                                                \
 
249
                                Throw(inException);                                                                                                             \
 
250
                        }
 
251
 
 
252
#define ThrowIfKernelError(inKernelError, inException, inMessage)                                               \
 
253
                        {                                                                                                                                                       \
 
254
                                kern_return_t __Err = (inKernelError);                                                                  \
 
255
                                if(__Err != 0)                                                                                                                  \
 
256
                                {                                                                                                                                               \
 
257
                                        DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
 
258
                                        Throw(inException);                                                                                                     \
 
259
                                }                                                                                                                                               \
 
260
                        }
 
261
 
 
262
#define ThrowIfError(inError, inException, inMessage)                                                                   \
 
263
                        {                                                                                                                                                       \
 
264
                                SInt32 __Err = (inError);                                                                                               \
 
265
                                if(__Err != 0)                                                                                                                  \
 
266
                                {                                                                                                                                               \
 
267
                                        char __4CC[5] = CA4CCToCString(__Err);                                                          \
 
268
                                        DebugMessageN2(inMessage ", Error: %ld (%s)", __Err, __4CC);            \
 
269
                                        Throw(inException);                                                                                                     \
 
270
                                }                                                                                                                                               \
 
271
                        }
 
272
 
 
273
#if TARGET_OS_WIN32
 
274
#define ThrowIfWinError(inError, inException, inMessage)                                                                \
 
275
                        {                                                                                                                                                       \
 
276
                                HRESULT __Err = (inError);                                                                                              \
 
277
                                if(FAILED(__Err))                                                                                                               \
 
278
                                {                                                                                                                                               \
 
279
                                        DebugMessageN1(inMessage ", Error: 0x%X", __Err);                                       \
 
280
                                        Throw(inException);                                                                                                     \
 
281
                                }                                                                                                                                               \
 
282
                        }
 
283
#endif
 
284
 
 
285
#define SubclassResponsibility(inMethodName, inException)                                                               \
 
286
                        {                                                                                                                                                       \
 
287
                                DebugMessage(inMethodName": Subclasses must implement this method");    \
 
288
                                Throw(inException);                                                                                                             \
 
289
                        }
 
290
 
 
291
#endif  //      defined(__cplusplus)
 
292
 
 
293
#else
 
294
 
 
295
#pragma mark    Release Macros
 
296
 
 
297
#define Assert(inCondition, inMessage)                                                                                                  \
 
298
                        if(!(inCondition))                                                                                                                      \
 
299
                        {                                                                                                                                                       \
 
300
                                STOP;                                                                                                                                   \
 
301
                        }
 
302
 
 
303
#define AssertNoError(inError, inMessage)                                                                                               \
 
304
                        {                                                                                                                                                       \
 
305
                                SInt32 __Err = (inError);                                                                                               \
 
306
                                if(__Err != 0)                                                                                                                  \
 
307
                                {                                                                                                                                               \
 
308
                                        STOP;                                                                                                                           \
 
309
                                }                                                                                                                                               \
 
310
                        }
 
311
 
 
312
#define AssertNoKernelError(inError, inMessage)                                                                                 \
 
313
                        {                                                                                                                                                       \
 
314
                                unsigned int __Err = (unsigned int)(inError);                                                   \
 
315
                                if(__Err != 0)                                                                                                                  \
 
316
                                {                                                                                                                                               \
 
317
                                        STOP;                                                                                                                           \
 
318
                                }                                                                                                                                               \
 
319
                        }
 
320
 
 
321
#define FailIf(inCondition, inHandler, inMessage)                                                                               \
 
322
                        if(inCondition)                                                                                                                         \
 
323
                        {                                                                                                                                                       \
 
324
                                STOP;                                                                                                                                   \
 
325
                                goto inHandler;                                                                                                                 \
 
326
                        }
 
327
 
 
328
#define FailWithAction(inCondition, inAction, inHandler, inMessage)                                             \
 
329
                        if(inCondition)                                                                                                                         \
 
330
                        {                                                                                                                                                       \
 
331
                                STOP;                                                                                                                                   \
 
332
                                { inAction; }                                                                                                                   \
 
333
                                goto inHandler;                                                                                                                 \
 
334
                        }
 
335
 
 
336
#define FailIfNULL(inPointer, inAction, inHandler, inMessage)                                                   \
 
337
                        if((inPointer) == NULL)                                                                                                         \
 
338
                        {                                                                                                                                                       \
 
339
                                STOP;                                                                                                                                   \
 
340
                                { inAction; }                                                                                                                   \
 
341
                                goto inHandler;                                                                                                                 \
 
342
                        }
 
343
 
 
344
#define FailIfKernelError(inKernelError, inException, inMessage)                                                \
 
345
                        if((inKernelError) != 0)                                                                                                        \
 
346
                        {                                                                                                                                                       \
 
347
                                STOP;                                                                                                                                   \
 
348
                                { inAction; }                                                                                                                   \
 
349
                                goto inHandler;                                                                                                                 \
 
350
                        }
 
351
 
 
352
#define FailIfError(inError, inException, inMessage)                                                                    \
 
353
                        if((inError) != 0)                                                                                                                      \
 
354
                        {                                                                                                                                                       \
 
355
                                STOP;                                                                                                                                   \
 
356
                                { inAction; }                                                                                                                   \
 
357
                                goto inHandler;                                                                                                                 \
 
358
                        }
 
359
 
 
360
#if defined(__cplusplus)
 
361
 
 
362
#define Throw(inException)  STOP; throw (inException)
 
363
 
 
364
#define ThrowIf(inCondition, inException, inMessage)                                                                    \
 
365
                        if(inCondition)                                                                                                                         \
 
366
                        {                                                                                                                                                       \
 
367
                                Throw(inException);                                                                                                             \
 
368
                        }
 
369
 
 
370
#define ThrowIfNULL(inPointer, inException, inMessage)                                                                  \
 
371
                        if((inPointer) == NULL)                                                                                                         \
 
372
                        {                                                                                                                                                       \
 
373
                                Throw(inException);                                                                                                             \
 
374
                        }
 
375
 
 
376
#define ThrowIfKernelError(inKernelError, inException, inMessage)                                               \
 
377
                        {                                                                                                                                                       \
 
378
                                kern_return_t __Err = (inKernelError);                                                                  \
 
379
                                if(__Err != 0)                                                                                                                  \
 
380
                                {                                                                                                                                               \
 
381
                                        Throw(inException);                                                                                                     \
 
382
                                }                                                                                                                                               \
 
383
                        }
 
384
 
 
385
#define ThrowIfError(inError, inException, inMessage)                                                                   \
 
386
                        {                                                                                                                                                       \
 
387
                                SInt32 __Err = (inError);                                                                                               \
 
388
                                if(__Err != 0)                                                                                                                  \
 
389
                                {                                                                                                                                               \
 
390
                                        Throw(inException);                                                                                                     \
 
391
                                }                                                                                                                                               \
 
392
                        }
 
393
 
 
394
#if TARGET_OS_WIN32
 
395
#define ThrowIfWinError(inError, inException, inMessage)                                                                \
 
396
                        {                                                                                                                                                       \
 
397
                                HRESULT __Err = (inError);                                                                                              \
 
398
                                if(FAILED(__Err))                                                                                                               \
 
399
                                {                                                                                                                                               \
 
400
                                        Throw(inException);                                                                                                     \
 
401
                                }                                                                                                                                               \
 
402
                        }
 
403
#endif
 
404
 
 
405
#define SubclassResponsibility(inMethodName, inException)                                                               \
 
406
                        {                                                                                                                                                       \
 
407
                                Throw(inException);                                                                                                             \
 
408
                        }
 
409
 
 
410
#endif  //      defined(__cplusplus)
 
411
 
 
412
#endif  //  DEBUG || CoreAudio_Debug
 
413
 
 
414
#endif