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
2 changes: 1 addition & 1 deletion tools/generator/JavaInteropCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ internal override void WriteConstructorBody (Ctor ctor, StreamWriter sw, string
var oldindent = indent;
indent += "\t";
ctor.Parameters.WriteCallArgs (sw, indent, opt, invoker:false);
sw.WriteLine ("{0}var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (){1});", indent, ctor.Parameters.GetCallArgs (opt, invoker:false));
sw.WriteLine ("{0}var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (){1});", indent, ctor.Parameters.GetCallArgs (opt, invoker:false));
sw.WriteLine ("{0}SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);", indent);
sw.WriteLine ("{0}_members.InstanceMethods.FinishCreateInstance (__id, this{1});", indent, ctor.Parameters.GetCallArgs (opt, invoker:false));
indent = oldindent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public unsafe SpannableString (Java.Lang.ICharSequence source)
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_source);
var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args);
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args);
SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
_members.InstanceMethods.FinishCreateInstance (__id, this, __args);
} finally {
Expand All @@ -65,7 +65,7 @@ public unsafe SpannableString (string source)
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_source);
var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args);
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args);
SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
_members.InstanceMethods.FinishCreateInstance (__id, this, __args);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public unsafe SpannableString (Java.Lang.ICharSequence source)
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_source);
if (GetType () != typeof (SpannableString)) {
if (((object) this).GetType () != typeof (SpannableString)) {
SetHandle (
global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(Ljava/lang/CharSequence;)V", __args),
global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(Ljava/lang/CharSequence;)V", __args),
JniHandleOwnership.TransferLocalRef);
global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(Ljava/lang/CharSequence;)V", __args);
return;
Expand Down Expand Up @@ -68,9 +68,9 @@ public unsafe SpannableString (string source)
try {
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_source);
if (GetType () != typeof (SpannableString)) {
if (((object) this).GetType () != typeof (SpannableString)) {
SetHandle (
global::Android.Runtime.JNIEnv.StartCreateInstance (GetType (), "(Ljava/lang/CharSequence;)V", __args),
global::Android.Runtime.JNIEnv.StartCreateInstance (((object) this).GetType (), "(Ljava/lang/CharSequence;)V", __args),
JniHandleOwnership.TransferLocalRef);
global::Android.Runtime.JNIEnv.FinishCreateInstance (((global::Java.Lang.Object) this).Handle, "(Ljava/lang/CharSequence;)V", __args);
return;
Expand Down Expand Up @@ -117,7 +117,7 @@ public override unsafe Android.Text.SpanTypes GetSpanFlags (Java.Lang.Object wha
__args [0] = new JValue (what);

Android.Text.SpanTypes __ret;
if (GetType () == ThresholdType)
if (((object) this).GetType () == ThresholdType)
__ret = (Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args);
else
__ret = (Android.Text.SpanTypes) JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSpanFlags", "(Ljava/lang/Object;)I"), __args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public virtual unsafe Android.Text.SpanTypes GetSpanFlags (Java.Lang.Object p0)
__args [0] = new JValue (p0);

Android.Text.SpanTypes __ret;
if (GetType () == ThresholdType)
if (((object) this).GetType () == ThresholdType)
__ret = (Android.Text.SpanTypes) JNIEnv.CallIntMethod (((global::Java.Lang.Object) this).Handle, id_getSpanFlags_Ljava_lang_Object_, __args);
else
__ret = (Android.Text.SpanTypes) JNIEnv.CallNonvirtualIntMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "getSpanFlags", "(Ljava/lang/Object;)I"), __args);
Expand Down
4 changes: 2 additions & 2 deletions tools/generator/Tests-Core/expected/Android.Views.View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public virtual unsafe void SetOnClickListener (Android.Views.View.IOnClickListen
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (l);

if (GetType () == ThresholdType)
if (((object) this).GetType () == ThresholdType)
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_setOnClickListener_Landroid_view_View_OnClickListener_, __args);
else
JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "setOnClickListener", "(Landroid/view/View$OnClickListener;)V"), __args);
Expand Down Expand Up @@ -201,7 +201,7 @@ public virtual unsafe void AddTouchables (System.Collections.Generic.IList<Andro
JValue* __args = stackalloc JValue [1];
__args [0] = new JValue (native_views);

if (GetType () == ThresholdType)
if (((object) this).GetType () == ThresholdType)
JNIEnv.CallVoidMethod (((global::Java.Lang.Object) this).Handle, id_addTouchables_Ljava_util_ArrayList_, __args);
else
JNIEnv.CallNonvirtualVoidMethod (((global::Java.Lang.Object) this).Handle, ThresholdClass, JNIEnv.GetMethodID (ThresholdClass, "addTouchables", "(Ljava/util/ArrayList;)V"), __args);
Expand Down
19 changes: 19 additions & 0 deletions tools/generator/Tests/expected.ji/Adapters/Mono.Android.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.AbsSpinner.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.AdapterView.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.GenericReturnObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.IAdapter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.ISpinnerAdapter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
15 changes: 15 additions & 0 deletions tools/generator/Tests/expected.ji/Arrays/Mono.Android.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public unsafe SomeObject ()
return;

try {
var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), null);
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null);
SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
_members.InstanceMethods.FinishCreateInstance (__id, this, null);
} finally {
Expand All @@ -61,7 +61,7 @@ public unsafe SomeObject (int aint)
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (aint);
var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args);
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args);
SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
_members.InstanceMethods.FinishCreateInstance (__id, this, __args);
} finally {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.NotificationCompatBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public unsafe InstanceInner (global::Xamarin.Test.NotificationCompatBase __self)
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue ((__self == null) ? IntPtr.Zero : ((global::Java.Lang.Object) __self).Handle);
var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args);
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args);
SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
_members.InstanceMethods.FinishCreateInstance (__id, this, __args);
} finally {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
16 changes: 16 additions & 0 deletions tools/generator/Tests/expected.ji/NormalMethods/Java.Lang.Class.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using Android.Runtime;
using Java.Interop;

namespace Java.Lang {

// Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Class']"
[global::Android.Runtime.Register ("java/lang/Class", DoNotGenerateAcw=true)]
[global::Java.Interop.JavaTypeParameters (new string [] {"T"})]
public partial class Class : global::Java.Lang.Object {

protected Class (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) {}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using Android.Runtime;
using Java.Interop;

namespace Java.Lang {

// Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Throwable']"
[global::Android.Runtime.Register ("java/lang/Throwable", DoNotGenerateAcw=true)]
public partial class Throwable {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Class.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Integer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Throwable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.A.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.C.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,41 @@ public unsafe SomeObject (global::Java.Lang.Class c)
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue ((c == null) ? IntPtr.Zero : ((global::Java.Lang.Object) c).Handle);
var __r = _members.InstanceMethods.StartCreateInstance (__id, GetType (), __args);
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), __args);
SetHandle (__r.Handle, JniHandleOwnership.TransferLocalRef);
_members.InstanceMethods.FinishCreateInstance (__id, this, __args);
} finally {
}
}

static Delegate cb_getType;
#pragma warning disable 0169
static Delegate GetGetTypeHandler ()
{
if (cb_getType == null)
cb_getType = JNINativeWrapper.CreateDelegate ((Func<IntPtr, IntPtr, IntPtr>) n_GetType);
return cb_getType;
}

static IntPtr n_GetType (IntPtr jnienv, IntPtr native__this)
{
global::Xamarin.Test.SomeObject __this = global::Java.Lang.Object.GetObject<global::Xamarin.Test.SomeObject> (jnienv, native__this, JniHandleOwnership.DoNotTransfer);
return JNIEnv.NewArray (__this.GetType ());
}
#pragma warning restore 0169

// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='SomeObject']/method[@name='getType' and count(parameter)=0]"
[Register ("getType", "()[I", "GetGetTypeHandler")]
public virtual unsafe int[] GetType ()
{
const string __id = "getType.()[I";
try {
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return (int[]) JNIEnv.GetArray (__rm.Handle, JniHandleOwnership.TransferLocalRef, typeof (int));
} finally {
}
}

static Delegate cb_handle_Ljava_lang_Object_Ljava_lang_Throwable_;
#pragma warning disable 0169
static Delegate GetHandle_Ljava_lang_Object_Ljava_lang_Throwable_Handler ()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Integer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.A.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4</DefineConstants>
</PropertyGroup>
<!-- Classes -->
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.SomeObject.cs" />
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" />
</ItemGroup>
<!-- Enums -->
<ItemGroup />
</Project>
Loading