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 tests/generator-Tests/Integration-Tests/Adapters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace generatortests
[TestFixture]
public class Adapters : BaseGeneratorTest
{
protected override bool TryJavaInterop1 => false;
protected override bool TryJavaInterop1 => true;

[Test]
public void GeneratedOK ()
Expand Down
2 changes: 1 addition & 1 deletion tests/generator-Tests/Integration-Tests/Java_Lang_Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace generatortests
[TestFixture]
public class Java_Lang_Enum : BaseGeneratorTest
{
protected override bool TryJavaInterop1 => false;
protected override bool TryJavaInterop1 => true;

[Test]
public void Generated_OK ()
Expand Down
10 changes: 10 additions & 0 deletions tests/generator-Tests/expected.ji/Adapters/Java.Lang.Object.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand Down Expand Up @@ -64,20 +74,19 @@ public AbsSpinnerInvoker (ref JniObjectReference reference, JniObjectReferenceOp
const string __id = "getAdapter.()Lxamarin/test/Adapter;";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
}
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
set {
const string __id = "setAdapter.(Lxamarin/test/Adapter;)V";
IntPtr native_value = JNIEnv.ToLocalJniHandle (value);
var native_value = (value?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
} finally {
JNIEnv.DeleteLocalRef (native_value);
global::System.GC.KeepAlive (value);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand All @@ -22,11 +32,11 @@ protected AdapterView (ref JniObjectReference reference, JniObjectReferenceOptio

protected abstract global::Java.Lang.Object RawAdapter {
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='getAdapter' and count(parameter)=0]"
[Register ("getAdapter", "()Lxamarin/test/Adapter;", "GetGetAdapterHandler")]
[global::Java.Interop.JniMethodSignature ("getAdapter", "()Lxamarin/test/Adapter;")]
get;

// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
[Register ("setAdapter", "(Lxamarin/test/Adapter;)V", "GetSetAdapter_Lxamarin_test_Adapter_Handler")]
[global::Java.Interop.JniMethodSignature ("setAdapter", "(Lxamarin/test/Adapter;)V")]
set;
}

Expand All @@ -52,20 +62,19 @@ public AdapterViewInvoker (ref JniObjectReference reference, JniObjectReferenceO
const string __id = "getAdapter.()Lxamarin/test/Adapter;";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.Object>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
}
// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='AdapterView']/method[@name='setAdapter' and count(parameter)=1 and parameter[1][@type='T']]"
set {
const string __id = "setAdapter.(Lxamarin/test/Adapter;)V";
IntPtr native_value = JNIEnv.ToLocalJniHandle (value);
var native_value = (value?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_value);
_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
} finally {
JNIEnv.DeleteLocalRef (native_value);
global::System.GC.KeepAlive (value);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand All @@ -20,6 +30,7 @@ protected GenericReturnObject (ref JniObjectReference reference, JniObjectRefere
}

// Metadata.xml XPath method reference: path="/api/package[@name='xamarin.test']/class[@name='GenericReturnObject']/method[@name='GenericReturn' and count(parameter)=0]"
[global::Java.Interop.JniMethodSignature ("GenericReturn", "()Lxamarin/test/AdapterView;")]
public virtual unsafe global::Xamarin.Test.AdapterView GenericReturn ()
{
const string __id = "GenericReturn.()Lxamarin/test/AdapterView;";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,20 @@ namespace Xamarin.Test {
[global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)]
public partial interface IAdapter : IJavaPeerable {
}

[global::Java.Interop.JniTypeSignature ("xamarin/test/Adapter", GenerateJavaPeer=false)]
internal partial class IAdapterInvoker : global::Java.Lang.Object, IAdapter {
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
get { return _members_xamarin_test_Adapter; }
}

static readonly JniPeerMembers _members_xamarin_test_Adapter = new JniPeerMembers ("xamarin/test/Adapter", typeof (IAdapterInvoker));

public IAdapterInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
{
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,22 @@ namespace Xamarin.Test {
[global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)]
public partial interface ISpinnerAdapter : global::Xamarin.Test.IAdapter {
}

[global::Java.Interop.JniTypeSignature ("xamarin/test/SpinnerAdapter", GenerateJavaPeer=false)]
internal partial class ISpinnerAdapterInvoker : global::Java.Lang.Object, ISpinnerAdapter {
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
get { return _members_xamarin_test_SpinnerAdapter; }
}

static readonly JniPeerMembers _members_xamarin_test_Adapter = new JniPeerMembers ("xamarin/test/Adapter", typeof (ISpinnerAdapterInvoker));

static readonly JniPeerMembers _members_xamarin_test_SpinnerAdapter = new JniPeerMembers ("xamarin/test/SpinnerAdapter", typeof (ISpinnerAdapterInvoker));

public ISpinnerAdapterInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
{
}

}
}
14 changes: 12 additions & 2 deletions tests/generator-Tests/expected.ji/java.lang.Enum/Java.Lang.Enum.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand All @@ -21,17 +31,17 @@ protected Enum (ref JniObjectReference reference, JniObjectReferenceOptions opti
}

// Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/class[@name='Enum']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='E']]"
[global::Java.Interop.JniMethodSignature ("compareTo", "(Ljava/lang/Enum;)I")]
public unsafe int CompareTo (global::Java.Lang.Object o)
{
const string __id = "compareTo.(Ljava/lang/Enum;)I";
IntPtr native_o = JNIEnv.ToLocalJniHandle (o);
var native_o = (o?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_o);
var __rm = _members.InstanceMethods.InvokeNonvirtualInt32Method (__id, this, __args);
return __rm;
} finally {
JNIEnv.DeleteLocalRef (native_o);
global::System.GC.KeepAlive (o);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,38 @@ namespace Java.Lang {
[global::Java.Interop.JavaTypeParameters (new string [] {"T"})]
public partial interface IComparable : IJavaPeerable {
// Metadata.xml XPath method reference: path="/api/package[@name='java.lang']/interface[@name='Comparable']/method[@name='compareTo' and count(parameter)=1 and parameter[1][@type='T']]"
[global::Java.Interop.JniMethodSignature ("compareTo", "(Ljava/lang/Object;)I")]
int CompareTo (global::Java.Lang.Object another);

}

[global::Java.Interop.JniTypeSignature ("java/lang/Comparable", GenerateJavaPeer=false)]
internal partial class IComparableInvoker : global::Java.Lang.Object, IComparable {
[global::System.Diagnostics.DebuggerBrowsable (global::System.Diagnostics.DebuggerBrowsableState.Never)]
[global::System.ComponentModel.EditorBrowsable (global::System.ComponentModel.EditorBrowsableState.Never)]
public override global::Java.Interop.JniPeerMembers JniPeerMembers {
get { return _members_java_lang_Comparable; }
}

static readonly JniPeerMembers _members_java_lang_Comparable = new JniPeerMembers ("java/lang/Comparable", typeof (IComparableInvoker));

public IComparableInvoker (ref JniObjectReference reference, JniObjectReferenceOptions options) : base (ref reference, options)
{
}

public unsafe int CompareTo (global::Java.Lang.Object another)
{
const string __id = "compareTo.(Ljava/lang/Object;)I";
var native_another = (another?.PeerReference ?? default);
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (native_another);
var __rm = _members_java_lang_Comparable.InstanceMethods.InvokeAbstractInt32Method (__id, this, __args);
return __rm;
} finally {
global::System.GC.KeepAlive (another);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

#nullable restore
using System;
using System.Collections.Generic;
using Java.Interop;
Expand All @@ -14,7 +24,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "BLOCKED.Ljava/lang/State;";

var __v = _members.StaticFields.GetObjectValue (__id);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

Expand All @@ -25,7 +35,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "NEW.Ljava/lang/State;";

var __v = _members.StaticFields.GetObjectValue (__id);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

Expand All @@ -36,7 +46,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "RUNNABLE.Ljava/lang/State;";

var __v = _members.StaticFields.GetObjectValue (__id);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

Expand All @@ -47,7 +57,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "TERMINATED.Ljava/lang/State;";

var __v = _members.StaticFields.GetObjectValue (__id);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

Expand All @@ -58,7 +68,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "TIMED_WAITING.Ljava/lang/State;";

var __v = _members.StaticFields.GetObjectValue (__id);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

Expand All @@ -69,7 +79,7 @@ public sealed partial class State : global::Java.Lang.Enum {
const string __id = "WAITING.Ljava/lang/State;";

var __v = _members.StaticFields.GetObjectValue (__id);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State> (ref __v.Handle, JniObjectReferenceOptions.CopyAndDispose);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Lang.State >(ref __v, JniObjectReferenceOptions.Copy);
}
}

Expand Down