Skip to content

MisraScope

Description

Reserved identifier used by Scope-aware public macros to find the “current” allocator. The Scope and ScopeWith macros introduce this name into the enclosing block; tier-1 public macros (VecInit, …) expand to references to it. Outside any Scope/ScopeWith block the name is undeclared and the call site is a compile error.

Do not declare a local variable with this name in user code.

Usage example (Cross-references)

Usage examples (Cross-references)
    ///
    #define KvConfigInit(...) MISRA_OVERLOAD(KvConfigInit, __VA_ARGS__)
    #define KvConfigInit_0()  KvConfigInit_1(MisraScope)
    #define KvConfigInit_1(allocator_ptr)                                                                                  \
        MapInitFull_9(                                                                                                     \
    #define ReadCompleteFile(...) MISRA_OVERLOAD(ReadCompleteFile, __VA_ARGS__)
    #define ReadCompleteFile_4(filename, data, file_size, capacity)                                                        \
        read_complete_file((filename), (data), (file_size), (capacity), MisraScope)
    #define ReadCompleteFile_5(filename, data, file_size, capacity, allocator)                                             \
        read_complete_file((filename), (data), (file_size), (capacity), (allocator))
                       _scope_loop_##name = NULL)                                                                          \
            for (Allocator *name               = &_scope_user_##name.base,                                                 \
                           *MisraScope         = &_scope_internal_##name.base,                                             \
                           *_scope_done_##name = name;                                                                     \
                 _scope_done_##name;                                                                                       \
    ///
    #define ScopeWith(alloc_ptr)                                                                                           \
        for (Allocator *MisraScope = (alloc_ptr), *_scope_with_done = MisraScope; _scope_with_done; _scope_with_done = NULL)
    
    ///
    ///
    #define BitVecInit(...) MISRA_OVERLOAD(BitVecInit, __VA_ARGS__)
    #define BitVecInit_0()  BitVecInit_1(MisraScope)
    #ifdef __cplusplus
    #    define BitVecInit_1(allocator_ptr)                                                                                \
    ///
    #define FloatInit(...)             MISRA_OVERLOAD(FloatInit, __VA_ARGS__)
    #define FloatInit_0()              ((Float) {.negative = false, .significand = IntInit_1(MisraScope), .exponent = 0})
    #define FloatInit_1(allocator_ptr) ((Float) {.negative = false, .significand = IntInit_1(allocator_ptr), .exponent = 0})
    #define MapInitFull(...) MISRA_OVERLOAD(MapInitFull, __VA_ARGS__)
    #define MapInitFull_8(hash_fn, compare_fn, vcmp, kci, kcd, vci, vcd, policy_value)                                     \
        MapInitFull_9(hash_fn, compare_fn, vcmp, kci, kcd, vci, vcd, policy_value, MisraScope)
    
    ///
    ///
    #define MapInit(...)                   MISRA_OVERLOAD(MapInit, __VA_ARGS__)
    #define MapInit_2(hash_fn, compare_fn) MapInit_3(hash_fn, compare_fn, MisraScope)
    #define MapInit_3(hash_fn, compare_fn, typed_alloc_ptr)                                                                \
        MapInitFull_9((hash_fn), (compare_fn), NULL, NULL, NULL, NULL, NULL, MisraMapPolicyLinear, typed_alloc_ptr)
    #define MapInitWithValueCompare(...) MISRA_OVERLOAD(MapInitWithValueCompare, __VA_ARGS__)
    #define MapInitWithValueCompare_3(hash_fn, compare_fn, value_compare_fn)                                               \
        MapInitWithValueCompare_4(hash_fn, compare_fn, value_compare_fn, MisraScope)
    #define MapInitWithValueCompare_4(hash_fn, compare_fn, value_compare_fn, typed_alloc_ptr)                              \
        MapInitFull_9(                                                                                                     \
    #define MapInitWithPolicy(...) MISRA_OVERLOAD(MapInitWithPolicy, __VA_ARGS__)
    #define MapInitWithPolicy_3(hash_fn, compare_fn, policy_value)                                                         \
        MapInitWithPolicy_4(hash_fn, compare_fn, policy_value, MisraScope)
    #define MapInitWithPolicy_4(hash_fn, compare_fn, policy_value, typed_alloc_ptr)                                        \
        MapInitFull_9((hash_fn), (compare_fn), NULL, NULL, NULL, NULL, NULL, (policy_value), typed_alloc_ptr)
    #define MapInitWithValueCompareAndPolicy(...) MISRA_OVERLOAD(MapInitWithValueCompareAndPolicy, __VA_ARGS__)
    #define MapInitWithValueCompareAndPolicy_4(hash_fn, compare_fn, value_compare_fn, policy_value)                        \
        MapInitWithValueCompareAndPolicy_5(hash_fn, compare_fn, value_compare_fn, policy_value, MisraScope)
    #define MapInitWithValueCompareAndPolicy_5(hash_fn, compare_fn, value_compare_fn, policy_value, typed_alloc_ptr)       \
        MapInitFull_9((hash_fn), (compare_fn), (value_compare_fn), NULL, NULL, NULL, NULL, (policy_value), typed_alloc_ptr)
    #define MapInitWithDeepCopy(...) MISRA_OVERLOAD(MapInitWithDeepCopy, __VA_ARGS__)
    #define MapInitWithDeepCopy_6(hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd)                                 \
        MapInitWithDeepCopy_7(hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd, MisraScope)
    #define MapInitWithDeepCopy_7(hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd, typed_alloc_ptr)                \
        MapInitFull_9(                                                                                                     \
    #define MapInitT(m, ...) MISRA_OVERLOAD(MapInitT, m, __VA_ARGS__)
    #ifdef __cplusplus
    #    define MapInitT_3(m, hash_fn, compare_fn) (TYPE_OF(m) MapInit_3((hash_fn), (compare_fn), MisraScope))
    #    define MapInitT_4(m, hash_fn, compare_fn, typed_alloc_ptr)                                                        \
            (TYPE_OF(m) MapInit_3((hash_fn), (compare_fn), typed_alloc_ptr))
            (TYPE_OF(m) MapInit_3((hash_fn), (compare_fn), typed_alloc_ptr))
    #else
    #    define MapInitT_3(m, hash_fn, compare_fn) ((TYPE_OF(m))MapInit_3((hash_fn), (compare_fn), MisraScope))
    #    define MapInitT_4(m, hash_fn, compare_fn, typed_alloc_ptr)                                                        \
            ((TYPE_OF(m))MapInit_3((hash_fn), (compare_fn), typed_alloc_ptr))
    #    define MapInitWithDeepCopyT_7(m, hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd)                         \
            (TYPE_OF(m)                                                                                                    \
                 MapInitWithDeepCopy_7((hash_fn), (compare_fn), (key_ci), (key_cd), (value_ci), (value_cd), MisraScope))
    #    define MapInitWithDeepCopyT_8(m, hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd, typed_alloc_ptr)        \
            (TYPE_OF(                                                                                                      \
    #    define MapInitWithDeepCopyT_7(m, hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd)                         \
            ((TYPE_OF(m))                                                                                                  \
                 MapInitWithDeepCopy_7((hash_fn), (compare_fn), (key_ci), (key_cd), (value_ci), (value_cd), MisraScope))
    #    define MapInitWithDeepCopyT_8(m, hash_fn, compare_fn, key_ci, key_cd, value_ci, value_cd, typed_alloc_ptr)        \
            ((                                                                                                             \
    ///
    #define ListInit(...)               MISRA_OVERLOAD(ListInit, __VA_ARGS__)
    #define ListInit_0()                ListInitWithDeepCopy_3(NULL, NULL, MisraScope)
    #define ListInit_1(typed_alloc_ptr) ListInitWithDeepCopy_3(NULL, NULL, typed_alloc_ptr)
    ///
    #define ListInitT(l, ...)               MISRA_OVERLOAD(ListInitT, l, __VA_ARGS__)
    #define ListInitT_1(l)                  ListInitWithDeepCopyT_4(l, NULL, NULL, MisraScope)
    #define ListInitT_2(l, typed_alloc_ptr) ListInitWithDeepCopyT_4(l, NULL, NULL, typed_alloc_ptr)
    ///
    #define ListInitWithDeepCopy(...)      MISRA_OVERLOAD(ListInitWithDeepCopy, __VA_ARGS__)
    #define ListInitWithDeepCopy_2(ci, cd) ListInitWithDeepCopy_3(ci, cd, MisraScope)
    #define ListInitWithDeepCopy_3(ci, cd, typed_alloc_ptr)                                                                \
        {.head        = NULL,                                                                                              \
    #define ListInitWithDeepCopyT(l, ...) MISRA_OVERLOAD(ListInitWithDeepCopyT, l, __VA_ARGS__)
    #ifdef __cplusplus
    #    define ListInitWithDeepCopyT_3(l, ci, cd) (TYPE_OF(l) ListInitWithDeepCopy_3(ci, cd, MisraScope))
    #    define ListInitWithDeepCopyT_4(l, ci, cd, typed_alloc_ptr)                                                        \
            (TYPE_OF(l) ListInitWithDeepCopy_3(ci, cd, typed_alloc_ptr))
            (TYPE_OF(l) ListInitWithDeepCopy_3(ci, cd, typed_alloc_ptr))
    #else
    #    define ListInitWithDeepCopyT_3(l, ci, cd) ((TYPE_OF(l))ListInitWithDeepCopy_3(ci, cd, MisraScope))
    #    define ListInitWithDeepCopyT_4(l, ci, cd, typed_alloc_ptr)                                                        \
            ((TYPE_OF(l))ListInitWithDeepCopy_3(ci, cd, typed_alloc_ptr))
    
    #define StrInitFromCstr(...)                MISRA_OVERLOAD(StrInitFromCstr, __VA_ARGS__)
    #define StrInitFromCstr_2(cstr, len)        str_init_from_cstr((cstr), (len), MisraScope)
    #define StrInitFromCstr_3(cstr, len, alloc) str_init_from_cstr((cstr), (len), ALLOCATOR_OF(alloc))
    #define StrInit(...) MISRA_OVERLOAD(StrInit, __VA_ARGS__)
    #ifdef __cplusplus
    #    define StrInit_0()          (Str VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
    #else
    #    define StrInit_1(alloc_ptr) (Str VecInit_1(alloc_ptr))
    #else
    #    define StrInit_0()          ((Str)VecInit_1(MisraScope))
    #    define StrInit_1(alloc_ptr) ((Str)VecInit_1(alloc_ptr))
    #endif
    ///
    #define IntInit(...)             MISRA_OVERLOAD(IntInit, __VA_ARGS__)
    #define IntInit_0()              ((Int) {.bits = BitVecInit_1(MisraScope)})
    #define IntInit_1(allocator_ptr) ((Int) {.bits = BitVecInit_1(allocator_ptr)})
    ///
    #define VecInit(...) MISRA_OVERLOAD(VecInit, __VA_ARGS__)
    #define VecInit_0()  VecInit_1(MisraScope)
    #define VecInit_1(allocator_ptr)                                                                                       \
        {.length      = 0,                                                                                                 \
    #define VecInitT(v, ...) MISRA_OVERLOAD(VecInitT, v, __VA_ARGS__)
    #ifdef __cplusplus
    #    define VecInitT_1(v)            (TYPE_OF(v) VecInit_1(MisraScope))
    #    define VecInitT_2(v, alloc_ptr) (TYPE_OF(v) VecInit_1(alloc_ptr))
    #else
    #    define VecInitT_2(v, alloc_ptr) (TYPE_OF(v) VecInit_1(alloc_ptr))
    #else
    #    define VecInitT_1(v)            ((TYPE_OF(v))VecInit_1(MisraScope))
    #    define VecInitT_2(v, alloc_ptr) ((TYPE_OF(v))VecInit_1(alloc_ptr))
    #endif
    ///
    #define VecInitWithDeepCopy(...)      MISRA_OVERLOAD(VecInitWithDeepCopy, __VA_ARGS__)
    #define VecInitWithDeepCopy_2(ci, cd) VecInitWithDeepCopy_3(ci, cd, MisraScope)
    #define VecInitWithDeepCopy_3(ci, cd, allocator_ptr)                                                                   \
        {.length      = 0,                                                                                                 \
    #define VecInitWithDeepCopyT(v, ...) MISRA_OVERLOAD(VecInitWithDeepCopyT, v, __VA_ARGS__)
    #ifdef __cplusplus
    #    define VecInitWithDeepCopyT_3(v, ci, cd)            (TYPE_OF(v) VecInitWithDeepCopy_3(ci, cd, MisraScope))
    #    define VecInitWithDeepCopyT_4(v, ci, cd, alloc_ptr) (TYPE_OF(v) VecInitWithDeepCopy_3(ci, cd, alloc_ptr))
    #else
    #    define VecInitWithDeepCopyT_4(v, ci, cd, alloc_ptr) (TYPE_OF(v) VecInitWithDeepCopy_3(ci, cd, alloc_ptr))
    #else
    #    define VecInitWithDeepCopyT_3(v, ci, cd)            ((TYPE_OF(v))VecInitWithDeepCopy_3(ci, cd, MisraScope))
    #    define VecInitWithDeepCopyT_4(v, ci, cd, alloc_ptr) ((TYPE_OF(v))VecInitWithDeepCopy_3(ci, cd, alloc_ptr))
    #endif
    
    #define GraphInit(...)               MISRA_OVERLOAD(GraphInit, __VA_ARGS__)
    #define GraphInit_0()                GraphInitWithDeepCopy_3(NULL, NULL, MisraScope)
    #define GraphInit_1(typed_alloc_ptr) GraphInitWithDeepCopy_3(NULL, NULL, typed_alloc_ptr)
    
    #define GraphInitT(g, ...)               MISRA_OVERLOAD(GraphInitT, g, __VA_ARGS__)
    #define GraphInitT_1(g)                  GraphInitWithDeepCopyT_4((g), NULL, NULL, MisraScope)
    #define GraphInitT_2(g, typed_alloc_ptr) GraphInitWithDeepCopyT_4((g), NULL, NULL, typed_alloc_ptr)
    
    #define GraphInitWithDeepCopy(...)                       MISRA_OVERLOAD(GraphInitWithDeepCopy, __VA_ARGS__)
    #define GraphInitWithDeepCopy_2(ci, cd)                  GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), MisraScope)
    #define GraphInitWithDeepCopy_3(ci, cd, typed_alloc_ptr) GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), typed_alloc_ptr)
    #define GraphInitWithDeepCopyT(g, ...) MISRA_OVERLOAD(GraphInitWithDeepCopyT, g, __VA_ARGS__)
    #ifdef __cplusplus
    #    define GraphInitWithDeepCopyT_3(g, ci, cd) (TYPE_OF(g) GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), MisraScope))
    #    define GraphInitWithDeepCopyT_4(g, ci, cd, typed_alloc_ptr)                                                       \
            (TYPE_OF(g) GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), typed_alloc_ptr))
            (TYPE_OF(g) GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), typed_alloc_ptr))
    #else
    #    define GraphInitWithDeepCopyT_3(g, ci, cd) ((TYPE_OF(g))GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), MisraScope))
    #    define GraphInitWithDeepCopyT_4(g, ci, cd, typed_alloc_ptr)                                                       \
            ((TYPE_OF(g))GRAPH_INIT_WITH_DEEP_COPY_VALUE((ci), (cd), typed_alloc_ptr))
Last updated on