Mon, 31 Aug 2015 04:57:16 +0300
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
968 | 3 | * Copyright (C) 2013 - 2015 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #pragma once |
709
47a2f9d10ebe
- added safety check to the countof macro
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
20 | #include <type_traits> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #ifndef __GNUC__ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | # define __attribute__(X) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #endif |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
967 | 26 | template <typename T, size_t N> |
27 | char (&countofHelper (T(&)[N]))[N]; | |
28 | #define countof(x) ((int) sizeof (countofHelper(x))) | |
709
47a2f9d10ebe
- added safety check to the countof macro
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
29 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE) \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | private: \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | TYPE m_##READ; \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | public: \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | inline TYPE const& READ() const \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | { \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | return m_##READ; \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | } \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | ACCESS: \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | void WRITE (TYPE const& a) PROPERTY_##WRITETYPE (READ) \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | #define PROPERTY_STOCK_WRITE(READ) \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | { \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | m_##READ = a; \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | #define PROPERTY_CUSTOM_WRITE(READ) \ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | ; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
51 | #define DEFINE_CLASS(SELF, SUPER) \ |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
52 | public: \ |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
53 | using Self = SELF; \ |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
54 | using Super = SUPER; |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
55 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | #ifdef WIN32 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | # define DIRSLASH "\\" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | # define DIRSLASH_CHAR '\\' |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | #else // WIN32 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | # define DIRSLASH "/" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | # define DIRSLASH_CHAR '/' |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | #endif // WIN32 |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | #define dvalof(A) dprint ("value of '%1' = %2\n", #A, A) |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
755
diff
changeset
|
65 | #define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z})) |
754
c37564d59ce1
- grids now have a single coordinate snap value instead of individual X, Y and Z values
Santeri Piippo <crimsondusk64@gmail.com>
parents:
709
diff
changeset
|
66 | |
967 | 67 | #define MAKE_ITERABLE_ENUM(T) \ |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
755
diff
changeset
|
68 | inline T operator++ (T& a) { a = (T) ((int) a + 1); return a; } \ |
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
755
diff
changeset
|
69 | inline T operator-- (T& a) { a = (T) ((int) a - 1); return a; } \ |
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
755
diff
changeset
|
70 | inline T operator++ (T& a, int) { T result = a; a = (T) ((int) a + 1); return result; } \ |
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
755
diff
changeset
|
71 | inline T operator-- (T& a, int) { T result = a; a = (T) ((int) a - 1); return result; } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
73 | #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
74 | # define USE_QT5 |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
75 | #endif |
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
847
diff
changeset
|
76 | |
847 | 77 | #define FOR_ENUM_NAME_HELPER(LINE) enum_iterator_ ## LINE |
78 | #define FOR_ENUM_NAME(LINE) FOR_ENUM_NAME_HELPER(LINE) | |
79 | ||
80 | #define for_enum(ENUM, NAME) \ | |
81 | for (std::underlying_type<ENUM>::type FOR_ENUM_NAME (__LINE__) = \ | |
82 | std::underlying_type<ENUM>::type (ENUM::FirstValue); \ | |
83 | FOR_ENUM_NAME (__LINE__) < std::underlying_type<ENUM>::type (ENUM::NumValues); \ | |
84 | ++FOR_ENUM_NAME (__LINE__)) \ | |
85 | for (ENUM NAME = ENUM (FOR_ENUM_NAME (__LINE__)); NAME != ENUM::NumValues; \ | |
86 | NAME = ENUM::NumValues) | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
87 | |
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
88 | #define ConfigOption(...) |