1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-03 11:30:02 +00:00

Gives function overloading a try.

This commit is contained in:
Thomas Harte 2020-02-19 22:26:31 -05:00
parent 7bf04d5338
commit d6c6b9bdb8
3 changed files with 18 additions and 9 deletions

View File

@ -11,7 +11,6 @@
#include "../../../Reflection/Enum.h"
ReflectiveEnum(MacintoshModel, int, Mac128k, Mac512k, Mac128ke, MacPlus);
namespace Analyser {
namespace Static {
@ -19,11 +18,24 @@ namespace Macintosh {
struct Target: public ::Analyser::Static::Target {
MacintoshModel model = MacintoshModel::MacPlus;
ReflectiveEnum(Model, int, Mac128k, Mac512k, Mac512ke, MacPlus);
Target() {
// Model m;
// printf("%s\n", __declaration(m));
printf("%zu\n", Reflection::Enum<Model>::size());
// for(size_t c = 0; c < Reflection::Enum<Model>::size(); ++c) {
// const auto name = Reflection::Enum<Model>::toString(Model(c));
// printf("%.*s\n", int(name.size()), name.data());
// }
}
Model model = Model::MacPlus;
};
}
}
}
#endif /* Analyser_Static_Macintosh_Target_h */

View File

@ -34,6 +34,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
disableMainThreadChecker = "YES"
launchStyle = "0"
useCustomWorkingDirectory = "NO"

View File

@ -40,8 +40,8 @@ template <typename EnumType> struct Enum {
@returns A vector of string_views naming the members of this enum in value order.
*/
static std::vector<std::string_view> members() {
Enum<EnumType> m;
const char *const declaration = m.declaration();
EnumType m;
const char *const declaration = __declaration(m);
const char *d_ptr = declaration;
std::vector<std::string_view> result;
@ -60,10 +60,6 @@ template <typename EnumType> struct Enum {
return result;
}
private:
constexpr const char *declaration();
};
}
@ -75,6 +71,6 @@ template <typename EnumType> struct Enum {
*/
#define ReflectiveEnum(Name, Type, ...) \
enum class Name: Type { __VA_ARGS__ }; \
template <> constexpr const char *::Reflection::Enum<Name>::declaration() { return #__VA_ARGS__; };
constexpr const char *__declaration(Name) { return #__VA_ARGS__; }
#endif /* Enum_h */