[API] Remove lazy-created sructs and add methods to verify struct pointer

This commit is contained in:
SpaiR committed 2021-02-27 16:15:11 +02:00
1 parent c33331e13b
commit 91d636a659
8 files changed
+60 -75

No files matched your search

@@ -3,11 +3,13 @@ package imgui.binding;
import imgui.ImGui;
/**
* Class provides a communication layer between binding and Dear ImGui library though the "pointer" field.
* Class provides a communication layer between binding and Dear ImGui library through the "pointer" field.
*/
public abstract class ImGuiStruct {
/**
* Pointer to the natively allocated object,
* Pointer to the natively allocated object.
* Could be zero if JNI returned NULL instead of the real object.
* For such cases methods {@link #isValidPtr()} and {@link #isNotValidPtr()} could be used to verify that object points to the real object.
*/
public long ptr;
@@ -15,4 +17,22 @@ public abstract class ImGuiStruct {
ImGui.init();
this.ptr = ptr;
}
/**
* Shows if object pointer is valid and does it point to the existing object.
*
* @return true, if pointer is valid
*/
public final boolean isValidPtr() {
return ptr != 0;
}
/**
* Shows if object pointer is valid and does it point to the existing object.
*
* @return true, if pointer is invalid
*/
public final boolean isNotValidPtr() {
return !isValidPtr();
}
}