From fe65165079ea37e22e80b45e5d1bd62ae0632720 Mon Sep 17 00:00:00 2001 From: shun suzuki Date: Mon, 4 Nov 2024 09:50:41 +0900 Subject: [PATCH] mv ffi into native methods --- src/AUTD3Sharp.cs | 1 - src/NativeMethods/DriverExt.cs | 11 +++++++++++ src/Utils/Ffi.cs | 13 ------------- unity/Assets/Scripts/NativeMethods/DriverExt.cs | 11 +++++++++++ unity/Assets/Scripts/Utils/Ffi.cs.meta | 2 -- 5 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 src/Utils/Ffi.cs delete mode 100644 unity/Assets/Scripts/Utils/Ffi.cs.meta diff --git a/src/AUTD3Sharp.cs b/src/AUTD3Sharp.cs index 06d4cdfd..228e61ec 100644 --- a/src/AUTD3Sharp.cs +++ b/src/AUTD3Sharp.cs @@ -1,5 +1,4 @@ using AUTD3Sharp.NativeMethods; -using AUTD3Sharp.Utils; namespace AUTD3Sharp { diff --git a/src/NativeMethods/DriverExt.cs b/src/NativeMethods/DriverExt.cs index 712b1df9..b9dfe92c 100644 --- a/src/NativeMethods/DriverExt.cs +++ b/src/NativeMethods/DriverExt.cs @@ -190,5 +190,16 @@ public static LinkBuilderPtr Validate(this ResultLinkBuilder res) throw new AUTDException(err); } } + + public static class Ffi + { + public static byte[] toNullTerminatedUtf8(string str) + { + var len = System.Text.Encoding.UTF8.GetByteCount(str); + var bytes = new byte[len + 1]; + System.Text.Encoding.UTF8.GetBytes(str, 0, str.Length, bytes, bytes.GetLowerBound(0)); + return bytes; + } + } } } diff --git a/src/Utils/Ffi.cs b/src/Utils/Ffi.cs deleted file mode 100644 index e261bab8..00000000 --- a/src/Utils/Ffi.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace AUTD3Sharp.Utils -{ - internal static class Ffi - { - internal static byte[] toNullTerminatedUtf8(string str) - { - var len = System.Text.Encoding.UTF8.GetByteCount(str); - var bytes = new byte[len + 1]; - System.Text.Encoding.UTF8.GetBytes(str, 0, str.Length, bytes, bytes.GetLowerBound(0)); - return bytes; - } - } -} \ No newline at end of file diff --git a/unity/Assets/Scripts/NativeMethods/DriverExt.cs b/unity/Assets/Scripts/NativeMethods/DriverExt.cs index 712b1df9..b9dfe92c 100644 --- a/unity/Assets/Scripts/NativeMethods/DriverExt.cs +++ b/unity/Assets/Scripts/NativeMethods/DriverExt.cs @@ -190,5 +190,16 @@ public static LinkBuilderPtr Validate(this ResultLinkBuilder res) throw new AUTDException(err); } } + + public static class Ffi + { + public static byte[] toNullTerminatedUtf8(string str) + { + var len = System.Text.Encoding.UTF8.GetByteCount(str); + var bytes = new byte[len + 1]; + System.Text.Encoding.UTF8.GetBytes(str, 0, str.Length, bytes, bytes.GetLowerBound(0)); + return bytes; + } + } } } diff --git a/unity/Assets/Scripts/Utils/Ffi.cs.meta b/unity/Assets/Scripts/Utils/Ffi.cs.meta deleted file mode 100644 index 2f880c9d..00000000 --- a/unity/Assets/Scripts/Utils/Ffi.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 28a8e38b0392cf84c85462123be4f966 \ No newline at end of file