Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,69 +30,6 @@ public void ConstructorExceptions ()
Assert.AreEqual (4200, e.Code);
}

[Test]
public void GenerateInParallel ()
{
var assemblyDef = AssemblyDefinition.ReadAssembly (typeof (DefaultName).Assembly.Location);
var types = new []{
typeof (AbstractClassInvoker),
typeof (AbstractClass),
typeof (ActivityName),
typeof (ApplicationName),
typeof (DefaultName),
typeof (DefaultName.A),
typeof (DefaultName.A.B),
typeof (DefaultName.C.D),
// Skip because this will produce nested types
// typeof (ExampleOuterClass),
// typeof (ExampleOuterClass.ExampleInnerClass),
typeof (InstrumentationName),
// Skip because this will produce nested types
// typeof (NonStaticOuterClass),
// typeof (NonStaticOuterClass.NonStaticInnerClass),
typeof (ProviderName),
typeof (ReceiverName),
typeof (RegisterName),
typeof (RegisterName.DefaultNestedName),
typeof (RegisterName.OverrideNestedName),
typeof (ServiceName),
};
var typeDefs = types.Select (t => SupportDeclarations.GetTypeDefinition (t, assemblyDef))
.ToList ();

var tasks = typeDefs.Select (type => Task.Run (() => {
var g = new JavaCallableWrapperGenerator (type, log: Console.WriteLine);
var o = new StringWriter ();
g.Generate (o);
var r = new StringReader (o.ToString ());
var l = r.ReadLine ();
if (!l.StartsWith ("package ", StringComparison.Ordinal))
throw new InvalidOperationException ($"Invalid JCW for {type.FullName}!");
var p = l.Substring ("package ".Length);
p = p.Substring (0, p.Length - 1);
l = r.ReadLine ();
if (l.Length != 0)
throw new InvalidOperationException ($"Invalid JCW for {type.FullName}! (Missing newline)");
l = r.ReadLine ();
if (l.Length != 0)
throw new InvalidOperationException ($"Invalid JCW for {type.FullName}! (Missing 2nd newline)");
l = r.ReadLine ();
string c = null;
if (l.StartsWith ("public class ", StringComparison.Ordinal))
c = l.Substring ("public class ".Length);
else if (l.StartsWith ("public abstract class ", StringComparison.Ordinal))
c = l.Substring ("public abstract class ".Length);
else
throw new InvalidOperationException ($"Invalid JCW for {type.FullName}! (Missing class)");
return p + "/" + c;
})).ToArray ();
Task.WaitAll (tasks);
for (int i = 0; i < types.Length; ++i) {
Assert.AreEqual (JniType.ToJniName (typeDefs [i]), tasks [i].Result);
Assert.AreEqual (JniType.ToJniName (types [i]), tasks [i].Result);
}
}

[Test]
public void GenerateApplication (
[Values (null, "android.app.Application", "android.support.multidex.MultiDexApplication")] string applicationJavaClass
Expand Down
9 changes: 5 additions & 4 deletions tools/jcw-gen/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public static int Main (string [] args)
resolver.SearchDirectories.Add (Path.GetDirectoryName (assembly));
resolver.Load (assembly);
}
var tasks = JavaTypeScanner.GetJavaTypes (assemblies, resolver, log: Console.WriteLine)
.Where (td => !JavaTypeScanner.ShouldSkipJavaCallableWrapperGeneration (td))
.Select (td => Task.Run (() => GenerateJavaCallableWrapper (td, outputPath)));
Task.WaitAll (tasks.ToArray ());
var types = JavaTypeScanner.GetJavaTypes (assemblies, resolver, log: Console.WriteLine)
.Where (td => !JavaTypeScanner.ShouldSkipJavaCallableWrapperGeneration (td));
foreach (var type in types) {
GenerateJavaCallableWrapper (type, outputPath);
}
return 0;
}
catch (Exception e) {
Expand Down