From aef032f93b7bdc6e5908b2fa5f940a43bcfce50e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 29 May 2015 20:32:43 +0300 Subject: Add support for strong typed enums. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/enums/simpletypes/enumdefines.h | 46 +++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/enums/simpletypes/enumdefines.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2a925e6b..0ea642998 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1062,6 +1062,7 @@ SET(SRCS enums/simpletypes/booldefines.h enums/simpletypes/damaged.h enums/simpletypes/enable.h + enums/simpletypes/enumdefines.h enums/simpletypes/equipm.h enums/simpletypes/equipped.h enums/simpletypes/favorite.h diff --git a/src/Makefile.am b/src/Makefile.am index 374382f58..4c6612e63 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1191,6 +1191,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ enums/simpletypes/booldefines.h \ enums/simpletypes/damaged.h \ enums/simpletypes/enable.h \ + enums/simpletypes/enumdefines.h \ enums/simpletypes/equipm.h \ enums/simpletypes/equipped.h \ enums/simpletypes/favorite.h \ diff --git a/src/enums/simpletypes/enumdefines.h b/src/enums/simpletypes/enumdefines.h new file mode 100644 index 000000000..95ccad764 --- /dev/null +++ b/src/enums/simpletypes/enumdefines.h @@ -0,0 +1,46 @@ +/* + * The ManaPlus Client + * Copyright (C) 2015 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 2 of the License, or + * 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 . + */ + +#ifndef ENUMS_SIMPLETYPES_ENUMDEFINES_H +#define ENUMS_SIMPLETYPES_ENUMDEFINES_H + +#include "localconsts.h" + +#ifdef ADVGCC + +#define enumStart(name) enum class name +#define enumEnd(name) ; \ + typedef name name##T + +#else // ADVGCC + +#define enumStart(name) \ + namespace name \ + { \ + enum T + +#define enumEnd(name) \ + ;\ + } \ + typedef name::T name##T + +#endif // ADVGCC + +#endif // ENUMS_SIMPLETYPES_ENUMDEFINES_H -- cgit v1.2.3-60-g2f50