|
6 | 6 | using System.Linq; |
7 | 7 | using System.Reflection; |
8 | 8 | using System.Runtime.CompilerServices; |
| 9 | +using System.Runtime.Versioning; |
9 | 10 | using System.Threading; |
10 | 11 |
|
11 | 12 | namespace Java.Interop { |
12 | 13 |
|
| 14 | +#if NET |
| 15 | + [RequiresPreviewFeatures] |
| 16 | + public struct ReplacementMethodInfo : IEquatable<ReplacementMethodInfo> |
| 17 | + { |
| 18 | + public string? JniSourceType {get; set;} |
| 19 | + public string? SourceJniMethodName {get; set;} |
| 20 | + public string? SourceJniMethodSignature {get; set;} |
| 21 | + public string? JniTargetType {get; set;} |
| 22 | + public string? TargetJniMethodName {get; set;} |
| 23 | + public string? TargetJniMethodSignature {get; set;} |
| 24 | + public int? TargetJniMethodParameterCount {get; set;} |
| 25 | + public bool TargetJniMethodIsStatic {get; set;} |
| 26 | + |
| 27 | + public override bool Equals (object? obj) |
| 28 | + { |
| 29 | + if (obj is ReplacementMethodInfo o) { |
| 30 | + return Equals (o); |
| 31 | + } |
| 32 | + return false; |
| 33 | + } |
| 34 | + |
| 35 | + public bool Equals (ReplacementMethodInfo other) |
| 36 | + { |
| 37 | + return string.Equals (JniSourceType, other.JniSourceType) && |
| 38 | + string.Equals (SourceJniMethodName, other.SourceJniMethodName) && |
| 39 | + string.Equals (SourceJniMethodSignature, other.SourceJniMethodSignature) && |
| 40 | + string.Equals (JniTargetType, other.JniTargetType) && |
| 41 | + string.Equals (TargetJniMethodName, other.TargetJniMethodName) && |
| 42 | + string.Equals (TargetJniMethodSignature, other.TargetJniMethodSignature) && |
| 43 | + TargetJniMethodParameterCount == other.TargetJniMethodParameterCount && |
| 44 | + TargetJniMethodIsStatic == other.TargetJniMethodIsStatic; |
| 45 | + } |
| 46 | + |
| 47 | + public override int GetHashCode () |
| 48 | + { |
| 49 | + return (JniSourceType?.GetHashCode () ?? 0) ^ |
| 50 | + (SourceJniMethodName?.GetHashCode () ?? 0) ^ |
| 51 | + (SourceJniMethodSignature?.GetHashCode () ?? 0) ^ |
| 52 | + (JniTargetType?.GetHashCode () ?? 0) ^ |
| 53 | + (TargetJniMethodName?.GetHashCode () ?? 0) ^ |
| 54 | + (TargetJniMethodSignature?.GetHashCode () ?? 0) ^ |
| 55 | + (TargetJniMethodParameterCount?.GetHashCode () ?? 0) ^ |
| 56 | + TargetJniMethodIsStatic.GetHashCode (); |
| 57 | + } |
| 58 | + |
| 59 | + public override string ToString () |
| 60 | + { |
| 61 | + return $"{nameof (ReplacementMethodInfo)} {{ " + |
| 62 | + $"JniSourceType = \"{JniSourceType}\"" + |
| 63 | + $", SourceJniMethodName = \"{SourceJniMethodName}\"" + |
| 64 | + $", SourceJniMethodSignature = \"{SourceJniMethodSignature}\"" + |
| 65 | + $", JniTargetType = \"{JniTargetType}\"" + |
| 66 | + $", TargetJniMethodName = \"{TargetJniMethodName}\"" + |
| 67 | + $", TargetJniMethodSignature = \"{TargetJniMethodSignature}\"" + |
| 68 | + $", TargetJniMethodParameterCount = {TargetJniMethodParameterCount?.ToString () ?? "null"}" + |
| 69 | + $", TargetJniMethodIsStatic = {TargetJniMethodIsStatic}" + |
| 70 | + $"}}"; |
| 71 | + } |
| 72 | + |
| 73 | + public static bool operator==(ReplacementMethodInfo a, ReplacementMethodInfo b) => a.Equals (b); |
| 74 | + public static bool operator!=(ReplacementMethodInfo a, ReplacementMethodInfo b) => !a.Equals (b); |
| 75 | + } |
| 76 | +#endif // NET |
| 77 | + |
13 | 78 | public partial class JniRuntime { |
14 | 79 |
|
15 | 80 | public class JniTypeManager : IDisposable, ISetRuntime { |
@@ -251,6 +316,14 @@ IEnumerable<Type> CreateGetTypesForSimpleReferenceEnumerator (string jniSimpleRe |
251 | 316 | yield break; |
252 | 317 | } |
253 | 318 |
|
| 319 | +#if NET |
| 320 | + [RequiresPreviewFeatures] |
| 321 | + internal protected virtual string[]? GetFallbackTypes (string jniSimpleReference) => null; |
| 322 | + // public virtual string? GetReplacementType (string jniTypeSimpleReference) => null; |
| 323 | + [RequiresPreviewFeatures] |
| 324 | + internal protected virtual ReplacementMethodInfo? GetReplacementMethodInfo (string jniSourceType, string jniMethodName, string jniMethodSignature) => null; |
| 325 | +#endif // NET |
| 326 | + |
254 | 327 | public virtual void RegisterNativeMembers (JniType nativeClass, Type type, string? methods) |
255 | 328 | { |
256 | 329 | TryRegisterNativeMembers (nativeClass, type, methods); |
|
0 commit comments