|
2 | 2 | // |
3 | 3 | // debug.h: Rcpp R/C++ interface class library -- debug macros |
4 | 4 | // |
5 | | -// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois |
| 5 | +// Copyright (C) 2012 - 2013 Dirk Eddelbuettel and Romain Francois |
6 | 6 | // |
7 | 7 | // This file is part of Rcpp. |
8 | 8 | // |
|
27 | 27 | #define RCPP_DEBUG_LEVEL 0 |
28 | 28 | #endif |
29 | 29 |
|
| 30 | +#ifndef RCPP_DEBUG_MODULE_LEVEL |
| 31 | + #define RCPP_DEBUG_MODULE_LEVEL RCPP_DEBUG_LEVEL |
| 32 | +#endif |
| 33 | + |
| 34 | + |
30 | 35 | #if RCPP_DEBUG_LEVEL > 0 |
31 | 36 | #define RCPP_DEBUG( MSG ) Rprintf( "%40s:%4d %s\n" , short_file_name(__FILE__), __LINE__, MSG ) ; |
32 | 37 | #define RCPP_DEBUG_1( fmt, MSG ) Rprintf( "%40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, MSG ) ; |
|
43 | 48 | #define RCPP_DEBUG_5( fmt, M1, M2, M3, M4, M5 ) |
44 | 49 | #endif |
45 | 50 |
|
| 51 | +#if RCPP_DEBUG_MODULE_LEVEL > 0 |
| 52 | + #define RCPP_DEBUG_MODULE( MSG ) { \ |
| 53 | + Rcpp::Module * mod__ = getCurrentScope() ; \ |
| 54 | + if( mod__ ){ \ |
| 55 | + Rprintf( "[module (%s) <%p> ] %40s:%4d %s\n" , mod__->name.c_str(), mod__, short_file_name(__FILE__), __LINE__, MSG ) ;\ |
| 56 | + } else { \ |
| 57 | + Rprintf( "[module () ] %40s:%4d %s\n" , short_file_name(__FILE__), __LINE__, MSG ) ; \ |
| 58 | + } \ |
| 59 | + } |
| 60 | + #define RCPP_DEBUG_MODULE_1( fmt, MSG ) { \ |
| 61 | + Rcpp::Module * mod__ = getCurrentScope() ; \ |
| 62 | + if( mod__ ){ \ |
| 63 | + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, short_file_name(__FILE__), __LINE__, MSG ) ;\ |
| 64 | + } else { \ |
| 65 | + Rprintf( "[module () ] %40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, MSG ) ; \ |
| 66 | + } \ |
| 67 | + } |
| 68 | + #define RCPP_DEBUG_MODULE_2( fmt, M1, M2 ) { \ |
| 69 | + Rcpp::Module * mod__ = getCurrentScope() ; \ |
| 70 | + if( mod__ ){ \ |
| 71 | + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, short_file_name(__FILE__), __LINE__, M1, M2 ) ;\ |
| 72 | + } else { \ |
| 73 | + Rprintf( "[module () ] %40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, M1, M2 ) ; \ |
| 74 | + } \ |
| 75 | + } |
| 76 | + #define RCPP_DEBUG_MODULE_3( fmt, M1, M2, M3 ) { \ |
| 77 | + Rcpp::Module * mod__ = getCurrentScope() ; \ |
| 78 | + if( mod__ ){ \ |
| 79 | + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, short_file_name(__FILE__), __LINE__, M1, M2, M3 ) ;\ |
| 80 | + } else { \ |
| 81 | + Rprintf( "[module () ] %40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, M1, M2, M3 ) ; \ |
| 82 | + } \ |
| 83 | + } |
| 84 | + #define RCPP_DEBUG_MODULE_4( fmt, M1, M2, M3, M4 ) { \ |
| 85 | + Rcpp::Module * mod__ = getCurrentScope() ; \ |
| 86 | + if( mod__ ) { \ |
| 87 | + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, short_file_name(__FILE__), __LINE__, M1, M2, M3, M4 ) ;\ |
| 88 | + } else { \ |
| 89 | + Rprintf( "[module () ] %40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, M1, M2, M3, M4 ) ; \ |
| 90 | + } \ |
| 91 | + } |
| 92 | + #define RCPP_DEBUG_MODULE_5( fmt, M1, M2, M3, M4, M5 ) { \ |
| 93 | + Rcpp::Module * mod__ = getCurrentScope() ; \ |
| 94 | + if( mod__ ){ \ |
| 95 | + Rprintf( "[module (%s) <%p> ] %40s:%4d " fmt "\n" , mod__->name.c_str(), mod__, short_file_name(__FILE__), __LINE__, M1, M2, M3, M4, M5 ) ;\ |
| 96 | + } else { \ |
| 97 | + Rprintf( "[module () ] %40s:%4d " fmt "\n" , short_file_name(__FILE__), __LINE__, M1, M2, M3, M4, M5 ) ; \ |
| 98 | + } \ |
| 99 | + } |
| 100 | +#else |
| 101 | + #define RCPP_DEBUG_MODULE( MSG ) |
| 102 | + #define RCPP_DEBUG_MODULE_1( fmt, MSG ) |
| 103 | + #define RCPP_DEBUG_MODULE_2( fmt, M1, M2 ) |
| 104 | + #define RCPP_DEBUG_MODULE_3( fmt, M1, M2, M3 ) |
| 105 | + #define RCPP_DEBUG_MODULE_4( fmt, M1, M2, M3, M4 ) |
| 106 | + #define RCPP_DEBUG_MODULE_5( fmt, M1, M2, M3, M4, M5 ) |
| 107 | +#endif |
| 108 | + |
46 | 109 | #endif |
0 commit comments