public JniObjectReference(IntPtr handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid) #if FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES : this(FromIntPtr(handle, type), type) #endif // FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES { #if FEATURE_JNIOBJECTREFERENCE_INTPTRS referenceInfo = (uint)type; Handle = handle; #endif // FEATURE_JNIOBJECTREFERENCE_INTPTRS }
static void AssertReferenceType(ref JniObjectReference reference, JniObjectReferenceType type) { if (reference.Type == type) { return; } Debug.Assert(reference.Type == type, string.Format("Object reference {0} should be of type {1}, is instead {2}!", reference.ToString(), type, reference.Type)); }
static string ToString(JniObjectReferenceType type) { switch (type) { case JniObjectReferenceType.Global: return("G"); case JniObjectReferenceType.Invalid: return("I"); case JniObjectReferenceType.Local: return("L"); case JniObjectReferenceType.WeakGlobal: return("W"); } return(type.ToString()); }
static byte ToByte(JniObjectReferenceType type) { switch (type) { case JniObjectReferenceType.Global: return((byte)'G'); case JniObjectReferenceType.Invalid: return((byte)'I'); case JniObjectReferenceType.Local: return((byte)'L'); case JniObjectReferenceType.WeakGlobal: return((byte)'W'); } return((byte)'*'); }
static JniReferenceSafeHandle FromIntPtr(IntPtr handle, JniObjectReferenceType type) { if (handle == IntPtr.Zero) { return(JniReferenceSafeHandle.Null); } switch (type) { case JniObjectReferenceType.Local: return(new JniLocalReference(handle)); case JniObjectReferenceType.Global: return(new JniGlobalReference(handle)); case JniObjectReferenceType.WeakGlobal: return(new JniWeakGlobalReference(handle)); default: return(new JniInvocationHandle(handle)); } }
protected void SetPeerReference(ref JniObjectReference reference, JniObjectReferenceOptions options) { if (options == JniObjectReferenceOptions.None) { ((IJavaPeerable)this).SetPeerReference(new JniObjectReference()); return; } #if FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES this.reference = reference; #endif // FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES #if FEATURE_JNIOBJECTREFERENCE_INTPTRS this.handle = reference.Handle; this.handle_type = reference.Type; #endif // FEATURE_JNIOBJECTREFERENCE_INTPTRS JniObjectReference.Dispose(ref reference, options); }
public JniObjectReference(IntPtr handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid) { SafeHandle = null; Handle = handle; Type = type; }
public JniObjectReference(JniReferenceSafeHandle handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid) { SafeHandle = handle; Handle = IntPtr.Zero; Type = type; }
internal JniObjectReference(JniReferenceSafeHandle handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid) { this.gcHandle = GCHandle.Alloc(handle, GCHandleType.Normal); referenceInfo = (uint)type; }
static byte GetObjectRefType(JniObjectReferenceType type) { switch (type) { case JniObjectReferenceType.Invalid: return (byte) 'I'; case JniObjectReferenceType.Local: return (byte) 'L'; case JniObjectReferenceType.Global: return (byte) 'G'; case JniObjectReferenceType.WeakGlobal: return (byte) 'W'; default: return (byte) '*'; } }