KerepWrapper project

This commit is contained in:
Timerix22 2023-02-12 18:45:05 +06:00
parent 8c4426abc1
commit 4c2d0a03e5
18 changed files with 123 additions and 41 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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");
}
}
}
*/

View File

@ -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");
}
}
}
*/

View File

@ -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");
}
}
}
*/

View File

@ -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)
{ }

View File

@ -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

View File

@ -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<T> : IEnumerable<T>, IDisposable where T : struct
{

View File

@ -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<T>
{

View File

@ -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<KVPair>
{

View File

@ -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<Unitype>
{

View File

@ -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<KVPair>, IDisposable
{

View File

@ -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
{

View File

@ -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;

View File

@ -1,4 +1,7 @@
namespace DTLib.Dtsod.V24.KerepTypes;
using System;
using System.Collections.Generic;
namespace KerepWrapper.KerepTypes;
public enum KerepTypeCode : byte
{

View File

@ -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()

View File

@ -0,0 +1,51 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!--package info-->
<PackageId>KerepWrapper</PackageId>
<Version>0.2.0</Version>
<Authors>Timerix</Authors>
<Description>Definitely not json</Description>
<RepositoryType>GIT</RepositoryType>
<RepositoryUrl>https://github.com/Timerix22/DTLib</RepositoryUrl>
<PackageProjectUrl>https://github.com/Timerix22/DTLib</PackageProjectUrl>
<Configuration>Release</Configuration>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--compilation properties-->
<TargetFrameworks>net6.0;netstandard2.0;net48</TargetFrameworks>
<DebugType>embedded</DebugType>
<!--language features-->
<LangVersion>10</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
<!--external dependencies-->
<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
<Reference Include="System.Dynamic" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>
<!--DTLib dependencies-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<ProjectReference Include="..\DTLib\DTLib.csproj" />
<ProjectReference Include="..\DTLib.Dtsod\DTLib.Dtsod.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' != 'Debug' ">
<PackageReference Include="DTLib.Dtsod" Version="1.1.0" />
</ItemGroup>
<!--project files-->
<ItemGroup>
<Content Include="runtimes\**\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Pack>true</Pack>
<PackagePath>runtimes/</PackagePath>
</Content>
<Compile Remove="Experimental/**/*" />
<None Include="Experimental/**/*" />
</ItemGroup>
</Project>