targets/var_access.c
author Mario de Sousa <msousa@fe.up.pt>
Mon, 21 Dec 2020 22:35:07 +0000
changeset 2716 ebb2595504f0
parent 2632 534387caf43d
child 2710 aaa1dc426213
permissions -rw-r--r--
merge
2632
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     1
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     2
#define __Unpack_case_t(TYPENAME) \
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     3
        case TYPENAME##_ENUM :\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     4
            *flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     5
            forced_value_p = *real_value_p = &((__IEC_##TYPENAME##_t *)varp)->value;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     6
            break;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     7
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     8
#define __Unpack_case_p(TYPENAME)\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
     9
        case TYPENAME##_O_ENUM :\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    10
            *flags = __IEC_OUTPUT_FLAG;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    11
        case TYPENAME##_P_ENUM :\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    12
            *flags |= ((__IEC_##TYPENAME##_p *)varp)->flags;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    13
            *real_value_p = ((__IEC_##TYPENAME##_p *)varp)->value;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    14
            forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    15
            break;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    16
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    17
static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    18
{
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    19
    void *varp = dsc->ptr;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    20
    void *forced_value_p = NULL;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    21
    *flags = 0;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    22
    /* find data to copy*/
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    23
    switch(dsc->type){
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    24
        __ANY(__Unpack_case_t)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    25
        __ANY(__Unpack_case_p)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    26
    default:
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    27
        break;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    28
    }
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    29
    if (*flags & __IEC_FORCE_FLAG)
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    30
        return forced_value_p;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    31
    return *real_value_p;
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    32
}
534387caf43d variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
Edouard Tisserant
parents:
diff changeset
    33