fix: ref opt native fns should be instance methods

This commit is contained in:
Orion Kindel
2023-04-18 17:42:03 -05:00
parent 72285ad7a1
commit ff7c0b00e4
7 changed files with 97 additions and 120 deletions

View File

@@ -10,7 +10,7 @@ public class Option implements dev.toad.msg.Option, AutoCloseable {
Ptr ptr;
final long number;
native dev.toad.msg.ref.OptionValue[] values(long ptr);
public native dev.toad.msg.ref.OptionValue[] valueRefs();
Option(long addr, long number) {
this.ptr = Ptr.register(this.getClass(), addr);
@@ -21,12 +21,8 @@ public class Option implements dev.toad.msg.Option, AutoCloseable {
return this.number;
}
public dev.toad.msg.ref.OptionValue[] valueRefs() {
return this.values(this.ptr.addr());
}
public List<dev.toad.msg.OptionValue> values() {
return Arrays.asList(this.values(this.ptr.addr()));
return Arrays.asList(this.valueRefs());
}
public dev.toad.msg.owned.Option toOwned() {

View File

@@ -5,20 +5,16 @@ import dev.toad.ffi.Ptr;
public final class OptionValue
implements dev.toad.msg.OptionValue, AutoCloseable {
private final Ptr ptr;
final Ptr ptr;
private native byte[] bytes(long addr);
public native byte[] asBytes();
OptionValue(long addr) {
this.ptr = Ptr.register(this.getClass(), addr);
}
public byte[] asBytes() {
return this.bytes(this.ptr.addr());
}
public String asString() {
return new String(this.bytes(this.ptr.addr()));
return new String(this.asBytes());
}
public dev.toad.msg.owned.OptionValue toOwned() {