private int execMount(String[] arg) { return libFuse.fuse_main_real(arg.length, arg, fuseOperations, Struct.size(fuseOperations), null); }
public Pointer toNative(Struct value, ToNativeContext ctx) { return value != null ? Struct.getMemory(value, flags) : null; } }
@SuppressWarnings("unchecked") public static <T extends Struct> T[] arrayOf(Runtime runtime, Class<T> type, int length) { try { T[] array = (T[]) Array.newInstance(type, length); Constructor<T> c = type.getConstructor(Runtime.class); for (int i = 0; i < length; ++i) { array[i] = c.newInstance(runtime); } if (array.length > 0) { final int structSize = align(Struct.size(array[0]), Struct.alignment(array[0])); jnr.ffi.Pointer memory = runtime.getMemoryManager().allocateDirect(structSize * length); for (int i = 0; i < array.length; ++i) { array[i].useMemory(memory.slice(structSize * i, structSize)); } } return array; } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Creates an array of <tt>Signed16</tt> instances. * * @param array the array to store the instances in * @return the array that was passed in */ protected final Signed16[] array(Signed16[] array) { arrayBegin(); for (int i = 0; i < array.length; ++i) { array[i] = new Signed16(); } arrayEnd(); return array; }
@Override public void postInvoke(Struct[] structs, Pointer primitive, ToNativeContext context) { if (structs != null && primitive != null) { try { int off = 0; for (int i = 0; i < structs.length; i++) { structs[i] = constructor.newInstance(runtime); int structSize = align(Struct.size(structs[i]), Struct.alignment(structs[i])); structs[i].useMemory(primitive.slice(off = align(off, Struct.alignment(structs[i])), structSize)); off += structSize; } } catch (InstantiationException ie) { throw new RuntimeException(ie); } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite); } } } }
public static int getsockopt(int s, SocketLevel level, SocketOption optname, Struct data) { Pointer struct_ptr = Struct.getMemory(data); IntByReference ref = new IntByReference(Struct.size(data)); ByteBuffer buf = ByteBuffer.wrap((byte[])struct_ptr.array()); return Native.libsocket().getsockopt(s, level.intValue(), optname.intValue(), buf, ref); }
public int utimes(String path, long[] atimeval, long[] mtimeval) { Timeval[] times = null; if (atimeval != null && mtimeval != null) { times = Struct.arrayOf(getRuntime(), DefaultNativeTimeval.class, 2); times[0].setTime(atimeval); times[1].setTime(mtimeval); } return libc().utimes(path, times); }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
protected final <T extends Struct> T inner(T struct) { int off = align(__info.size, struct.__info.getMinimumAlignment()); struct.__info.enclosing = this; struct.__info.offset = off; __info.size = off + struct.__info.size; return struct; }
@Override public Struct fromNative(Pointer nativeValue, FromNativeContext context) { try { Struct s = constructor.newInstance(context.getRuntime()); s.useMemory(nativeValue); return s; } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
/** * Creates an array of <tt>Signed32</tt> instances. * * @param array the array to store the instances in * @return the array that was passed in */ protected final Signed32[] array(Signed32[] array) { arrayBegin(); for (int i = 0; i < array.length; ++i) { array[i] = new Signed32(); } arrayEnd(); return array; }
@Override public void postInvoke(Struct[] structs, Pointer primitive, ToNativeContext context) { if (structs != null && primitive != null) { try { int off = 0; for (int i = 0; i < structs.length; i++) { structs[i] = constructor.newInstance(runtime); int structSize = align(Struct.size(structs[i]), Struct.alignment(structs[i])); structs[i].useMemory(primitive.slice(off = align(off, Struct.alignment(structs[i])), structSize)); off += structSize; } } catch (InstantiationException ie) { throw new RuntimeException(ie); } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite); } } } }
public int utimensat(int dirfd, String path, long[] atimespec, long[] mtimespec, int flag) { Timespec[] times = null; if (atimespec != null && mtimespec != null) { times = Struct.arrayOf(getRuntime(), DefaultNativeTimespec.class, 2); times[0].setTime(atimespec); times[1].setTime(mtimespec); } return libc().utimensat(dirfd, path, times, flag); }
/** * Gets the size of a Pointer in bits * * @return the size of the Pointer */ public final int size() { return getRuntime().findType(NativeType.ADDRESS).size() * 8; }
protected final <T extends Struct> T inner(T struct) { int off = align(__info.size, struct.__info.getMinimumAlignment()); struct.__info.enclosing = this; struct.__info.offset = off; __info.size = off + struct.__info.size; return struct; }
@Override public Struct fromNative(Pointer nativeValue, FromNativeContext context) { try { Struct s = constructor.newInstance(context.getRuntime()); s.useMemory(nativeValue); return s; } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
private int execMount(String[] arg) { return libFuse.fuse_main_real(arg.length, arg, fuseOperations, Struct.size(fuseOperations), null); }
@SuppressWarnings("unchecked") public static <T extends Struct> T[] arrayOf(Runtime runtime, Class<T> type, int length) { try { T[] array = (T[]) Array.newInstance(type, length); Constructor<T> c = type.getConstructor(Runtime.class); for (int i = 0; i < length; ++i) { array[i] = c.newInstance(runtime); } if (array.length > 0) { final int structSize = align(Struct.size(array[0]), Struct.alignment(array[0])); jnr.ffi.Pointer memory = runtime.getMemoryManager().allocateDirect(structSize * length); for (int i = 0; i < array.length; ++i) { array[i].useMemory(memory.slice(structSize * i, structSize)); } } return array; } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Creates an array of <tt>Float</tt> instances. * * @param array the array to store the instances in * @return the array that was passed in */ protected final Float[] array(Float[] array) { arrayBegin(); for (int i = 0; i < array.length; ++i) { array[i] = new Float(); } arrayEnd(); return array; }
public Pointer toNative(Struct value, ToNativeContext ctx) { return value != null ? Struct.getMemory(value, flags) : null; } }