示例#1
0
			bool NativeCallback (ref InvocationHint hint, uint n_pvals, IntPtr pvals_ptr, IntPtr data)
			{
				object[] pvals = new object [n_pvals];
				for (int i = 0; i < n_pvals; i++) {
					IntPtr p = new IntPtr ((long) pvals_ptr + i * Marshal.SizeOf (typeof (Value)));
					Value v = (Value) Marshal.PtrToStructure (p, typeof (Value));
					pvals [i] = v.Val;
				}
				bool result = handler (hint, pvals);
				if (!result)
					gch.Free ();
				return result;
			}
示例#2
0
            bool NativeCallback(ref InvocationHint hint, uint n_pvals, IntPtr pvals_ptr, IntPtr data)
            {
                object[] pvals = new object [n_pvals];
                for (int i = 0; i < n_pvals; i++)
                {
                    IntPtr p = new IntPtr((long)pvals_ptr + i * Marshal.SizeOf(typeof(Value)));
                    Value  v = (Value)Marshal.PtrToStructure(p, typeof(Value));
                    pvals [i] = v.Val;
                }
                bool result = handler(hint, pvals);

                if (!result)
                {
                    gch.Free();
                }
                return(result);
            }
示例#3
0
            bool NativeInvoker(InvocationHint ihint, object[] pvals)
            {
                int    val_sz = Marshal.SizeOf(typeof(Value));
                IntPtr buf    = Marshal.AllocHGlobal(pvals.Length * val_sz);

                Value[] vals = new Value [pvals.Length];
                for (int i = 0; i < pvals.Length; i++)
                {
                    vals [i] = new Value(pvals [i]);
                    IntPtr p = new IntPtr((long)buf + i * val_sz);
                    Marshal.StructureToPtr(vals [i], p, false);
                }
                bool result = cb(ref ihint, (uint)pvals.Length, buf, user_data);

                foreach (Value v in vals)
                {
                    v.Dispose();
                }
                Marshal.FreeHGlobal(buf);
                return(result);
            }
示例#4
0
 bool NativeInvoker(InvocationHint ihint, object[] pvals)
 {
     int val_sz = Marshal.SizeOf (typeof (Value));
     IntPtr buf = Marshal.AllocHGlobal (pvals.Length * val_sz);
     Value[] vals = new Value [pvals.Length];
     for (int i = 0; i < pvals.Length; i++) {
         vals [i] = new Value (pvals [i]);
         IntPtr p = new IntPtr ((long) buf + i * val_sz);
         Marshal.StructureToPtr (vals [i], p, false);
     }
     bool result = cb (ref ihint, (uint) pvals.Length, buf, user_data);
     foreach (Value v in vals)
         v.Dispose ();
     Marshal.FreeHGlobal (buf);
     return result;
 }