Implement Cloneable for all primitive wrappers

This commit is contained in:
SpaiR committed 2020-06-06 16:40:08 +03:00
1 parent 1e52d6ef82
commit 71e7265858
9 files changed
+100 -9

No files matched your search

+10 -1
View File
@@ -2,12 +2,16 @@ package imgui;
import java.util.Objects;
public final class ImBool {
public final class ImBool implements Cloneable {
final boolean[] data = new boolean[]{false};
public ImBool() {
}
public ImBool(final ImBool imBool) {
this.data[0] = imBool.data[0];
}
public ImBool(final boolean value) {
data[0] = value;
}
@@ -41,4 +45,9 @@ public final class ImBool {
public int hashCode() {
return Objects.hash(data[0]);
}
@Override
public ImBool clone() {
return new ImBool(this);
}
}
@@ -2,12 +2,16 @@ package imgui;
import java.util.Objects;
public final class ImDouble {
public final class ImDouble implements Cloneable {
final double[] data = new double[]{0.0d};
public ImDouble() {
}
public ImDouble(final ImDouble imDouble) {
this.data[0] = imDouble.data[0];
}
public ImDouble(final double value) {
set(value);
}
@@ -41,4 +45,9 @@ public final class ImDouble {
public int hashCode() {
return Objects.hash(data[0]);
}
@Override
public ImDouble clone() {
return new ImDouble(this);
}
}
+10 -1
View File
@@ -2,12 +2,16 @@ package imgui;
import java.util.Objects;
public final class ImFloat {
public final class ImFloat implements Cloneable {
final float[] data = new float[]{0};
public ImFloat() {
}
public ImFloat(final ImFloat imFloat) {
this.data[0] = imFloat.data[0];
}
public ImFloat(final float value) {
set(value);
}
@@ -41,4 +45,9 @@ public final class ImFloat {
public int hashCode() {
return Objects.hash(data[0]);
}
@Override
public ImFloat clone() {
return new ImFloat(this);
}
}
+10 -1
View File
@@ -2,12 +2,16 @@ package imgui;
import java.util.Objects;
public final class ImInt {
public final class ImInt implements Cloneable {
final int[] data = new int[]{0};
public ImInt() {
}
public ImInt(final ImInt imInt) {
this.data[0] = imInt.data[0];
}
public ImInt(final int value) {
set(value);
}
@@ -41,4 +45,9 @@ public final class ImInt {
public int hashCode() {
return Objects.hashCode(data[0]);
}
@Override
public ImInt clone() {
return new ImInt(this);
}
}
+10 -1
View File
@@ -2,12 +2,16 @@ package imgui;
import java.util.Objects;
public final class ImLong {
public final class ImLong implements Cloneable {
final long[] data = new long[]{0};
public ImLong() {
}
public ImLong(final ImLong imLong) {
this.data[0] = imLong.data[0];
}
public ImLong(final long value) {
set(value);
}
@@ -41,4 +45,9 @@ public final class ImLong {
public int hashCode() {
return Objects.hashCode(data[0]);
}
@Override
public ImLong clone() {
return new ImLong(this);
}
}
+10 -1
View File
@@ -2,12 +2,16 @@ package imgui;
import java.util.Objects;
public final class ImShort {
public final class ImShort implements Cloneable {
final short[] data = new short[]{0};
public ImShort() {
}
public ImShort(final ImShort imShort) {
this.data[0] = imShort.data[0];
}
public ImShort(final short value) {
set(value);
}
@@ -41,4 +45,9 @@ public final class ImShort {
public int hashCode() {
return Objects.hashCode(data[0]);
}
@Override
public ImShort clone() {
return new ImShort(this);
}
}
@@ -6,7 +6,7 @@ import java.util.Objects;
/**
* Wrapper for {@link String} to use inside of th Dear ImGui input widgets.
*/
public final class ImString {
public final class ImString implements Cloneable {
/**
* Default size of the inner buffer, if {@link ImString} created with a constructor without args.
*/
@@ -32,6 +32,16 @@ public final class ImString {
this(DEFAULT_LENGTH);
}
public ImString(final ImString imString) {
this(imString.text, imString.data.length);
this.inputData.allowedChars = imString.inputData.allowedChars;
this.inputData.isResizable = imString.inputData.isResizable;
this.inputData.resizeFactor = imString.inputData.resizeFactor;
this.inputData.size = imString.inputData.size;
this.inputData.isDirty = imString.inputData.isDirty;
this.inputData.isResized = imString.inputData.isResized;
}
/**
* Creates an {@link ImString} instance with provided size for the inner buffer.
* @param length size of the inner buffer to use
@@ -150,4 +160,9 @@ public final class ImString {
public int hashCode() {
return text.hashCode();
}
@Override
public ImString clone() {
return new ImString(this);
}
}
+11 -1
View File
@@ -5,13 +5,18 @@ import java.util.Objects;
/**
* 2D vector (often used to store positions or sizes)
*/
public final class ImVec2 {
public final class ImVec2 implements Cloneable {
public float x;
public float y;
public ImVec2() {
}
public ImVec2(final ImVec2 imVec2) {
this.x = imVec2.x;
this.y = imVec2.y;
}
public ImVec2(final float x, final float y) {
this.x = x;
this.y = y;
@@ -41,4 +46,9 @@ public final class ImVec2 {
public int hashCode() {
return Objects.hash(x, y);
}
@Override
public ImVec2 clone() {
return new ImVec2(this);
}
}
+13 -1
View File
@@ -5,7 +5,7 @@ import java.util.Objects;
/**
* 4D vector (often used to store floating-point colors)
*/
public final class ImVec4 {
public final class ImVec4 implements Cloneable {
public float x;
public float y;
public float z;
@@ -14,6 +14,13 @@ public final class ImVec4 {
public ImVec4() {
}
public ImVec4(final ImVec4 imVec4) {
this.x = imVec4.x;
this.y = imVec4.y;
this.z = imVec4.z;
this.w = imVec4.w;
}
public ImVec4(final float x, final float y, final float z, final float w) {
this.x = x;
this.y = y;
@@ -47,4 +54,9 @@ public final class ImVec4 {
public int hashCode() {
return Objects.hash(x, y, z, w);
}
@Override
public ImVec4 clone() {
return new ImVec4(this);
}
}