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
//! Generates C# bindings for [Interoptopus](https://github.com/ralfbiedert/interoptopus).
//!
//!
//! ## Usage
//!
//! In your library or a support project add this:
//!
//! ```
//! # mod my_crate { use interoptopus::{Library}; pub fn ffi_inventory() -> Library { todo!() } }
//! use my_crate::ffi_inventory;
//!
//! #[test]
//! fn generate_csharp_bindings() {
//! use interoptopus::Interop;
//! use interoptopus_backend_csharp::{Generator, CSharpWriter, Config};
//!
//! // Converts an `ffi_inventory()` into C# interop definitions.
//! Generator::new(Config::default(), ffi_inventory()).write_to("Interop.cs")
//! }
//! ```
//!
//! And we might produce something like this:
//!
//! ```cs
//! using System;
//! using System.Runtime.InteropServices;
//!
//! namespace My.Company
//! {
//! public static class InteropClass
//! {
//! public const string NativeLib = "hello_world";
//!
//! /// A function which does something with the vector.
//! [DllImport(NativeLib, CallingConvention = CallingConvention.Cdecl, EntryPoint = "my_game_function")]
//! public static extern Vec3f32 my_game_function(ref Vec3f32 input);
//! }
//!
//! [Serializable]
//! [StructLayout(LayoutKind.Sequential)]
//! public partial struct Vec3f32
//! {
//! public float x;
//! public float y;
//! public float z;
//! }
//! }
//! ```
use IndentWriter;
use Interop;
use ;
pub use crate Config;
pub use crate;
pub use crate CSharpWriter;
/// **Start here**, main converter implementing [`Interop`].