File: NestedStruct.c

package info (click to toggle)
jnr-ffi 2.2.15-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,828 kB
  • sloc: java: 29,131; ansic: 875; xml: 320; sh: 137; makefile: 10
file content (76 lines) | stat: -rw-r--r-- 1,825 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "StructTypes.h"

#define SET_VAL(TYPE) \
    TYPE nested_struct_inner_struct_get_##TYPE(NestedStruct *s) { \
        return s->inner_NumericStruct.val_##TYPE; \
    } \
    TYPE nested_struct_ptr_struct_get_##TYPE(NestedStruct *s) { \
        return s->ptr_NumericStruct->val_##TYPE; \
    } \
    TYPE nested_struct_inner_union_get_##TYPE(NestedStruct *s) { \
        return s->inner_NumericUnion.val_##TYPE; \
    } \
    TYPE nested_struct_ptr_union_get_##TYPE(NestedStruct *s) { \
        return s->ptr_NumericUnion->val_##TYPE; \
    }

#define GET_VAL(TYPE) \
    void nested_struct_inner_struct_set_##TYPE(NestedStruct *s, TYPE v) { \
        s->inner_NumericStruct.val_##TYPE = v; \
    } \
    void nested_struct_ptr_struct_set_##TYPE(NestedStruct *s, TYPE v) { \
        s->ptr_NumericStruct->val_##TYPE = v; \
    } \
    void nested_struct_inner_union_set_##TYPE(NestedStruct *s, TYPE v) { \
        s->inner_NumericUnion.val_##TYPE = v; \
    } \
    void nested_struct_ptr_union_set_##TYPE(NestedStruct *s, TYPE v) { \
        s->ptr_NumericUnion->val_##TYPE = v; \
    }


// ============================= Set Functions ======================

SET_VAL(int8_t);
SET_VAL(int16_t);
SET_VAL(int32_t);
SET_VAL(long);
SET_VAL(int64_t);

SET_VAL(uint8_t);
SET_VAL(uint16_t);
SET_VAL(uint32_t);
SET_VAL(ulong);
SET_VAL(uint64_t);

SET_VAL(float);
SET_VAL(double);

SET_VAL(bool);
SET_VAL(Enum);
SET_VAL(pointer);

// ============================= Get Functions ======================

GET_VAL(int8_t);
GET_VAL(int16_t);
GET_VAL(int32_t);
GET_VAL(long);
GET_VAL(int64_t);

GET_VAL(uint8_t);
GET_VAL(uint16_t);
GET_VAL(uint32_t);
GET_VAL(ulong);
GET_VAL(uint64_t);

GET_VAL(float);
GET_VAL(double);

GET_VAL(bool);
GET_VAL(Enum);
GET_VAL(pointer);

int nested_struct_size() {
    return sizeof(NestedStruct);
}