Skip to content
Open
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
@@ -1,4 +1,5 @@
using System;
using System.IO;
using NUnit.Framework;

namespace generatortests
Expand All @@ -15,7 +16,27 @@ public void GeneratedOK ()
outputRelativePath: "NormalMethods",
apiDescriptionFile: "expected.ji/NormalMethods/NormalMethods.xml",
expectedRelativePath: "NormalMethods");

var output = File.ReadAllText (FullPath ("out.xaji/NormalMethods/Xamarin.Test.SomeObject.cs"));
Assert.That (output, Does.Contain (string.Join (Environment.NewLine, new [] {
"\t\t\tvar __result = __rm;",
"\t\t\tglobal::System.GC.KeepAlive (o);",
"\t\t\tglobal::System.GC.KeepAlive (t);",
"\t\t\treturn __result;",
})));
Assert.That (output, Does.Contain (string.Join (Environment.NewLine, new [] {
"\t\t\t_members.InstanceMethods.FinishCreateInstance (__id, this, __args);",
"\t\t\tglobal::System.GC.KeepAlive (c);",
})));
Assert.That (output, Does.Contain (string.Join (Environment.NewLine, new [] {
"\t\t\ttry {",
"\t\t\t\tJniArgumentValue* __args = stackalloc JniArgumentValue [3];",
})));
Assert.That (output, Does.Contain (string.Join (Environment.NewLine, new [] {
"\t\t\t} finally {",
"\t\t\t\tJNIEnv.DeleteLocalRef (native_astring);",
"\t\t\t\tglobal::System.GC.KeepAlive (anObject);",
})));
}
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.IO;
using NUnit.Framework;

namespace generatortests
Expand All @@ -13,7 +14,12 @@ public void GeneratedOK ()
outputRelativePath: "NormalProperties",
apiDescriptionFile: "expected.ji/NormalProperties/NormalProperties.xml",
expectedRelativePath: "NormalProperties");

var output = File.ReadAllText (FullPath ("out.xaji/NormalProperties/Xamarin.Test.SomeObject.cs"));
Assert.That (output, Does.Contain (string.Join (Environment.NewLine, new [] {
"\t\t\t\t_members.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);",
"\t\t\t\tglobal::System.GC.KeepAlive (value);",
})));
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ public partial class MyClass {
if (PeerReference.IsValid)
return;

try {
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null);
Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose);
_members.InstanceMethods.FinishCreateInstance (__id, this, null);
} finally {
}
var __r = _members.InstanceMethods.StartCreateInstance (__id, ((object) this).GetType (), null);
Construct (ref __r, JniObjectReferenceOptions.CopyAndDispose);
_members.InstanceMethods.FinishCreateInstance (__id, this, null);
}

// Metadata.xml XPath constructor reference: path="/api/package[@name='java.code']/class[@name='MyClass']/constructor[@name='MyClass' and count(parameter)=1 and parameter[1][@type='java.lang.String']]"
Expand Down Expand Up @@ -49,33 +46,24 @@ public partial class MyClass {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_Count' and count(parameter)=0]"
get {
const string __id = "get_Count.()I";
try {
var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, null);
return __rm;
} finally {
}
var __rm = _members.InstanceMethods.InvokeVirtualInt32Method (__id, this, null);
return __rm;
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_Count' and count(parameter)=1 and parameter[1][@type='int']]"
set {
const string __id = "set_Count.(I)V";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args);
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args);
}
}

