Skip to content

Commit ebedc74

Browse files
committed
use CppPinvokeGenerator for codegen
1 parent b9614c3 commit ebedc74

File tree

12 files changed

+848
-687
lines changed

12 files changed

+848
-687
lines changed

benchmarks/CountStrings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public unsafe ulong SimdJsonNUtf16(byte[] data, string fileName, string fileSize
4444
{
4545
while (iterator.MoveForward())
4646
{
47-
if (iterator.IsString)
47+
if (iterator.IsString())
4848
{
4949
if (iterator.GetUtf16String().StartsWith('a')) // UTF16 in SimdJsonN is expected to be slow for now (see https://github.com/lemire/simdjson/pull/101)
5050
wordsCount++;
@@ -91,7 +91,7 @@ public unsafe ulong SimdJsonNUtf8(byte[] data, string fileName, string fileSize)
9191
{
9292
while (iterator.MoveForward())
9393
{
94-
if (iterator.IsString)
94+
if (iterator.IsString())
9595
{
9696
if (*iterator.GetUtf8String() == (byte)'a')
9797
wordsCount++;

benchmarks/MinifyBenchmarks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public unsafe string SimdJsonN_Validation(byte[] jsonData, string fileName, stri
5353
fixed (byte* dataPtr = jsonData)
5454
{
5555
using (var doc = SimdJsonN.ParseJson(dataPtr, jsonData.Length))
56-
if (!doc.IsValid)
56+
if (!doc.IsValid())
5757
throw new InvalidOperationException("Json is invalid");
5858
}
5959

samples/HelloWorld/Program.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Text;
3-
using System.Text.Json;
43
using SimdJsonSharp;
54

65
namespace ConsoleApp124
@@ -9,6 +8,7 @@ class Program
98
{
109
static unsafe void Main(string[] args)
1110
{
11+
1212
string helloWorldJson = @"{ ""answer"": 42, ""name"": ""Egor"" }";
1313
ReadOnlySpan<byte> bytes = Encoding.UTF8.GetBytes(helloWorldJson);
1414
// SimdJson is UTF8 only
@@ -19,16 +19,16 @@ static unsafe void Main(string[] args)
1919
// SimdJson -- fully managed .NET Core 3.0 port
2020
using (ParsedJsonN doc = SimdJsonN.ParseJson(ptr, bytes.Length))
2121
{
22-
Console.WriteLine($"Is json valid:{doc.IsValid}\n");
22+
Console.WriteLine($"Is json valid:{doc.IsValid()}\n");
2323

2424
// open iterator:
2525
using (var iterator = new ParsedJsonIteratorN(doc))
2626
{
2727
while (iterator.MoveForward())
2828
{
29-
if (iterator.IsInteger)
29+
if (iterator.IsInteger())
3030
Console.WriteLine("integer: " + iterator.GetInteger());
31-
if (iterator.IsString)
31+
if (iterator.IsString())
3232
Console.WriteLine("string: " + iterator.GetUtf16String());
3333
}
3434
}

samples/MinifyJson/Program.cs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO;
33
using System.Reflection;
44
using System.Text;
5+
using Microsoft.Win32.SafeHandles;
56
using SimdJsonSharp;
67

78
namespace MinifyJson

solution.sln

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimdJsonNative", "src\Bindi
2929
EndProject
3030
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimdJsonSharp.Bindings", "src\BindingsForNativeLib\SimdJsonSharp.Bindings\SimdJsonSharp.Bindings.csproj", "{399AA870-D18B-40BB-AAB2-4DFDDB7B8DE6}"
3131
EndProject
32-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BindingsGenerator", "src\BindingsForNativeLib\BindingsGenerator\BindingsGenerator.csproj", "{F6024B33-8886-47AD-A504-24879BFC0A42}"
32+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BindingsGenerator", "src\BindingsForNativeLib\BindingsGenerator\BindingsGenerator.csproj", "{F6024B33-8886-47AD-A504-24879BFC0A42}"
3333
EndProject
3434
Global
3535
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -101,7 +101,8 @@ Global
101101
{D795C37F-D8D3-4B29-ADBA-548C6711D69B}.Release|x64.Build.0 = Release|Any CPU
102102
{D795C37F-D8D3-4B29-ADBA-548C6711D69B}.Release|x86.ActiveCfg = Release|Any CPU
103103
{D795C37F-D8D3-4B29-ADBA-548C6711D69B}.Release|x86.Build.0 = Release|Any CPU
104-
{B688E099-77FF-46D9-B61B-5C6D718DDBFB}.Debug|Any CPU.ActiveCfg = Debug|Win32
104+
{B688E099-77FF-46D9-B61B-5C6D718DDBFB}.Debug|Any CPU.ActiveCfg = Debug|x64
105+
{B688E099-77FF-46D9-B61B-5C6D718DDBFB}.Debug|Any CPU.Build.0 = Debug|x64
105106
{B688E099-77FF-46D9-B61B-5C6D718DDBFB}.Debug|x64.ActiveCfg = Debug|x64
106107
{B688E099-77FF-46D9-B61B-5C6D718DDBFB}.Debug|x64.Build.0 = Debug|x64
107108
{B688E099-77FF-46D9-B61B-5C6D718DDBFB}.Debug|x86.ActiveCfg = Debug|Win32

src/BindingsForNativeLib/BindingsGenerator/BindingsGenerator.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="CppAst" Version="0.1.3" />
11+
<PackageReference Include="CppAst" Version="0.5.7" />
12+
<PackageReference Include="CppPinvokeGenerator" Version="0.1.2" />
1213
</ItemGroup>
1314

1415
</Project>

0 commit comments

Comments
 (0)