mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-02-07 16:01:52 +08:00
41 lines
2.3 KiB
Django/Jinja
41 lines
2.3 KiB
Django/Jinja
/*[# This is the original template, thus the warning below does not apply to this file #]
|
|
* ============================ WARNING ============================
|
|
* ==== This is an autogenerated file. ====
|
|
* ==== Any changes to this file will be lost when recompiling. ====
|
|
* =================================================================
|
|
*
|
|
* This file contains serializing/deserializing stubs for the functions defined
|
|
* in your interface file.
|
|
*
|
|
*/
|
|
|
|
#include <fibre/bufptr.hpp>
|
|
|
|
[% for intf in interfaces.values() %]
|
|
[% for func in intf.functions.values() %]
|
|
static inline bool [[func.fullname | to_snake_case]]([% for arg in func.in.values() %]std::optional<[[arg.type.c_name]]> in_[[arg.name]], [% endfor %][% for arg in func.out.values() %][[arg.type.c_name]]* out_[[arg.name]], [% endfor %]fibre::cbufptr_t* input_buffer, fibre::bufptr_t* output_buffer) {
|
|
[%- if func.in %]
|
|
bool success = [% for arg in func.in.values() %](in_[[arg.name]].has_value() || (in_[[arg.name]] = fibre::Codec<[[arg.type.c_name]]>::decode(input_buffer)).has_value()[% if arg.optional %] || true[% endif %])[% if not loop.last %]
|
|
&& [% endif %][% endfor %];
|
|
[%- else %]
|
|
bool success = true;
|
|
[%- endif %]
|
|
if (!success) {
|
|
return false;
|
|
}
|
|
[%- if func.implementation %]
|
|
[% if func.out %]std::tuple<[% for arg in func.out.values() %][[arg.type.c_name]][[', ' if not loop.last]][% endfor %]> ret = [% endif %][[func.implementation]]([% for arg in func.in.values() %](*in_[[arg.name]][% if not arg.optional %])[% endif %][[', ' if not loop.last]][% endfor %]);
|
|
[%- else %]
|
|
[% if func.out %]std::tuple<[% for arg in func.out.values() %][[arg.type.c_name]][[', ' if not loop.last]][% endfor %]> ret = [% endif %](*in_[[(func.in.values() | first).name]])->[[func.name]]([% for arg in func.in.values() | skip_first %][% if not arg.optional %]*[% endif %]in_[[arg.name]][[', ' if not loop.last]][% endfor %]);
|
|
[%- endif %]
|
|
[%- if func.out %]
|
|
return [% for arg in func.out.values() %]((out_[[arg.name]] && ((*out_[[arg.name]] = std::get<[[loop.index0]]>(ret)), true)) || fibre::Codec<[[arg.type.c_name]]>::encode(std::get<[[loop.index0]]>(ret), output_buffer))[% if not loop.last %]
|
|
&& [% endif %][% endfor %];
|
|
[%- else %]
|
|
return true;
|
|
[%- endif %]
|
|
}
|
|
[% endfor %]
|
|
[% endfor %]
|
|
|