Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: runtime/platform/assert.h

Issue 298963006: Change COMPILE_ASSERT to take only one argument and use it in more places. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef PLATFORM_ASSERT_H_ 5 #ifndef PLATFORM_ASSERT_H_
6 #define PLATFORM_ASSERT_H_ 6 #define PLATFORM_ASSERT_H_
7 7
8 // TODO(5411406): include sstream for now, once we have a Utils::toString() 8 // TODO(5411406): include sstream for now, once we have a Utils::toString()
9 // implemented for all the primitive types we can replace the usage of 9 // implemented for all the primitive types we can replace the usage of
10 // sstream by Utils::toString() 10 // sstream by Utils::toString()
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 #define DEBUG_ASSERT(cond) 268 #define DEBUG_ASSERT(cond)
269 269
270 #endif // if defined(DEBUG) 270 #endif // if defined(DEBUG)
271 271
272 272
273 // The COMPILE_ASSERT macro can be used to verify that a compile time 273 // The COMPILE_ASSERT macro can be used to verify that a compile time
274 // expression is true. For example, you could use it to verify the 274 // expression is true. For example, you could use it to verify the
275 // size of a static array: 275 // size of a static array:
276 // 276 //
277 // COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES, 277 // COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES);
278 // content_type_names_incorrect_size);
279 // 278 //
280 // or to make sure a struct is smaller than a certain size: 279 // or to make sure a struct is smaller than a certain size:
281 // 280 //
282 // COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large); 281 // COMPILE_ASSERT(sizeof(foo) < 128);
283 // 282 //
284 // The second argument to the macro is the name of the variable. If
285 // the expression is false, most compilers will issue a warning/error
286 // containing the name of the variable.
287 283
288 template <bool> 284 template <bool>
289 struct CompileAssert { 285 struct CompileAssert {
290 }; 286 };
291 287 // Macro to concatenate two tokens. The helper is need to proper expansion
292 #define COMPILE_ASSERT(expr, msg) \ 288 // in case an argument is a macro itself.
289 #define COMPILE_ASSERT_JOIN(a, b) COMPILE_ASSERT_JOIN_HELPER(a, b)
290 #define COMPILE_ASSERT_JOIN_HELPER(a, b) a##b
291 #define COMPILE_ASSERT(expr) \
293 DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \ 292 DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \
294 msg[static_cast<bool>(expr) ? 1 : -1] 293 COMPILE_ASSERT_JOIN(CompileAssertTypeDef, __LINE__)[static_cast<bool>(expr) \
295 294 ? 1 : -1]
296 295
297 #if defined(TESTING) 296 #if defined(TESTING)
298 297
299 // EXPECT and FAIL are equivalent to ASSERT and FATAL except that they do not 298 // EXPECT and FAIL are equivalent to ASSERT and FATAL except that they do not
300 // cause early termination of the unit test. This allows testing to proceed 299 // cause early termination of the unit test. This allows testing to proceed
301 // further to be able to report other failures before reporting the overall 300 // further to be able to report other failures before reporting the overall
302 // unit tests as failing. 301 // unit tests as failing.
303 302
304 #define EXPECT(condition) \ 303 #define EXPECT(condition) \
305 if (!(condition)) { \ 304 if (!(condition)) { \
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 343
345 #define FAIL1(format, p1) \ 344 #define FAIL1(format, p1) \
346 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) 345 dart::Expect(__FILE__, __LINE__).Fail(format, (p1))
347 346
348 #define FAIL2(format, p1, p2) \ 347 #define FAIL2(format, p1, p2) \
349 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) 348 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2))
350 349
351 #endif // defined(TESTING) 350 #endif // defined(TESTING)
352 351
353 #endif // PLATFORM_ASSERT_H_ 352 #endif // PLATFORM_ASSERT_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/assembler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698