Skip to content
Closed
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
50 changes: 4 additions & 46 deletions src/Mono.Android/Java.Interop/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,29 +218,9 @@ static Exception CreateJavaLocationException ()
if (type != null)
return type;

if (!JNIEnv.IsRunningOnDesktop) {
// Miss message is logged in the native runtime
if (JNIEnv.LogTypemapMissStackTrace)
JNIEnv.LogTypemapTrace (new System.Diagnostics.StackTrace (true));
return null;
}
if (!JNIEnv.IsRunningOnDesktop && JNIEnv.LogTypemapMissStackTrace)
JNIEnv.LogTypemapTrace (new System.Diagnostics.StackTrace (true));

__TypeRegistrations.RegisterPackages ();

type = null;
int ls = class_name.LastIndexOf ('/');
var package = ls >= 0 ? class_name.Substring (0, ls) : "";
if (packageLookup.TryGetValue (package, out var mappers)) {
foreach (Converter<string, Type?> c in mappers) {
type = c (class_name);
if (type == null)
continue;
return type;
}
}
if ((type = Type.GetType (JavaNativeTypeManager.ToCliType (class_name))) != null) {
return type;
}
return null;
}

Expand Down Expand Up @@ -353,36 +333,14 @@ public static void RegisterType (string java_class, Type t)
}
}

static Dictionary<string, List<Converter<string, Type?>>> packageLookup = new Dictionary<string, List<Converter<string, Type?>>> ();

public static void RegisterPackage (string package, Converter<string, Type> lookup)
{
lock (packageLookup) {
if (!packageLookup.TryGetValue (package, out var lookups))
packageLookup.Add (package, lookups = new List<Converter<string, Type?>> ());
lookups.Add (lookup);
}
throw new NotImplementedException ();
}

public static void RegisterPackages (string[] packages, Converter<string, Type?>[] lookups)
{
if (packages == null)
throw new ArgumentNullException ("packages");
if (lookups == null)
throw new ArgumentNullException ("lookups");
if (packages.Length != lookups.Length)
throw new ArgumentException ("`packages` and `lookups` arrays must have same number of elements.");

lock (packageLookup) {
for (int i = 0; i < packages.Length; ++i) {
string package = packages [i];
var lookup = lookups [i];

if (!packageLookup.TryGetValue (package, out var _lookups))
packageLookup.Add (package, _lookups = new List<Converter<string, Type?>> ());
_lookups.Add (lookup);
}
}
throw new NotImplementedException ();
}

[Register ("mono/android/TypeManager", DoNotGenerateAcw = true)]
Expand Down
6 changes: 5 additions & 1 deletion src/Mono.Android/Mono.Android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@
<Import Project="..\..\build-tools\scripts\JavaCallableWrappers.targets" />
<Import Project="$(IntermediateOutputPath)mcw\Mono.Android.projitems" Condition="Exists('$(IntermediateOutputPath)mcw\Mono.Android.projitems')" />

<ItemGroup>
<ItemGroup>
<Compile Remove="$(IntermediateOutputPath)mcw\Java.Interop.__TypeRegistrations.cs" />
</ItemGroup>

<ItemGroup>
<Compile Include="Android\IncludeAndroidResourcesFromAttribute.cs" />
<Compile Include="Android\LinkerSafeAttribute.cs" />
<Compile Include="Android\NativeLibraryReferenceAttribute.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/Mono.Android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
IgnoreStandardErrorWarningFormat="True"
/>
<ItemGroup>
<Compile Include="$(_FullIntermediateOutputPath)\mcw\**\*.cs" KeepDuplicates="False" />
<Compile Include="$(_FullIntermediateOutputPath)\mcw\**\*.cs" KeepDuplicates="False" Exclude="$(_FullIntermediateOutputPath)\mcw\Java.Interop.__TypeRegistrations.cs" />
</ItemGroup>
<XmlPeek
Namespaces="&lt;Namespace Prefix='msbuild' Uri='http://schemas.microsoft.com/developer/msbuild/2003' /&gt;"
Expand Down