1#
2# Copyright 2016, Data61
3# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4# ABN 41 687 119 230.
5#
6# This software may be distributed and modified according to the terms of
7# the BSD 2-Clause license. Note that NO WARRANTY is provided.
8# See "LICENSE_BSD2.txt" for details.
9#
10# @TAG(D61_BSD)
11#
12
13{{py: first = True}}
14{{return_type}} {{fname}}(
15        {{for type, itype, name, mode, dr, apfx, aref, apsfx in calist}}
16            {{if first}}
17                {{py: first = False}}
18            {{else}}
19                ,
20            {{endif}}
21            {{type}} {{name}}
22        {{endfor}}
23    ) {\n
24
25____int rpc__error_;\n
26
27{{if return_type != 'void'}}
28    ____{{return_type}} __ret__;\n
29    ____memset(&__ret__, 0, sizeof({{return_type}}));\n
30{{endif}}
31\n\n
32
33____rpc_init("{{fname}}", RPC_{{fname.upper()}});\n
34
35{{if connect_ep != ''}}
36    ____rpc_set_dest({{connect_ep}});\n
37{{elif default_connect_ep != ''}}
38    ____rpc_set_dest({{default_connect_ep}});\n
39{{endif}}
40
41{{for type, itype, name, mode, dr, apfx, aref, apsfx in alist}}
42    ____rpc_push_{{itype}}{{apfx}}({{aref}}{{name}}
43        {{if itype in ['buf', 'bufref']}}
44            , sizeof({{type.replace('*', '')}})
45        {{endif}}
46    {{apsfx}});\n
47{{endfor}}
48
49\n\n
50____rpc__error_ = rpc_call_server();\n
51____if (rpc__error_) {\n
52________rpc_release();\n
53        {{if return_type != 'void':}}
54            ________return __ret__;\n
55        {{endif}}
56____}\n\n
57
58
59{{for type, itype, name, mode, dr, apfx, aref, apsfx in oalist}}
60    ____
61
62    {{if itype in ['uint', 'cptr']}}
63        {{name}} = ({{type}}) rpc_pop_{{itype}}();\n
64    {{else}}
65        rpc_pop_{{itype}}{{apfx}}(
66            {{aref}}{{name}}
67            {{if itype in ['buf', 'bufref']}}
68                , sizeof({{type.replace('*', '')}})
69            {{endif}}
70            {{apsfx}}
71        );\n
72    {{endif}}
73
74{{endfor}}
75
76{{for type, itype, name, mode, dr, apfx, aref, apsfx in oalist}}
77    {{if itype == 'cptr'}}
78        ____{{name}} = rpc_copyout_cptr({{name}});\n
79    {{endif}}
80{{endfor}}
81
82____rpc_release();\n
83
84    {{if return_type != 'void'}}
85        ____return __ret__;\n
86    {{endif}}
87}
88\n
89