source: webkit/trunk/JavaScriptCore/wtf/Assertions.h@ 38146

Last change on this file since 38146 was 35900, checked in by [email protected], 17 years ago

2008-08-23 Cameron Zwarich <[email protected]>

Rubber-stamped by Mark Rowe.

Remove modelines.

JavaScriptCore:

  • API/APICast.h:
  • API/JSBase.cpp:
  • API/JSCallbackConstructor.cpp:
  • API/JSCallbackConstructor.h:
  • API/JSCallbackFunction.cpp:
  • API/JSCallbackFunction.h:
  • API/JSCallbackObject.cpp:
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:
  • API/JSClassRef.cpp:
  • API/JSContextRef.cpp:
  • API/JSObjectRef.cpp:
  • API/JSProfilerPrivate.cpp:
  • API/JSStringRef.cpp:
  • API/JSStringRefBSTR.cpp:
  • API/JSStringRefCF.cpp:
  • API/JSValueRef.cpp:
  • API/tests/JSNode.c:
  • API/tests/JSNode.h:
  • API/tests/JSNodeList.c:
  • API/tests/JSNodeList.h:
  • API/tests/Node.c:
  • API/tests/Node.h:
  • API/tests/NodeList.c:
  • API/tests/NodeList.h:
  • API/tests/minidom.c:
  • API/tests/minidom.js:
  • API/tests/testapi.c:
  • API/tests/testapi.js:
  • JavaScriptCore.pro:
  • kjs/FunctionConstructor.h:
  • kjs/FunctionPrototype.h:
  • kjs/JSArray.h:
  • kjs/JSString.h:
  • kjs/JSWrapperObject.cpp:
  • kjs/NumberConstructor.h:
  • kjs/NumberObject.h:
  • kjs/NumberPrototype.h:
  • kjs/lexer.h:
  • kjs/lookup.h:
  • wtf/Assertions.cpp:
  • wtf/Assertions.h:
  • wtf/HashCountedSet.h:
  • wtf/HashFunctions.h:
  • wtf/HashIterators.h:
  • wtf/HashMap.h:
  • wtf/HashSet.h:
  • wtf/HashTable.h:
  • wtf/HashTraits.h:
  • wtf/ListHashSet.h:
  • wtf/ListRefPtr.h:
  • wtf/Noncopyable.h:
  • wtf/OwnArrayPtr.h:
  • wtf/OwnPtr.h:
  • wtf/PassRefPtr.h:
  • wtf/Platform.h:
  • wtf/RefPtr.h:
  • wtf/RefPtrHashMap.h:
  • wtf/RetainPtr.h:
  • wtf/UnusedParam.h:
  • wtf/Vector.h:
  • wtf/VectorTraits.h:
  • wtf/unicode/Unicode.h:
  • wtf/unicode/icu/UnicodeIcu.h:

WebCore:

  • WebCore.pro:
  • bridge/testbindings.cpp:
  • dom/DocPtr.h:
  • loader/SubstituteData.h:
  • page/Chrome.cpp:
  • page/Chrome.h:
  • page/ChromeClient.h:
  • page/Frame.h:
  • page/FrameLoadRequest.h:
  • page/FrameTree.cpp:
  • page/FrameTree.h:
  • page/Page.h:
  • page/mac/ChromeMac.mm:
  • platform/network/HTTPHeaderMap.h:
  • platform/network/ResourceErrorBase.cpp:
  • platform/network/ResourceErrorBase.h:
  • platform/network/ResourceHandleInternal.h:
  • platform/network/ResourceRequestBase.cpp:
  • platform/network/ResourceRequestBase.h:
  • platform/network/ResourceResponseBase.cpp:
  • platform/network/ResourceResponseBase.h:
  • platform/network/cf/ResourceError.h:
  • platform/network/cf/ResourceRequest.h:
  • platform/network/cf/ResourceRequestCFNet.h:
  • platform/network/cf/ResourceResponse.h:
  • platform/network/cf/ResourceResponseCFNet.h:
  • platform/network/curl/ResourceError.h:
  • platform/network/curl/ResourceRequest.h:
  • platform/network/curl/ResourceResponse.h:
  • platform/network/mac/ResourceError.h:
  • platform/network/mac/ResourceErrorMac.mm:
  • platform/network/mac/ResourceRequest.h:
  • platform/network/mac/ResourceRequestMac.mm:
  • platform/network/mac/ResourceResponse.h:
  • platform/network/mac/ResourceResponseMac.mm:
  • platform/network/qt/ResourceError.h:
  • platform/network/qt/ResourceRequest.h:
  • platform/network/qt/ResourceResponse.h:
  • platform/network/soup/CookieJarSoup.cpp:
  • platform/network/soup/ResourceError.h:
  • platform/network/soup/ResourceRequest.h:
  • platform/network/soup/ResourceResponse.h:
  • Property svn:eol-style set to native
