checkpoint

This commit is contained in:
2020-04-30 13:33:30 -04:00
parent 19a9fc06ba
commit 9bc522180d
21 changed files with 337 additions and 276 deletions

View File

@@ -1,12 +1,9 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
namespace Foodsoft.Alpm
{
[StructLayout(LayoutKind.Sequential)]
[SuppressMessage("ReSharper", "ConvertToConstant.Local")]
public class Depend
{
public enum ModType
@@ -19,16 +16,31 @@ namespace Foodsoft.Alpm
LessThan
}
[field: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8OutMarshaler))]
public string Name { get; } = null!;
public string Name { get; }
public string Version { get; }
public string Description { get; }
public ulong NameHash { get; }
public ModType Mod { get; }
[field: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8OutMarshaler))]
public string Version { get; } = null!;
[StructLayout(LayoutKind.Sequential)]
private readonly unsafe struct NativeDepend
{
internal readonly sbyte* name;
internal readonly sbyte* version;
internal readonly sbyte* description;
internal readonly ulong name_hash;
internal readonly Depend.ModType mod;
}
[field: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8OutMarshaler))]
public string Description { get; } = null!;
public ulong NameHash { get; } = 0;
public ModType Mod { get; } = ModType.Any;
internal unsafe Depend(IntPtr ptr)
{
var native = (NativeDepend*) ptr;
Name = new string(native->name);
Version = new string(native->version);
Description = new string(native->description);
NameHash = native->name_hash;
Mod = native->mod;
}
}
}