2023-03-04 05:39:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// See https://aka.ms/new-console-template for more information
|
2023-02-27 22:18:10 +00:00
|
|
|
|
//using Csbindgen;
|
2023-02-28 01:22:34 +00:00
|
|
|
|
using CsBindgen;
|
2023-03-04 05:39:45 +00:00
|
|
|
|
using System.Buffers.Text;
|
2023-02-28 09:39:52 +00:00
|
|
|
|
using System.Reflection;
|
2023-02-26 18:31:44 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Runtime.InteropServices;
|
2023-03-04 05:39:45 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-02-26 18:31:44 +00:00
|
|
|
|
unsafe
|
|
|
|
|
{
|
2023-03-03 08:49:05 +00:00
|
|
|
|
var a = false;
|
|
|
|
|
var b = false;
|
|
|
|
|
var c = false;
|
2023-03-04 05:39:45 +00:00
|
|
|
|
Console.WriteLine(Encoding.Default);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var p = LibRust.unsafe_return_string();
|
|
|
|
|
|
|
|
|
|
var s = Encoding.UTF8.GetString(p, 5);
|
|
|
|
|
Console.WriteLine(s);
|
2023-02-26 18:31:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-03-03 08:49:05 +00:00
|
|
|
|
var z = LibRust.my_bool(true, false, true, &a, &b, &c);
|
2023-02-26 18:31:44 +00:00
|
|
|
|
|
|
|
|
|
|
2023-03-03 08:49:05 +00:00
|
|
|
|
Console.WriteLine(a);
|
|
|
|
|
Console.WriteLine(b);
|
|
|
|
|
Console.WriteLine(c);
|
|
|
|
|
Console.WriteLine(z);
|
2023-02-26 18:31:44 +00:00
|
|
|
|
|
|
|
|
|
}
|
2023-02-28 09:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
2023-03-03 08:49:05 +00:00
|
|
|
|
public static unsafe partial class LibraryImportNativeMethods
|
|
|
|
|
{
|
|
|
|
|
const string __DllName = "csbindgen_tests";
|
2023-02-28 09:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
2023-03-03 08:49:05 +00:00
|
|
|
|
[LibraryImport(__DllName, EntryPoint = "my_bool")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.U1)]
|
|
|
|
|
public static partial bool my_bool([MarshalAs(UnmanagedType.U1)] bool x, [MarshalAs(UnmanagedType.U1)] bool y, [MarshalAs(UnmanagedType.U1)] bool z, bool* xr, bool* yr, bool* zr);
|
2023-02-28 09:39:52 +00:00
|
|
|
|
|
|
|
|
|
|
2023-03-04 05:39:45 +00:00
|
|
|
|
|
|
|
|
|
[LibraryImport(__DllName)]
|
|
|
|
|
public static partial void foo(Foo f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct Foo
|
|
|
|
|
{
|
|
|
|
|
[MarshalAs(UnmanagedType.U1)] public bool A;
|
2023-02-28 09:39:52 +00:00
|
|
|
|
}
|