コード例 #1
0
        public MarshalMemberBuilder(JniRuntime runtime)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException(nameof(runtime));
            }

            OnSetRuntime(runtime);
        }
コード例 #2
0
            public virtual void OnSetRuntime(JniRuntime runtime)
            {
                if (disposed)
                {
                    throw new ObjectDisposedException(GetType().Name);
                }

                this.runtime = runtime;
            }
コード例 #3
0
 internal static void    SetEnvironmentPointer(IntPtr environmentPointer, JniRuntime runtime)
 {
     if (!Info.IsValueCreated)
     {
         Info.Value = new JniEnvironmentInfo(environmentPointer, runtime);
         return;
     }
     CurrentInfo.EnvironmentPointer = environmentPointer;
 }
コード例 #4
0
 public override void OnSetRuntime(JniRuntime runtime)
 {
     base.OnSetRuntime(runtime);
     bridge = NativeMethods.java_interop_gc_bridge_get_current();
     if (bridge != IntPtr.Zero)
     {
         logLocalRefs  = NativeMethods.java_interop_gc_bridge_lref_get_log_file(bridge) != IntPtr.Zero;
         logGlobalRefs = NativeMethods.java_interop_gc_bridge_gref_get_log_file(bridge) != IntPtr.Zero;
     }
 }
コード例 #5
0
        public override void OnSetRuntime(JniRuntime runtime)
        {
            base.OnSetRuntime(runtime);

            bridge = NativeMethods.java_interop_gc_bridge_get_current();
            if (bridge != IntPtr.Zero)
            {
                return;
            }

            bridge = NativeMethods.java_interop_gc_bridge_new(runtime.InvocationPointer);
            if (bridge == IntPtr.Zero)
            {
                throw new NotSupportedException("Could not initialize JNI::Mono GC Bridge!");
            }

            try {
                if (NativeMethods.java_interop_gc_bridge_set_bridge_processing_field(bridge, typeof(MonoRuntimeValueManager).TypeHandle, nameof(GCBridgeProcessingIsActive)) < 0)
                {
                    throw new NotSupportedException("Could not set bridge processing field!");
                }
                foreach (var t in new[] { typeof(JavaObject), typeof(JavaException) })
                {
                    if (NativeMethods.java_interop_gc_bridge_register_bridgeable_type(bridge, t.TypeHandle) < 0)
                    {
                        throw new NotSupportedException("Could not register type " + t.FullName + "!");
                    }
                }
                if (NativeMethods.java_interop_gc_bridge_add_current_app_domain(bridge) < 0)
                {
                    throw new NotSupportedException("Could not register current AppDomain!");
                }
                if (NativeMethods.java_interop_gc_bridge_set_current_once(bridge) < 0)
                {
                    throw new NotSupportedException("Could not set GC Bridge instance!");
                }
            }
            catch (Exception) {
                NativeMethods.java_interop_gc_bridge_free(bridge);
                bridge = IntPtr.Zero;
                throw;
            }
            if (NativeMethods.java_interop_gc_bridge_register_hooks(bridge, GCBridgeUseWeakReferenceKind.Jni) < 0)
            {
                throw new NotSupportedException("Could not register GC Bridge with Mono!");
            }
        }
コード例 #6
0
        static object[] GetValues(JniRuntime runtime, JniObjectReference values, Type[] types)
        {
            if (!values.IsValid)
            {
                return(null);
            }

            int len = JniEnvironment.Arrays.GetArrayLength(values);

            Debug.Assert(len == types.Length,
                         string.Format("Unexpected number of parameter types! Expected {0}, got {1}", types.Length, len));
            var pvalues = new object [types.Length];

            for (int i = 0; i < pvalues.Length; ++i)
            {
                var n_value = JniEnvironment.Arrays.GetObjectArrayElement(values, i);
                var value   = runtime.ValueManager.GetValue(ref n_value, JniObjectReferenceOptions.CopyAndDispose, types [i]);
                pvalues [i] = value;
            }

            return(pvalues);
        }
コード例 #7
0
 public virtual void OnSetRuntime(JniRuntime runtime)
 {
     AssertValid();
     this.runtime = runtime;
 }
コード例 #8
0
 public virtual void OnSetRuntime(JniRuntime runtime)
 {
     Runtime = runtime;
 }
コード例 #9
0
 public override void OnSetRuntime(JniRuntime runtime)
 {
     base.OnSetRuntime(runtime);
 }
コード例 #10
0
        static void DeletedReference(TextWriter?writer, string kind, int count, JniObjectReference reference, JniRuntime runtime)
        {
            if (writer == null)
            {
                return;
            }
            string message = $"{kind} {count} handle {reference.ToString ()} " +
                             $"from thread '{runtime.GetCurrentManagedThreadName ()}'({Environment.CurrentManagedThreadId})" +
                             Environment.NewLine +
                             runtime.GetCurrentManagedThreadStackTrace(skipFrames: 2, fNeedFileInfo: true);

            writer.WriteLine(message);
            writer.Flush();
        }
コード例 #11
0
 internal JniEnvironmentInfo(IntPtr environmentPointer, JniRuntime runtime)
 {
     EnvironmentPointer = environmentPointer;
     Runtime            = runtime;
 }