mirror of
https://github.com/TheOfficialFloW/bd-jb
synced 2024-12-22 06:28:50 -05:00
Allow passing addresses to Buffer and Int* primitives.
This commit is contained in:
parent
efad4e8928
commit
077b002273
@ -18,6 +18,16 @@ abstract class AbstractInt extends Buffer {
|
||||
this.elementSize = elementSize;
|
||||
}
|
||||
|
||||
protected AbstractInt(long address, int[] dimensions, int elementSize) {
|
||||
super(address, size(dimensions, elementSize));
|
||||
this.dimensions = dimensions;
|
||||
this.elementSize = elementSize;
|
||||
}
|
||||
|
||||
protected AbstractInt(long address, int elementSize) {
|
||||
this(address, new int[] {1}, elementSize);
|
||||
}
|
||||
|
||||
protected AbstractInt(int elementSize) {
|
||||
this(new int[] {1}, elementSize);
|
||||
}
|
||||
|
@ -22,13 +22,24 @@ public class Buffer {
|
||||
|
||||
private final int size;
|
||||
|
||||
private final boolean allocated;
|
||||
|
||||
public Buffer(int size) {
|
||||
this.size = size;
|
||||
this.address = api.malloc(size);
|
||||
this.size = size;
|
||||
this.allocated = true;
|
||||
}
|
||||
|
||||
public Buffer(long address, int size) {
|
||||
this.address = address;
|
||||
this.size = size;
|
||||
this.allocated = false;
|
||||
}
|
||||
|
||||
public void finalize() {
|
||||
api.free(address);
|
||||
if (allocated) {
|
||||
api.free(address);
|
||||
}
|
||||
}
|
||||
|
||||
public long address() {
|
||||
|
@ -10,17 +10,20 @@ package com.bdjb.api;
|
||||
public final class Int16 extends AbstractInt {
|
||||
public static final int SIZE = 2;
|
||||
|
||||
public Int16(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int16() {
|
||||
super(SIZE);
|
||||
}
|
||||
|
||||
public Int16(short value) {
|
||||
this();
|
||||
this.set(value);
|
||||
public Int16(long address) {
|
||||
super(address, SIZE);
|
||||
}
|
||||
|
||||
public Int16(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int16(long address, int[] dimensions) {
|
||||
super(address, dimensions, SIZE);
|
||||
}
|
||||
|
||||
public short get() {
|
||||
|
@ -10,17 +10,20 @@ package com.bdjb.api;
|
||||
public final class Int32 extends AbstractInt {
|
||||
public static final int SIZE = 4;
|
||||
|
||||
public Int32(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int32() {
|
||||
super(SIZE);
|
||||
}
|
||||
|
||||
public Int32(int value) {
|
||||
this();
|
||||
this.set(value);
|
||||
public Int32(long address) {
|
||||
super(address, SIZE);
|
||||
}
|
||||
|
||||
public Int32(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int32(long address, int[] dimensions) {
|
||||
super(address, dimensions, SIZE);
|
||||
}
|
||||
|
||||
public int get() {
|
||||
|
@ -10,17 +10,20 @@ package com.bdjb.api;
|
||||
public final class Int64 extends AbstractInt {
|
||||
public static final int SIZE = 8;
|
||||
|
||||
public Int64(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int64() {
|
||||
super(SIZE);
|
||||
}
|
||||
|
||||
public Int64(long value) {
|
||||
this();
|
||||
this.set(value);
|
||||
public Int64(long address) {
|
||||
super(address, SIZE);
|
||||
}
|
||||
|
||||
public Int64(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int64(long address, int[] dimensions) {
|
||||
super(address, dimensions, SIZE);
|
||||
}
|
||||
|
||||
public long get() {
|
||||
|
@ -10,17 +10,20 @@ package com.bdjb.api;
|
||||
public final class Int8 extends AbstractInt {
|
||||
public static final int SIZE = 1;
|
||||
|
||||
public Int8(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int8() {
|
||||
super(SIZE);
|
||||
}
|
||||
|
||||
public Int8(byte value) {
|
||||
this();
|
||||
this.set(value);
|
||||
public Int8(long address) {
|
||||
super(address, SIZE);
|
||||
}
|
||||
|
||||
public Int8(int[] dimensions) {
|
||||
super(dimensions, SIZE);
|
||||
}
|
||||
|
||||
public Int8(long address, int[] dimensions) {
|
||||
super(address, dimensions, SIZE);
|
||||
}
|
||||
|
||||
public byte get() {
|
||||
|
Loading…
Reference in New Issue
Block a user