Skip to content

Commit

Permalink
* Add BytePointer.getUnsigned() and putUnsigned() methods for co…
Browse files Browse the repository at this point in the history
…nvenience (pull #574)
  • Loading branch information
before31 authored May 31, 2022
1 parent 429bdb5 commit 12d7cbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add `BytePointer.getUnsigned()` and `putUnsigned()` methods for convenience ([pull #574](https://github.com/bytedeco/javacpp/pull/574))
* Let `Parser` consider `alignas` as an explicit attribute to be ignored by default ([issue bytedeco/javacpp-presets#1168](https://github.com/bytedeco/javacpp-presets/issues/1168))
* Add "org.bytedeco.javacpp.findLibraries" system property to disable search for libraries ([pull #565](https://github.com/bytedeco/javacpp/pull/565))
* Fix `Generator` causing memory leaks for `String` parameters on callback ([issue bytedeco/javacpp-presets#1141](https://github.com/bytedeco/javacpp-presets/issues/1141))
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/bytedeco/javacpp/BytePointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ public BytePointer putString(String s) {
return asByteBuffer();
}

/** Returns {@code getUnsigned(0)}. */
public int getUnsigned() { return getUnsigned(0); }
/** Returns the {@code byte} value at the i-th {@code byte} in the native array, treated as unsigned. */
public int getUnsigned(long i) { return get(i) & 0xFF; }
/** Returns {@code putUnsigned(0, b)}. */
public BytePointer putUnsigned(int b) { return putUnsigned(0, b); }
/** Sets the {@code byte} value at the i-th {@code byte} in the native array, treated as unsigned. */
public BytePointer putUnsigned(long i, int b) { return put(i, (byte)b); }

/** Returns {@code getShort(0)}. */
public short getShort() { return getShort(0); }
/** Returns the {@code short} value at the i-th {@code byte} in the native array. */
Expand Down

0 comments on commit 12d7cbc

Please sign in to comment.