From de33f8c8cefca6ab82e6c989cd42ecca3cbc38f7 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 30 May 2019 10:51:49 +1000 Subject: [PATCH] types/dispatch: remember to include the original enum tag --- types/dispatch.hpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/types/dispatch.hpp b/types/dispatch.hpp index b599e21a..829e942d 100644 --- a/types/dispatch.hpp +++ b/types/dispatch.hpp @@ -23,39 +23,39 @@ namespace cruft::types { decltype(auto) visit (description const &descriminator, FunctionT &&func, Args&&...args) { - #define INVOKE(KLASS) \ + #define INVOKE(TAG) \ return std::invoke( \ std::forward (func), \ std::forward (args)..., \ - type_tag {} \ + TAG \ ); switch (descriminator.category) { - case category ::NONE: INVOKE(void) + case category ::NONE: INVOKE(type_tag {}) case category::REAL: switch (descriminator.width) { - case 4: INVOKE(f32) - case 8: INVOKE(f64) + case 4: INVOKE(type_tag {}) + case 8: INVOKE(type_tag {}) default: throw std::invalid_argument ("Unsupported floating point width"); } - case category::BOOL: INVOKE(bool) + case category::BOOL: INVOKE(type_tag {}) case category::ENUM: { if (descriminator.signedness) { switch (descriminator.width) { - case 1: INVOKE(unknown_enum_tag) - case 2: INVOKE(unknown_enum_tag) - case 3: INVOKE(unknown_enum_tag) - case 4: INVOKE(unknown_enum_tag) + case 1: INVOKE(type_tag> { descriminator }) + case 2: INVOKE(type_tag> { descriminator }) + case 3: INVOKE(type_tag> { descriminator }) + case 4: INVOKE(type_tag> { descriminator }) } } else { switch (descriminator.width) { - case 1: INVOKE(unknown_enum_tag) - case 2: INVOKE(unknown_enum_tag) - case 3: INVOKE(unknown_enum_tag) - case 4: INVOKE(unknown_enum_tag) + case 1: INVOKE(type_tag> { descriminator }) + case 2: INVOKE(type_tag> { descriminator }) + case 3: INVOKE(type_tag> { descriminator }) + case 4: INVOKE(type_tag> { descriminator }) } } break; @@ -66,17 +66,17 @@ namespace cruft::types { if (descriminator.signedness) { switch (descriminator.width) { - case 1: INVOKE(i08) - case 2: INVOKE(i16) - case 3: INVOKE(i32) - case 4: INVOKE(i64) + case 1: INVOKE(type_tag {}) + case 2: INVOKE(type_tag {}) + case 3: INVOKE(type_tag {}) + case 4: INVOKE(type_tag {}) } } else { switch (descriminator.width) { - case 1: INVOKE(u08) - case 2: INVOKE(u16) - case 3: INVOKE(u32) - case 4: INVOKE(u64) + case 1: INVOKE(type_tag {}) + case 2: INVOKE(type_tag {}) + case 3: INVOKE(type_tag {}) + case 4: INVOKE(type_tag {}) } }