| 1 |
/* -*- coding: utf-8;mode:c++;c-file-style:"stroustrup" -*- */ |
| 2 |
/* |
| 3 |
Licensed under the terms of the BSD 3-Clause |
| 4 |
(see plotpy/__init__.py for details) |
| 5 |
*/ |
| 6 |
#ifndef __DEBUG_HPP__ |
| 7 |
#define __DEBUG_HPP__ |
| 8 |
|
| 9 |
#define DEBUG 0 |
| 10 |
|
| 11 |
#if DEBUG |
| 12 |
|
| 13 |
#define check(msg, x, n, r) \ |
| 14 |
if (x < 0 || x >= n) \ |
| 15 |
{ \ |
| 16 |
printf(msg "%d out of bound (%d)\n", x, n); \ |
| 17 |
return r; \ |
| 18 |
} |
| 19 |
#define check_img_ptr(msg, p, r, img) \ |
| 20 |
if (p < img.base || p > (img.base + (img.ni - 1) * img.si + (img.nj - 1) * img.sj)) \ |
| 21 |
{ \ |
| 22 |
printf(msg "%p out of bound (%p,%dx%d, %dx%d\n", p, img.base, img.ni, img.si, img.nj, img.sj); \ |
| 23 |
return r; \ |
| 24 |
} |
| 25 |
|
| 26 |
#else |
| 27 |
|
| 28 |
#define check(msg, x, n, r) ; |
| 29 |
#define check_img_ptr(msg, p, r, img) ; |
| 30 |
|
| 31 |
#endif |
| 32 |
|
| 33 |
#endif |