Skip to content

UNPL

Description

Build an identifier unique to the source line by concatenating base with __LINE__. Used by Scope / ScopeWith and other multi-temp expansion macros to introduce macro-local temporaries that cannot collide with each other across nested or sibling expansions on different lines.

Usage example (from documentation)

  for (int UNPL(idx) = 0; ...)   // expands to `idx<N>` where N = __LINE__

Success

Resolves to the identifier <base><LINE>.

Failure

Macro cannot fail. Two expansions on the same source line produce the same identifier – callers needing multiple temps on one line must pass distinct base prefixes.

Usage example (Cross-references)

Usage examples (Cross-references)
                break;                                                                                                     \
            }                                                                                                              \
            StrIter UNPL(saved_si) = si;                                                                                   \
            si                     = JSkipWhitespace(si);                                                                  \
            char UNPL(jr_c);                                                                                               \
            StrIter UNPL(saved_si) = si;                                                                                   \
            si                     = JSkipWhitespace(si);                                                                  \
            char UNPL(jr_c);                                                                                               \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') {                                                     \
                LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
            si                     = JSkipWhitespace(si);                                                                  \
            char UNPL(jr_c);                                                                                               \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') {                                                     \
                LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
                si = UNPL(saved_si);                                                                                       \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') {                                                     \
                LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
                si = UNPL(saved_si);                                                                                       \
                break;                                                                                                     \
            }                                                                                                              \
            StrIterMustNext(&si);                                                                                          \
            si = JSkipWhitespace(si);                                                                                      \
            StrIter UNPL(read_si);                                                                                         \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
            si = JSkipWhitespace(si);                                                                                      \
            StrIter UNPL(read_si);                                                                                         \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
            StrIter UNPL(read_si);                                                                                         \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
            bool    UNPL(failed)       = false;                                                                            \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
                        UNPL(failed) = true;                                                                               \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                    }                                                                                                      \
                }                                                                                                          \
                Str key       = StrInit(&alloc);                                                                           \
                UNPL(read_si) = JReadString(si, &key);                                                                     \
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                Str key       = StrInit(&alloc);                                                                           \
                UNPL(read_si) = JReadString(si, &key);                                                                     \
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                    StrDeinit(&key);                                                                                       \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
                    break;                                                                                                 \
                }                                                                                                          \
                si = UNPL(read_si);                                                                                        \
                si = JSkipWhitespace(si);                                                                                  \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') {                                                 \
                si = UNPL(read_si);                                                                                        \
                si = JSkipWhitespace(si);                                                                                  \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') {                                                 \
                    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
                    StrDeinit(&key);                                                                                       \
                    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
                StrIterMustNext(&si);                                                                                      \
                si                           = JSkipWhitespace(si);                                                        \
                StrIter UNPL(si_before_read) = si;                                                                         \
                { reader }                                                                                                 \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                StrIter UNPL(si_before_read) = si;                                                                         \
                { reader }                                                                                                 \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    StrIter UNPL(skip_si) = JSkipValue(si);                                                                \
                    if (StrIterIndex(&UNPL(skip_si)) == StrIterIndex(&si)) {                                               \
                { reader }                                                                                                 \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    StrIter UNPL(skip_si) = JSkipValue(si);                                                                \
                    if (StrIterIndex(&UNPL(skip_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    StrIter UNPL(skip_si) = JSkipValue(si);                                                                \
                    if (StrIterIndex(&UNPL(skip_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        StrDeinit(&key);                                                                                   \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        StrDeinit(&key);                                                                                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                        StrDeinit(&key);                                                                                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                    }                                                                                                      \
                        break;                                                                                             \
                    }                                                                                                      \
                    si = UNPL(skip_si);                                                                                    \
                }                                                                                                          \
                StrDeinit(&key);                                                                                           \
                StrDeinit(&key);                                                                                           \
                si                 = JSkipWhitespace(si);                                                                  \
                UNPL(expect_comma) = true;                                                                                 \
            }                                                                                                              \
            if (!UNPL(failed)) {                                                                                           \
                UNPL(expect_comma) = true;                                                                                 \
            }                                                                                                              \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
            }                                                                                                              \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
    #define JR_STR(si, str)                                                                                                \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit(&alloc);                                                                            \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit(&alloc);                                                                            \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        } while (0)
            Str UNPL(my_str) = StrInit(&alloc);                                                                            \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        } while (0)
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                Str UNPL(my_str) = StrInit(&alloc);                                                                        \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
            if (!StrCmp(&key, (k))) {                                                                                      \
                Str UNPL(my_str) = StrInit(&alloc);                                                                        \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
            }                                                                                                              \
                Str UNPL(my_str) = StrInit(&alloc);                                                                        \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
            }                                                                                                              \
        } while (0)
    ///
    #define Scope(name, AllocType)                                                                                         \
        for (AllocType UNPL(scope_user)     = AllocType##Init(),                                                           \
                       UNPL(scope_internal) = AllocType##Init(),                                                           \
                       *UNPL(scope_loop)    = &UNPL(scope_user);                                                           \
    #define Scope(name, AllocType)                                                                                         \
        for (AllocType UNPL(scope_user)     = AllocType##Init(),                                                           \
                       UNPL(scope_internal) = AllocType##Init(),                                                           \
                       *UNPL(scope_loop)    = &UNPL(scope_user);                                                           \
             UNPL(scope_loop);                                                                                             \
        for (AllocType UNPL(scope_user)     = AllocType##Init(),                                                           \
                       UNPL(scope_internal) = AllocType##Init(),                                                           \
                       *UNPL(scope_loop)    = &UNPL(scope_user);                                                           \
             UNPL(scope_loop);                                                                                             \
             AllocType##Deinit(&UNPL(scope_internal)), AllocType##Deinit(&UNPL(scope_user)), UNPL(scope_loop) = NULL)      \
                       UNPL(scope_internal) = AllocType##Init(),                                                           \
                       *UNPL(scope_loop)    = &UNPL(scope_user);                                                           \
             UNPL(scope_loop);                                                                                             \
             AllocType##Deinit(&UNPL(scope_internal)), AllocType##Deinit(&UNPL(scope_user)), UNPL(scope_loop) = NULL)      \
            for (Allocator *name             = &UNPL(scope_user).base,                                                     \
                       *UNPL(scope_loop)    = &UNPL(scope_user);                                                           \
             UNPL(scope_loop);                                                                                             \
             AllocType##Deinit(&UNPL(scope_internal)), AllocType##Deinit(&UNPL(scope_user)), UNPL(scope_loop) = NULL)      \
            for (Allocator *name             = &UNPL(scope_user).base,                                                     \
                           *MisraScope       = &UNPL(scope_internal).base,                                                 \
             UNPL(scope_loop);                                                                                             \
             AllocType##Deinit(&UNPL(scope_internal)), AllocType##Deinit(&UNPL(scope_user)), UNPL(scope_loop) = NULL)      \
            for (Allocator *name             = &UNPL(scope_user).base,                                                     \
                           *MisraScope       = &UNPL(scope_internal).base,                                                 \
                           *UNPL(scope_done) = name;                                                                       \
             AllocType##Deinit(&UNPL(scope_internal)), AllocType##Deinit(&UNPL(scope_user)), UNPL(scope_loop) = NULL)      \
            for (Allocator *name             = &UNPL(scope_user).base,                                                     \
                           *MisraScope       = &UNPL(scope_internal).base,                                                 \
                           *UNPL(scope_done) = name;                                                                       \
                 (UNUSED(MisraScope), UNPL(scope_done));                                                                   \
            for (Allocator *name             = &UNPL(scope_user).base,                                                     \
                           *MisraScope       = &UNPL(scope_internal).base,                                                 \
                           *UNPL(scope_done) = name;                                                                       \
                 (UNUSED(MisraScope), UNPL(scope_done));                                                                   \
                 UNPL(scope_done) = NULL)
                           *MisraScope       = &UNPL(scope_internal).base,                                                 \
                           *UNPL(scope_done) = name;                                                                       \
                 (UNUSED(MisraScope), UNPL(scope_done));                                                                   \
                 UNPL(scope_done) = NULL)
                           *UNPL(scope_done) = name;                                                                       \
                 (UNUSED(MisraScope), UNPL(scope_done));                                                                   \
                 UNPL(scope_done) = NULL)
    
    ///
    ///
    #define ScopeWith(alloc_ptr)                                                                                           \
        for (Allocator *MisraScope = (alloc_ptr), *UNPL(scope_with_done) = MisraScope;                                     \
             (UNUSED(MisraScope), UNPL(scope_with_done));                                                                  \
             UNPL(scope_with_done) = NULL)
    #define ScopeWith(alloc_ptr)                                                                                           \
        for (Allocator *MisraScope = (alloc_ptr), *UNPL(scope_with_done) = MisraScope;                                     \
             (UNUSED(MisraScope), UNPL(scope_with_done));                                                                  \
             UNPL(scope_with_done) = NULL)
        for (Allocator *MisraScope = (alloc_ptr), *UNPL(scope_with_done) = MisraScope;                                     \
             (UNUSED(MisraScope), UNPL(scope_with_done));                                                                  \
             UNPL(scope_with_done) = NULL)
    
    ///
    #define StrReadFmt_IMPL2(input, fmtstr, varr)                                                                          \
        do {                                                                                                               \
            TypeSpecificIO *UNPL(argv) = &(varr)[0];                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO);                                            \
            Zstr            UNPL(out)  = str_read_fmt((input), (fmtstr), UNPL(argv), UNPL(argc) - 1);                      \
        do {                                                                                                               \
            TypeSpecificIO *UNPL(argv) = &(varr)[0];                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO);                                            \
            Zstr            UNPL(out)  = str_read_fmt((input), (fmtstr), UNPL(argv), UNPL(argc) - 1);                      \
            if (UNPL(out))                                                                                                 \
            TypeSpecificIO *UNPL(argv) = &(varr)[0];                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO);                                            \
            Zstr            UNPL(out)  = str_read_fmt((input), (fmtstr), UNPL(argv), UNPL(argc) - 1);                      \
            if (UNPL(out))                                                                                                 \
                (input) = UNPL(out);                                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO);                                            \
            Zstr            UNPL(out)  = str_read_fmt((input), (fmtstr), UNPL(argv), UNPL(argc) - 1);                      \
            if (UNPL(out))                                                                                                 \
                (input) = UNPL(out);                                                                                       \
        } while (0)
            Zstr            UNPL(out)  = str_read_fmt((input), (fmtstr), UNPL(argv), UNPL(argc) - 1);                      \
            if (UNPL(out))                                                                                                 \
                (input) = UNPL(out);                                                                                       \
        } while (0)
    #define FReadFmt_IMPL2(file, fmtstr, varr)                                                                             \
        do {                                                                                                               \
            TypeSpecificIO *UNPL(argv) = &(varr)[0];                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                        \
            f_read_fmt((file), (fmtstr), UNPL(argv), UNPL(argc));                                                          \
        do {                                                                                                               \
            TypeSpecificIO *UNPL(argv) = &(varr)[0];                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                        \
            f_read_fmt((file), (fmtstr), UNPL(argv), UNPL(argc));                                                          \
        } while (0)
            TypeSpecificIO *UNPL(argv) = &(varr)[0];                                                                       \
            u64             UNPL(argc) = sizeof(varr) / sizeof(TypeSpecificIO) - 1;                                        \
            f_read_fmt((file), (fmtstr), UNPL(argv), UNPL(argc));                                                          \
        } while (0)
    #define WriteFmt(...)                                                                                                  \
        do {                                                                                                               \
            File UNPL(out) = FileStdout();                                                                                 \
            FWriteFmt(&UNPL(out), __VA_ARGS__);                                                                            \
        } while (0)
        do {                                                                                                               \
            File UNPL(out) = FileStdout();                                                                                 \
            FWriteFmt(&UNPL(out), __VA_ARGS__);                                                                            \
        } while (0)
    #define WriteFmtLn(...)                                                                                                \
        do {                                                                                                               \
            File UNPL(out) = FileStdout();                                                                                 \
            FWriteFmtLn(&UNPL(out), __VA_ARGS__);                                                                          \
        } while (0)
        do {                                                                                                               \
            File UNPL(out) = FileStdout();                                                                                 \
            FWriteFmtLn(&UNPL(out), __VA_ARGS__);                                                                          \
        } while (0)
    #define ReadFmt(...)                                                                                                   \
        do {                                                                                                               \
            File UNPL(in) = FileStdin();                                                                                   \
            FReadFmt(&UNPL(in), __VA_ARGS__);                                                                              \
        } while (0)
        do {                                                                                                               \
            File UNPL(in) = FileStdin();                                                                                   \
            FReadFmt(&UNPL(in), __VA_ARGS__);                                                                              \
        } while (0)
    #define LOG_FATAL(...)                                                                                                 \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            Abort();                                                                                                       \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            Abort();                                                                                                       \
        } while (0)
    #define LOG_ERROR(...)                                                                                                 \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
    #define LOG_INFO(...)                                                                                                  \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
        do {                                                                                                               \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
    #define LOG_SYS_FATAL(eno, ...)                                                                                        \
        do {                                                                                                               \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
        do {                                                                                                               \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            Abort();                                                                                                       \
            LogWrite(LOG_MESSAGE_TYPE_FATAL, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            Abort();                                                                                                       \
        } while (0)
    #define LOG_SYS_ERROR(eno, ...)                                                                                        \
        do {                                                                                                               \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
        do {                                                                                                               \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            LogWrite(LOG_MESSAGE_TYPE_ERROR, __func__, __LINE__, StrBegin(&UNPL(m)));                                      \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
    #define LOG_SYS_INFO(eno, ...)                                                                                         \
        do {                                                                                                               \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
        do {                                                                                                               \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            i32           UNPL(sys_eno)   = (i32)(eno);                                                                    \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
            HeapAllocator UNPL(log_alloc) = HeapAllocatorInit();                                                           \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
            Str           UNPL(m)         = StrInit(&UNPL(log_alloc));                                                     \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            StrAppendFmt(&UNPL(m), __VA_ARGS__);                                                                           \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            StrInitStack(UNPL(syserr), 256) {                                                                              \
                StrError(UNPL(sys_eno), &UNPL(syserr));                                                                    \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
                StrAppendFmt(&UNPL(m), " : {}", UNPL(syserr));                                                             \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
            }                                                                                                              \
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
            LogWrite(LOG_MESSAGE_TYPE_INFO, __func__, __LINE__, StrBegin(&UNPL(m)));                                       \
            StrDeinit(&UNPL(m));                                                                                           \
            HeapAllocatorDeinit(&UNPL(log_alloc));                                                                         \
        } while (0)
    ///
    #define GraphForeachNode(g, node)                                                                                      \
        for (TYPE_OF(g) UNPL(pg) = (g); UNPL(pg); UNPL(pg) = NULL)                                                         \
            if ((ValidateGraph(UNPL(pg)), 1) && GraphNodeCount(UNPL(pg)) > 0)                                              \
                for (GenericGraphNodeIter UNPL(iter) = graph_node_iter_begin(GENERIC_GRAPH(UNPL(pg))); UNPL(iter).graph;  \
    #define GraphForeachNode(g, node)                                                                                      \
        for (TYPE_OF(g) UNPL(pg) = (g); UNPL(pg); UNPL(pg) = NULL)                                                         \
            if ((ValidateGraph(UNPL(pg)), 1) && GraphNodeCount(UNPL(pg)) > 0)                                              \
                for (GenericGraphNodeIter UNPL(iter) = graph_node_iter_begin(GENERIC_GRAPH(UNPL(pg))); UNPL(iter).graph;  \
                     UNPL(iter).graph = NULL)                                                                              \
        for (TYPE_OF(g) UNPL(pg) = (g); UNPL(pg); UNPL(pg) = NULL)                                                         \
            if ((ValidateGraph(UNPL(pg)), 1) && GraphNodeCount(UNPL(pg)) > 0)                                              \
                for (GenericGraphNodeIter UNPL(iter) = graph_node_iter_begin(GENERIC_GRAPH(UNPL(pg))); UNPL(iter).graph;  \
                     UNPL(iter).graph = NULL)                                                                              \
                    for (GraphNode node = {0}; graph_node_iter_next(&UNPL(iter), &node);)
            if ((ValidateGraph(UNPL(pg)), 1) && GraphNodeCount(UNPL(pg)) > 0)                                              \
                for (GenericGraphNodeIter UNPL(iter) = graph_node_iter_begin(GENERIC_GRAPH(UNPL(pg))); UNPL(iter).graph;  \
                     UNPL(iter).graph = NULL)                                                                              \
                    for (GraphNode node = {0}; graph_node_iter_next(&UNPL(iter), &node);)
                for (GenericGraphNodeIter UNPL(iter) = graph_node_iter_begin(GENERIC_GRAPH(UNPL(pg))); UNPL(iter).graph;  \
                     UNPL(iter).graph = NULL)                                                                              \
                    for (GraphNode node = {0}; graph_node_iter_next(&UNPL(iter), &node);)
    
    ///
    ///
    #define GraphNodeForeachNeighbor(node, neighbor)                                                                       \
        for (GraphNode UNPL(src_node) = (node); UNPL(src_node)._graph_; UNPL(src_node)._graph_ = NULL)                    \
            for (GenericGraphNeighborIter UNPL(iter) = graph_neighbor_iter_begin(UNPL(src_node)); UNPL(iter).graph;       \
                 UNPL(iter).graph = NULL)                                                                                  \
    #define GraphNodeForeachNeighbor(node, neighbor)                                                                       \
        for (GraphNode UNPL(src_node) = (node); UNPL(src_node)._graph_; UNPL(src_node)._graph_ = NULL)                    \
            for (GenericGraphNeighborIter UNPL(iter) = graph_neighbor_iter_begin(UNPL(src_node)); UNPL(iter).graph;       \
                 UNPL(iter).graph = NULL)                                                                                  \
                for (GraphNode neighbor = {0}; graph_neighbor_iter_next(&UNPL(iter), &neighbor);)
        for (GraphNode UNPL(src_node) = (node); UNPL(src_node)._graph_; UNPL(src_node)._graph_ = NULL)                    \
            for (GenericGraphNeighborIter UNPL(iter) = graph_neighbor_iter_begin(UNPL(src_node)); UNPL(iter).graph;       \
                 UNPL(iter).graph = NULL)                                                                                  \
                for (GraphNode neighbor = {0}; graph_neighbor_iter_next(&UNPL(iter), &neighbor);)
            for (GenericGraphNeighborIter UNPL(iter) = graph_neighbor_iter_begin(UNPL(src_node)); UNPL(iter).graph;       \
                 UNPL(iter).graph = NULL)                                                                                  \
                for (GraphNode neighbor = {0}; graph_neighbor_iter_next(&UNPL(iter), &neighbor);)
    
    ///
    ///
    #define GraphNodeForeachPredecessor(node, predecessor)                                                                \
        for (GraphNode UNPL(dst_node) = (node); UNPL(dst_node)._graph_; UNPL(dst_node)._graph_ = NULL)                   \
            for (GenericGraphPredecessorIter UNPL(iter) = graph_predecessor_iter_begin(UNPL(dst_node));                  \
                 UNPL(iter).graph;                                                                                        \
    #define GraphNodeForeachPredecessor(node, predecessor)                                                                \
        for (GraphNode UNPL(dst_node) = (node); UNPL(dst_node)._graph_; UNPL(dst_node)._graph_ = NULL)                   \
            for (GenericGraphPredecessorIter UNPL(iter) = graph_predecessor_iter_begin(UNPL(dst_node));                  \
                 UNPL(iter).graph;                                                                                        \
                 UNPL(iter).graph = NULL)                                                                                 \
        for (GraphNode UNPL(dst_node) = (node); UNPL(dst_node)._graph_; UNPL(dst_node)._graph_ = NULL)                   \
            for (GenericGraphPredecessorIter UNPL(iter) = graph_predecessor_iter_begin(UNPL(dst_node));                  \
                 UNPL(iter).graph;                                                                                        \
                 UNPL(iter).graph = NULL)                                                                                 \
                for (GraphNode predecessor = {0}; graph_predecessor_iter_next(&UNPL(iter), &predecessor);)
            for (GenericGraphPredecessorIter UNPL(iter) = graph_predecessor_iter_begin(UNPL(dst_node));                  \
                 UNPL(iter).graph;                                                                                        \
                 UNPL(iter).graph = NULL)                                                                                 \
                for (GraphNode predecessor = {0}; graph_predecessor_iter_next(&UNPL(iter), &predecessor);)
                 UNPL(iter).graph;                                                                                        \
                 UNPL(iter).graph = NULL)                                                                                 \
                for (GraphNode predecessor = {0}; graph_predecessor_iter_next(&UNPL(iter), &predecessor);)
    
    #endif // MISRA_STD_CONTAINER_GRAPH_FOREACH_H
    ///
    #define ListForeach(l, var)                                                                                                      \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                          \
    #define ListForeach(l, var)                                                                                                      \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                        \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                                 UNPL(_once) = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                                 UNPL(_once) = false)
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                                 UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachPtr(l, var)                                                                                                 \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                        \
    #define ListForeachPtr(l, var)                                                                                                 \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                        \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                      \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                        \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->head))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                        \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                        \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                                 UNPL(_once) = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                                 UNPL(_once) = false)
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                                 UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachReverse(l, var)                                                                                               \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                            \
    #define ListForeachReverse(l, var)                                                                                               \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                            \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                        \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                   \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                            \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                     \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                            \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                            \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                        \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                        \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                    \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                                 UNPL(_once) = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                                 UNPL(_once) = false)
                            for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data)); \
                                 UNPL(_once);                                                                      \
                                 UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachPtrReverse(l, var)                                                                                          \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                          \
    #define ListForeachPtrReverse(l, var)                                                                                          \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                      \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                 \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
            if ((ValidateList(UNPL(pl)), 1) && (UNPL(pl)->tail))                                                                   \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                          \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                      \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                    if (((void *)UNPL(node)->next != (void *)UNPL(node)) &&                                      \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                        ((void *)UNPL(node)->prev != (void *)UNPL(node)) && (UNPL(node)->data))                  \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                                 UNPL(_once) = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                          \
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                                 UNPL(_once) = false)
                            for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data); \
                                 UNPL(_once);                                                                    \
                                 UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachInRange(l, var, start, end)                                                                                           \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
    #define ListForeachInRange(l, var, start, end)                                                                                           \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachPtrInRange(l, var, start, end)                                                                                        \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
    #define ListForeachPtrInRange(l, var, start, end)                                                                                        \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeBegin(UNPL(pl)); UNPL(node);                                  \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                     UNPL(node)                   = ListNodeNext(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodeNext(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachReverseInRange(l, var, start, end)                                                                                    \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
    #define ListForeachReverseInRange(l, var, start, end)                                                                                    \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));     \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachPtrReverseInRange(l, var, start, end)                                                                                 \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
    #define ListForeachPtrReverseInRange(l, var, start, end)                                                                                 \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail)                                                                               \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                for (GenericListNode * UNPL(node) = (GenericListNode *)ListNodeEnd(UNPL(pl)); UNPL(node);                                    \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                     UNPL(node)                   = ListNodePrev(UNPL(node)))                                                                \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                    for (u64 UNPL(i) = 0; UNPL(node) && UNPL(i) < (end); UNPL(node) = ListNodePrev(UNPL(node)), ++UNPL(i)) \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                        if (UNPL(i) >= (start) && (UNPL(node)->data))                                                      \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data);       \
                                     UNPL(_once);                                                                          \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachIdx(l, var, idx)                                                                                      \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
    #define ListForeachIdx(l, var, idx)                                                                                      \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachPtrIdx(l, var, idx)                                                                                   \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
    #define ListForeachPtrIdx(l, var, idx)                                                                                   \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->head)                                                               \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                    for (u64 idx = 0, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0; idx < UNPL(pl)->length;                \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                             idx = ((idx != UNPL(resolved_idx)) ? idx : (UNPL(resolved_idx) + 1)))                          \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachReverseIdx(l, var, idx)                                                                               \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
    #define ListForeachReverseIdx(l, var, idx)                                                                               \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) var = *((LIST_DATA_TYPE(UNPL(pl)) *)(UNPL(node)->data));      \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define ListForeachPtrReverseIdx(l, var, idx)                                                                            \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
    #define ListForeachPtrReverseIdx(l, var, idx)                                                                            \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
        for (TYPE_OF(l) UNPL(pl) = (l); UNPL(pl); UNPL(pl) = NULL)                                                           \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
            if ((ValidateList(UNPL(pl)), 1) && UNPL(pl)->tail && UNPL(pl)->length > 0)                                      \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                for (GenericListNode * UNPL(cursor) = NULL, *UNPL(node) = NULL; UNPL(pl); UNPL(pl) = NULL)                 \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                    for (u64 idx = UNPL(pl)->length - 1, UNPL(cursor_idx) = 0, UNPL(resolved_idx) = 0;                     \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                         idx < UNPL(pl)->length;                                                                            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                         UNPL(cursor) = UNPL(node), UNPL(cursor_idx) = UNPL(resolved_idx),                                  \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                             idx = ((idx != UNPL(resolved_idx)) ? idx :                                                      \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                                                                   (UNPL(resolved_idx) > 0 ? UNPL(resolved_idx) - 1        \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                                                                                            : UNPL(pl)->length)))            \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                        if ((UNPL(node) = get_node_for_list_iteration(                                                       \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                 GENERIC_LIST(UNPL(pl)), UNPL(cursor), UNPL(cursor_idx), idx)) &&                           \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                            ((UNPL(resolved_idx) = idx), 1) && UNPL(node)->data)                                             \
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                            for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                  \
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
                                for (LIST_DATA_TYPE(UNPL(pl)) *var = (LIST_DATA_TYPE(UNPL(pl)) *)UNPL(node)->data;          \
                                     UNPL(_once);                                                                            \
                                     UNPL(_once) = false)
    
    #endif // MISRA_STD_CONTAINER_LIST_FOREACH_H
                 _Alignas(T) char d[sizeof(T) * ((ne) + 1)];                                                               \
                 int              done;                                                                                    \
             } UNPL(_s) = {{0}, 0};                                                                                        \
             UNPL(_s).done == 0;                                                                                           \
             MemSet(UNPL(_s).d, 0, sizeof(UNPL(_s).d)), UNPL(_s).done = 1)                                                 \
                 int              done;                                                                                    \
             } UNPL(_s) = {{0}, 0};                                                                                        \
             UNPL(_s).done == 0;                                                                                           \
             MemSet(UNPL(_s).d, 0, sizeof(UNPL(_s).d)), UNPL(_s).done = 1)                                                 \
            for (Vec(T) name = {.length      = 0,                                                                          \
             } UNPL(_s) = {{0}, 0};                                                                                        \
             UNPL(_s).done == 0;                                                                                           \
             MemSet(UNPL(_s).d, 0, sizeof(UNPL(_s).d)), UNPL(_s).done = 1)                                                 \
            for (Vec(T) name = {.length      = 0,                                                                          \
                                .capacity    = (ne),                                                                       \
                                .copy_init   = NULL,                                                                       \
                                .copy_deinit = NULL,                                                                       \
                                .data        = (T *)UNPL(_s).d,                                                            \
                                .allocator   = NULL,                                                                       \
                                .__magic     = VEC_MAGIC | MAGIC_VALIDATED_BIT},                                                                 \
                                .allocator   = NULL,                                                                       \
                                .__magic     = VEC_MAGIC | MAGIC_VALIDATED_BIT},                                                                 \
                     *UNPL(_done) = &name;                                                                                  \
                 UNPL(_done);                                                                                              \
                 MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
                                .__magic     = VEC_MAGIC | MAGIC_VALIDATED_BIT},                                                                 \
                     *UNPL(_done) = &name;                                                                                  \
                 UNPL(_done);                                                                                              \
                 MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
                     *UNPL(_done) = &name;                                                                                  \
                 UNPL(_done);                                                                                              \
                 MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
    
    ///
    ///
    #define VecForeachIdx(v, var, idx)                                                                                     \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
    #define VecForeachIdx(v, var, idx)                                                                                     \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (VEC_DATATYPE(UNPL(pv)) var = {0}; idx < UNPL(pv)->length && (var = VecAt(UNPL(pv), idx), 1); idx++)
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (VEC_DATATYPE(UNPL(pv)) var = {0}; idx < UNPL(pv)->length && (var = VecAt(UNPL(pv), idx), 1); idx++)
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (VEC_DATATYPE(UNPL(pv)) var = {0}; idx < UNPL(pv)->length && (var = VecAt(UNPL(pv), idx), 1); idx++)
    
    ///
    ///
    #define VecForeachReverseIdx(v, var, idx)                                                                              \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
    #define VecForeachReverseIdx(v, var, idx)                                                                              \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (VEC_DATATYPE(UNPL(pv)) var = VecAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (VEC_DATATYPE(UNPL(pv)) var = VecAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (VEC_DATATYPE(UNPL(pv)) var = VecAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
    
    ///
    ///
    #define VecForeachPtrIdx(v, var, idx)                                                                                  \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
    #define VecForeachPtrIdx(v, var, idx)                                                                                  \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (VEC_DATATYPE(UNPL(pv)) *var = NULL; idx < UNPL(pv)->length && (var = VecPtrAt(UNPL(pv), idx), 1); \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (VEC_DATATYPE(UNPL(pv)) *var = NULL; idx < UNPL(pv)->length && (var = VecPtrAt(UNPL(pv), idx), 1); \
                         idx++)
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (VEC_DATATYPE(UNPL(pv)) *var = NULL; idx < UNPL(pv)->length && (var = VecPtrAt(UNPL(pv), idx), 1); \
                         idx++)
    ///
    #define VecForeachPtrReverseIdx(v, var, idx)                                                                           \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
    #define VecForeachPtrReverseIdx(v, var, idx)                                                                           \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
                for (u64 idx = UNPL(pv)->length; idx-- > 0 && idx < UNPL(pv)->length;)                                     \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(run_once); UNPL(run_once) = 0)
    
    ///
    /// TAGS: Foreach, Vec, Iteration, Loop
    ///
    #define VecForeach(v, var) VecForeachIdx((v), (var), UNPL(iter))
    
    ///
    /// TAGS: Foreach, Vec, Iteration, Loop, Reverse
    ///
    #define VecForeachReverse(v, var) VecForeachReverseIdx((v), (var), UNPL(iter))
    
    ///
    /// TAGS: Foreach, Vec, Iteration, Loop, Pointer
    ///
    #define VecForeachPtr(v, var) VecForeachPtrIdx((v), (var), UNPL(iter))
    
    ///
    /// TAGS: Foreach, Vec, Iteration, Loop, Reverse, Pointer
    ///
    #define VecForeachPtrReverse(v, var) VecForeachPtrReverseIdx((v), (var), UNPL(iter))
    
    ///
    ///
    #define VecForeachInRangeIdx(v, var, idx, start, end)                                                                  \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
    #define VecForeachInRangeIdx(v, var, idx, start, end)                                                                  \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (VEC_DATATYPE(UNPL(pv)) var = VecAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (VEC_DATATYPE(UNPL(pv)) var = VecAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (VEC_DATATYPE(UNPL(pv)) var = VecAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
    
    ///
    /// TAGS: Foreach, Vec, Iteration, Loop, Range
    ///
    #define VecForeachInRange(v, var, start, end) VecForeachInRangeIdx((v), (var), UNPL(iter), (start), (end))
    
    ///
    ///
    #define VecForeachPtrInRangeIdx(v, var, idx, start, end)                                                               \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
    #define VecForeachPtrInRangeIdx(v, var, idx, start, end)                                                               \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     idx >= UNPL(s) && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
        for (TYPE_OF(v) UNPL(pv) = (v); UNPL(pv); UNPL(pv) = NULL)                                                         \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     idx >= UNPL(s) && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
            if ((ValidateVec(UNPL(pv)), 1) && UNPL(pv)->length > 0)                                                        \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     idx >= UNPL(s) && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     idx >= UNPL(s) && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
                     idx >= UNPL(s) && idx < UNPL(e) && idx < UNPL(pv)->length && UNPL(s) <= UNPL(e);                      \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (VEC_DATATYPE(UNPL(pv)) *var = VecPtrAt(UNPL(pv), idx); UNPL(d); UNPL(d) = 0)
    
    ///
    /// TAGS: Foreach, Vec, Iteration, Loop, Range, Pointer
    ///
    #define VecForeachPtrInRange(v, var, start, end) VecForeachPtrInRangeIdx((v), (var), UNPL(iter), (start), (end))
    
    #endif // MISRA_STD_CONTAINER_VEC_FOREACH_H
    ///
    #define BitVecForeachIdx(bv, var, idx)                                                                                 \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
    #define BitVecForeachIdx(bv, var, idx)                                                                                 \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (bool var = 0; idx < UNPL(pbv)->length && (var = BitVecGet(UNPL(pbv), idx), 1); idx++)
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (bool var = 0; idx < UNPL(pbv)->length && (var = BitVecGet(UNPL(pbv), idx), 1); idx++)
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = 0, UNPL(d) = 1; UNPL(d); UNPL(d)--)                                                         \
                    for (bool var = 0; idx < UNPL(pbv)->length && (var = BitVecGet(UNPL(pbv), idx), 1); idx++)
    
    ///
    ///
    #define BitVecForeachReverseIdx(bv, var, idx)                                                                          \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = UNPL(pbv)->length; idx-- > 0 && idx < UNPL(pbv)->length;)                                   \
    #define BitVecForeachReverseIdx(bv, var, idx)                                                                          \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = UNPL(pbv)->length; idx-- > 0 && idx < UNPL(pbv)->length;)                                   \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = UNPL(pbv)->length; idx-- > 0 && idx < UNPL(pbv)->length;)                                   \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(run_once); UNPL(run_once) = 0)
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 idx = UNPL(pbv)->length; idx-- > 0 && idx < UNPL(pbv)->length;)                                   \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(run_once); UNPL(run_once) = 0)
                for (u64 idx = UNPL(pbv)->length; idx-- > 0 && idx < UNPL(pbv)->length;)                                   \
                    for (u8 UNPL(run_once) = 1; UNPL(run_once); UNPL(run_once) = 0)                                        \
                        for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(run_once); UNPL(run_once) = 0)
    
    ///
    /// TAGS: BitVec, Foreach, Forward, Iteration
    ///
    #define BitVecForeach(bv, var) BitVecForeachIdx((bv), (var), UNPL(iter))
    
    ///
    /// TAGS: BitVec, Foreach, Reverse, Iteration
    ///
    #define BitVecForeachReverse(bv, var) BitVecForeachReverseIdx((bv), (var), UNPL(iter))
    
    ///
    ///
    #define BitVecForeachInRangeIdx(bv, var, idx, start, end)                                                              \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
    #define BitVecForeachInRangeIdx(bv, var, idx, start, end)                                                              \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pbv)->length && UNPL(s) <= UNPL(e);                     \
        for (TYPE_OF(bv) UNPL(pbv) = (bv); UNPL(pbv); UNPL(pbv) = NULL)                                                    \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pbv)->length && UNPL(s) <= UNPL(e);                     \
                     ++idx, UNPL(d) = 1)                                                                                   \
            if ((ValidateBitVec(UNPL(pbv)), 1) && UNPL(pbv)->length > 0)                                                   \
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pbv)->length && UNPL(s) <= UNPL(e);                     \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(d); UNPL(d) = 0)
                for (u64 UNPL(s) = (start), UNPL(e) = (end), idx = UNPL(s), UNPL(d) = 1;                                   \
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pbv)->length && UNPL(s) <= UNPL(e);                     \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(d); UNPL(d) = 0)
                     UNPL(s) <= idx && idx < UNPL(e) && idx < UNPL(pbv)->length && UNPL(s) <= UNPL(e);                     \
                     ++idx, UNPL(d) = 1)                                                                                   \
                    for (bool var = BitVecGet(UNPL(pbv), idx); UNPL(d); UNPL(d) = 0)
    
    /// TAGS: BitVec, Foreach, Range, Iteration
    ///
    #define BitVecForeachInRange(bv, var, start, end) BitVecForeachInRangeIdx((bv), (var), UNPL(iter), (start), (end))
    
    #endif // MISRA_STD_CONTAINER_BITVEC_FOREACH_H
    ///
    #define StrInitStack(name, ne)                                                                                         \
        for (char UNPL(_d)[(ne) + 1] = {0}, *UNPL(_loop) = UNPL(_d); UNPL(_loop);                                          \
             MemSet(UNPL(_d), 0, sizeof(UNPL(_d))), UNPL(_loop) = NULL)                                                    \
            for (Str name = {.length      = 0,                                                                             \
    #define StrInitStack(name, ne)                                                                                         \
        for (char UNPL(_d)[(ne) + 1] = {0}, *UNPL(_loop) = UNPL(_d); UNPL(_loop);                                          \
             MemSet(UNPL(_d), 0, sizeof(UNPL(_d))), UNPL(_loop) = NULL)                                                    \
            for (Str name = {.length      = 0,                                                                             \
                             .capacity    = (ne),                                                                          \
            for (Str name = {.length      = 0,                                                                             \
                             .capacity    = (ne),                                                                          \
                             .data        = UNPL(_d),                                                                      \
                             .allocator   = NULL,                                                                          \
                             .copy_init   = NULL,                                                                          \
                             .copy_deinit = NULL,                                                                          \
                             .__magic     = VEC_MAGIC | MAGIC_VALIDATED_BIT},                                                                    \
                     *UNPL(_done) = &name;                                                                                  \
                 UNPL(_done);                                                                                              \
                 MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
                             .__magic     = VEC_MAGIC | MAGIC_VALIDATED_BIT},                                                                    \
                     *UNPL(_done) = &name;                                                                                  \
                 UNPL(_done);                                                                                              \
                 MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
                     *UNPL(_done) = &name;                                                                                  \
                 UNPL(_done);                                                                                              \
                 MemSet(&name, 0, sizeof(name)), UNPL(_done) = NULL)
    
        ///
            ValidateMap(lhs);                                                                                              \
            ValidateMap(rhs);                                                                                              \
            TYPE_OF(*(lhs)) UNPL(tmp) = *(lhs);                                                                            \
            *(lhs)                    = *(rhs);                                                                            \
            *(rhs)                    = UNPL(tmp);                                                                         \
            TYPE_OF(*(lhs)) UNPL(tmp) = *(lhs);                                                                            \
            *(lhs)                    = *(rhs);                                                                            \
            *(rhs)                    = UNPL(tmp);                                                                         \
        } while (0)
    ///
    #define MapForeachPairPtr(m, key_ptr, value_ptr)                                                                                   \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                                     \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                    \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                               \
    #define MapForeachPairPtr(m, key_ptr, value_ptr)                                                                                   \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                                     \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                    \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                               \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                       \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                                     \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                    \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                               \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                       \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                                \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                    \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                               \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                       \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                                \
                            for (MAP_KEY_TYPE(UNPL(pm)) *key_ptr = map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                  \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                               \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                       \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                                \
                            for (MAP_KEY_TYPE(UNPL(pm)) *key_ptr = map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                  \
                                 UNPL(_once)                     = false)                                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                       \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                                \
                            for (MAP_KEY_TYPE(UNPL(pm)) *key_ptr = map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                  \
                                 UNPL(_once)                     = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                                \
                            for (MAP_KEY_TYPE(UNPL(pm)) *key_ptr = map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                  \
                                 UNPL(_once)                     = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                                     value_ptr;                                                                    \
                            for (MAP_KEY_TYPE(UNPL(pm)) *key_ptr = map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                  \
                                 UNPL(_once)                     = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                                     value_ptr;                                                                    \
                                     value_ptr = NULL)
    ///
    #define MapForeachPair(m, key_var, value_var)                                                                                     \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                                    \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                   \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                              \
    #define MapForeachPair(m, key_var, value_var)                                                                                     \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                                    \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                   \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                      \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                                    \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                   \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                               \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                                   \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                               \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                 \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                               \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                 \
                                 UNPL(_once)                    = false)                                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                               \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                 \
                                 UNPL(_once)                    = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                               \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                 \
                                 UNPL(_once)                    = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                                     UNPL(_once);                                                                  \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);                 \
                                 UNPL(_once)                    = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                                     UNPL(_once);                                                                  \
                                     UNPL(_once) = false)
                                 UNPL(_once)                    = false)                                                              \
                                for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                                     UNPL(_once);                                                                  \
                                     UNPL(_once) = false)
                                for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot)); \
                                     UNPL(_once);                                                                  \
                                     UNPL(_once) = false)
    
    ///
    ///
    #define MapForeachKey(m, key_var)                                                                                      \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
    #define MapForeachKey(m, key_var)                                                                                      \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)) && (map_find_index(                                        \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)) && (map_find_index(                                        \
                                                                        GENERIC_MAP(UNPL(pm)),                             \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)) && (map_find_index(                                        \
                                                                        GENERIC_MAP(UNPL(pm)),                             \
                                                                        map_key_ptr_at(UNPL(pm), UNPL(slot)),              \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)) && (map_find_index(                                        \
                                                                        GENERIC_MAP(UNPL(pm)),                             \
                                                                        map_key_ptr_at(UNPL(pm), UNPL(slot)),              \
                                                                        sizeof(MAP_ENTRY_TYPE(UNPL(pm))),                  \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)) && (map_find_index(                                        \
                                                                        GENERIC_MAP(UNPL(pm)),                             \
                                                                        map_key_ptr_at(UNPL(pm), UNPL(slot)),              \
                                                                        sizeof(MAP_ENTRY_TYPE(UNPL(pm))),                  \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), key),           \
                                                                        GENERIC_MAP(UNPL(pm)),                             \
                                                                        map_key_ptr_at(UNPL(pm), UNPL(slot)),              \
                                                                        sizeof(MAP_ENTRY_TYPE(UNPL(pm))),                  \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), key),           \
                                                                        sizeof(MAP_KEY_TYPE(UNPL(pm))),                    \
                                                                        map_key_ptr_at(UNPL(pm), UNPL(slot)),              \
                                                                        sizeof(MAP_ENTRY_TYPE(UNPL(pm))),                  \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), key),           \
                                                                        sizeof(MAP_KEY_TYPE(UNPL(pm))),                    \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), hash)           \
                                                                        sizeof(MAP_ENTRY_TYPE(UNPL(pm))),                  \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), key),           \
                                                                        sizeof(MAP_KEY_TYPE(UNPL(pm))),                    \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), hash)           \
                                                                    ) == UNPL(slot)))                                      \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), key),           \
                                                                        sizeof(MAP_KEY_TYPE(UNPL(pm))),                    \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), hash)           \
                                                                    ) == UNPL(slot)))                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                                                                        sizeof(MAP_KEY_TYPE(UNPL(pm))),                    \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), hash)           \
                                                                    ) == UNPL(slot)))                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);      \
                                                                        offsetof(MAP_ENTRY_TYPE(UNPL(pm)), hash)           \
                                                                    ) == UNPL(slot)))                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);      \
                                 UNPL(_once)                    = false)
                                                                    ) == UNPL(slot)))                                      \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);      \
                                 UNPL(_once)                    = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_KEY_TYPE(UNPL(pm)) key_var = *map_key_ptr_at(UNPL(pm), UNPL(slot)); UNPL(_once);      \
                                 UNPL(_once)                    = false)
    
    ///
    ///
    #define MapForeachValue(m, value_var)                                                                                  \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
    #define MapForeachValue(m, value_var)                                                                                  \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                                 UNPL(_once) = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                                 UNPL(_once) = false)
                            for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                                 UNPL(_once) = false)
    
    ///
    ///
    #define MapForeachValuePtr(m, value_ptr)                                                                               \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
    #define MapForeachValuePtr(m, value_ptr)                                                                               \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                                   \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                    if (map_slot_occupied(UNPL(pm), UNPL(slot)))                                                           \
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                                 UNPL(_once) = false)
                        for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                                    \
                            for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                                 UNPL(_once) = false)
                            for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));             \
                                 UNPL(_once);                                                                              \
                                 UNPL(_once) = false)
    
    ///
    ///
    #define MapForeachValueForKey(m, lookup_key, value_var)                                                                \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
    #define MapForeachValueForKey(m, lookup_key, value_var)                                                                \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                         UNPL(_once) = false)
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                         UNPL(_once) = false)
                                    for (MAP_VALUE_TYPE(UNPL(pm)) value_var = *map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                         UNPL(_once) = false)
    
    ///
    ///
    #define MapForeachValuePtrForKey(m, lookup_key, value_ptr)                                                             \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
    #define MapForeachValuePtrForKey(m, lookup_key, value_ptr)                                                             \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
        for (TYPE_OF(m) UNPL(pm) = (m); UNPL(pm); UNPL(pm) = NULL)                                                         \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
            if ((ValidateMap(UNPL(pm)), 1) && UNPL(pm)->length > 0)                                                        \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                for (bool UNPL(_key_once) = true; UNPL(_key_once); UNPL(_key_once) = false)                                \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                    for (MAP_KEY_TYPE(UNPL(pm)) UNPL(find_key) = (lookup_key); UNPL(_key_once); UNPL(_key_once) = false)   \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                        for (size UNPL(slot) = 0; UNPL(slot) < UNPL(pm)->capacity; UNPL(slot)++)                           \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                            if (map_slot_occupied(UNPL(pm), UNPL(slot)) &&                                                 \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                (UNPL(pm)->key_compare(map_key_ptr_at(UNPL(pm), UNPL(slot)), &UNPL(find_key)) == 0))       \
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                         UNPL(_once) = false)
                                for (bool UNPL(_once) = true; UNPL(_once); UNPL(_once) = false)                            \
                                    for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                         UNPL(_once) = false)
                                    for (MAP_VALUE_TYPE(UNPL(pm)) *value_ptr = map_value_ptr_at(UNPL(pm), UNPL(slot));     \
                                         UNPL(_once);                                                                      \
                                         UNPL(_once) = false)
    
    #endif // MISRA_STD_CONTAINER_MAP_FOREACH_H
    #define ProcReadFromStdoutFmt(p, ...)                                                                                  \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStdout((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStdout((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStdout((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
            ProcReadFromStdout((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
    #define ProcReadFromStderrFmt(p, ...)                                                                                  \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStderr((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStderr((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            Str UNPL(buf) = StrInit();                                                                                     \
            ProcReadFromStderr((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
            ProcReadFromStderr((p), &UNPL(buf));                                                                           \
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            Zstr UNPL(in) = StrBegin(&UNPL(buf));                                                                          \
            StrReadFmt(UNPL(in), __VA_ARGS__);                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
    #define ProcWriteToStdinFmt(p, ...)                                                                                    \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
    #define ProcWriteToStdinFmtLn(p, ...)                                                                                  \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
        do {                                                                                                               \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            Str UNPL(buf) = StrInit();                                                                                     \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
            StrAppendFmt(&UNPL(buf), __VA_ARGS__);                                                                         \
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
            StrPushBackR(&UNPL(buf), '\n');                                                                                 \
            ProcWriteToStdin((p), &UNPL(buf));                                                                             \
            StrDeinit(&UNPL(buf));                                                                                         \
        } while (0)
    #define JR_STR(si, str)                                                                                                \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit();                                                                                  \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit();                                                                                  \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        } while (0)
            Str UNPL(my_str) = StrInit();                                                                                  \
            si               = JReadString((si), &UNPL(my_str));                                                           \
            (str)            = UNPL(my_str);                                                                               \
        } while (0)
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                Str UNPL(my_str) = StrInit();                                                                              \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
            if (!StrCmp(&key, (k))) {                                                                                      \
                Str UNPL(my_str) = StrInit();                                                                              \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
            }                                                                                                              \
                Str UNPL(my_str) = StrInit();                                                                              \
                si               = JReadString((si), &UNPL(my_str));                                                       \
                (str)            = UNPL(my_str);                                                                           \
            }                                                                                                              \
        } while (0)
    #define JR_INT(si, i)                                                                                                  \
        do {                                                                                                               \
            i64 UNPL(my_int) = 0;                                                                                          \
            si               = JReadInteger((si), &UNPL(my_int));                                                          \
            (i)              = UNPL(my_int);                                                                               \
        do {                                                                                                               \
            i64 UNPL(my_int) = 0;                                                                                          \
            si               = JReadInteger((si), &UNPL(my_int));                                                          \
            (i)              = UNPL(my_int);                                                                               \
        } while (0)
            i64 UNPL(my_int) = 0;                                                                                          \
            si               = JReadInteger((si), &UNPL(my_int));                                                          \
            (i)              = UNPL(my_int);                                                                               \
        } while (0)
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                i64 UNPL(my_int) = 0;                                                                                      \
                si               = JReadInteger((si), &UNPL(my_int));                                                      \
                (i)              = UNPL(my_int);                                                                           \
            if (!StrCmp(&key, (k))) {                                                                                      \
                i64 UNPL(my_int) = 0;                                                                                      \
                si               = JReadInteger((si), &UNPL(my_int));                                                      \
                (i)              = UNPL(my_int);                                                                           \
            }                                                                                                              \
                i64 UNPL(my_int) = 0;                                                                                      \
                si               = JReadInteger((si), &UNPL(my_int));                                                      \
                (i)              = UNPL(my_int);                                                                           \
            }                                                                                                              \
        } while (0)
    #define JR_FLT(si, f)                                                                                                  \
        do {                                                                                                               \
            f64 UNPL(my_flt) = 0;                                                                                          \
            si               = JReadFloat((si), &UNPL(my_flt));                                                            \
            (f)              = UNPL(my_flt);                                                                               \
        do {                                                                                                               \
            f64 UNPL(my_flt) = 0;                                                                                          \
            si               = JReadFloat((si), &UNPL(my_flt));                                                            \
            (f)              = UNPL(my_flt);                                                                               \
        } while (0)
            f64 UNPL(my_flt) = 0;                                                                                          \
            si               = JReadFloat((si), &UNPL(my_flt));                                                            \
            (f)              = UNPL(my_flt);                                                                               \
        } while (0)
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                f64 UNPL(my_flt) = 0;                                                                                      \
                si               = JReadFloat((si), &UNPL(my_flt));                                                        \
                (f)              = UNPL(my_flt);                                                                           \
            if (!StrCmp(&key, (k))) {                                                                                      \
                f64 UNPL(my_flt) = 0;                                                                                      \
                si               = JReadFloat((si), &UNPL(my_flt));                                                        \
                (f)              = UNPL(my_flt);                                                                           \
            }                                                                                                              \
                f64 UNPL(my_flt) = 0;                                                                                      \
                si               = JReadFloat((si), &UNPL(my_flt));                                                        \
                (f)              = UNPL(my_flt);                                                                           \
            }                                                                                                              \
        } while (0)
    #define JR_BOOL(si, b)                                                                                                 \
        do {                                                                                                               \
            bool UNPL(my_b) = 0;                                                                                           \
            si              = JReadBool((si), &UNPL(my_b));                                                                \
            (b)             = UNPL(my_b);                                                                                  \
        do {                                                                                                               \
            bool UNPL(my_b) = 0;                                                                                           \
            si              = JReadBool((si), &UNPL(my_b));                                                                \
            (b)             = UNPL(my_b);                                                                                  \
        } while (0)
            bool UNPL(my_b) = 0;                                                                                           \
            si              = JReadBool((si), &UNPL(my_b));                                                                \
            (b)             = UNPL(my_b);                                                                                  \
        } while (0)
        do {                                                                                                               \
            if (!StrCmp(&key, (k))) {                                                                                      \
                bool UNPL(my_b) = 0;                                                                                       \
                si              = JReadBool((si), &UNPL(my_b));                                                            \
                (b)             = UNPL(my_b);                                                                              \
            if (!StrCmp(&key, (k))) {                                                                                      \
                bool UNPL(my_b) = 0;                                                                                       \
                si              = JReadBool((si), &UNPL(my_b));                                                            \
                (b)             = UNPL(my_b);                                                                              \
            }                                                                                                              \
                bool UNPL(my_b) = 0;                                                                                       \
                si              = JReadBool((si), &UNPL(my_b));                                                            \
                (b)             = UNPL(my_b);                                                                              \
            }                                                                                                              \
        } while (0)
            }                                                                                                              \
                                                                                                                           \
            StrIter UNPL(saved_si) = si;                                                                                   \
            si                     = JSkipWhitespace(si);                                                                  \
                                                                                                                           \
                                                                                                                           \
            /* starting of an array */                                                                                     \
            char UNPL(jr_c);                                                                                               \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '[') {                                                     \
                LOG_ERROR("Invalid array start. Expected '['.");                                                           \
            /* starting of an array */                                                                                     \
            char UNPL(jr_c);                                                                                               \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '[') {                                                     \
                LOG_ERROR("Invalid array start. Expected '['.");                                                           \
                si = UNPL(saved_si);                                                                                       \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '[') {                                                     \
                LOG_ERROR("Invalid array start. Expected '['.");                                                           \
                si = UNPL(saved_si);                                                                                       \
                break;                                                                                                     \
            }                                                                                                              \
            si = JSkipWhitespace(si);                                                                                      \
                                                                                                                           \
            bool UNPL(expect_comma) = false;                                                                               \
            bool UNPL(failed)       = false;                                                                               \
                                                                                                                           \
                                                                                                                           \
            bool UNPL(expect_comma) = false;                                                                               \
            bool UNPL(failed)       = false;                                                                               \
                                                                                                                           \
            /* while not at the end of array. */                                                                           \
                                                                                                                           \
            /* while not at the end of array. */                                                                           \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != ']') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
            /* while not at the end of array. */                                                                           \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != ']') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");                            \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != ']') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");                            \
                        UNPL(failed) = true;                                                                               \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");                            \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                        LOG_ERROR("Expected ',' between values in array. Invalid JSON array.");                            \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                    }                                                                                                      \
                                                                                                                           \
                /* try reading using user provided reader */                                                               \
                StrIter UNPL(si_before_read) = si;                                                                         \
                { reader }                                                                                                 \
                                                                                                                           \
                                                                                                                           \
                /* if no advancement in read position */                                                                   \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    /* skip the value */                                                                                   \
                    StrIter UNPL(read_si) = JSkipValue(si);                                                                \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    /* skip the value */                                                                                   \
                    StrIter UNPL(read_si) = JSkipValue(si);                                                                \
                                                                                                                           \
                    /* if still no advancement in read position */                                                         \
                                                                                                                           \
                    /* if still no advancement in read position */                                                         \
                    if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        UNPL(failed) = true;                                                                               \
                    if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                    }                                                                                                      \
                        break;                                                                                             \
                    }                                                                                                      \
                    si = UNPL(read_si);                                                                                    \
                }                                                                                                          \
                si = JSkipWhitespace(si);                                                                                  \
                                                                                                                           \
                /* expect a comma after a successful value read in array */                                                \
                UNPL(expect_comma) = true;                                                                                 \
            }                                                                                                              \
                                                                                                                           \
                                                                                                                           \
            /* end of array */                                                                                             \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ']') {                                                 \
                    LOG_ERROR("Invalid end of array. Expected ']'.");                                                      \
            /* end of array */                                                                                             \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ']') {                                                 \
                    LOG_ERROR("Invalid end of array. Expected ']'.");                                                      \
                    UNPL(failed) = true;                                                                                   \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ']') {                                                 \
                    LOG_ERROR("Invalid end of array. Expected ']'.");                                                      \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    LOG_ERROR("Invalid end of array. Expected ']'.");                                                      \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
            }                                                                                                              \
                                                                                                                           \
            StrIter UNPL(saved_si) = si;                                                                                   \
            si                     = JSkipWhitespace(si);                                                                  \
                                                                                                                           \
                                                                                                                           \
            /* starting of an object */                                                                                    \
            char UNPL(jr_c);                                                                                               \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') {                                                     \
                LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
            /* starting of an object */                                                                                    \
            char UNPL(jr_c);                                                                                               \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') {                                                     \
                LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
                si = UNPL(saved_si);                                                                                       \
            if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '{') {                                                     \
                LOG_ERROR("Invalid object start. Expected '{'.");                                                          \
                si = UNPL(saved_si);                                                                                       \
                break;                                                                                                     \
            }                                                                                                              \
            si = JSkipWhitespace(si);                                                                                      \
                                                                                                                           \
            StrIter UNPL(read_si);                                                                                         \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
                                                                                                                           \
            StrIter UNPL(read_si);                                                                                         \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
                                                                                                                           \
            StrIter UNPL(read_si);                                                                                         \
            bool    UNPL(expect_comma) = false;                                                                            \
            bool    UNPL(failed)       = false;                                                                            \
                                                                                                                           \
            /* while not at the end of object. */                                                                          \
                                                                                                                           \
            /* while not at the end of object. */                                                                          \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
            /* while not at the end of object. */                                                                          \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
            while (StrIterPeek(&si, &UNPL(jr_c)) && UNPL(jr_c) != '}') {                                                   \
                if (UNPL(expect_comma)) {                                                                                  \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
                        UNPL(failed) = true;                                                                               \
                    if (UNPL(jr_c) != ',') {                                                                               \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                        LOG_ERROR("Expected ',' after key/value pairs in object. Invalid JSON object.");                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                    }                                                                                                      \
                                                                                                                           \
                /* key start */                                                                                            \
                UNPL(read_si) = JReadString(si, &key);                                                                     \
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                /* key start */                                                                                            \
                UNPL(read_si) = JReadString(si, &key);                                                                     \
                if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                                   \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                    StrDeinit(&key);                                                                                       \
                    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
                }                                                                                                          \
                                                                                                                           \
                si = UNPL(read_si);                                                                                        \
                si = JSkipWhitespace(si);                                                                                  \
                                                                                                                           \
                                                                                                                           \
                                                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != ':') {                                                 \
                    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
                    StrDeinit(&key);                                                                                       \
                    LOG_ERROR("Expected ':' after key string. Failed to read JSON");                                       \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    StrDeinit(&key);                                                                                       \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
                                                                                                                           \
                /* try reading using user provided reader */                                                               \
                StrIter UNPL(si_before_read) = si;                                                                         \
                { reader }                                                                                                 \
                                                                                                                           \
                                                                                                                           \
                /* if no advancement in read position */                                                                   \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    /* skip the value */                                                                                   \
                    UNPL(read_si) = JSkipValue(si);                                                                        \
                if (StrIterIndex(&UNPL(si_before_read)) == StrIterIndex(&si)) {                                            \
                    /* skip the value */                                                                                   \
                    UNPL(read_si) = JSkipValue(si);                                                                        \
                                                                                                                           \
                                                                                                                           \
                                                                                                                           \
                    /* if still no advancement in read position */                                                         \
                    if (StrIterIndex(&UNPL(read_si)) == StrIterIndex(&si)) {                                               \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        StrDeinit(&key);                                                                                   \
                        LOG_ERROR("Failed to parse value. Invalid JSON.");                                                 \
                        StrDeinit(&key);                                                                                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                        StrDeinit(&key);                                                                                   \
                        UNPL(failed) = true;                                                                               \
                        si           = UNPL(saved_si);                                                                     \
                        break;                                                                                             \
                    }                                                                                                      \
                                                                                                                           \
                    LOG_INFO("User skipped reading of '{}' field in JSON object.", key);                                   \
                    si = UNPL(read_si);                                                                                    \
                }                                                                                                          \
                StrDeinit(&key);                                                                                           \
                                                                                                                           \
                /* expect a comma after a successful key-value pair read */                                                \
                UNPL(expect_comma) = true;                                                                                 \
            }                                                                                                              \
                                                                                                                           \
            }                                                                                                              \
                                                                                                                           \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                                                                                                                           \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
            if (!UNPL(failed)) {                                                                                           \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                if (!StrIterPeek(&si, &UNPL(jr_c)) || UNPL(jr_c) != '}') {                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                    LOG_ERROR("Expected end of object '}' but found '{c}'", UNPL(jr_c));                                   \
                    UNPL(failed) = true;                                                                                   \
                    si           = UNPL(saved_si);                                                                         \
                    break;                                                                                                 \
                }                                                                                                          \
    #define JW_INT(j, i)                                                                                                   \
        do {                                                                                                               \
            i64 UNPL(my_int) = (i);                                                                                        \
            StrAppendFmt(&(j), "{}", UNPL(my_int));                                                                        \
        } while (0)
        do {                                                                                                               \
            i64 UNPL(my_int) = (i);                                                                                        \
            StrAppendFmt(&(j), "{}", UNPL(my_int));                                                                        \
        } while (0)
    #define JW_FLT(j, f)                                                                                                   \
        do {                                                                                                               \
            f64 UNPL(my_flt) = (f);                                                                                        \
            StrAppendFmt(&(j), "{}", UNPL(my_flt));                                                                        \
        } while (0)
        do {                                                                                                               \
            f64 UNPL(my_flt) = (f);                                                                                        \
            StrAppendFmt(&(j), "{}", UNPL(my_flt));                                                                        \
        } while (0)
    #define JW_STR(j, s)                                                                                                   \
        do {                                                                                                               \
            const Str *UNPL(jw_s)   = &(s);                                                                                \
            u64        UNPL(jw_len) = StrLen(UNPL(jw_s));                                                                  \
            StrAppendFmt(&(j), "\"{}\"", UNPL(jw_len) ? (Zstr)StrBegin(UNPL(jw_s)) : (Zstr) "");                           \
        do {                                                                                                               \
            const Str *UNPL(jw_s)   = &(s);                                                                                \
            u64        UNPL(jw_len) = StrLen(UNPL(jw_s));                                                                  \
            StrAppendFmt(&(j), "\"{}\"", UNPL(jw_len) ? (Zstr)StrBegin(UNPL(jw_s)) : (Zstr) "");                           \
        } while (0)
            const Str *UNPL(jw_s)   = &(s);                                                                                \
            u64        UNPL(jw_len) = StrLen(UNPL(jw_s));                                                                  \
            StrAppendFmt(&(j), "\"{}\"", UNPL(jw_len) ? (Zstr)StrBegin(UNPL(jw_s)) : (Zstr) "");                           \
        } while (0)
Last updated on