private GpioHandleRequest setRawFlags( int flags ) { this.memory.setInt( NativeGpioHandleRequest.OFFSET_FLAGS , flags ) ; return this ; }
private GpioEventRequest setRawFlags( int flags ) { this.memory.setInt( NativeGpioEventRequest.OFFSET_HANDLE_FLAGS , flags ) ; return this ; }
/** * Selects which line will be requested. * * @param line * Number of the line. * * @return This instance. */ public GpioEventRequest setLine( int line ) { this.memory.setInt( NativeGpioEventRequest.OFFSET_LINE , line ) ; return this ; }
void setLine( int line ) { this.memory.setInt( NativeGpioLineInfo.OFFSET_LINE , line ) ; }
/** * Selects edge-detection. * * @param edgeDetection * Edge-detection mode. * * @return This instance. */ public GpioEventRequest setEdgeDetection( GpioEdgeDetection edgeDetection ) { this.memory.setInt( NativeGpioEventRequest.OFFSET_EVENT_FLAGS , edgeDetection.flags ) ; this.edgeDetection = edgeDetection ; return this ; }
@Override public Memory bufferForResult(Object methodCallResult) { Memory result = new Memory(4); result.setInt(0, ((Integer) methodCallResult)); return result; } });
/** * Adds a GPIO line to the request. * <p> * A handle can drive at most 64 lines at once. * * @param lineNumber * Which line. * * @return A GPIO line useful for handling a buffer. * * @see GpioBuffer */ public GpioLine addLine( int lineNumber ) { int index = this.memory.getInt( NativeGpioHandleRequest.OFFSET_LINES ) ; this.memory.setInt( NativeGpioHandleRequest.OFFSET_LINE_OFFSETS + 4 * index , lineNumber ) ; this.memory.setInt( NativeGpioHandleRequest.OFFSET_LINES , index + 1 ) ; return new GpioLine( lineNumber , index ) ; }
private void setIntSockopt(int option, int optval) { NativeLong length = new NativeLong(Integer.SIZE / 8); Memory value = new Memory(Integer.SIZE / 8); value.setInt(0, (int)optval); zmq.zmq_setsockopt(ptr, option, value, length); }
public void setValue(String value) { if(value == null) { value = ""; } try { byte[] encodedValue = value.getBytes("UTF-16LE"); // 4 bytes for the length prefix, length for the encoded data, // 2 bytes for the two NULL terminators Memory mem = new Memory(4 + encodedValue.length + 2); mem.clear(); mem.setInt(0, encodedValue.length); mem.write(4, encodedValue, 0, encodedValue.length); this.setPointer(mem.share(4)); } catch (UnsupportedEncodingException ex) { throw new RuntimeException("UTF-16LE charset is not supported", ex); } }
@Override public void setWindowSize(int width, int height) { Memory struct = new Memory(8); // 4 unsigned shorts struct.setShort(0,(short)height); struct.setShort(2,(short)width); struct.setInt(4,0); if (LIBC.ioctl(pty.getValue(),TIOCSWINSZ,struct)!=0) throw new IllegalStateException("Failed to ioctl(TIOCSWINSZ)"); }
class BSTRUtils { private BSTR() { } public static Memory toNative(String value) { Memory m = new Memory(value.length()*2+6); m.setInt(0, value.length()*2); m.setString(4, value, true); return m; } public static String toString(PointerByReference pbr) { return toString(pbr.getValue()); } public static String toString(Pointer p) { int length = p.getInt(0); char[] data = p.getCharArray(4, length/2); return new String(data); } }
intMem.setInt(0, 666); // setting allocated memory to an integer Pointer intPointer = intMem.getPointer(0);
Memory mem = new Memory(((BOOL[]) value).length * 4); for (int i = 0; i < ((BOOL[]) value).length; i++) { mem.setInt(i * 4, ((BOOL[]) value)[i].intValue());
case VT_INT: mem = new Memory(4); mem.setInt(0, ((Number) arg).intValue()); hr = OleAuto.INSTANCE.SafeArrayPutElement(this, paramIndices, mem); COMUtils.checkRC(hr); case VT_ERROR: mem = new Memory(4); mem.setInt(0, ((Number) arg).intValue()); hr = OleAuto.INSTANCE.SafeArrayPutElement(this, paramIndices, mem); COMUtils.checkRC(hr);