targets/var_access.c
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 02 Feb 2021 10:43:43 +0100
branchsvghmi
changeset 3120 7ecaefe38f6f
parent 2825 b4b69e85ed53
child 3395 93ad018fb602
permissions -rw-r--r--
SVGHMI: Remove recursive walk in parsed widget to find unique type and use xsl:key instead.
2767
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     1
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     2
#define __Unpack_case_t(TYPENAME) \
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     3
        case TYPENAME##_ENUM :\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     4
            *flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     5
            forced_value_p = *real_value_p = &((__IEC_##TYPENAME##_t *)varp)->value;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     6
            break;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     7
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     8
#define __Unpack_case_p(TYPENAME)\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
     9
        case TYPENAME##_O_ENUM :\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    10
            *flags = __IEC_OUTPUT_FLAG;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    11
        case TYPENAME##_P_ENUM :\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    12
            *flags |= ((__IEC_##TYPENAME##_p *)varp)->flags;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    13
            *real_value_p = ((__IEC_##TYPENAME##_p *)varp)->value;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    14
            forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    15
            break;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    16
2825
b4b69e85ed53 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2767
diff changeset
    17
#define __Is_a_string(dsc) (dsc->type == STRING_ENUM)   ||\
b4b69e85ed53 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2767
diff changeset
    18
                           (dsc->type == STRING_P_ENUM) ||\
b4b69e85ed53 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2767
diff changeset
    19
                           (dsc->type == STRING_O_ENUM)
b4b69e85ed53 plc_debug.c/var_acces.c : whitespace cleanup and other cosmetic changes
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2767
diff changeset
    20
2767
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    21
static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    22
{
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    23
    void *varp = dsc->ptr;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    24
    void *forced_value_p = NULL;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    25
    *flags = 0;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    26
    /* find data to copy*/
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    27
    switch(dsc->type){
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    28
        __ANY(__Unpack_case_t)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    29
        __ANY(__Unpack_case_p)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    30
    default:
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    31
        break;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    32
    }
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    33
    if (*flags & __IEC_FORCE_FLAG)
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    34
        return forced_value_p;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    35
    return *real_value_p;
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    36
}
302347f48193 svghmi.c : deduplicated variable access code borrowed from plc_debug.c. Added targets/var_access.c.
Edouard Tisserant
parents:
diff changeset
    37