- forgot macros.h out of the previous commit

Wed, 05 Mar 2014 05:31:07 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 05 Mar 2014 05:31:07 +0200
changeset 643
a79277000830
parent 642
751a8df42842
child 644
93dcd1a0e4bd

- forgot macros.h out of the previous commit

src/Macros.h file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Macros.h	Wed Mar 05 05:31:07 2014 +0200
@@ -0,0 +1,110 @@
+/*
+ *  LDForge: LDraw parts authoring CAD
+ *  Copyright (C) 2013, 2014 Santeri Piippo
+ *
+ *  This program is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+// =============================================================================
+//
+#define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE)			\
+private:														\
+	TYPE m_##READ;												\
+																\
+public:															\
+	inline TYPE const& READ() const								\
+	{															\
+		return m_##READ; 										\
+	}															\
+																\
+ACCESS:															\
+	void WRITE (TYPE const& a) PROPERTY_##WRITETYPE (READ)		\
+
+#define PROPERTY_STOCK_WRITE(READ)								\
+	{															\
+		m_##READ = a;											\
+	}
+
+#define PROPERTY_CUSTOM_WRITE(READ)								\
+	;
+
+// =============================================================================
+//
+#define elif(A) else if (A)
+
+// =============================================================================
+//
+#ifdef WIN32
+# define DIRSLASH "\\"
+# define DIRSLASH_CHAR '\\'
+#else // WIN32
+# define DIRSLASH "/"
+# define DIRSLASH_CHAR '/'
+#endif // WIN32
+
+// =============================================================================
+//
+#ifdef __GNUC__
+#define FUNCNAME __PRETTY_FUNCTION__
+#else
+#define FUNCNAME __func__
+#endif // __GNUC__
+
+// =============================================================================
+//
+#ifdef IN_IDE_PARSER
+void dlog(void, ...) {}
+#else
+# ifdef DEBUG
+#  define dlog(...) log (QString (__PRETTY_FUNCTION__) + ": " __VA_ARGS__)
+# else
+#  define dlog(...)
+# endif // DEBUG
+#endif // IN_IDE_PARSER
+
+#define dvalof(A) dlog ("value of '%1' = %2\n", #A, A)
+
+// =============================================================================
+//
+// Replace assert with a version that shows a GUI dialog if possible.
+// On Windows I just can't get the actual error messages otherwise.
+//
+#undef assert
+
+#ifdef DEBUG
+# define assert(N) { ((N) ? (void) 0 : assertionFailure (__FILE__, __LINE__, FUNCNAME, #N)); }
+#else
+# define assert(N) {}
+#endif // DEBUG
+
+#define for_axes(AX) for (const Axis AX : std::initializer_list<const Axis> ({X, Y, Z}))
+
+// =============================================================================
+#ifdef IN_IDE_PARSER // KDevelop workarounds:
+# error IN_IDE_PARSER is defined (this code is only for KDevelop workarounds)
+# define COMPILE_DATE "14-01-10 10:31:09"
+
+# ifndef va_start
+#  define va_start(va, arg)
+# endif // va_start
+
+# ifndef va_end
+#  define va_end(va)
+# endif // va_end
+
+static const char* __func__ = ""; // Current function name
+typedef void FILE; // :|
+#endif // IN_IDE_PARSER
\ No newline at end of file

mercurial