feat(api): use uintptr_t instead of intptr_t for pointers (#265)

Image methods now accept the `long` type instead of `int`,
as they are expected to work with pointers as well.
This commit is contained in:
SpaiR authored and GitHub committed 2024-08-29 16:54:43 +03:00
1 parent 473521edba
commit c4c03bee9f
58 files changed
+303 -303

No files matched your search

@@ -68,7 +68,7 @@ public final class ImDrawData extends ImGuiStruct {
* Ignore if never using images or multiple fonts atlas.
*/
public native int getCmdListCmdBufferTextureId(int cmdListIdx, int cmdBufferIdx); /*
return (intptr_t)THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].GetTexID();
return (uintptr_t)THIS->CmdLists[cmdListIdx]->CmdBuffer[cmdBufferIdx].GetTexID();
*/
/**
@@ -50,7 +50,7 @@ public final class ImDrawList extends ImGuiStruct {
public native void PopClipRect();
@BindingMethod
public native void PushTextureID(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int textureId);
public native void PushTextureID(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long textureId);
@BindingMethod
public native void PopTextureID();
@@ -137,13 +137,13 @@ public final class ImDrawList extends ImGuiStruct {
// - "uvMin" and "uvMax" represent the normalized texture coordinates to use for those corners. Using (0,0)->(1,1) texture coordinates will generally display the entire texture.
@BindingMethod
public native void AddImage(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int textureID, ImVec2 pMin, ImVec2 pMax, @OptArg ImVec2 uvMin, @OptArg ImVec2 uvMax, @OptArg int col);
public native void AddImage(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long textureID, ImVec2 pMin, ImVec2 pMax, @OptArg ImVec2 uvMin, @OptArg ImVec2 uvMax, @OptArg int col);
@BindingMethod
public native void AddImageQuad(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int textureID, ImVec2 p1, ImVec2 p2, ImVec2 p3, ImVec2 p4, @OptArg ImVec2 uv1, @OptArg ImVec2 uv2, @OptArg ImVec2 uv3, @OptArg ImVec2 uv4, @OptArg int col);
public native void AddImageQuad(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long textureID, ImVec2 p1, ImVec2 p2, ImVec2 p3, ImVec2 p4, @OptArg ImVec2 uv1, @OptArg ImVec2 uv2, @OptArg ImVec2 uv3, @OptArg ImVec2 uv4, @OptArg int col);
@BindingMethod
public native void AddImageRounded(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int textureID, ImVec2 pMin, ImVec2 pMax, ImVec2 uvMin, ImVec2 uvMax, int col, float rounding, @OptArg int imDrawFlags);
public native void AddImageRounded(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long textureID, ImVec2 pMin, ImVec2 pMax, ImVec2 uvMin, ImVec2 uvMax, int col, float rounding, @OptArg int imDrawFlags);
// Stateful path API, add points then finish with PathFillConvex() or PathStroke()
@@ -33,7 +33,7 @@ public final class ImFont extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImFont());
return (uintptr_t)(new ImFont());
*/
// TODO IndexAdvanceX
@@ -63,7 +63,7 @@ public final class ImFontAtlas extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImFontConfig());
return (uintptr_t)(new ImFontConfig());
*/
@BindingMethod
@@ -243,7 +243,7 @@ public final class ImFontAtlas extends ImGuiStructDestroyable {
* It is passed back to you during rendering via the ImDrawCmd structure.
*/
@BindingMethod
public native void SetTexID(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int textureID);
public native void SetTexID(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long textureID);
//-------------------------------------------
// Glyph Ranges
@@ -27,7 +27,7 @@ public final class ImFontConfig extends ImGuiStructDestroyable {
private native long nCreate(); /*
ImFontConfig* cfg = new ImFontConfig();
cfg->FontDataOwnedByAtlas = false;
return (intptr_t)cfg;
return (uintptr_t)cfg;
*/
/**
@@ -29,7 +29,7 @@ public final class ImFontGlyph extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImFontGlyph());
return (uintptr_t)(new ImFontGlyph());
*/
/**
+2 -2
View File
@@ -1040,13 +1040,13 @@ public class ImGui {
public static native boolean ArrowButton(String strId, int dir);
@BindingMethod
public static native void Image(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int userTextureId, ImVec2 size, @OptArg ImVec2 uv0, @OptArg ImVec2 uv1, @OptArg ImVec4 tintCol, @OptArg ImVec4 borderCol);
public static native void Image(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long userTextureId, ImVec2 size, @OptArg ImVec2 uv0, @OptArg ImVec2 uv1, @OptArg ImVec4 tintCol, @OptArg ImVec4 borderCol);
/**
* {@code <0} framePadding uses default frame padding settings. 0 for no padding
*/
@BindingMethod
public static native boolean ImageButton(@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int userTextureId, ImVec2 size, @OptArg ImVec2 uv0, @OptArg ImVec2 uv1, @OptArg(callValue = "-1") int framePadding, @OptArg ImVec4 bgCol, @OptArg ImVec4 tintCol);
public static native boolean ImageButton(@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long userTextureId, ImVec2 size, @OptArg ImVec2 uv0, @OptArg ImVec2 uv1, @OptArg(callValue = "-1") int framePadding, @OptArg ImVec4 bgCol, @OptArg ImVec4 tintCol);
public static boolean checkbox(String label, boolean active) {
return nCheckbox(label, active);
@@ -29,7 +29,7 @@ public final class ImGuiKeyData extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiKeyData());
return (uintptr_t)(new ImGuiKeyData());
*/
/**
@@ -102,7 +102,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
void PlatformStub##name(ImGuiViewport* vp) {\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);\
Jni::CallImPlatformFuncViewport(env, platformCallback##name, jTmpViewport);\
}\
}\
@@ -155,7 +155,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
void PlatformStub##name(ImGuiViewport* vp, ImVec2 pos) {\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);\
Jni::ImVec2Cpy(env, pos, jTmpImVec2);\
Jni::CallImPlatformFuncViewportImVec2(env, platformCallback##name, jTmpViewport, jTmpImVec2);\
}\
@@ -185,7 +185,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
ImVec2 dst;\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);\
Jni::CallImPlatformFuncViewportSuppImVec2(env, platformCallback##name, jTmpViewport, jTmpImVec2);\
Jni::ImVec2Cpy(env, jTmpImVec2, &dst);\
}\
@@ -248,7 +248,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
bool PlatformStub##name(ImGuiViewport* vp) {\
if (platformCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);\
return Jni::CallImPlatformFuncViewportSuppBoolean(env, platformCallback##name, jTmpViewport);\
}\
return false;\
@@ -287,7 +287,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
void PlatformStubSetWindowTitle(ImGuiViewport* vp, const char* str) {
if (platformCallbackSetWindowTitle != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);
Jni::CallImPlatformFuncViewportString(env, platformCallbackSetWindowTitle, jTmpViewport, str);
}
}
@@ -309,7 +309,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
void PlatformStubSetWindowAlpha(ImGuiViewport* vp, float alpha) {
if (platformCallbackSetWindowAlpha != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);
Jni::CallImPlatformFuncViewportFloat(env, platformCallbackSetWindowAlpha, jTmpViewport, alpha);
}
}
@@ -364,7 +364,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
float PlatformStubGetWindowDpiScale(ImGuiViewport* vp) {
if (platformCallbackGetWindowDpiScale != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);
return Jni::CallImPlatformFuncViewportSuppFloat(env, platformCallbackGetWindowDpiScale, jTmpViewport);
}
return false;
@@ -401,7 +401,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
void RendererStub##name(ImGuiViewport* vp) {\
if (rendererCallback##name != NULL) {\
JNIEnv* env = Jni::GetEnv();\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);\
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);\
Jni::CallImPlatformFuncViewport(env, rendererCallback##name, jTmpViewport);\
}\
}\
@@ -442,7 +442,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
void RendererStubSetWindowSize(ImGuiViewport* vp, ImVec2 pos) {
if (rendererCallbackSetWindowSize != NULL) {
JNIEnv* env = Jni::GetEnv();
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (intptr_t)vp);
env->SetLongField(jTmpViewport, Jni::GetBindingStructPtrID(), (uintptr_t)vp);
Jni::ImVec2Cpy(env, pos, jTmpImVec2);
Jni::CallImPlatformFuncViewportImVec2(env, rendererCallbackSetWindowSize, jTmpViewport, jTmpImVec2);
}
@@ -519,7 +519,7 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
}
private native long nGetMonitors(int idx); /*
return (intptr_t)&IMGUI_PLATFORM_IO->Monitors[idx];
return (uintptr_t)&IMGUI_PLATFORM_IO->Monitors[idx];
*/
// Viewports list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
@@ -535,6 +535,6 @@ public final class ImGuiPlatformIO extends ImGuiStruct {
}
private native long nGetViewports(int idx); /*
return (intptr_t)IMGUI_PLATFORM_IO->Viewports[idx];
return (uintptr_t)IMGUI_PLATFORM_IO->Viewports[idx];
*/
}
@@ -36,7 +36,7 @@ public final class ImGuiStorage extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiStorage());
return (uintptr_t)(new ImGuiStorage());
*/
// - Get***() functions find pair, never add/allocate. Pairs are sorted so a query is O(log N)
@@ -32,7 +32,7 @@ public final class ImGuiStyle extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiStyle());
return (uintptr_t)(new ImGuiStyle());
*/
/**
@@ -39,7 +39,7 @@ public final class ImGuiTableSortSpecs extends ImGuiStruct {
int specsCount = THIS->SpecsCount;
jlong jBuf[specsCount];
for (int i = 0; i < specsCount; i++) {
jBuf[i] = (intptr_t)specs;
jBuf[i] = (uintptr_t)specs;
specs++;
}
jlongArray result = env->NewLongArray(specsCount);
@@ -34,7 +34,7 @@ public final class ImGuiTextFilter extends ImGuiStructDestroyable {
*/
private native long nCreate(String defaultFilter); /*
return (intptr_t)(new ImGuiTextFilter(defaultFilter));
return (uintptr_t)(new ImGuiTextFilter(defaultFilter));
*/
@BindingMethod
@@ -126,7 +126,7 @@ public final class ImGuiViewport extends ImGuiStruct {
* void* for FindViewportByPlatformHandle(). (e.g. suggested to use natural platform handle such as HWND, GLFWWindow*, SDL_Window*)
*/
public native long getPlatformHandle(); /*
return (intptr_t)THIS->PlatformHandle;
return (uintptr_t)THIS->PlatformHandle;
*/
/**
@@ -140,7 +140,7 @@ public final class ImGuiViewport extends ImGuiStruct {
* void* to hold lower-level, platform-native window handle (e.g. the HWND) when using an abstraction layer like GLFW or SDL (where PlatformHandle would be a SDL_Window*)
*/
public native long getPlatformHandleRaw(); /*
return (intptr_t)THIS->PlatformHandleRaw;
return (uintptr_t)THIS->PlatformHandleRaw;
*/
/**
@@ -34,7 +34,7 @@ public final class ImGuiWindowClass extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImGuiWindowClass());
return (uintptr_t)(new ImGuiWindowClass());
*/
/**
@@ -301,6 +301,6 @@ public final class ImGuiFileDialog {
* @return user datas sent with Open Dialog/Modal
*/
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetUserDatas();
}
@@ -973,7 +973,7 @@ public final class ImPlot {
*/
@BindingMethod
public static native void PlotImage(String labelId,
@ArgValue(callPrefix = "(ImTextureID)(intptr_t)") int userTextureId,
@ArgValue(callPrefix = "(ImTextureID)(uintptr_t)") long userTextureId,
ImPlotPoint boundsMin,
ImPlotPoint boundsMax,
@OptArg ImVec2 uv0,
@@ -25,7 +25,7 @@ public final class ImPlotInputMap extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImPlotInputMap());
return (uintptr_t)(new ImPlotInputMap());
*/
/**
@@ -28,7 +28,7 @@ public final class ImPlotStyle extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ImPlotStyle());
return (uintptr_t)(new ImPlotStyle());
*/
@BindingField
@@ -33,7 +33,7 @@ public final class MemoryEditor extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new MemoryEditor());
return (uintptr_t)(new MemoryEditor());
*/
@BindingField
@@ -25,7 +25,7 @@ public final class MemoryEditorSizes extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new MemoryEditor::Sizes());
return (uintptr_t)(new MemoryEditor::Sizes());
*/
@BindingField
@@ -293,17 +293,17 @@ public final class NodeEditor {
public static native long getNodeWithContextMenu(); /*
ax::NodeEditor::NodeId id;
return ax::NodeEditor::ShowNodeContextMenu(&id) ? (intptr_t)(uintptr_t)id : -1;
return ax::NodeEditor::ShowNodeContextMenu(&id) ? (uintptr_t)id : -1;
*/
public static native long getPinWithContextMenu(); /*
ax::NodeEditor::PinId id;
return ax::NodeEditor::ShowPinContextMenu(&id) ? (intptr_t)(uintptr_t)id : -1;
return ax::NodeEditor::ShowPinContextMenu(&id) ? (uintptr_t)id : -1;
*/
public static native long getLinkWithContextMenu(); /*
ax::NodeEditor::LinkId id;
return ax::NodeEditor::ShowLinkContextMenu(&id) ? (intptr_t)(uintptr_t)id : -1;
return ax::NodeEditor::ShowLinkContextMenu(&id) ? (uintptr_t)id : -1;
*/
@BindingMethod
@@ -349,27 +349,27 @@ public final class NodeEditor {
public static native float GetCurrentZoom();
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)(uintptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetHoveredNode();
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)(uintptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetHoveredPin();
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)(uintptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetHoveredLink();
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)(uintptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetDoubleClickedNode();
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)(uintptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetDoubleClickedPin();
@BindingMethod
@ReturnValue(callPrefix = "(intptr_t)(uintptr_t)")
@ReturnValue(callPrefix = "(uintptr_t)")
public static native long GetDoubleClickedLink();
@BindingMethod
@@ -17,7 +17,7 @@ public final class NodeEditorConfig extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new ax::NodeEditor::Config());
return (uintptr_t)(new ax::NodeEditor::Config());
*/
@BindingField
@@ -32,7 +32,7 @@ public final class TextEditor extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new TextEditor());
return (uintptr_t)(new TextEditor());
*/
@BindingMethod
@@ -31,7 +31,7 @@ public final class TextEditorLanguageDefinition extends ImGuiStructDestroyable {
*/
private native long nCreate(); /*
return (intptr_t)(new TextEditor::LanguageDefinition());
return (uintptr_t)(new TextEditor::LanguageDefinition());
*/
@BindingField(callName = "mName")
@@ -61,7 +61,7 @@ public final class ImGuiDockNode extends ImGuiStruct {
}
private native long nGetChildNodeFirst(); /*
return (intptr_t)THIS->ChildNodes[0];
return (uintptr_t)THIS->ChildNodes[0];
*/
/**
@@ -83,7 +83,7 @@ public final class ImGuiDockNode extends ImGuiStruct {
}
private native long nGetChildNodeSecond(); /*
return (intptr_t)THIS->ChildNodes[1];
return (uintptr_t)THIS->ChildNodes[1];
*/
/**