Skip to content

Commit

Permalink
Clean up some of the custom marshallers
Browse files Browse the repository at this point in the history
  • Loading branch information
ThadHouse committed Feb 7, 2024
1 parent 45447f5 commit 7ae6703
Show file tree
Hide file tree
Showing 16 changed files with 11 additions and 307 deletions.
61 changes: 0 additions & 61 deletions src/cscore/Natives/CsEnumPropertyArrayMarshaller.cs

This file was deleted.

4 changes: 0 additions & 4 deletions src/cscore/Natives/CsNative.Free.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ public static unsafe partial class CsNative
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void ReleaseEnumeratedSinks(int* sinks, int count);

[LibraryImport("cscore", EntryPoint = "CS_FreeString")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeString(byte* str);

[LibraryImport("cscore", EntryPoint = "CS_FreeEnumPropertyChoices")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void FreeEnumPropertyChoices(byte** choices, int count);
Expand Down
12 changes: 0 additions & 12 deletions src/cscore/Natives/CsStringFree.cs

This file was deleted.

61 changes: 0 additions & 61 deletions src/cscore/Natives/HttpCameraUrlsArrayMarshaller.cs

This file was deleted.

61 changes: 0 additions & 61 deletions src/cscore/Natives/NetworkInterfacesArrayMarshaller.cs

This file was deleted.

3 changes: 3 additions & 0 deletions src/hal/Assembly.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: DisableRuntimeMarshalling]
2 changes: 1 addition & 1 deletion src/hal/JoystickDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public readonly unsafe string FromNullTerminatedString()
ReadOnlySpan<byte> thisSpan = this;
fixed (byte* b = thisSpan)
{
return Marshal.PtrToStringUTF8((nint)b)!;
return System.Runtime.InteropServices.Marshal.PtrToStringUTF8((nint)b)!;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WPIUtil.Marshal;
namespace WPIHal.Marshal;

public interface INullTerminatedStringFree<T> where T : unmanaged
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WPIUtil.Marshal;
namespace WPIHal.Marshal;

public class NoFreeNullTerminatedStringFree : INullTerminatedStringFree<byte>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Runtime.InteropServices.Marshalling;
using WPIUtil.Marshal;

namespace WPIUtil.Marshal;
namespace WPIHal.Marshal;

[CustomMarshaller(typeof(string), MarshalMode.ManagedToUnmanagedOut, typeof(NullTerminatedStringMarshaller<>))]
[CustomMarshaller(typeof(string), MarshalMode.ElementOut, typeof(NullTerminatedStringMarshaller<>))]
Expand Down
2 changes: 1 addition & 1 deletion src/hal/MatchInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public readonly unsafe string FromNullTerminatedString()
ReadOnlySpan<byte> thisSpan = this;
fixed (byte* b = thisSpan)
{
return Marshal.PtrToStringUTF8((nint)b)!;
return System.Runtime.InteropServices.Marshal.PtrToStringUTF8((nint)b)!;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/hal/Natives/HalBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using WPIHal.Handles;
using WPIHal.Marshal;
using WPIUtil.Marshal;

namespace WPIHal.Natives;
Expand Down
7 changes: 1 addition & 6 deletions src/hal/Natives/HalDriverStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ public static partial class HalDriverStation

[LibraryImport("wpiHal", EntryPoint = "HAL_GetJoystickName")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
[return: MarshalUsing(typeof(NullTerminatedStringMarshaller<JoystickNameStringFree>))]
public static partial string GetJoystickName(int joystickNum);

[LibraryImport("wpiHal", EntryPoint = "HAL_FreeJoystickName")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static unsafe partial void FreeJoystickName(byte* joystickName);
public static partial void GetJoystickName([MarshalUsing(typeof(WpiStringMarshaller))] out string name, int joystickNum);

[LibraryImport("wpiHal", EntryPoint = "HAL_GetJoystickPOVs")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
Expand Down
11 changes: 0 additions & 11 deletions src/hal/Natives/JoystickNameStringFree.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/wpiutil/Marshal/EmptyStringMarshaller.cs

This file was deleted.

68 changes: 0 additions & 68 deletions src/wpiutil/Marshal/StringLengthPairMarshaller.cs

This file was deleted.

0 comments on commit 7ae6703

Please sign in to comment.