From 4c2d0a03e551072a01d941142e3d891527ef7c5b Mon Sep 17 00:00:00 2001 From: Timerix22 Date: Sun, 12 Feb 2023 18:45:05 +0600 Subject: [PATCH] KerepWrapper project --- DTLib.Dtsod/DtsodConverter.cs | 6 +-- DTLib.Dtsod/DtsodVersion.cs | 5 +- DTLib.Tests/Dtsod/TestAutoarr.cs | 8 +-- DTLib.Tests/Dtsod/TestDtsodV24.cs | 10 ++-- DTLib.Tests/Dtsod/TestPInvoke.cs | 8 +-- DTLib.Tests/Program.cs | 6 +-- DTLib.sln | 7 +++ .../V24 => KerepWrapper}/Autoarr/Autoarr.cs | 6 ++- .../Autoarr/AutoarrFunctions.cs | 8 +-- .../Autoarr/AutoarrKVPairFunctions.cs | 4 +- .../Autoarr/AutoarrUnitypeFunctions.cs | 4 +- .../V24 => KerepWrapper/Dtsod}/DtsodV24.cs | 12 +++-- .../Dtsod}/DtsodV24Functions.cs | 7 ++- .../V24 => KerepWrapper}/KerepTypes/KVPair.cs | 7 +-- .../KerepTypes/KerepTypeCode.cs | 5 +- .../KerepTypes/Unitype.cs | 10 ++-- KerepWrapper/KerepWrapper.csproj | 51 ++++++++++++++++++ .../runtimes/win-x64/native/kerep.dll | Bin 18 files changed, 123 insertions(+), 41 deletions(-) rename {DTLib.Dtsod/V24 => KerepWrapper}/Autoarr/Autoarr.cs (92%) rename {DTLib.Dtsod/V24 => KerepWrapper}/Autoarr/AutoarrFunctions.cs (89%) rename {DTLib.Dtsod/V24 => KerepWrapper}/Autoarr/AutoarrKVPairFunctions.cs (95%) rename {DTLib.Dtsod/V24 => KerepWrapper}/Autoarr/AutoarrUnitypeFunctions.cs (95%) rename {DTLib.Dtsod/V24 => KerepWrapper/Dtsod}/DtsodV24.cs (90%) rename {DTLib.Dtsod/V24 => KerepWrapper/Dtsod}/DtsodV24Functions.cs (94%) rename {DTLib.Dtsod/V24 => KerepWrapper}/KerepTypes/KVPair.cs (76%) rename {DTLib.Dtsod/V24 => KerepWrapper}/KerepTypes/KerepTypeCode.cs (92%) rename {DTLib.Dtsod/V24 => KerepWrapper}/KerepTypes/Unitype.cs (95%) create mode 100644 KerepWrapper/KerepWrapper.csproj rename {DTLib.Dtsod => KerepWrapper}/runtimes/win-x64/native/kerep.dll (100%) diff --git a/DTLib.Dtsod/DtsodConverter.cs b/DTLib.Dtsod/DtsodConverter.cs index 76421e5..d967f65 100644 --- a/DTLib.Dtsod/DtsodConverter.cs +++ b/DTLib.Dtsod/DtsodConverter.cs @@ -1,6 +1,4 @@ -using DTLib.Dtsod.V24; - -namespace DTLib.Dtsod; +namespace DTLib.Dtsod; public static class DtsodConverter { @@ -10,7 +8,7 @@ public static class DtsodConverter DtsodVersion.V21 => new DtsodV21(src.ToDictionary()), DtsodVersion.V22 => throw new Exception("DtsodV22 is deprecated"), DtsodVersion.V23 => new DtsodV23(src.ToDictionary()), - DtsodVersion.V24 => new DtsodV24(src.ToDictionary()), + // DtsodVersion.V24 => new DtsodV24(src.ToDictionary()), #if DEBUG //DtsodVersion.V30 => new DtsodV30(src.ToDictionary()), #endif diff --git a/DTLib.Dtsod/DtsodVersion.cs b/DTLib.Dtsod/DtsodVersion.cs index b68f0ff..e7b0394 100644 --- a/DTLib.Dtsod/DtsodVersion.cs +++ b/DTLib.Dtsod/DtsodVersion.cs @@ -5,8 +5,9 @@ public enum DtsodVersion : byte V21 = 21, V22 = 22, V23 = 23, - V24 = 24 + V24 = 24, + V25, #if DEBUG - ,V30 = 30 + V30 = 30 #endif } diff --git a/DTLib.Tests/Dtsod/TestAutoarr.cs b/DTLib.Tests/Dtsod/TestAutoarr.cs index 0605159..d25d732 100644 --- a/DTLib.Tests/Dtsod/TestAutoarr.cs +++ b/DTLib.Tests/Dtsod/TestAutoarr.cs @@ -1,5 +1,6 @@ -using DTLib.Dtsod.V24.Autoarr; -using DTLib.Dtsod.V24.KerepTypes; +/* +using KerepWrapper.Autoarr; +using KerepWrapper.KerepTypes; namespace DTLib.Tests; @@ -35,4 +36,5 @@ public static class TestAutoarr ar.Dispose(); OldLogger.Log("g", "test completed"); } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/DTLib.Tests/Dtsod/TestDtsodV24.cs b/DTLib.Tests/Dtsod/TestDtsodV24.cs index 3861c36..9ad8eda 100644 --- a/DTLib.Tests/Dtsod/TestDtsodV24.cs +++ b/DTLib.Tests/Dtsod/TestDtsodV24.cs @@ -1,6 +1,7 @@ -using DTLib.Dtsod.V24; -using DTLib.Dtsod.V24.Autoarr; -using DTLib.Dtsod.V24.KerepTypes; +/* +using KerepWrapper.Dtsod; +using KerepWrapper.Autoarr; +using KerepWrapper.KerepTypes; namespace DTLib.Tests; @@ -79,4 +80,5 @@ public static class TestDtsodV24 LogOperationTime("V24 serialization", 64, () => text = dtsod.ToString()); OldLogger.Log("g", "test completed"); } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/DTLib.Tests/Dtsod/TestPInvoke.cs b/DTLib.Tests/Dtsod/TestPInvoke.cs index b7ee175..c24c392 100644 --- a/DTLib.Tests/Dtsod/TestPInvoke.cs +++ b/DTLib.Tests/Dtsod/TestPInvoke.cs @@ -1,6 +1,7 @@ +/* using System.Runtime.InteropServices; -using DTLib.Dtsod.V24; -using DTLib.Dtsod.V24.KerepTypes; +using KerepWrapper.Dtsod; +using KerepWrapper.KerepTypes; namespace DTLib.Tests; @@ -49,4 +50,5 @@ public static class TestPInvoke OldLogger.Log("b", k.ToString()); OldLogger.Log("g", "test completed"); } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/DTLib.Tests/Program.cs b/DTLib.Tests/Program.cs index d058ea8..db546e5 100644 --- a/DTLib.Tests/Program.cs +++ b/DTLib.Tests/Program.cs @@ -31,10 +31,10 @@ public static class Program try { new LaunchArgumentParser().WithNoExit().ParseAndHandle(args); - TestPInvoke.TestAll(); - TestAutoarr.TestAll(); TestDtsodV23.TestAll(); - TestDtsodV24.TestAll(); + // TestPInvoke.TestAll(); + // TestAutoarr.TestAll(); + // TestDtsodV24.TestAll(); } catch(LaunchArgumentParser.ExitAfterHelpException) { } diff --git a/DTLib.sln b/DTLib.sln index d1638f1..f97288e 100644 --- a/DTLib.sln +++ b/DTLib.sln @@ -26,6 +26,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution push_packages.sh = push_packages.sh EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KerepWrapper", "KerepWrapper\KerepWrapper.csproj", "{9ADC4AA1-1DE4-4BB6-AF38-E84C1A142032}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,6 +70,11 @@ Global {AC7CB524-4D59-42E0-9F96-1C201A92494B}.Release|Any CPU.Build.0 = Release|Any CPU {AC7CB524-4D59-42E0-9F96-1C201A92494B}.Publish|Any CPU.ActiveCfg = Release|Any CPU {AC7CB524-4D59-42E0-9F96-1C201A92494B}.Publish|Any CPU.Build.0 = Release|Any CPU + {9ADC4AA1-1DE4-4BB6-AF38-E84C1A142032}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9ADC4AA1-1DE4-4BB6-AF38-E84C1A142032}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9ADC4AA1-1DE4-4BB6-AF38-E84C1A142032}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9ADC4AA1-1DE4-4BB6-AF38-E84C1A142032}.Release|Any CPU.Build.0 = Release|Any CPU + {9ADC4AA1-1DE4-4BB6-AF38-E84C1A142032}.Publish|Any CPU.ActiveCfg = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DTLib.Dtsod/V24/Autoarr/Autoarr.cs b/KerepWrapper/Autoarr/Autoarr.cs similarity index 92% rename from DTLib.Dtsod/V24/Autoarr/Autoarr.cs rename to KerepWrapper/Autoarr/Autoarr.cs index ba95bb1..d2f5c22 100644 --- a/DTLib.Dtsod/V24/Autoarr/Autoarr.cs +++ b/KerepWrapper/Autoarr/Autoarr.cs @@ -1,6 +1,8 @@ -using System.Runtime.InteropServices; +using System; +using System.Collections; +using System.Collections.Generic; -namespace DTLib.Dtsod.V24.Autoarr; +namespace KerepWrapper.Autoarr; public class Autoarr : IEnumerable, IDisposable where T : struct { diff --git a/DTLib.Dtsod/V24/Autoarr/AutoarrFunctions.cs b/KerepWrapper/Autoarr/AutoarrFunctions.cs similarity index 89% rename from DTLib.Dtsod/V24/Autoarr/AutoarrFunctions.cs rename to KerepWrapper/Autoarr/AutoarrFunctions.cs index 3e884f0..f811a18 100644 --- a/DTLib.Dtsod/V24/Autoarr/AutoarrFunctions.cs +++ b/KerepWrapper/Autoarr/AutoarrFunctions.cs @@ -1,7 +1,9 @@ -using DTLib.Dtsod.V24.KerepTypes; +using System; +using DTLib; +using KerepWrapper.KerepTypes; -namespace DTLib.Dtsod.V24.Autoarr; -using AutoarrPtr=IntPtr; +namespace KerepWrapper.Autoarr; +using AutoarrPtr=DtsodPtr; public abstract class AutoarrFunctions { diff --git a/DTLib.Dtsod/V24/Autoarr/AutoarrKVPairFunctions.cs b/KerepWrapper/Autoarr/AutoarrKVPairFunctions.cs similarity index 95% rename from DTLib.Dtsod/V24/Autoarr/AutoarrKVPairFunctions.cs rename to KerepWrapper/Autoarr/AutoarrKVPairFunctions.cs index faa6fed..b8d2f29 100644 --- a/DTLib.Dtsod/V24/Autoarr/AutoarrKVPairFunctions.cs +++ b/KerepWrapper/Autoarr/AutoarrKVPairFunctions.cs @@ -1,7 +1,7 @@ using System.Runtime.InteropServices; -using DTLib.Dtsod.V24.KerepTypes; +using KerepWrapper.KerepTypes; -namespace DTLib.Dtsod.V24.Autoarr; +namespace KerepWrapper.Autoarr; internal class AutoarrKVPairFunctions : AutoarrFunctions { diff --git a/DTLib.Dtsod/V24/Autoarr/AutoarrUnitypeFunctions.cs b/KerepWrapper/Autoarr/AutoarrUnitypeFunctions.cs similarity index 95% rename from DTLib.Dtsod/V24/Autoarr/AutoarrUnitypeFunctions.cs rename to KerepWrapper/Autoarr/AutoarrUnitypeFunctions.cs index 536d949..e198373 100644 --- a/DTLib.Dtsod/V24/Autoarr/AutoarrUnitypeFunctions.cs +++ b/KerepWrapper/Autoarr/AutoarrUnitypeFunctions.cs @@ -1,7 +1,7 @@ using System.Runtime.InteropServices; -using DTLib.Dtsod.V24.KerepTypes; +using KerepWrapper.KerepTypes; -namespace DTLib.Dtsod.V24.Autoarr; +namespace KerepWrapper.Autoarr; internal class AutoarrUnitypeFunctions : AutoarrFunctions { diff --git a/DTLib.Dtsod/V24/DtsodV24.cs b/KerepWrapper/Dtsod/DtsodV24.cs similarity index 90% rename from DTLib.Dtsod/V24/DtsodV24.cs rename to KerepWrapper/Dtsod/DtsodV24.cs index 7ca6b41..50d3c38 100644 --- a/DTLib.Dtsod/V24/DtsodV24.cs +++ b/KerepWrapper/Dtsod/DtsodV24.cs @@ -1,8 +1,12 @@ -using DTLib.Dtsod.V24.Autoarr; -using DTLib.Dtsod.V24.KerepTypes; -using Funcs=DTLib.Dtsod.V24.DtsodV24Functions; +using System; +using System.Collections; +using System.Collections.Generic; +using DTLib.Dtsod; +using KerepWrapper.KerepTypes; +using KerepWrapper.Autoarr; +using Funcs=KerepWrapper.Dtsod.DtsodV24Functions; -namespace DTLib.Dtsod.V24; +namespace KerepWrapper.Dtsod; public class DtsodV24 : IDtsod, IEnumerable, IDisposable { diff --git a/DTLib.Dtsod/V24/DtsodV24Functions.cs b/KerepWrapper/Dtsod/DtsodV24Functions.cs similarity index 94% rename from DTLib.Dtsod/V24/DtsodV24Functions.cs rename to KerepWrapper/Dtsod/DtsodV24Functions.cs index b08f934..050fb38 100644 --- a/DTLib.Dtsod/V24/DtsodV24Functions.cs +++ b/KerepWrapper/Dtsod/DtsodV24Functions.cs @@ -2,10 +2,13 @@ global using DtsodPtr=System.IntPtr; global using AutoarrKVPairPtr=System.IntPtr; global using AutoarrUnitypePtr=System.IntPtr; global using CharPtr=System.IntPtr; +using System; using System.Runtime.InteropServices; -using DTLib.Dtsod.V24.KerepTypes; +using DTLib; +using DTLib.Extensions; +using KerepWrapper.KerepTypes; -namespace DTLib.Dtsod.V24; +namespace KerepWrapper.Dtsod; internal static class DtsodV24Functions { diff --git a/DTLib.Dtsod/V24/KerepTypes/KVPair.cs b/KerepWrapper/KerepTypes/KVPair.cs similarity index 76% rename from DTLib.Dtsod/V24/KerepTypes/KVPair.cs rename to KerepWrapper/KerepTypes/KVPair.cs index b421dd9..44a6233 100644 --- a/DTLib.Dtsod/V24/KerepTypes/KVPair.cs +++ b/KerepWrapper/KerepTypes/KVPair.cs @@ -1,14 +1,15 @@ using System.Runtime.InteropServices; +using DTLib.Extensions; -namespace DTLib.Dtsod.V24.KerepTypes; +namespace KerepWrapper.KerepTypes; [StructLayout(LayoutKind.Sequential)] public struct KVPair { - public IntPtr key; + public DtsodPtr key; public Unitype value; - public KVPair(IntPtr k, Unitype v) + public KVPair(DtsodPtr k, Unitype v) { key = k; value = v; diff --git a/DTLib.Dtsod/V24/KerepTypes/KerepTypeCode.cs b/KerepWrapper/KerepTypes/KerepTypeCode.cs similarity index 92% rename from DTLib.Dtsod/V24/KerepTypes/KerepTypeCode.cs rename to KerepWrapper/KerepTypes/KerepTypeCode.cs index 1f3a7f6..1ba0f68 100644 --- a/DTLib.Dtsod/V24/KerepTypes/KerepTypeCode.cs +++ b/KerepWrapper/KerepTypes/KerepTypeCode.cs @@ -1,4 +1,7 @@ -namespace DTLib.Dtsod.V24.KerepTypes; +using System; +using System.Collections.Generic; + +namespace KerepWrapper.KerepTypes; public enum KerepTypeCode : byte { diff --git a/DTLib.Dtsod/V24/KerepTypes/Unitype.cs b/KerepWrapper/KerepTypes/Unitype.cs similarity index 95% rename from DTLib.Dtsod/V24/KerepTypes/Unitype.cs rename to KerepWrapper/KerepTypes/Unitype.cs index 3e38ea4..68bd870 100644 --- a/DTLib.Dtsod/V24/KerepTypes/Unitype.cs +++ b/KerepWrapper/KerepTypes/Unitype.cs @@ -1,7 +1,11 @@ +using System; +using System.Collections.Generic; using System.Runtime.InteropServices; -using DTLib.Dtsod.V24.Autoarr; +using DTLib.Extensions; +using KerepWrapper.Autoarr; +using KerepWrapper.Dtsod; -namespace DTLib.Dtsod.V24.KerepTypes; +namespace KerepWrapper.KerepTypes; [StructLayout(LayoutKind.Explicit)] public struct Unitype @@ -11,7 +15,7 @@ public struct Unitype [FieldOffset(0)] public double Float64; [MarshalAs(UnmanagedType.I1)] [FieldOffset(0)] public bool Bool; - [FieldOffset(0)] public IntPtr VoidPtr; + [FieldOffset(0)] public DtsodPtr VoidPtr; [FieldOffset(8)] public KerepTypeCode TypeCode; public Unitype(object v) : this() diff --git a/KerepWrapper/KerepWrapper.csproj b/KerepWrapper/KerepWrapper.csproj new file mode 100644 index 0000000..21a5bfc --- /dev/null +++ b/KerepWrapper/KerepWrapper.csproj @@ -0,0 +1,51 @@ + + + + + KerepWrapper + 0.2.0 + Timerix + Definitely not json + GIT + https://github.com/Timerix22/DTLib + https://github.com/Timerix22/DTLib + Release + MIT + + net6.0;netstandard2.0;net48 + embedded + + 10 + disable + disable + + + + + + + + + + + + + + + + + + + + + + + + Always + true + runtimes/ + + + + + diff --git a/DTLib.Dtsod/runtimes/win-x64/native/kerep.dll b/KerepWrapper/runtimes/win-x64/native/kerep.dll similarity index 100% rename from DTLib.Dtsod/runtimes/win-x64/native/kerep.dll rename to KerepWrapper/runtimes/win-x64/native/kerep.dll