コード例 #1
0
        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
        }
コード例 #2
0
            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));
            }
コード例 #3
0
        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());
        }
コード例 #4
0
        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)'*');
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public JniObjectReference(IntPtr handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid)
 {
     SafeHandle = null;
     Handle     = handle;
     Type       = type;
 }
コード例 #8
0
 public JniObjectReference(JniReferenceSafeHandle handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid)
 {
     SafeHandle = handle;
     Handle     = IntPtr.Zero;
     Type       = type;
 }
コード例 #9
0
 internal JniObjectReference(JniReferenceSafeHandle handle, JniObjectReferenceType type = JniObjectReferenceType.Invalid)
 {
     this.gcHandle = GCHandle.Alloc(handle, GCHandleType.Normal);
     referenceInfo = (uint)type;
 }
コード例 #10
0
 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) '*';
     }
 }