Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
feast107 committed Nov 7, 2024
1 parent f9d3707 commit 1a9a17b
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 86 deletions.
18 changes: 9 additions & 9 deletions src/Antelcat.LibuvSharp/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public static class UV
internal static bool IsUnix => isUnix;

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
internal static extern int uv_ip4_addr(string ip, int port, out sockaddr_in address);
private static extern int uv_ip4_addr(string ip, int port, out sockaddr_in address);

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
internal static extern int uv_ip6_addr(string ip, int port, out sockaddr_in6 address);
private static extern int uv_ip6_addr(string ip, int port, out sockaddr_in6 address);

internal static sockaddr_in ToStruct(string ip, int port)
{
Expand All @@ -51,21 +51,21 @@ internal static sockaddr_in6 ToStruct6(string ip, int port)
}

[DllImport("__Internal", EntryPoint = nameof(ntohs), CallingConvention = CallingConvention.Cdecl)]
internal static extern ushort ntohs_unix(ushort bytes);
private static extern ushort ntohs_unix(ushort bytes);

[DllImport("Ws2_32", EntryPoint = nameof(ntohs))]
internal static extern ushort ntohs_win(ushort bytes);
private static extern ushort ntohs_win(ushort bytes);

internal static ushort ntohs(ushort bytes)
{
return isUnix ? ntohs_unix(bytes) : ntohs_win(bytes);
}

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern int uv_ip4_name(IntPtr src, byte[] dst, IntPtr size);
private static extern int uv_ip4_name(IntPtr src, byte[] dst, IntPtr size);

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern int uv_ip6_name(IntPtr src, byte[] dst, IntPtr size);
private static extern int uv_ip6_name(IntPtr src, byte[] dst, IntPtr size);

private static bool IsMapping(byte[] data)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ private static int strlen(byte[] bytes)
}

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern int uv_req_size(RequestType type);
private static extern int uv_req_size(RequestType type);

internal static int Sizeof(RequestType type)
{
Expand Down Expand Up @@ -194,7 +194,7 @@ public static void PrintPointers()
#endif

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern uint uv_version();
private static extern uint uv_version();

public static void GetVersion(out int major, out int minor, out int patch)
{
Expand All @@ -214,7 +214,7 @@ public static Version Version
}

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe sbyte* uv_version_string();
private static extern unsafe sbyte* uv_version_string();

public static unsafe string VersionString => new(uv_version_string());

Expand Down
18 changes: 8 additions & 10 deletions src/Antelcat.LibuvSharp/DynamicLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ public static DynamicLibrary Open()
internal class LibuvDynamicLibrary : DynamicLibrary
{
[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern int uv_dlopen(IntPtr name, IntPtr handle);
private static extern int uv_dlopen(IntPtr name, IntPtr handle);

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern int uv_dlopen(string name, IntPtr handle);
private static extern int uv_dlopen(string name, IntPtr handle);

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern void uv_dlclose(IntPtr handle);
private static extern void uv_dlclose(IntPtr handle);

[DllImport(NativeMethods.Libuv, CallingConvention = CallingConvention.Cdecl)]
internal static extern int uv_dlsym(IntPtr handle, string name, out IntPtr ptr);
private static extern int uv_dlsym(IntPtr handle, string name, out IntPtr ptr);

[DllImport(NativeMethods.Libuv)]
internal static extern IntPtr uv_dlerror(IntPtr handle);
private static extern IntPtr uv_dlerror(IntPtr handle);

[DllImport(NativeMethods.Libuv)]
internal static extern IntPtr uv_dlerror_free(IntPtr handle);
Expand Down Expand Up @@ -77,11 +77,9 @@ public LibuvDynamicLibrary(string library)

public override void Close()
{
if(!Closed)
{
uv_dlclose(handle);
handle = IntPtr.Zero;
}
if (Closed) return;
uv_dlclose(handle);
handle = IntPtr.Zero;
}

public override bool TryGetSymbol(string name, out IntPtr pointer)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Net;
using Antelcat.LibuvSharp.Internal;
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Net;
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;

Expand Down
4 changes: 1 addition & 3 deletions src/Antelcat.LibuvSharp/Extensions/IHandleExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;
namespace Antelcat.LibuvSharp.Extensions;

internal static class IHandleExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System.Net;
using Antelcat.LibuvSharp.Internal;
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;

internal static class IMessageSenderExtensions
internal static class MessageSenderExtensions
{
#region IPAddress string

Expand Down
1 change: 0 additions & 1 deletion src/Antelcat.LibuvSharp/Extensions/IPCPipeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text;
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;

Expand Down
1 change: 0 additions & 1 deletion src/Antelcat.LibuvSharp/Extensions/IUVStreamExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Text;
using Antelcat.LibuvSharp.Internal;
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;

Expand Down
4 changes: 1 addition & 3 deletions src/Antelcat.LibuvSharp/Extensions/ListenerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;
namespace Antelcat.LibuvSharp.Extensions;

internal static class ListenerExtensions
{
Expand Down
1 change: 0 additions & 1 deletion src/Antelcat.LibuvSharp/Extensions/StreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using Antelcat.LibuvSharp.Threading.Tasks;

namespace Antelcat.LibuvSharp.Extensions;

Expand Down
2 changes: 0 additions & 2 deletions src/Antelcat.LibuvSharp/Extensions/UVFileStreamExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Antelcat.LibuvSharp.Threading;

namespace Antelcat.LibuvSharp.Extensions;

internal static class UVFileStreamExtensions
Expand Down
Loading

0 comments on commit 1a9a17b

Please sign in to comment.