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
use interoptopus::util::NamespaceMappings; /// The types to write for the given recorder. #[derive(Clone, Debug, Eq, PartialEq)] pub enum WriteTypes { /// Only write items defined in the library for this namespace. Namespace, /// Write types in this namespace and global interoptopus types (e.g., FFIBool) NamespaceAndInteroptopusGlobal, /// Write every type in the library, regardless of namespace association. All, } /// Configures C# code generation. #[derive(Clone, Debug)] pub struct Config { /// The file header, e.g., `// (c) My Company`. pub file_header_comment: String, /// Static class for Interop methods, e.g., `Interop`. pub class: String, /// DLL to load, e.g., `my_library`. pub dll_name: String, /// Maps which namespace id belongs into which FQN (e.g., "common" => "MyCompany.Common"). pub namespace_mappings: NamespaceMappings, /// Namespace ID of _this_ namespace to write (default ""). pub namespace_id: String, /// Whether [`Visibility`](interoptopus::lang::c::Visibility) information should be honored. pub emit_rust_visibility: bool, /// Whether, say, a `x: [u8; 3]` should become 3 `x0: u8, ...` instead. /// /// If this is not set, interop generation with arrays in structr will fail. This is a somewhat /// open issue w.r.t Unity-sans-unsafe support and feedback would be greatly welcome! pub unroll_struct_arrays: bool, /// Which types to write. pub write_types: WriteTypes, /// If enabled bindings will use C# `unsafe` for increased performance; but will need to be enabled in C# project settings to work. pub use_unsafe: bool, /// Also generate markers for easier debugging pub debug: bool, } impl Config {} impl Default for Config { fn default() -> Self { Self { file_header_comment: "// Automatically generated by Interoptopus.".to_string(), class: "Interop".to_string(), dll_name: "library".to_string(), namespace_mappings: NamespaceMappings::new("My.Company"), namespace_id: "".to_string(), emit_rust_visibility: false, unroll_struct_arrays: false, write_types: WriteTypes::NamespaceAndInteroptopusGlobal, use_unsafe: false, debug: false, } } }