-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
For now, we have CreateDelegate to create delegate from PROC and FARPROC. But when the delegate has generated to a struct for delegate*, it cannot work.
Describe the solution you'd like
Add a CreateDelegatePointer method for PROC and FARPROC, such as:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal TDelegate CreateDelegatePointer<TDelegate>() where T : unmanaged => Unsafe.As<PROC, T>(ref this.Value);Describe alternatives you've considered
For now, we can create an extension to use it:
JClass mainClass = env->functions->FindClass.CreateDelegatePointer<FindClass>().Value(env, "java/lang/String"u8.AsPCSTR());
file static class Extensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static PCSTR AsPCSTR(this scoped in ReadOnlySpan<byte> data) => Unsafe.As<ReadOnlySpan<byte>, PCSTR>(ref Unsafe.AsRef(in data));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TDelegate CreateDelegatePointer<TDelegate>(this PROC function) where T : unmanaged => Unsafe.As<PROC, T>(ref function);
}Additional context
#1629
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request