File size: 7.3 KB
Line 
1/*
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef WTF_Assertions_h
27#define WTF_Assertions_h
28
29/*
30 no namespaces because this file has to be includable from C and Objective-C
31
32 Note, this file uses many GCC extensions, but it should be compatible with
33 C, Objective C, C++, and Objective C++.
34
35 For non-debug builds, everything is disabled by default.
36 Defining any of the symbols explicitly prevents this from having any effect.
37
38 MSVC7 note: variadic macro support was added in MSVC8, so for now we disable
39 those macros in MSVC7. For more info, see the MSDN document on variadic
40 macros here:
41
42 http://msdn2.microsoft.com/en-us/library/ms177415(VS.80).aspx
43*/
44
45#include "Platform.h"
46
47#if COMPILER(MSVC)
48#include <stddef.h>
49#else
50#include <inttypes.h>
51#endif
52
53#ifdef NDEBUG
54#define ASSERTIONS_DISABLED_DEFAULT 1
55#else
56#define ASSERTIONS_DISABLED_DEFAULT 0
57#endif
58
59#ifndef ASSERT_DISABLED
60#define ASSERT_DISABLED ASSERTIONS_DISABLED_DEFAULT
61#endif
62
63#ifndef ASSERT_ARG_DISABLED
64#define ASSERT_ARG_DISABLED ASSERTIONS_DISABLED_DEFAULT
65#endif
66
67#ifndef FATAL_DISABLED
68#define FATAL_DISABLED ASSERTIONS_DISABLED_DEFAULT
69#endif
70
71#ifndef ERROR_DISABLED
72#define ERROR_DISABLED ASSERTIONS_DISABLED_DEFAULT
73#endif
74
75#ifndef LOG_DISABLED
76#define LOG_DISABLED ASSERTIONS_DISABLED_DEFAULT
77#endif
78
79#if COMPILER(GCC)
80#define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__
81#else
82#define WTF_PRETTY_FUNCTION __FUNCTION__
83#endif
84
85/* WTF logging functions can process %@ in the format string to log a NSObject* but the printf format attribute
86 emits a warning when %@ is used in the format string. Until <rdar://problem/5195437> is resolved we can't include
87 the attribute when being used from Objective-C code in case it decides to use %@. */
88#if COMPILER(GCC) && !defined(__OBJC__)
89#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__((__format__(printf, formatStringArgument, extraArguments)))
90#else
91#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments)
92#endif
93
94/* These helper functions are always declared, but not necessarily always defined if the corresponding function is disabled. */
95
96#ifdef __cplusplus
97extern "C" {
98#endif
99
100typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState;
101
102typedef struct {
103 unsigned mask;
104 const char *defaultName;
105 WTFLogChannelState state;
106} WTFLogChannel;
107
108void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion);
109void WTFReportAssertionFailureWithMessage(const char* file, int line, const char* function, const char* assertion, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
110void WTFReportArgumentAssertionFailure(const char* file, int line, const char* function, const char* argName, const char* assertion);
111void WTFReportFatalError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
112void WTFReportError(const char* file, int line, const char* function, const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5);
113void WTFLog(WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(2, 3);
114void WTFLogVerbose(const char* file, int line, const char* function, WTFLogChannel* channel, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6);
115
116#ifdef __cplusplus
117}
118#endif
119
120/* CRASH -- gets us into the debugger or the crash reporter -- signals are ignored by the crash reporter so we must do better */
121
122#ifndef CRASH
123#define CRASH() *(int *)(uintptr_t)0xbbadbeef = 0
124#endif
125
126/* ASSERT, ASSERT_WITH_MESSAGE, ASSERT_NOT_REACHED */
127
128#if PLATFORM(WIN_OS)
129/* FIXME: Change to use something other than ASSERT to avoid this conflict with win32. */
130#undef ASSERT
131#endif
132
133#if ASSERT_DISABLED
134
135#define ASSERT(assertion) ((void)0)
136#define ASSERT_WITH_MESSAGE(assertion, ...) ((void)0)
137#define ASSERT_NOT_REACHED() ((void)0)
138
139#else
140
141#define ASSERT(assertion) do \
142 if (!(assertion)) { \
143 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \
144 CRASH(); \
145 } \
146while (0)
147#if COMPILER(MSVC7)
148#define ASSERT_WITH_MESSAGE(assertion) ((void)0)
149#else
150#define ASSERT_WITH_MESSAGE(assertion, ...) do \
151 if (!(assertion)) { \
152 WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion, __VA_ARGS__); \
153 CRASH(); \
154 } \
155while (0)
156#endif /* COMPILER(MSVC7) */
157#define ASSERT_NOT_REACHED() do { \
158 WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
159 CRASH(); \
160} while (0)
161
162#endif
163
164/* ASSERT_ARG */
165
166#if ASSERT_ARG_DISABLED
167
168#define ASSERT_ARG(argName, assertion) ((void)0)
169
170#else
171
172#define ASSERT_ARG(argName, assertion) do \
173 if (!(assertion)) { \
174 WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #argName, #assertion); \
175 CRASH(); \
176 } \
177while (0)
178
179#endif
180
181/* COMPILE_ASSERT */
182#ifndef COMPILE_ASSERT
183#define COMPILE_ASSERT(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
184#endif
185
186/* FATAL */
187
188#if FATAL_DISABLED
189#define FATAL(...) ((void)0)
190#elif COMPILER(MSVC7)
191#define FATAL() ((void)0)
192#else
193#define FATAL(...) do { \
194 WTFReportFatalError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__); \
195 CRASH(); \
196} while (0)
197#endif
198
199/* LOG_ERROR */
200
201#if ERROR_DISABLED
202#define LOG_ERROR(...) ((void)0)
203#elif COMPILER(MSVC7)
204#define LOG_ERROR() ((void)0)
205#else
206#define LOG_ERROR(...) WTFReportError(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, __VA_ARGS__)
207#endif
208
209/* LOG */
210
211#if LOG_DISABLED
212#define LOG(channel, ...) ((void)0)
213#elif COMPILER(MSVC7)
214#define LOG() ((void)0)
215#else
216#define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
217#define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel)
218#define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel
219#endif
220
221/* LOG_VERBOSE */
222
223#if LOG_DISABLED
224#define LOG_VERBOSE(channel, ...) ((void)0)
225#elif COMPILER(MSVC7)
226#define LOG_VERBOSE(channel) ((void)0)
227#else
228#define LOG_VERBOSE(channel, ...) WTFLogVerbose(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, &JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
229#endif
230
231#endif /* WTF_Assertions_h */
Note: See TracBrowser for help on using the repository browser.