public virtual unsafe string? Key {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_Key' and count(parameter)=0]"
get {
const string __id = "get_Key.()Ljava/lang/String;";
try {
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_Key' and count(parameter)=1 and parameter[1][@type='java.lang.String']]"
set {
Expand All @@ -95,21 +83,15 @@ public partial class MyClass {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_StaticCount' and count(parameter)=0]"
get {
const string __id = "get_StaticCount.()I";
try {
var __rm = _members.StaticMethods.InvokeInt32Method (__id, null);
return __rm;
} finally {
}
var __rm = _members.StaticMethods.InvokeInt32Method (__id, null);
return __rm;
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_StaticCount' and count(parameter)=1 and parameter[1][@type='int']]"
set {
const string __id = "set_StaticCount.(I)V";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members.StaticMethods.InvokeVoidMethod (__id, __args);
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members.StaticMethods.InvokeVoidMethod (__id, __args);
}
}

Expand Down Expand Up @@ -144,22 +126,16 @@ public partial class MyClass {
public virtual unsafe string? Key ()
{
const string __id = "Key.()Ljava/lang/String;";
try {
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}

// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='StaticMethod' and count(parameter)=0]"
[global::Java.Interop.JniMethodSignature ("StaticMethod", "()V")]
public static unsafe void StaticMethod ()
{
const string __id = "StaticMethod.()V";
try {
_members.StaticMethods.InvokeVoidMethod (__id, null);
} finally {
}
_members.StaticMethods.InvokeVoidMethod (__id, null);
}

// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='AbstractMethod' and count(parameter)=0]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,20 @@ internal partial class AnimatorListenerInvoker : global::Java.Lang.Object, Anima
public unsafe bool OnAnimationEnd (int param1)
{
const string __id = "OnAnimationEnd.(I)Z";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (param1);
var __rm = _members_java_code_AnimatorListener.InstanceMethods.InvokeAbstractBooleanMethod (__id, this, __args);
return __rm;
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (param1);
var __rm = _members_java_code_AnimatorListener.InstanceMethods.InvokeAbstractBooleanMethod (__id, this, __args);
return __rm;
}

public unsafe bool OnAnimationEnd (int param1, int param2)
{
const string __id = "OnAnimationEnd.(II)Z";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [2];
__args [0] = new JniArgumentValue (param1);
__args [1] = new JniArgumentValue (param2);
var __rm = _members_java_code_AnimatorListener.InstanceMethods.InvokeAbstractBooleanMethod (__id, this, __args);
return __rm;
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [2];
__args [0] = new JniArgumentValue (param1);
__args [1] = new JniArgumentValue (param2);
var __rm = _members_java_code_AnimatorListener.InstanceMethods.InvokeAbstractBooleanMethod (__id, this, __args);
return __rm;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,15 @@ public partial interface IMyInterface : IJavaPeerable {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='IMyInterface']/method[@name='get_StaticCount' and count(parameter)=0]"
get {
const string __id = "get_StaticCount.()I";
try {
var __rm = _members.StaticMethods.InvokeInt32Method (__id, null);
return __rm;
} finally {
}
var __rm = _members.StaticMethods.InvokeInt32Method (__id, null);
return __rm;
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/interface[@name='IMyInterface']/method[@name='set_StaticCount' and count(parameter)=1 and parameter[1][@type='int']]"
set {
const string __id = "set_StaticCount.(I)V";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members.StaticMethods.InvokeVoidMethod (__id, __args);
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members.StaticMethods.InvokeVoidMethod (__id, __args);
}
}

Expand All @@ -72,10 +66,7 @@ public partial interface IMyInterface : IJavaPeerable {
public static unsafe void StaticMethod ()
{
const string __id = "StaticMethod.()V";
try {
_members.StaticMethods.InvokeVoidMethod (__id, null);
} finally {
}
_members.StaticMethods.InvokeVoidMethod (__id, null);
}

}
Expand All @@ -97,31 +88,22 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
public unsafe int Count {
get {
const string __id = "get_Count.()I";
try {
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeVirtualInt32Method (__id, this, null);
return __rm;
} finally {
}
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeVirtualInt32Method (__id, this, null);
return __rm;
}
set {
const string __id = "set_Count.(I)V";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members_java_code_IMyInterface.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args);
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members_java_code_IMyInterface.InstanceMethods.InvokeVirtualVoidMethod (__id, this, __args);
}
}

public unsafe string? Key {
get {
const string __id = "get_Key.()Ljava/lang/String;";
try {
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}
set {
const string __id = "set_Key.(Ljava/lang/String;)V";
Expand All @@ -139,20 +121,14 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
public unsafe int AbstractCount {
get {
const string __id = "get_AbstractCount.()I";
try {
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeAbstractInt32Method (__id, this, null);
return __rm;
} finally {
}
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeAbstractInt32Method (__id, this, null);
return __rm;
}
set {
const string __id = "set_AbstractCount.(I)V";
try {
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members_java_code_IMyInterface.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
} finally {
}
JniArgumentValue* __args = stackalloc JniArgumentValue [1];
__args [0] = new JniArgumentValue (value);
_members_java_code_IMyInterface.InstanceMethods.InvokeAbstractVoidMethod (__id, this, __args);
}
}

Expand All @@ -173,20 +149,14 @@ internal partial class IMyInterfaceInvoker : global::Java.Lang.Object, IMyInterf
public unsafe string? Key ()
{
const string __id = "Key.()Ljava/lang/String;";
try {
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members_java_code_IMyInterface.InstanceMethods.InvokeVirtualObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Strings.ToString (ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}

public unsafe void AbstractMethod ()
{
const string __id = "AbstractMethod.()V";
try {
_members_java_code_IMyInterface.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null);
} finally {
}
_members_java_code_IMyInterface.InstanceMethods.InvokeAbstractVoidMethod (__id, this, null);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ public partial class MyClass {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_UIntProp' and count(parameter)=0]"
get {
const string __id = "get_UIntProp.()[I";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaInt32Array>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaInt32Array>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_UIntProp' and count(parameter)=1 and parameter[1][@type='uint[]']]"
set {
Expand All @@ -38,11 +35,8 @@ public partial class MyClass {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_UShortProp' and count(parameter)=0]"
get {
const string __id = "get_UShortProp.()[S";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaInt16Array>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaInt16Array>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_UShortProp' and count(parameter)=1 and parameter[1][@type='ushort[]']]"
set {
Expand All @@ -65,11 +59,8 @@ public partial class MyClass {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_ULongProp' and count(parameter)=0]"
get {
const string __id = "get_ULongProp.()[J";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaInt64Array>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaInt64Array>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_ULongProp' and count(parameter)=1 and parameter[1][@type='ulong[]']]"
set {
Expand All @@ -92,11 +83,8 @@ public partial class MyClass {
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='get_UByteProp' and count(parameter)=0]"
get {
const string __id = "get_UByteProp.()[B";
try {
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaSByteArray>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
} finally {
}
var __rm = _members.InstanceMethods.InvokeAbstractObjectMethod (__id, this, null);
return global::Java.Interop.JniEnvironment.Runtime.ValueManager.GetValue<global::Java.Interop.JavaSByteArray>(ref __rm, JniObjectReferenceOptions.CopyAndDispose);
}
// Metadata.xml XPath method reference: path="/api/package[@name='java.code']/class[@name='MyClass']/method[@name='set_UByteProp' and count(parameter)=1 and parameter[1][@type='ubyte[]']]"
set {
Expand Down
Loading
Loading