Skip to content

LVAL

Description

Creates a temporary, addressable l-value from a given expression x.

Parameters

Name Direction Description
x in The expression whose value needs to be addressable.

Success

Returns addressable version of x as first element of temporary array.

Failure

Function cannot fail - creates temporary storage unconditionally.

Usage example (Cross-references)

Usage examples (Cross-references)
    
                if (!next || next == in) {
                    LOG_ERROR("Failed to read value for placeholder {}", LVAL(arg_index - 1));
                    return NULL;
                }
                    LOG_ERROR(
                        "Input '{.8}' does not match format string '{.8}'",
                        LVAL(in ? in : "(null)"),
                        LVAL(p ? p : "(null)")
                    );
                        "Input '{.8}' does not match format string '{.8}'",
                        LVAL(in ? in : "(null)"),
                        LVAL(p ? p : "(null)")
                    );
                    return NULL;
    
        if (start1 + len > bv1->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector1 length {}", start1, LVAL(start1 + len - 1), bv1->length);
        }
        if (start2 + len > bv2->length) {
        }
        if (start2 + len > bv2->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector2 length {}", start2, LVAL(start2 + len - 1), bv2->length);
        }
    
        if (start1 + len > bv1->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector1 length {}", start1, LVAL(start1 + len - 1), bv1->length);
        }
        if (start2 + len > bv2->length) {
        }
        if (start2 + len > bv2->length) {
            LOG_FATAL("Range [{}:{}] exceeds bitvector2 length {}", start2, LVAL(start2 + len - 1), bv2->length);
        }
                                LOG_ERROR(
                                    "No unicode support '{.6}'. Unicode sequence will be skipped.",
                                    LVAL(StrIterDataAt(&si, StrIterIndex(&si) - 1))
                                );
                                StrIterMustMove(&si, 5);
    
        if (!StrLen(&ns)) {
            LOG_ERROR("Failed to parse number. '{.8}'", LVAL(StrIterDataAt(&saved_si, StrIterIndex(&saved_si))));
            StrDeinit(&ns);
            DefaultAllocatorDeinit(&scratch);
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities
    #include <Misra/Std/Log.h>
    
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities
        Str              s     = StrInit(&alloc);
        StrAppendFmt(&s, "old prefix ");
        StrWriteFmt(&s, "fresh {}", LVAL(42));
        bool ok = (StrLen(&s) == 8) && (StrBegin(&s)[0] == 'f') && (StrBegin(&s)[StrLen(&s) - 1] == '2');
        StrDeinit(&s);
        StrAppendFmt(&s, "AAAAAAAA");
        size before_length = StrLen(&s);
        bool ok            = StrPatchFmt(&s, 2, "{}", LVAL(1234));
        ok                 = ok && StrLen(&s) == before_length;
        ok                 = ok && StrBegin(&s)[0] == 'A' && StrBegin(&s)[1] == 'A';
    
        // Patch that would extend past the end must fail.
        ok = ok && !StrPatchFmt(&s, 6, "{}", LVAL(9999));
        ok = ok && StrLen(&s) == before_length;
        ok = ok && StrBegin(&s)[6] == 'A' && StrBegin(&s)[7] == 'A';
    #include <Misra/Std/Log.h>
    
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities
    #include <Misra/Std/Log.h>
    
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities for deadend testing
    #include <Misra/Std/Memory.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities
    #include <Misra/Std/Container/Vec.h>
    #include <Misra/Std/Log.h>
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities
    
        // Test R-value insert operations
        VecPushBackR(&vec, LVAL(42));
    
        // Check that the element was added
    
        // Test R-value insert at index
        VecInsertR(&vec, LVAL(50), 1);
    
        // Check that the element was inserted
    
        // Test R-value fast insert
        VecInsertFastR(&vec, LVAL(60), 1);
    
        // Check that the element was inserted
    #include <Misra/Std/Log.h>
    #include <Misra/Std/Io.h>
    #include <Misra/Types.h> // For LVAL macro
    
    // Include test utilities
    #ifdef __cplusplus
    #    define ZstrIO(zstr, alloc_ptr)                                                                                    \
            TO_TYPE_SPECIFIC_IO(ZstrAlloc, &LVAL(((ZstrIOArg) {.value = (void *)&(zstr), .allocator = (alloc_ptr)})))
    #else
    #    define ZstrIO(zstr, alloc_ptr)                                                                                    \
    /// Used in following macros
    ///
    #define IOFMT_LVAL_APPEND_COMMA(x) IOFMT(LVAL(x)),
    #define IOFMT_APPEND_COMMA(x)      IOFMT(x),
Last updated on