Skip to content

Commit

Permalink
mv ffi into native methods
Browse files Browse the repository at this point in the history
  • Loading branch information
s5suzuki committed Nov 4, 2024
1 parent 6a142b3 commit fe65165
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/AUTD3Sharp.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AUTD3Sharp.NativeMethods;
using AUTD3Sharp.Utils;

namespace AUTD3Sharp
{
Expand Down
11 changes: 11 additions & 0 deletions src/NativeMethods/DriverExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
13 changes: 0 additions & 13 deletions src/Utils/Ffi.cs

This file was deleted.

11 changes: 11 additions & 0 deletions unity/Assets/Scripts/NativeMethods/DriverExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
2 changes: 0 additions & 2 deletions unity/Assets/Scripts/Utils/Ffi.cs.meta

This file was deleted.

0 comments on commit fe65165

Please sign in to comment.