src/Macros.h

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

mercurial