Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeGen: implement the wide architecture set #356

Merged
merged 58 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f556c45
(#354) CodeGen: implement the wide architecture set
ForNeVeR Dec 11, 2022
2c8853a
(#354) Runtime: introduce the CPtr type
ForNeVeR Dec 11, 2022
15ed227
(#354) FunctionType: add a TODO about the wide architecture
ForNeVeR Dec 13, 2022
244b6bd
(#354) Docs: document the current decision on pointer portability
ForNeVeR Feb 12, 2023
8ed11c6
(#354) CPtr, FPtr: add tests
ForNeVeR Feb 12, 2023
7c73251
(#354) VoidPtr, FuncPtr
ForNeVeR Feb 17, 2023
3833c05
(#354) Add more tests
ForNeVeR Feb 17, 2023
bfbbec1
(#354) Functions: add TODO
ForNeVeR Feb 21, 2023
6f39aa4
(#356) Docs: document the new pointer types in the architecture set d…
ForNeVeR Jul 29, 2023
7cf15f0
(#384) Docs: more clarification
ForNeVeR Jul 29, 2023
b5512a0
(#354) Docs: more clarifications
ForNeVeR Jul 29, 2023
665c544
Merge branch 'main' into feature/354.wide-arch
ForNeVeR Jul 29, 2023
ec67da2
(#354) Roll back the runtime lib changes
ForNeVeR Aug 5, 2023
704d062
(#354) Runtime: roll back the unnecessary changes
ForNeVeR Aug 12, 2023
1fefa3a
(#354) Apply test data diff
ForNeVeR Aug 13, 2023
e74fb50
(#356) Test fixes
ForNeVeR Aug 17, 2023
a43396e
(#354) Tests: add .NET interop tests
ForNeVeR Aug 17, 2023
a1689a2
(#354) Tests: add .NET pointer interop tests
ForNeVeR Aug 17, 2023
b97e32a
(#356) Refactor CodeGenNetInteropTests
ForNeVeR Aug 19, 2023
e63f01a
(#354) Tests: add CSharpCompilationUtil
ForNeVeR Aug 21, 2023
95a209d
(#354) Tests: compile C# projects with unsafe enabled
ForNeVeR Aug 25, 2023
9a5e3a4
(#354) Finish .NET compilation support for tests
ForNeVeR Aug 27, 2023
2424b21
(#354) Tests: add a test for CPtr in struct generation
ForNeVeR Aug 29, 2023
b4ef7d7
(#354) Basic support for new runtime wide pointer wrappers
ForNeVeR Aug 29, 2023
4350ca1
(#354) CodeGen: support CPtr interop on the Wide architecture
ForNeVeR Sep 2, 2023
e6b682d
(#354) CodeGen: add a test for CPtr<CPtr<T>>
ForNeVeR Sep 6, 2023
8667d7d
(#354) More tests for pointer interop
ForNeVeR Oct 30, 2023
a653fb7
Merge remote-tracking branch 'origin/main' into feature/354.wide-arch
ForNeVeR Oct 30, 2023
3f530d6
(#354) Fix compilation, deduplicate some redundant tests
ForNeVeR Oct 30, 2023
d94ea64
(#354) CodeGen: implement generic delegate cache
ForNeVeR Oct 31, 2023
19b4a1e
(#354) CodeGen: fix the remaining tests
ForNeVeR Oct 31, 2023
2d4c688
(#354) CodeGen: more tests for the various types of pointer interop
ForNeVeR Oct 31, 2023
84e53f9
(#354) CodeGen: match compatibility ptr types with the actual pointer…
ForNeVeR Nov 2, 2023
8e894e0
(#354) FunctionCallExpression: extract the type conversion into a sep…
ForNeVeR Nov 2, 2023
2e93313
(#354) CodeGen: groundwork for CLR type conversion
ForNeVeR Nov 2, 2023
fc71a17
(#354) CodeGen: call implicit cast operator for VoidPtr
ForNeVeR Nov 5, 2023
ee109a1
(#354) CodeGen: emit additional type case before calling the cast ope…
ForNeVeR Nov 5, 2023
6614b32
Merge remote-tracking branch 'origin/main' into feature/354.wide-arch
ForNeVeR Nov 5, 2023
e64f5d5
(#354) CodeGen: move further on CPtr cast operator
ForNeVeR Nov 11, 2023
e4c9183
(#354) CodeGen: support proper CPtr interop
ForNeVeR Nov 13, 2023
1a9bf18
(#354) FuncPtr conversion via constructor
ForNeVeR Nov 17, 2023
118e2d7
Merge branch 'main' into feature/354.wide-arch
ForNeVeR Nov 17, 2023
862f518
(#354) Tests: fix for unsafe class
ForNeVeR Nov 18, 2023
12b22d4
(#354) CodeGen: improve validation of vararg CLI imports
ForNeVeR Nov 18, 2023
3259db0
(#354) Tests: fix the runtimes properly
ForNeVeR Nov 18, 2023
10d1cd7
(#354) CodeGen: add integration tests
ForNeVeR Nov 19, 2023
193c090
(#354) CodeGen: proper FuncPtr conversion
ForNeVeR Nov 19, 2023
44c0f1a
(#354) CodeGen: add an integration test for function pointers inside …
ForNeVeR Nov 21, 2023
72ced1b
(#354) TODO sweep, better typoe checks
ForNeVeR Nov 21, 2023
0b133df
Merge branch 'main' into feature/354.wide-arch
ForNeVeR Nov 21, 2023
69a5c06
(#354) FunctionInfo: add a TODO
ForNeVeR Nov 23, 2023
4b2783f
(#354) Integration tests: drop an incorrect project item
ForNeVeR Nov 23, 2023
ad2fcd6
(#354) IntegrationTestContext: code cleanup
ForNeVeR Nov 23, 2023
443597e
(#354) Docs: small improvement
ForNeVeR Nov 23, 2023
b76311e
(#78, #285, #487, #488, #489, #490, #491, #492) Connect TODOs with th…
ForNeVeR Nov 23, 2023
79e2967
(#487, #493) Connect TODOs with the issues
ForNeVeR Nov 23, 2023
171fbee
WipException.ToDo: better documentation
ForNeVeR Nov 23, 2023
d76e339
Build: use the last version of JetBrains.Annotations everywhere
ForNeVeR Nov 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Cesium.Runtime.Tests/PtrTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Cesium.Runtime.Tests;

public unsafe class PtrTests
{
[Fact]
public void CPtrTests()
{
CPtr v = (void*)0x1234;
Assert.Equal(0x1234L, (long)v.AsPtr());
Assert.Equal(0x1234L, (long)v.AsPtr<byte>());

Assert.Equal(sizeof(long), sizeof(CPtr));

CPtr<int> t = (int*)0x2345;
Assert.Equal(0x2345L, (long)t.AsPtr());
Assert.Equal((IntPtr)0x2345, t.AsIntPtr());
Assert.Equal(0x2345L, (long)t.AsPtr<byte>());

Assert.Equal(sizeof(long), sizeof(CPtr<int>));
}

[Fact]
public void FPtrTests()
{
var a = new FPtr<Action>((void*)0x1234);
Assert.Equal(0x1234L, (long)a.AsPtr());
Assert.Equal(sizeof(long), sizeof(FPtr<Action>));
}
}
4 changes: 2 additions & 2 deletions Cesium.Runtime/CPtr.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Cesium.Runtime;

/// <summary>A class encapsulating an opaque pointer (aka <code>void*</code> in C).</summary>
public unsafe readonly struct CPtr
public readonly unsafe struct CPtr
{
private readonly long _value;

Expand All @@ -19,7 +19,7 @@ private CPtr(long value)

/// <summary>A class encapsulating an object pointer.</summary>
/// <typeparam name="T">Type this pointer may be resolved to.</typeparam>
public unsafe readonly struct CPtr<T> where T : unmanaged
public readonly unsafe struct CPtr<T> where T : unmanaged
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And maybe VoidPtr. I do like CPtr, but it sounds too broad for me. But that's just remark. I do have only vague feeling here.

{
private readonly long _value;

Expand Down
14 changes: 14 additions & 0 deletions Cesium.Runtime/FPtr.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Cesium.Runtime;

/// <summary>A class encapsulating a C function pointer.</summary>
public readonly unsafe struct FPtr<TDelegate> where TDelegate : Delegate // TODO: Think about vararg and empty parameter list encoding.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe FuncPtr?

{
private readonly long _value;

public FPtr(void* ptr)
{
_value = (long)ptr;
}

public void* AsPtr() => (void*)_value;
}
2 changes: 1 addition & 1 deletion Cesium.Runtime/StringFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Cesium.Runtime;
/// <summary>
/// Functions declared in the string.h
/// </summary>
public unsafe static class StringFunctions
public static unsafe class StringFunctions
{
public static uint StrLen(CPtr<byte> str)
{
Expand Down