Java Code Examples for com.sun.jna.Native#POINTER_SIZE
The following examples show how to use
com.sun.jna.Native#POINTER_SIZE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemHealthMonitor.java From consulo with Apache License 2.0 | 7 votes |
private void checkSignalBlocking() { if (SystemInfo.isUnix && JnaLoader.isLoaded()) { try { LibC lib = Native.loadLibrary("c", LibC.class); Memory buf = new Memory(1024); if (lib.sigaction(LibC.SIGINT, null, buf) == 0) { long handler = Native.POINTER_SIZE == 8 ? buf.getLong(0) : buf.getInt(0); if (handler == LibC.SIG_IGN) { showNotification(new KeyHyperlinkAdapter("ide.sigint.ignored.message")); } } } catch (Throwable t) { LOG.warn(t); } } }
Example 2
Source File: Nc4Cursor.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected long getElementSize(TypeNotes ti) { DapType type = ti.getType(); switch (type.getTypeSort()) { case Structure: case Sequence: return ti.getSize(); case String: case URL: // 8/16/2019 jlcaron upgrade to jna 5.4.0 // com.sun.jna.Pointer#SIZE is removed. Its use is replaced by // com.sun.jna.Native#POINTER_SIZE to prevent a class loading deadlock, when JNA is initialized from multiple // threads return Native.POINTER_SIZE; case Enum: return getElementSize((TypeNotes) ((Nc4DSP) getDSP()).find(ti.enumbase, NoteSort.TYPE)); case Opaque: return ti.getSize(); default: return type.getSize(); } }
Example 3
Source File: NotesTimeDate.java From domino-jna with Apache License 2.0 | 6 votes |
/** * Parses a timedate string to a {@link NotesTimeDate} * * @param intl international settings to be used for parsing * @param dateTimeStr timedate string * @return timedate */ public static NotesTimeDate fromString(NotesIntlFormat intl, String dateTimeStr) { Memory dateTimeStrLMBCS = NotesStringUtils.toLMBCS(dateTimeStr, true); //convert method expects a pointer to the date string in memory Memory dateTimeStrLMBCSPtr = new Memory(Native.POINTER_SIZE); dateTimeStrLMBCSPtr.setPointer(0, dateTimeStrLMBCS); IntlFormatStruct intlStruct = intl==null ? null : intl.getAdapter(IntlFormatStruct.class); DisposableMemory retTimeDateMem = new DisposableMemory(NotesConstants.timeDateSize); NotesTimeDateStruct retTimeDate = NotesTimeDateStruct.newInstance(retTimeDateMem); short result = NotesNativeAPI.get().ConvertTextToTIMEDATE(intlStruct, null, dateTimeStrLMBCSPtr, NotesConstants.MAXALPHATIMEDATE, retTimeDate); NotesErrorUtils.checkResult(result); retTimeDate.read(); int[] innards = retTimeDate.Innards; NotesTimeDate td = new NotesTimeDate(innards); retTimeDateMem.dispose(); return td; }
Example 4
Source File: LevelDBKeyIterator.java From leveldb-jna with MIT License | 6 votes |
public byte[] next() { levelDB.checkDatabaseOpen(); checkIteratorOpen(); PointerByReference resultLengthPointer = new PointerByReference(); PointerByReference resultPointer = LevelDBNative.leveldb_iter_key(iterator, resultLengthPointer); long resultLength; if (Native.POINTER_SIZE == 8) { resultLength = resultLengthPointer.getPointer().getLong(0); } else { resultLength = resultLengthPointer.getPointer().getInt(0); } byte[] key = resultPointer.getPointer().getByteArray(0, (int) resultLength); LevelDBNative.leveldb_iter_next(iterator); return key; }
Example 5
Source File: UnicornStructure.java From unidbg with Apache License 2.0 | 5 votes |
@Override protected int getNativeSize(Class<?> nativeType, Object value) { if (Pointer.class.isAssignableFrom(nativeType)) { Emulator<?> emulator = AbstractEmulator.getContextEmulator(); if (emulator == null) { log.warn("getNativeSize context emulator is null"); } return emulator == null ? Native.POINTER_SIZE : emulator.getPointerSize(); } return super.getNativeSize(nativeType, value); }
Example 6
Source File: UnicornStructure.java From unidbg with Apache License 2.0 | 5 votes |
@Override protected int getNativeAlignment(Class<?> type, Object value, boolean isFirstElement) { if (Pointer.class.isAssignableFrom(type)) { Emulator<?> emulator = AbstractEmulator.getContextEmulator(); return emulator == null ? Native.POINTER_SIZE : emulator.getPointerSize(); } return super.getNativeAlignment(type, value, isFirstElement); }
Example 7
Source File: PointerArray.java From djl with Apache License 2.0 | 5 votes |
/** * Constructs a {@link Memory} buffer PointerArray given the Pointers to include in it. * * @param arg the pointers to include in the array */ public PointerArray(Pointer... arg) { super(Native.POINTER_SIZE * (arg.length + 1)); length = arg.length; for (int i = 0; i < arg.length; i++) { setPointer(i * Native.POINTER_SIZE, arg[i]); } setPointer(Native.POINTER_SIZE * arg.length, null); }
Example 8
Source File: LMBCSStringArray.java From domino-jna with Apache License 2.0 | 5 votes |
public LMBCSStringArray(Object[] strValues) { super((strValues.length + 1) * Native.POINTER_SIZE); this.original = strValues; for (int i=0; i < strValues.length;i++) { Pointer p = null; if (strValues[i] != null) { Memory currStrMem = NotesStringUtils.toLMBCS(strValues[i].toString(), true); natives.add(currStrMem); p = currStrMem; } setPointer(Native.POINTER_SIZE * i, p); } setPointer(Native.POINTER_SIZE * strValues.length, null); }
Example 9
Source File: ItemDecoder.java From domino-jna with Apache License 2.0 | 5 votes |
public static List<Object> decodeTextListValue(Pointer ptr, boolean convertStringsLazily) { //read a text list item value int listCountAsInt = ptr.getShort(0) & 0xffff; List<Object> listValues = new ArrayList<Object>(listCountAsInt); Memory retTextPointer = new Memory(Native.POINTER_SIZE); ShortByReference retTextLength = new ShortByReference(); for (short l=0; l<listCountAsInt; l++) { short result = NotesNativeAPI.get().ListGetText(ptr, false, l, retTextPointer, retTextLength); NotesErrorUtils.checkResult(result); //retTextPointer[0] points to the list entry text Pointer pointerToTextInMem = retTextPointer.getPointer(0); int retTextLengthAsInt = retTextLength.getValue() & 0xffff; if (retTextLengthAsInt==0) { listValues.add(""); } else { if (convertStringsLazily) { byte[] stringDataArr = new byte[retTextLengthAsInt]; pointerToTextInMem.read(0, stringDataArr, 0, retTextLengthAsInt); LMBCSString lmbcsString = new LMBCSString(stringDataArr); listValues.add(lmbcsString); } else { String currListEntry = NotesStringUtils.fromLMBCS(pointerToTextInMem, (short) retTextLengthAsInt); listValues.add(currListEntry); } } } return listValues; }
Example 10
Source File: LevelDBOptions.java From leveldb-jna with MIT License | 5 votes |
public void setWriteBufferSize(long writeBufferSize) { checkOptionsOpen(); this.writeBufferSize = writeBufferSize; if (Native.POINTER_SIZE == 8) { LevelDBNative.leveldb_options_set_write_buffer_size(options, writeBufferSize); } else { LevelDBNative.leveldb_options_set_write_buffer_size(options, (int) writeBufferSize); } }
Example 11
Source File: LevelDBOptions.java From leveldb-jna with MIT License | 5 votes |
public void setBlockSize(long blockSize) { checkOptionsOpen(); this.blockSize = blockSize; if (Native.POINTER_SIZE == 8) { LevelDBNative.leveldb_options_set_block_size(options, blockSize); } else { LevelDBNative.leveldb_options_set_block_size(options, (int) blockSize); } }
Example 12
Source File: LevelDBKeyValueIterator.java From leveldb-jna with MIT License | 5 votes |
public KeyValuePair next() { levelDB.checkDatabaseOpen(); checkIteratorOpen(); PointerByReference resultPointer; PointerByReference resultLengthPointer = new PointerByReference(); long resultLength; resultPointer = LevelDBNative.leveldb_iter_key(iterator, resultLengthPointer); if (Native.POINTER_SIZE == 8) { resultLength = resultLengthPointer.getPointer().getLong(0); } else { resultLength = resultLengthPointer.getPointer().getInt(0); } byte[] key = resultPointer.getPointer().getByteArray(0, (int) resultLength); resultPointer = LevelDBNative.leveldb_iter_value(iterator, resultLengthPointer); if (Native.POINTER_SIZE == 8) { resultLength = resultLengthPointer.getPointer().getLong(0); } else { resultLength = resultLengthPointer.getPointer().getInt(0); } byte[] value = resultPointer.getPointer().getByteArray(0, (int) resultLength); LevelDBNative.leveldb_iter_next(iterator); return new KeyValuePair(key, value); }
Example 13
Source File: WindowsNotifier.java From netbeans with Apache License 2.0 | 4 votes |
public ULONG_PTR(long value) { super(Native.POINTER_SIZE, value); }
Example 14
Source File: WindowsNotifier.java From netbeans with Apache License 2.0 | 4 votes |
public HANDLEByReference(HANDLE h) { super(Native.POINTER_SIZE); setValue(h); }