Examples of IntPtr


Examples of cli.System.IntPtr

            int err = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
            if (hFileMapping.get_IsInvalid())
            {
                throw new IOException("Win32 error " + err);
            }
            IntPtr p = MapViewOfFile(hFileMapping, mapAccess, (int)(position >> 32), (int)position, IntPtr.op_Explicit(length));
            err = cli.System.Runtime.InteropServices.Marshal.GetLastWin32Error();
            hFileMapping.Close();
            if (p.Equals(IntPtr.Zero))
            {
                if (err == 8 /*ERROR_NOT_ENOUGH_MEMORY*/)
                {
                    throw new OutOfMemoryError("Map failed");
                }
                throw new IOException("Win32 error " + err);
            }
            cli.System.GC.AddMemoryPressure(length);
            return p.ToInt64();
        }
        finally
        {
            cli.System.GC.KeepAlive(fs);
        }
View Full Code Here

Examples of cli.System.IntPtr

    @cli.System.Security.SecuritySafeCriticalAttribute.Annotation
    private static long mapViewOfFilePosix(FileStream fs, int prot, long position, long length) throws IOException
    {
        byte writeable = prot != MAP_RO ? (byte)1 : (byte)0;
        byte copy_on_write = prot == MAP_PV ? (byte)1 : (byte)0;
        IntPtr p = ikvm_mmap(fs.get_SafeFileHandle(), writeable, copy_on_write, position, (int)length);
        cli.System.GC.KeepAlive(fs);
        // HACK ikvm_mmap should really be changed to return a null pointer on failure,
        // instead of whatever MAP_FAILED is defined to on the particular system we're running on,
        // common values for MAP_FAILED are 0 and -1, so we test for these.
        if (p.Equals(IntPtr.Zero) || p.Equals(new IntPtr(-1)))
        {
            throw new IOException("file mapping failed");
        }
        cli.System.GC.AddMemoryPressure(length);
        return p.ToInt64();
    }
View Full Code Here

Examples of org.gstreamer.lowlevel.IntPtr

*/
class Tracker {

    public Tracker(GObject obj) {
        super();
        GObjectAPI.GOBJECT_API.g_object_weak_ref(obj, notify, new IntPtr(System.identityHashCode(this)));
        ref = new WeakReference<GObject>(obj);
    }
View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

  public void arraysNonZeroLowerBound() throws Exception {
    Class clazz = compile("lbound.f", "LBound");

    Method test = clazz.getMethod("test_", DoublePtr.class, IntPtr.class);
    DoublePtr x = new DoublePtr( 0,0,0,);
    test.invoke(null, x, new IntPtr(4));

    assertThat(x.array[0], equalTo(1d*3d));
    assertThat(x.array[1], equalTo(2d*3d));
    assertThat(x.array[2], equalTo(3d*3d));
    assertThat(x.array[3], equalTo(4d*3d));
 
View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

  @Test
  public void logicalToInt() throws Exception {
    Class clazz = compile("bool2int.f", "LogicalInt");
    Method method = clazz.getMethod("test_", IntPtr.class, IntPtr.class);

    IntPtr x = new IntPtr(43);
    IntPtr y = new IntPtr(0);

    method.invoke(null, x, y);

  }
View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

  public void switchStatement() throws Exception {
    Class clazz = compile("switch.c", "SwitchTest");

    Method distance = clazz.getMethod("R_distance", IntPtr.class, int.class, int.class);

    assertThat((Integer)distance.invoke(null, new IntPtr(1), 13, 14), equalTo(1));
    assertThat((Integer)distance.invoke(null, new IntPtr(2), 3, 4), equalTo(-1));

  }
View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

    Class clazz = compile("logical.f", "Logical");

    clazz.getMethod("runtest_").invoke(null);

    Method iftest = clazz.getMethod("iftest_", IntPtr.class, IntPtr.class);
    IntPtr x = new IntPtr(0);

    iftest.invoke(null, new IntPtr(12), x);

    assertThat(x.unwrap(), equalTo(1));

  }
View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

    Method method = clazz.getMethod("test_", DoublePtr.class, IntPtr.class);
   
    double[] x = new double[9];

    method.invoke(null, new DoublePtr(x, 0), new IntPtr(3));
   
    System.out.println(x);
   
    assertThat(x[0], equalTo(1d));
    assertThat(x[4], equalTo(4d));
View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

            0.906247654231265,0.0680010921787471,0.397506368579343,
            0.836464448831975,0.460515640443191,0.927493635797873,
            0.219096470857039,0.300599258393049,0.561568872537464,
            0.20270675746724,0.303500573383644,0.967535280855373);

    IntPtr ldx = new IntPtr(3);
    IntPtr n = new IntPtr(3);
    IntPtr p = new IntPtr(4);
    DoublePtr tol = new DoublePtr(1e-07);
    IntPtr k = new IntPtr(new int[1]);
    DoublePtr qraux = new DoublePtr(new double[p.unwrap()]);
    IntPtr jpvt = new IntPtr(new int[] { 1, 2, 3, 4 });
    DoublePtr work = new DoublePtr(new double[2*p.unwrap()]);
   
   
    // check some sub-calcs first
    double nrmxl = (Double)dnrm2.invoke(null, n, x, new IntPtr(1));

    assertThat(nrmxl, closeTo(0.99192755400699972, 1e-5));

    dqrdc2.invoke(null, x, ldx, n, p, tol, k, qraux, jpvt, work);

View Full Code Here

Examples of org.renjin.gcc.runtime.IntPtr

    Method method = clazz.getMethod("test_", DoublePtr.class, IntPtr.class);

    double[] x = new double[9];

    method.invoke(null, new DoublePtr(x, 0), new IntPtr(3));

    System.out.println(x);

    assertThat(x[0], equalTo(1d));
    assertThat(x[4], equalTo(4d));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.