2 // Template to call into rust. Used in several places.
3 // Variable names in `arg_list_decl` should match up with arg lists
4 // passed to rust via `_arg_list_ffi_call` (we use `var_name_rb` in `lower_rb`)
7 {%- macro to_ffi_call(func) -%}
8 {%- match func.throws_name() -%}
9 {%- when Some with (e) -%}
10 {{ ci.namespace()|class_name_rb }}.rust_call_with_error({{ e|class_name_rb }},
12 {{ ci.namespace()|class_name_rb }}.rust_call(
14 :{{ func.ffi_func().name() }},
15 {%- call _arg_list_ffi_call(func) -%}
19 {%- macro to_ffi_call_with_prefix(prefix, func) -%}
20 {%- match func.throws_name() -%}
21 {%- when Some with (e) -%}
22 {{ ci.namespace()|class_name_rb }}.rust_call_with_error({{ e|class_name_rb }},
24 {{ ci.namespace()|class_name_rb }}.rust_call(
26 :{{ func.ffi_func().name() }},
28 {%- call _arg_list_ffi_call(func) -%}
32 {%- macro _arg_list_ffi_call(func) %}
33 {%- for arg in func.arguments() %}
34 {{- arg.name()|lower_rb(arg.as_type().borrow()) }}
35 {%- if !loop.last %},{% endif %}
40 // Arglist as used in Ruby declarations of methods, functions and constructors.
41 // Note the var_name_rb and type_rb filters.
44 {% macro arg_list_decl(func) %}
45 {%- for arg in func.arguments() -%}
46 {{ arg.name()|var_name_rb }}
47 {%- match arg.default_value() %}
48 {%- when Some with(literal) %} = {{ literal|literal_rb }}
51 {%- if !loop.last %}, {% endif -%}
56 // Arglist as used in the UniFFILib function declarations.
57 // Note unfiltered name but type_ffi filters.
59 {%- macro arg_list_ffi_decl(func) %}
60 [{%- for arg in func.arguments() -%}{{ arg.type_().borrow()|type_ffi }}, {% endfor -%} RustCallStatus.by_ref]
63 {%- macro coerce_args(func) %}
64 {%- for arg in func.arguments() %}
65 {{ arg.name() }} = {{ arg.name()|coerce_rb(ci.namespace()|class_name_rb, arg.as_type().borrow()) -}}
69 {%- macro coerce_args_extra_indent(func) %}
70 {%- for arg in func.arguments() %}
71 {{ arg.name() }} = {{ arg.name()|coerce_rb(ci.namespace()|class_name_rb, arg.as_type().borrow()) }}