src/common.h

Thu, 05 Dec 2013 23:20:50 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 05 Dec 2013 23:20:50 +0200
changeset 539
72ad83a67165
parent 525
4f6e46a3bfc3
child 540
0334789cb4d7
permissions
-rw-r--r--

- upgraded the PROPERTY macro, resulting in a major code refactor

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 437
diff changeset
4 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 437
diff changeset
9 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 437
diff changeset
14 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 // This file is included one way or another in every source file of LDForge.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 // Stuff defined and included here is universally included.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
23 #ifndef LDFORGE_COMMON_H
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
24 #define LDFORGE_COMMON_H
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
26 // Hack to make KDevelop parse QString properly. Q_REQUIRED_RESULT expands into
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
27 // an __attribute__((warn_unused_result)) KDevelop's lexer doesn't seem to
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
28 // understand, yielding an error and leaving some methods unlexed.
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
29 //
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
30 // The following first includes <QChar> to get Q_REQUIRED_RESULT defined first,
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
31 // then re-defining it as nothing. This causes Q_REQUIRED_RESULT to essentially
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
32 // "vanish" from QString's methods when KDevelop lexes them.
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
33 //
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
34 // Similar reasoning for Q_DECL_HIDDEN, except with Q_OBJECT this time.
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
35 #ifdef IN_IDE_PARSER
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
36 # include <QChar>
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
37 # undef Q_REQUIRED_RESULT
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
38 # undef Q_DECL_HIDDEN
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
39 # define Q_REQUIRED_RESULT
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
40 # define Q_DECL_HIDDEN
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
41 #endif
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
42
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 #include <stdio.h>
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 #include <stdlib.h>
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 #include <stdint.h>
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 #include <stdarg.h>
249
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
47 #include <QString>
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
48 #include <QMutex>
6b2cc2d82ba6 Use QMutex for the thread locking, remove filename from the progress dialog since it's not known anyway
Santeri Piippo <crimsondusk64@gmail.com>
parents: 248
diff changeset
49
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 #include "config.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 #define APPNAME "LDForge"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53 #define VERSION_MAJOR 0
374
6c30af56af11 Tag 0.2 alpha
Santeri Piippo <crimsondusk64@gmail.com>
parents: 351
diff changeset
54 #define VERSION_MINOR 2
375
54c90b15d35c Bump version to 0.2.999-intern now that 0.2-alpha is out.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 374
diff changeset
55 #define VERSION_PATCH 999
54c90b15d35c Bump version to 0.2.999-intern now that 0.2-alpha is out.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 374
diff changeset
56 #define BUILD_ID BUILD_INTERNAL
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57
321
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 316
diff changeset
58 #define BUILD_INTERNAL 0
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 316
diff changeset
59 #define BUILD_ALPHA 1
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 316
diff changeset
60 #define BUILD_BETA 2
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 316
diff changeset
61 #define BUILD_RC 3
48e429bfd58c Apply tr() for possible future translations
Santeri Piippo <crimsondusk64@gmail.com>
parents: 316
diff changeset
62 #define BUILD_RELEASE 4
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
63
437
51313dba897d corrected problems with the version string
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
64 // RC Number for BUILD_RC
51313dba897d corrected problems with the version string
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
65 #define RC_NUMBER 0
51313dba897d corrected problems with the version string
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
66
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
67 // =============================================
515
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
68 #ifdef DEBUG
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
69 # undef RELEASE
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
70 #endif // DEBUG
382
c1642530ea35 Converted ForgeWindow to Designer UI(!)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 381
diff changeset
71
515
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
72 #ifdef RELEASE
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
73 # undef DEBUG
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
74 #endif // RELEASE
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
75
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
76 // =============================================
433
b49930dcbe84 Moved the alias macro to common.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
77 #define alias auto&
515
a0ad72800b96 now displays build type in the window title (unless a release build of a release), fixed some macro shenanigans
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
78 #define elif(A) else if (A)
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
79
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
80 // Null pointer
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
81 static const std::nullptr_t null = nullptr;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 #ifdef WIN32
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
84 # define DIRSLASH "\\"
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
85 # define DIRSLASH_CHAR '\\'
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
86 #else // WIN32
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
87 # define DIRSLASH "/"
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
88 # define DIRSLASH_CHAR '/'
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 #endif // WIN32
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
91 #define PROPERTY( ACCESS, TYPE, NAME, OPS, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
92 private: \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
93 TYPE m_##NAME; \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
94 DEFINE_##CALLBACK( NAME ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
95 \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
96 public: \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
97 inline TYPE const& GET_READ_METHOD( NAME, OPS ) const \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
98 { return m_##NAME; \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
99 } \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
100 \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
101 ACCESS: \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
102 inline void set##NAME( TYPE const& NAME##_ ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
103 { m_##NAME = NAME##_; \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
104 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
105 } \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
106 \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
107 DEFINE_PROPERTY_##OPS( TYPE, NAME, CALLBACK )
266
12e7302f14e9 Make LDObject's color and parent properties with accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 250
diff changeset
108
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
109 #define GET_READ_METHOD( NAME, OPS ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
110 GET_READ_METHOD_##OPS( NAME )
274
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 272
diff changeset
111
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
112 #define GET_READ_METHOD_BOOL_OPS( NAME ) is##NAME()
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
113 #define GET_READ_METHOD_NO_OPS( NAME ) get##NAME()
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
114 #define GET_READ_METHOD_STR_OPS( NAME ) get##NAME()
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
115 #define GET_READ_METHOD_NUM_OPS( NAME ) get##NAME()
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
116
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
117 #define DEFINE_WITH_CB( NAME ) void NAME##Changed();
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
118 #define DEFINE_NO_CB( NAME )
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
119
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
120 #define DEFINE_PROPERTY_NO_OPS( TYPE, NAME, CALLBACK )
274
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 272
diff changeset
121
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
122 #define DEFINE_PROPERTY_STR_OPS( TYPE, NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
123 void append##NAME( TYPE a ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
124 { m_##NAME.append( a ); \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
125 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
126 } \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
127 \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
128 void prepend##NAME( TYPE a ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
129 { m_##NAME.prepend( a ); \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
130 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
131 } \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
132 \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
133 void replaceIn##NAME( TYPE a, TYPE b ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
134 { m_##NAME.replace( a, b ); \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
135 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
136 }
274
d232fe4d88a6 Reworked properties a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 272
diff changeset
137
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
138 #define DEFINE_PROPERTY_NUM_OPS( TYPE, NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
139 inline void increase##NAME( TYPE a = 1 ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
140 { m_##NAME += a; \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
141 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
142 } \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
143 \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
144 inline void decrease##NAME( TYPE a = 1 ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
145 { m_##NAME -= a; \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
146 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
147 }
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 246
diff changeset
148
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
149 #define DEFINE_PROPERTY_BOOL_OPS( TYPE, NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
150 inline void toggle##NAME() \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
151 { m_##NAME = !m_##NAME; \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
152 TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
153 }
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
154
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
155 #define TRIGGER_CALLBACK( NAME, CALLBACK ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
156 TRIGGER_CALLBACK_##CALLBACK( NAME );
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
157
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
158 #define TRIGGER_CALLBACK_NO_CB( NAME )
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
159 #define TRIGGER_CALLBACK_WITH_CB( NAME ) \
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 525
diff changeset
160 NAME##Changed();
327
9ea604af1319 Largely reworked the color selector. Still not perfect but is better
Santeri Piippo <crimsondusk64@gmail.com>
parents: 322
diff changeset
161
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 #ifdef null
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 #undef null
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164 #endif // null
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
166 #ifdef __GNUC__
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
167 #define FUNCNAME __PRETTY_FUNCTION__
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
168 #else
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
169 #define FUNCNAME __func__
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
170 #endif // __GNUC__
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
171
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
172 // Replace assert with a version that shows a GUI dialog if possible.
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
173 // On Windows I just can't get the actual error messages otherwise.
513
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
174 void assertionFailure (const char* file, int line, const char* funcname, const char* expr);
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
175
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
176 #ifdef assert
513
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
177 # undef assert
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
178 #endif // assert
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
179
513
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
180 #ifdef DEBUG
525
4f6e46a3bfc3 i'm dumb
Santeri Piippo <crimsondusk64@gmail.com>
parents: 523
diff changeset
181 # define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); }
513
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
182 #else
523
a12e36f2db5f enclosed the assert replacement in braces. In release mode, the assert is replaced with nothing and there's a little bit of code in addObjectDialog which uses it as a statement in an one-line if(). With the assert disappearing in release builds this triggered a GCC warning, as the if would be left without a body.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 515
diff changeset
183 # define assert(N) {}
513
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 498
diff changeset
184 #endif // DEBUG
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 246
diff changeset
185
437
51313dba897d corrected problems with the version string
Santeri Piippo <crimsondusk64@gmail.com>
parents: 436
diff changeset
186 // Version string identifier
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
187 QString versionString();
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
188 QString versionMoniker();
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
189 QString fullVersionString();
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
190
272
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
191 // -----------------------------------------------------------------------------
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
192 #ifdef IN_IDE_PARSER // KDevelop workarounds:
272
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
193 # error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 246
diff changeset
194
272
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
195 # ifndef va_start
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
196 # define va_start(va, arg)
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
197 # endif // va_start
211
8d35e631bef3 Added dialog for rotation points
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
198
272
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
199 # ifndef va_end
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
200 # define va_end(va)
2074672a6554 Cleansed the string class, moved implementations from header to code file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 267
diff changeset
201 # endif // va_end
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 246
diff changeset
202
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
203 static const char* __func__ = ""; // Current function name
248
4431371f3ffe Added a progress dialog for file loading to respond to desktops while loading files. With large files the no-response policy could be a bad thing. My first real use case of multi-threading...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 246
diff changeset
204 typedef void FILE; // :|
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
205 #endif // IN_IDE_PARSER
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
206
497
c51941e590b6 a bit more cleanup
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
207 #endif // LDFORGE_COMMON_H

mercurial