Debian Codegraph @

third_party/rust/uniffi_bindgen/src/bindings/swift/templates/BridgingHeaderTemplate.h

raw
1 // This file was autogenerated by some hot garbage in the `uniffi` crate.
2 // Trust me, you don't want to mess with it!
3
4 #pragma once
5
6 #include <stdbool.h>
7 #include <stddef.h>
8 #include <stdint.h>
9
10 // The following structs are used to implement the lowest level
11 // of the FFI, and thus useful to multiple uniffied crates.
12 // We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H.
13 #ifdef UNIFFI_SHARED_H
14 // We also try to prevent mixing versions of shared uniffi header structs.
15 // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4
16 #ifndef UNIFFI_SHARED_HEADER_V4
17 #error Combining helper code from multiple versions of uniffi is not supported
18 #endif // ndef UNIFFI_SHARED_HEADER_V4
19 #else
20 #define UNIFFI_SHARED_H
21 #define UNIFFI_SHARED_HEADER_V4
22 // ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
23 // ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
24
25 typedef struct RustBuffer
26 {
27 uint64_t capacity;
28 uint64_t len;
29 uint8_t *_Nullable data;
30 } RustBuffer;
31
32 typedef struct ForeignBytes
33 {
34 int32_t len;
35 const uint8_t *_Nullable data;
36 } ForeignBytes;
37
38 // Error definitions
39 typedef struct RustCallStatus {
40 int8_t code;
41 RustBuffer errorBuf;
42 } RustCallStatus;
43
44 // ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
45 // ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
46 #endif // def UNIFFI_SHARED_H
47
48 {%- for def in ci.ffi_definitions() %}
49 #ifndef {{ def.name()|if_guard_name }}
50 #define {{ def.name()|if_guard_name }}
51 {%- match def %}
52 {% when FfiDefinition::CallbackFunction(callback) %}
53 typedef
54 {%- match callback.return_type() %}{% when Some(return_type) %} {{ return_type|header_ffi_type_name }} {% when None %} void {% endmatch -%}
55 (*{{ callback.name()|ffi_callback_name }})(
56 {%- for arg in callback.arguments() -%}
57 {{ arg.type_().borrow()|header_ffi_type_name }}
58 {%- if !loop.last || callback.has_rust_call_status_arg() %}, {% endif %}
59 {%- endfor -%}
60 {%- if callback.has_rust_call_status_arg() %}
61 RustCallStatus *_Nonnull uniffiCallStatus
62 {%- endif %}
63 );
64 {% when FfiDefinition::Struct(struct_item) %}
65 typedef struct {{ struct_item.name()|ffi_struct_name }} {
66 {%- for field in struct_item.fields() %}
67 {{ field.type_().borrow()|header_ffi_type_name }} {{ field.name()|var_name }};
68 {%- endfor %}
69 } {{ struct_item.name()|ffi_struct_name }};
70 {% when FfiDefinition::Function(func) %}
71 {% match func.return_type() -%}{%- when Some(type_) %}{{ type_|header_ffi_type_name }}{% when None %}void{% endmatch %} {{ func.name() }}(
72 {%- if func.arguments().len() > 0 %}
73 {%- for arg in func.arguments() %}
74 {{- arg.type_().borrow()|header_ffi_type_name }} {{ arg.name() -}}{% if !loop.last || func.has_rust_call_status_arg() %}, {% endif %}
75 {%- endfor %}
76 {%- if func.has_rust_call_status_arg() %}RustCallStatus *_Nonnull out_status{% endif %}
77 {%- else %}
78 {%- if func.has_rust_call_status_arg() %}RustCallStatus *_Nonnull out_status{%- else %}void{% endif %}
79 {% endif %}
80 );
81 {%- endmatch %}
82 #endif
83 {%- endfor %}
84
85 {% import "macros.swift" as swift %}