forked from dotnet/java-interop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestType.cs
More file actions
210 lines (176 loc) · 6.68 KB
/
TestType.cs
File metadata and controls
210 lines (176 loc) · 6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
// This really should be auto-generated, but isn't for test purposes.
using System;
using Java.Interop;
using Java.Interop.GenericMarshaler;
using NUnit.Framework;
namespace Java.InteropTests
{
#if !NO_MARSHAL_MEMBER_BUILDER_SUPPORT
[JniTypeSignature (TestType.JniTypeName)]
public partial class TestType : JavaObject
{
internal const string JniTypeName = "com/xamarin/interop/TestType";
static readonly JniPeerMembers _members = new JniPeerMembers (JniTypeName, typeof (TestType));
[JniAddNativeMethodRegistrationAttribute]
static void RegisterNativeMembers (JniNativeMethodRegistrationArguments args)
{
args.Registrations.Add (new JniNativeMethodRegistration ("equalsThis", "(Ljava/lang/Object;)Z", GetEqualsThisHandler ()));
args.Registrations.Add (new JniNativeMethodRegistration ("getInt32Value", "()I", GetInt32ValueHandler ()));
}
[JniAddNativeMethodRegistrationAttribute]
static void RegisterNativeMembers2 (JniNativeMethodRegistrationArguments args)
{
args.Registrations.Add (new JniNativeMethodRegistration ("getStringValue", "(I)Ljava/lang/String;", _GetStringValueHandler ()));
args.Registrations.Add (new JniNativeMethodRegistration ("methodThrows", "()V", GetMethodThrowsHandler ()));
}
public override JniPeerMembers JniPeerMembers {
get {
return _members;
}
}
public bool ExecutedDefaultConstructor;
public TestType ()
{
ExecutedDefaultConstructor = true;
}
public bool ExecutedActivationConstructor;
public TestType (ref JniObjectReference reference, JniObjectReferenceOptions transfer)
: base (ref reference, transfer)
{
ExecutedActivationConstructor = true;
}
public static unsafe TestType NewTestType ()
{
var o = _members.StaticMethods.InvokeObjectMethod ("newTestType.()Lcom/xamarin/interop/TestType;", null);
return JniEnvironment.Runtime.ValueManager.GetValue<TestType> (ref o, JniObjectReferenceOptions.CopyAndDispose);
}
public static unsafe TestType NewTestTypeWithUnboundConstructor ()
{
const string id = "newTestTypeWithUnboundConstructor.()Lcom/xamarin/interop/TestType;";
var o = _members.StaticMethods.InvokeObjectMethod (id, null);
return JniEnvironment.Runtime.ValueManager.GetValue<TestType> (ref o, JniObjectReferenceOptions.CopyAndDispose);
}
public unsafe void RunTests ()
{
_members.InstanceMethods.InvokeVirtualVoidMethod ("runTests.()V", this, null);
}
public int UpdateInt32Array (int[] value)
{
return _members.InstanceMethods.InvokeGenericVirtualInt32Method ("updateInt32Array.([I)I", this, value);
}
public int UpdateInt32ArrayArray (int[][] value)
{
return _members.InstanceMethods.InvokeGenericVirtualInt32Method ("updateInt32ArrayArray.([[I)I", this, value);
}
public int UpdateInt32ArrayArrayArray (int[][][] value)
{
return _members.InstanceMethods.InvokeGenericVirtualInt32Method ("updateInt32ArrayArrayArray.([[[I)I", this, value);
}
public int Identity (int value)
{
return _members.InstanceMethods.InvokeGenericVirtualInt32Method ("identity.(I)I", this, value);
}
public static int StaticIdentity (int value)
{
return _members.StaticMethods.InvokeGenericInt32Method ("staticIdentity.(I)I", value);
}
public void MethodThrows ()
{
throw new InvalidOperationException ("jonp: bye!");
}
public unsafe void PropogateException ()
{
_members.InstanceMethods.InvokeVirtualVoidMethod ("propogateException.()V", this, null);
}
public bool PropogateFinallyBlockExecuted {
get {return _members.InstanceFields.GetBooleanValue ("propogateFinallyBlockExecuted.Z", this);}
}
static Delegate GetEqualsThisHandler ()
{
Func<IntPtr, IntPtr, IntPtr, bool> h = _EqualsThis;
return JniEnvironment.Runtime.MarshalMemberBuilder.CreateMarshalToManagedDelegate (h);
}
static bool _EqualsThis (IntPtr jnienv, IntPtr n_self, IntPtr n_value)
{
var jvm = JniEnvironment.Runtime;
var r_self = new JniObjectReference (n_self);
var self = jvm.ValueManager.GetValue<TestType>(ref r_self, JniObjectReferenceOptions.CopyAndDoNotRegister);
var r_value = new JniObjectReference (n_self);
var value = jvm.ValueManager.GetValue<IJavaPeerable> (ref r_value, JniObjectReferenceOptions.CopyAndDoNotRegister);
try {
return self.EqualsThis (value);
} finally {
self.DisposeUnlessReferenced ();
value.DisposeUnlessReferenced ();
}
}
static Delegate GetInt32ValueHandler ()
{
Func<IntPtr, IntPtr, int> h = _GetInt32Value;
return JniEnvironment.Runtime.MarshalMemberBuilder.CreateMarshalToManagedDelegate (h);
}
static int _GetInt32Value (IntPtr jnienv, IntPtr n_self)
{
var r_self = new JniObjectReference (n_self);
var self = JniEnvironment.Runtime.ValueManager.GetValue<TestType>(ref r_self, JniObjectReferenceOptions.CopyAndDoNotRegister);
try {
return self.GetInt32Value ();
} finally {
self.DisposeUnlessReferenced ();
}
}
static Delegate _GetStringValueHandler ()
{
Func<IntPtr, IntPtr, int, IntPtr> h = GetStringValueHandler;
return JniEnvironment.Runtime.MarshalMemberBuilder.CreateMarshalToManagedDelegate (h);
}
static IntPtr GetStringValueHandler (IntPtr jnienv, IntPtr n_self, int value)
{
var r_self = new JniObjectReference (n_self);
var self = JniEnvironment.Runtime.ValueManager.GetValue<TestType>(ref r_self, JniObjectReferenceOptions.CopyAndDoNotRegister);
try {
var s = self.GetStringValue (value);
var r = JniEnvironment.Strings.NewString (s);
try {
return JniEnvironment.References.NewReturnToJniRef (r);
} finally {
JniObjectReference.Dispose (ref r);
}
} finally {
self.DisposeUnlessReferenced ();
}
}
static Delegate GetMethodThrowsHandler ()
{
Action<IntPtr, IntPtr> h = MethodThrowsHandler;
return JniEnvironment.Runtime.MarshalMemberBuilder.CreateMarshalToManagedDelegate (h);
}
static void MethodThrowsHandler (IntPtr jnienv, IntPtr n_self)
{
var r_self = new JniObjectReference (n_self);
var self = JniEnvironment.Runtime.ValueManager.GetValue<TestType>(ref r_self, JniObjectReferenceOptions.CopyAndDoNotRegister);
try {
self.MethodThrows ();
} finally {
self.DisposeUnlessReferenced ();
}
}
public bool EqualsThis (IJavaPeerable value)
{
Assert.IsNotNull (value);
Assert.AreNotSame (this, value);
Assert.IsTrue (JniEnvironment.Types.IsSameObject (PeerReference, value.PeerReference));
return value != null && !object.ReferenceEquals (value, this) &&
JniEnvironment.Types.IsSameObject (PeerReference, value.PeerReference);
}
public int GetInt32Value ()
{
return 42;
}
public string GetStringValue (int value)
{
return value.ToString ();
}
}
#endif // !NO_MARSHAL_MEMBER_BUILDER_SUPPORT
}