src/Macros.h

changeset 706
d79083b9f74d
parent 705
09150d027e8c
parent 655
b376645315ab
child 707
c89b58ba266b
equal deleted inserted replaced
705:09150d027e8c 706:d79083b9f74d
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 #ifndef __GNUC__
22 # define __attribute__(X)
23 #endif
24
25 #define countof(A) ((int) (sizeof A / sizeof *A))
26
27 // =============================================================================
28 //
29 #define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE) \
30 private: \
31 TYPE m_##READ; \
32 \
33 public: \
34 inline TYPE const& READ() const \
35 { \
36 return m_##READ; \
37 } \
38 \
39 ACCESS: \
40 void WRITE (TYPE const& a) PROPERTY_##WRITETYPE (READ) \
41
42 #define PROPERTY_STOCK_WRITE(READ) \
43 { \
44 m_##READ = a; \
45 }
46
47 #define PROPERTY_CUSTOM_WRITE(READ) \
48 ;
49
50 // =============================================================================
51 //
52 #define elif(A) else if (A)
53
54 // =============================================================================
55 //
56 #ifdef WIN32
57 # define DIRSLASH "\\"
58 # define DIRSLASH_CHAR '\\'
59 #else // WIN32
60 # define DIRSLASH "/"
61 # define DIRSLASH_CHAR '/'
62 #endif // WIN32
63
64 // =============================================================================
65 //
66 #ifdef __GNUC__
67 #define FUNCNAME __PRETTY_FUNCTION__
68 #else
69 #define FUNCNAME __func__
70 #endif // __GNUC__
71
72 // =============================================================================
73 //
74 #define dvalof(A) dprint ("value of '%1' = %2\n", #A, A)
75
76 // =============================================================================
77 //
78 // Replace assert with a version that shows a GUI dialog if possible.
79 // On Windows I just can't get the actual error messages otherwise.
80 //
81 #undef assert
82
83 #ifdef DEBUG
84 # define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); }
85 #else
86 # define assert(N) {}
87 #endif // DEBUG
88
89 #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z}))
90
91 // =============================================================================
92 #ifdef IN_IDE_PARSER // KDevelop workarounds:
93 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
94 # define COMPILE_DATE "14-01-10 10:31:09"
95
96 # ifndef va_start
97 # define va_start(va, arg)
98 # endif // va_start
99
100 # ifndef va_end
101 # define va_end(va)
102 # endif // va_end
103
104 static const char* __func__ = ""; // Current function name
105 typedef void FILE; // :|
106 #endif // IN_IDE_PARSER

mercurial