src/Macros.h

changeset 643
a79277000830
child 644
93dcd1a0e4bd
equal deleted inserted replaced
642:751a8df42842 643:a79277000830
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013, 2014 Santeri Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #pragma once
20
21 // =============================================================================
22 //
23 #define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE) \
24 private: \
25 TYPE m_##READ; \
26 \
27 public: \
28 inline TYPE const& READ() const \
29 { \
30 return m_##READ; \
31 } \
32 \
33 ACCESS: \
34 void WRITE (TYPE const& a) PROPERTY_##WRITETYPE (READ) \
35
36 #define PROPERTY_STOCK_WRITE(READ) \
37 { \
38 m_##READ = a; \
39 }
40
41 #define PROPERTY_CUSTOM_WRITE(READ) \
42 ;
43
44 // =============================================================================
45 //
46 #define elif(A) else if (A)
47
48 // =============================================================================
49 //
50 #ifdef WIN32
51 # define DIRSLASH "\\"
52 # define DIRSLASH_CHAR '\\'
53 #else // WIN32
54 # define DIRSLASH "/"
55 # define DIRSLASH_CHAR '/'
56 #endif // WIN32
57
58 // =============================================================================
59 //
60 #ifdef __GNUC__
61 #define FUNCNAME __PRETTY_FUNCTION__
62 #else
63 #define FUNCNAME __func__
64 #endif // __GNUC__
65
66 // =============================================================================
67 //
68 #ifdef IN_IDE_PARSER
69 void dlog(void, ...) {}
70 #else
71 # ifdef DEBUG
72 # define dlog(...) log (QString (__PRETTY_FUNCTION__) + ": " __VA_ARGS__)
73 # else
74 # define dlog(...)
75 # endif // DEBUG
76 #endif // IN_IDE_PARSER
77
78 #define dvalof(A) dlog ("value of '%1' = %2\n", #A, A)
79
80 // =============================================================================
81 //
82 // Replace assert with a version that shows a GUI dialog if possible.
83 // On Windows I just can't get the actual error messages otherwise.
84 //
85 #undef assert
86
87 #ifdef DEBUG
88 # define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); }
89 #else
90 # define assert(N) {}
91 #endif // DEBUG
92
93 #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z}))
94
95 // =============================================================================
96 #ifdef IN_IDE_PARSER // KDevelop workarounds:
97 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
98 # define COMPILE_DATE "14-01-10 10:31:09"
99
100 # ifndef va_start
101 # define va_start(va, arg)
102 # endif // va_start
103
104 # ifndef va_end
105 # define va_end(va)
106 # endif // va_end
107
108 static const char* __func__ = ""; // Current function name
109 typedef void FILE; // :|
110 #endif // IN_IDE_PARSER

mercurial