src/Macros.h

Mon, 10 Mar 2014 14:12:28 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 10 Mar 2014 14:12:28 +0200
changeset 698
16e6d7d87982
parent 644
93dcd1a0e4bd
permissions
-rw-r--r--

- refactor

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
698
16e6d7d87982 - refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 644
diff changeset
25 #define countof(A) ((int) (sizeof A / sizeof *A))
16e6d7d87982 - refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 644
diff changeset
26
643
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 // =============================================================================
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 //
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE) \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 private: \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 TYPE m_##READ; \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 public: \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 inline TYPE const& READ() const \
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 return m_##READ; \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 } \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38 \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 ACCESS: \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 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
41
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 #define PROPERTY_STOCK_WRITE(READ) \
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 m_##READ = a; \
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 }
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 #define PROPERTY_CUSTOM_WRITE(READ) \
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 // =============================================================================
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 #define elif(A) else if (A)
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 // =============================================================================
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 //
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 #ifdef WIN32
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 # define DIRSLASH "\\"
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 # define DIRSLASH_CHAR '\\'
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 #else // WIN32
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 # define DIRSLASH "/"
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61 # define DIRSLASH_CHAR '/'
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
62 #endif // WIN32
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 // =============================================================================
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 //
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66 #ifdef __GNUC__
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
67 #define FUNCNAME __PRETTY_FUNCTION__
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 #else
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
69 #define FUNCNAME __func__
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 #endif // __GNUC__
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
71
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 // =============================================================================
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73 //
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
74 #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
75
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
76 // =============================================================================
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 //
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
78 // 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
79 // 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
80 //
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
81 #undef assert
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 #ifdef DEBUG
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 # 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
85 #else
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 # define assert(N) {}
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 #endif // DEBUG
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 #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
90
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 // =============================================================================
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 #ifdef IN_IDE_PARSER // KDevelop workarounds:
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 # 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
94 # 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
95
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 # ifndef va_start
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
97 # define va_start(va, arg)
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
98 # endif // va_start
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
99
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100 # ifndef va_end
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 # define va_end(va)
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 # endif // va_end
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
103
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 static const char* __func__ = ""; // Current function name
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105 typedef void FILE; // :|
a79277000830 - forgot macros.h out of the previous commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 #endif // IN_IDE_PARSER

mercurial