forked from dotnet/macios
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tools] Add a managed static registrar. Fixes dotnet#17324.
Fixes dotnet#17324.
- Loading branch information
1 parent
d627980
commit b43ab76
Showing
9 changed files
with
1,717 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// IManagedRegistrar.cs | ||
// | ||
// Authors: | ||
// Rolf Bjarne Kvinge | ||
// | ||
// Copyright 2023 Microsoft Corp | ||
|
||
|
||
#if NET | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace ObjCRuntime { | ||
// The managed static registrar will generate/inject a type that implements this method | ||
// in every assembly it processes. At runtime we'll instantiate a singleton instance | ||
// of this type. | ||
// The managed static registrar will make this interface public when needed. | ||
interface IManagedRegistrar { | ||
// Find a function pointer for a given [UnmanagedCallersOnly] method. | ||
// The entryPoint parameter is the EntryPoint value in the attribute, but it's not used for lookup (only tracing/logging/error messages). | ||
// The 'id' is instead used - the values and the lookup tables are generated and injected by the managed static registrar at build time. | ||
IntPtr LookupUnmanagedFunction (string? entryPoint, int id); | ||
// Find a type given an id generated by the managed static registrar. | ||
// This method is the mirror method of LookupTypeId. | ||
RuntimeTypeHandle LookupType (uint id); | ||
// Find an id generated by the managed static registrar given an id. | ||
// This method is the mirror method of LookupType. | ||
uint LookupTypeId (RuntimeTypeHandle handle); | ||
// Called by the runtime when looking up a wrapper type given an interface type. | ||
// This method will be called once per assembly, and the implementation has to | ||
// add all the interface -> wrapper type mappings to the dictionary. | ||
void RegisterWrapperTypes (Dictionary<RuntimeTypeHandle, RuntimeTypeHandle> type); | ||
} | ||
} | ||
|
||
#endif // NET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.