feat: introduce binding generator

A squash of hundreds of commits with a binding API generator.

The API generator works with a hybrid model:
1. We define methods and fields in the code.
2. Mark them with API annotations.
3. For specific use cases, we use the old approach with JNI generation comments.

There is also an API to generate an AST tree, which is saved to JSON.
This JSON can be used for full API generation by declaring only field/method names.
Currently, it is used to generate constants.

By eyeballing, 95% of the API has been converted to the new approach.
This is sufficient for the current moment. Only edge cases with specific API calls are left.

fix: ambiguous call for ImGui::GetColorU32

build: disable checkstyle for imgui-binding module

Since the module is heavily generated, checkstyle for it doesn't make sense.

build: make buildSrc to use JDK 11

build: make generateApi optional when compiling project

Initially generated module was not included to the project VCS.
Since it's now in the separate src folder, we don't need to call generator every time.
Only when a new generation result is required.
This commit is contained in:
SpaiR committed 2024-08-08 14:46:23 +03:00
1 parent e64df5a433
commit 8a8cd22ed6
323 files changed
+113518 -15318

No files matched your search

@@ -0,0 +1,300 @@
package imgui;
import imgui.binding.ImGuiStruct;
/**
* (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI.
* We use this information for multiple DPI support + clamping the position of popups and tooltips so they don't straddle multiple monitors.
*/
public final class ImGuiPlatformMonitor extends ImGuiStruct {
public ImGuiPlatformMonitor(final long ptr) {
super(ptr);
}
/*JNI
#include "_common.h"
#define THIS ((ImGuiPlatformMonitor*)STRUCT_PTR)
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public ImVec2 getMainPos() {
final ImVec2 dst = new ImVec2();
nGetMainPos(dst);
return dst;
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainPosX() {
return nGetMainPosX();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainPosY() {
return nGetMainPosY();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void getMainPos(final ImVec2 dst) {
nGetMainPos(dst);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainPos(final ImVec2 value) {
nSetMainPos(value.x, value.y);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainPos(final float valueX, final float valueY) {
nSetMainPos(valueX, valueY);
}
private native void nGetMainPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MainPos, dst);
*/
private native float nGetMainPosX(); /*
return THIS->MainPos.x;
*/
private native float nGetMainPosY(); /*
return THIS->MainPos.y;
*/
private native void nSetMainPos(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MainPos = value;
*/
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public ImVec2 getMainSize() {
final ImVec2 dst = new ImVec2();
nGetMainSize(dst);
return dst;
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainSizeX() {
return nGetMainSizeX();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public float getMainSizeY() {
return nGetMainSizeY();
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void getMainSize(final ImVec2 dst) {
nGetMainSize(dst);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainSize(final ImVec2 value) {
nSetMainSize(value.x, value.y);
}
/**
* Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
*/
public void setMainSize(final float valueX, final float valueY) {
nSetMainSize(valueX, valueY);
}
private native void nGetMainSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->MainSize, dst);
*/
private native float nGetMainSizeX(); /*
return THIS->MainSize.x;
*/
private native float nGetMainSizeY(); /*
return THIS->MainSize.y;
*/
private native void nSetMainSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->MainSize = value;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public ImVec2 getWorkPos() {
final ImVec2 dst = new ImVec2();
nGetWorkPos(dst);
return dst;
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkPosX() {
return nGetWorkPosX();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkPosY() {
return nGetWorkPosY();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void getWorkPos(final ImVec2 dst) {
nGetWorkPos(dst);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkPos(final ImVec2 value) {
nSetWorkPos(value.x, value.y);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkPos(final float valueX, final float valueY) {
nSetWorkPos(valueX, valueY);
}
private native void nGetWorkPos(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->WorkPos, dst);
*/
private native float nGetWorkPosX(); /*
return THIS->WorkPos.x;
*/
private native float nGetWorkPosY(); /*
return THIS->WorkPos.y;
*/
private native void nSetWorkPos(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->WorkPos = value;
*/
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public ImVec2 getWorkSize() {
final ImVec2 dst = new ImVec2();
nGetWorkSize(dst);
return dst;
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkSizeX() {
return nGetWorkSizeX();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public float getWorkSizeY() {
return nGetWorkSizeY();
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void getWorkSize(final ImVec2 dst) {
nGetWorkSize(dst);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkSize(final ImVec2 value) {
nSetWorkSize(value.x, value.y);
}
/**
* Coordinates without task bars / side bars / menu bars.
* Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
*/
public void setWorkSize(final float valueX, final float valueY) {
nSetWorkSize(valueX, valueY);
}
private native void nGetWorkSize(ImVec2 dst); /*
Jni::ImVec2Cpy(env, THIS->WorkSize, dst);
*/
private native float nGetWorkSizeX(); /*
return THIS->WorkSize.x;
*/
private native float nGetWorkSizeY(); /*
return THIS->WorkSize.y;
*/
private native void nSetWorkSize(float valueX, float valueY); /*MANUAL
ImVec2 value = ImVec2(valueX, valueY);
THIS->WorkSize = value;
*/
/**
* 1.0f = 96 DPI
*/
public float getDpiScale() {
return nGetDpiScale();
}
/**
* 1.0f = 96 DPI
*/
public void setDpiScale(final float value) {
nSetDpiScale(value);
}
private native float nGetDpiScale(); /*
return THIS->DpiScale;
*/
private native void nSetDpiScale(float value); /*
THIS->DpiScale = value;
*/
/*JNI
#undef THIS
*/
}