Skip to content

Commit 03f8edf

Browse files
committed
[generator] Extend skipInvokerMethods support to interfaces.
1 parent 14a9470 commit 03f8edf

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ public static InterfaceGen CreateInterface (XElement pkg, XElement elem, CodeGen
331331
!options.SupportNestedInterfaceTypes
332332
};
333333

334+
if (elem.Attribute ("skipInvokerMethods")?.Value is string skip)
335+
foreach (var m in skip.Split (new char [] { ',', ' ', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries))
336+
iface.SkippedInvokerMethods.Add (m);
337+
334338
FillApiSince (iface, pkg, elem);
335339
SetLineInfo (iface, elem, options);
336340

tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace MonoDroid.Generation
1111
public class ClassGen : GenBase
1212
{
1313
bool fill_explicit_implementation_started;
14-
HashSet<string> skipped_invoker_methods;
1514

1615
public List<Ctor> Ctors { get; private set; } = new List<Ctor> ();
1716

@@ -356,8 +355,6 @@ public override void ResetValidation ()
356355
base.ResetValidation ();
357356
}
358357

359-
public HashSet<string> SkippedInvokerMethods => skipped_invoker_methods ??= new HashSet<string> ();
360-
361358
public override string ToNative (CodeGenerationOptions opt, string varname, Dictionary<string, string> mappings = null)
362359
{
363360
if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) {

tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public abstract class GenBase : IGeneratable, ApiVersionsSupport.IApiAvailabilit
1717
protected bool iface_validation_failed;
1818
protected GenBaseSupport support;
1919
protected bool validated = false;
20+
HashSet<string> skipped_invoker_methods;
2021

2122
readonly List<string> implemented_interfaces = new List<string> ();
2223
readonly Dictionary<string, Method> jni_sig_hash = new Dictionary<string, Method> ();
@@ -854,6 +855,8 @@ bool ReturnTypeMatches (Method m, Method mm)
854855

855856
public bool ShouldGenerateAnnotationAttribute => IsAnnotation;
856857

858+
public HashSet<string> SkippedInvokerMethods => skipped_invoker_methods ??= new HashSet<string> ();
859+
857860
public void StripNonBindables (CodeGenerationOptions opt)
858861
{
859862
// Strip out default interface methods if not desired

tools/generator/SourceWriters/InterfaceInvokerClass.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public InterfaceInvokerClass (InterfaceGen iface, CodeGenerationOptions opt, Cod
6969

7070
Constructors.Add (new InterfaceInvokerConstructor (opt, iface, context));
7171

72-
AddMemberInvokers (iface, new HashSet<string> (), opt, context);
72+
AddMemberInvokers (iface, new HashSet<string> (), iface.SkippedInvokerMethods, opt, context);
7373
}
7474

7575
static HashSet<InterfaceGen> GetCompleteImplementedInterfaces (HashSet<InterfaceGen> ifaces, InterfaceGen toplevel)
@@ -81,15 +81,15 @@ static HashSet<InterfaceGen> GetCompleteImplementedInterfaces (HashSet<Interface
8181
return ifaces;
8282
}
8383

84-
void AddMemberInvokers (InterfaceGen iface, HashSet<string> members, CodeGenerationOptions opt, CodeGeneratorContext context)
84+
void AddMemberInvokers (InterfaceGen iface, HashSet<string> members, HashSet<string> skipInvokers, CodeGenerationOptions opt, CodeGeneratorContext context)
8585
{
8686
AddPropertyInvokers (iface, iface.Properties.Where (p => !p.Getter.IsStatic && !p.Getter.IsInterfaceDefaultMethod), members, opt, context);
87-
AddMethodInvokers (iface, iface.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod), members, opt, context);
87+
AddMethodInvokers (iface, iface.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod), members, skipInvokers, opt, context);
8888
AddCharSequenceEnumerators (iface);
8989

9090
foreach (var i in iface.GetAllDerivedInterfaces ()) {
9191
AddPropertyInvokers (iface, i.Properties.Where (p => !p.Getter.IsStatic && !p.Getter.IsInterfaceDefaultMethod), members, opt, context);
92-
AddMethodInvokers (iface, i.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod && !iface.IsCovariantMethod (m) && !(i.FullName.StartsWith ("Java.Lang.ICharSequence", StringComparison.Ordinal) && m.Name.EndsWith ("Formatted", StringComparison.Ordinal))), members, opt, context);
92+
AddMethodInvokers (iface, i.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod && !iface.IsCovariantMethod (m) && !(i.FullName.StartsWith ("Java.Lang.ICharSequence", StringComparison.Ordinal) && m.Name.EndsWith ("Formatted", StringComparison.Ordinal))), members, skipInvokers, opt, context);
9393
AddCharSequenceEnumerators (i);
9494
}
9595
}
@@ -113,10 +113,13 @@ void AddPropertyInvokers (InterfaceGen iface, IEnumerable<Property> properties,
113113
Properties.Add (new InterfaceInvokerProperty (iface, prop, opt, context));
114114
}
115115
}
116-
117-
void AddMethodInvokers (InterfaceGen iface, IEnumerable<Method> methods, HashSet<string> members, CodeGenerationOptions opt, CodeGeneratorContext context)
116+
117+
void AddMethodInvokers (InterfaceGen iface, IEnumerable<Method> methods, HashSet<string> members, HashSet<string> skipInvokers, CodeGenerationOptions opt, CodeGeneratorContext context)
118118
{
119119
foreach (var m in methods) {
120+
if (skipInvokers.Contains ($"{m.DeclaringType.RawJniName}.{m.JavaName}{m.JniSignature}"))
121+
continue;
122+
120123
var sig = m.GetSignature ();
121124

122125
if (members.Contains (sig))

0 commit comments

Comments
 (0)