summaryrefslogtreecommitdiffstats
path: root/src/sbus/codegen/templates/interface.h.tpl
blob: 89da556685d7f91212c768c837c5adbcbdbef6cb (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template name="file-header">
    /*
        Generated by sbus code generator

        Copyright (C) 2017 Red Hat

        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 3 of the License, or
        (at your option) any later version.

        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.

        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */

    #ifndef ${file-guard}
    #define ${file-guard}

    #include "${sbus-path}/sbus_interface_declarations.h"
    #include "${header:invokers}"
    #include "${header:symbols}"
    #include "${header:keygens}"

</template>

<template name="interface">
    /* Interface: ${name} */
    #define SBUS_IFACE_${token}(methods, signals, properties) ({ \
        sbus_interface("${name}", <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
            (methods), (signals), (properties)); \
    })

</template>

<template name="method">
    /* Method: ${interface}.${name} */
    #define SBUS_METHOD_SYNC_${token}(handler, data) ({ \
        SBUS_CHECK_SYNC((handler), (data)<loop name="in">, ${type}</loop><loop name="in-raw">, ${type}</loop><loop name="out">, ${type}</loop><loop name="out-raw">, ${type}</loop>); \
        sbus_method_sync("${name}", \
            &_sbus_args_${token}, \
            <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
            _sbus_invoke_in_${input-signature}_out_${output-signature}_send, \
            <toggle line name="keygen">_sbus_key_${key-signature}<loop name="key-argument">_${key-index}</loop><or>NULL</toggle>, \
            (handler), (data)); \
    })

    #define SBUS_METHOD_ASYNC_${token}(handler_send, handler_recv, data) ({ \
        SBUS_CHECK_SEND((handler_send), (data)<loop name="in">, ${type}</loop><loop name="in-raw">, ${type}</loop><loop name="out-raw">, ${type}</loop>); \
        SBUS_CHECK_RECV((handler_recv)<loop name="out">, ${type}</loop>); \
        sbus_method_async("${name}", \
            &_sbus_args_${token}, \
            <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
            _sbus_invoke_in_${input-signature}_out_${output-signature}_send, \
            <toggle line name="keygen">_sbus_key_${key-signature}<loop name="key-argument">_${key-index}</loop><or>NULL</toggle>, \
            (handler_send), (handler_recv), (data)); \
    })

</template>

<template name="signal">
    /* Signal: ${interface}.${name} */
    #define SBUS_SIGNAL_EMITS_${token}() ({ \
        sbus_signal("${name}", \
            _sbus_args_${token}, \
            <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>); \
    })

    #define SBUS_SIGNAL_SYNC_${token}(path, handler, data) ({ \
        SBUS_CHECK_SYNC((handler), (data)<loop name="in">, ${type}</loop><loop name="in-raw">, ${type}</loop>); \
        sbus_listener_sync("${interface}", "${name}", (path), \
            _sbus_invoke_in_${input-signature}_out_${output-signature}_send, \
            <toggle line name="keygen">_sbus_key_${key-signature}<loop name="key-argument">_${key-index}</loop><or>NULL</toggle>, \
            (handler), (data)); \
    })

    #define SBUS_SIGNAL_ASYNC_${token}(path, handler_send, handler_recv, data) ({ \
        SBUS_CHECK_SEND((handler_send), (data)<loop name="in">, ${type}</loop><loop name="in-raw">, ${type}</loop>); \
        SBUS_CHECK_RECV((handler_recv)); \
        sbus_listener_async("${interface}", "${name}", (path), \
            _sbus_invoke_in_${input-signature}_out_${output-signature}_send, \
            <toggle line name="keygen">_sbus_key_${key-signature}<loop name="key-argument">_${key-index}</loop><or>NULL</toggle>, \
            (handler_send), (handler_recv), (data)); \
    })

</template>

<template name="property">
    /* Property: ${interface}.${name} */
    #define SBUS_GETTER_SYNC_${token}(handler, data) ({ \
        SBUS_CHECK_SYNC((handler), (data)<loop name="out">, ${type}</loop><loop name="out-raw">, ${type}</loop>); \
        sbus_property_sync("${name}", "${type}", SBUS_PROPERTY_READABLE, \
           <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
           _sbus_invoke_in__out_${output-signature}_send, \
           (handler), (data)); \
    })

    #define SBUS_GETTER_ASYNC_${token}(handler_send, handler_recv, data) ({ \
        SBUS_CHECK_SEND((handler_send), (data)<loop name="out-raw">, ${type}</loop>); \
        SBUS_CHECK_RECV((handler_recv)<loop name="out">, ${type}</loop>); \
        sbus_property_async("${name}", "${type}", SBUS_PROPERTY_READABLE, \
           <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
           _sbus_invoke_in__out_${output-signature}_send, \
           (handler_send), (handler_recv), (data)); \
    })

    #define SBUS_SETTER_SYNC_${token}(handler, data) ({\
        SBUS_CHECK_SYNC((handler), (data)<loop name="in">, ${type}</loop><loop name="in-raw">, ${type}</loop>); \
        sbus_property_sync("${name}", "${type}", SBUS_PROPERTY_WRITABLE, \
           <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
           _sbus_invoke_in_${input-signature}_out__send, \
           (handler), (data)); \
    })

    #define SBUS_SETTER_ASYNC_${token}(handler_send, handler_recv, data) ({ \
        SBUS_CHECK_SEND((handler_send), (data)<loop name="in">, ${type}</loop><loop name="in-raw">, ${type}</loop>); \
        SBUS_CHECK_RECV((handler_recv)); \
        sbus_property_async("${name}", "${type}", SBUS_PROPERTY_WRITABLE, \
           <toggle line name="annotations">_sbus_annotations_${token}<or>NULL</toggle>, \
           _sbus_invoke_in_${input-signature}_out__send, \
           (handler_send), (handler_recv), (data)); \
    })

</template>

<template name="file-footer">
    #endif /* ${file-guard} */
</template>