src/Macros.h

Wed, 05 Mar 2014 16:22:15 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 05 Mar 2014 16:22:15 +0200
changeset 645
c0708f2d22b3
parent 644
93dcd1a0e4bd
child 698
16e6d7d87982
permissions
-rw-r--r--

- added license header to format.h

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

mercurial