Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding Generator API #240

Merged
merged 3 commits into from
Aug 8, 2024
Merged

Binding Generator API #240

merged 3 commits into from
Aug 8, 2024

Conversation

SpaiR
Copy link
Owner

@SpaiR SpaiR commented Aug 8, 2024

Description

This PR represents the final solution for auto-generating bindings as referenced in #132.

I must admit that I am not entirely satisfied with the implementation, but it has taken too long (2 years, sheeesh...), and we need to move forward. Initially, I aimed to fully auto-generate the bindings. However, due to complexities, the implementation got delayed. Therefore, I opted for a compromise. Part of the code can be fully auto-generated, which is very convenient for transferring enum objects. The rest is generated through corresponding declarations.

Key Points:

  • A new generateApi task for Gradle takes Java code from the main folder and generates native code and the code that calls it. The result is placed in the generated folder.
  • Special annotations are extensively used for generation. These annotations are removed from the generation results.
  • Constants are fully auto-generated based on AST trees created by the generateAst command.
  • Approximately 95% of the code has been converted to use the new API. This conversion has also helped automatically resolve issues where methods had incorrect signatures or were missing entirely. All relevant issues will be closed with the merge of this PR.

Detailed documentation on how to work with the auto-generation code will be provided in the future.

Examples

Some examples of how API generation changed the way of creating binding.

ImGui (partial example)

Before
/**
    * Get draw list associated to the current window, to append your own drawing primitives
    */
public static ImDrawList getWindowDrawList() {
    WINDOW_DRAW_LIST.ptr = nGetWindowDrawList();
    return WINDOW_DRAW_LIST;
}

private static native long nGetWindowDrawList(); /*
    return (intptr_t)ImGui::GetWindowDrawList();
*/

/**
    * Get DPI scale currently associated to the current window's viewport.
    */
public static native float getWindowDpiScale(); /*
    return ImGui::GetWindowDpiScale();
*/

/**
    * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
    */
public static ImVec2 getWindowPos() {
    final ImVec2 value = new ImVec2();
    getWindowPos(value);
    return value;
}

/**
    * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
    */
public static native void getWindowPos(ImVec2 dstImVec2); /*
    Jni::ImVec2Cpy(env, ImGui::GetWindowPos(), dstImVec2);
*/

/**
    * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
    */
public static native float getWindowPosX(); /*
    return ImGui::GetWindowPos().x;
*/

/**
    * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
    */
public static native float getWindowPosY(); /*
    return ImGui::GetWindowPos().y;
*/
After
/**
 * Get draw list associated to the current window, to append your own drawing primitives
 */
@BindingMethod
public static native ImDrawList GetWindowDrawList();

/**
 * Get DPI scale currently associated to the current window's viewport.
 */
@BindingMethod
public static native float GetWindowDpiScale();

/**
 * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
 */
@BindingMethod
public static native ImVec2 GetWindowPos();
Result
/**
 * Get draw list associated to the current window, to append your own drawing primitives
 */
public static ImDrawList getWindowDrawList() {
    return new ImDrawList(nGetWindowDrawList());
}

private static native long nGetWindowDrawList(); /*
    return (intptr_t)ImGui::GetWindowDrawList();
*/

/**
 * Get DPI scale currently associated to the current window's viewport.
 */
public static float getWindowDpiScale() {
    return nGetWindowDpiScale();
}

private static native float nGetWindowDpiScale(); /*
    return ImGui::GetWindowDpiScale();
*/

/**
 * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
 */
public static ImVec2 getWindowPos() {
    final ImVec2 dst = new ImVec2();
    nGetWindowPos(dst);
    return dst;
}

/**
 * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
 */
public static float getWindowPosX() {
    return nGetWindowPosX();
}

/**
 * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
 */
public static float getWindowPosY() {
    return nGetWindowPosY();
}

/**
 * Get current window position in screen space (useful if you want to do your own drawing via the DrawList API)
 */
public static void getWindowPos(final ImVec2 dst) {
    nGetWindowPos(dst);
}

private static native void nGetWindowPos(ImVec2 dst); /*
    Jni::ImVec2Cpy(env, ImGui::GetWindowPos(), dst);
*/

private static native float nGetWindowPosX(); /*
    return ImGui::GetWindowPos().x;
*/

private static native float nGetWindowPosY(); /*
    return ImGui::GetWindowPos().y;
*/

ImGuiWindowFlags

Before
public final class ImGuiWindowFlags {
    private ImGuiWindowFlags() {
    }

    public static final int None = 0;
    public static final int NoTitleBar = 1;
    /**
     * Disable user resizing with the lower-right grip
     */
    public static final int NoResize = 1 << 1;
    /**
     * Disable user moving the window
     */
    public static final int NoMove = 1 << 2;
    /**
     * Disable scrollbars (window can still scroll with mouse or programmatically)
     */
    public static final int NoScrollbar = 1 << 3;
    /**
     * Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
     */
    public static final int NoScrollWithMouse = 1 << 4;
    /**
     * Disable user collapsing window by double-clicking on it
     */
    public static final int NoCollapse = 1 << 5;
    /**
     * Resize every window to its content every frame
     */
    public static final int AlwaysAutoResize = 1 << 6;
    /**
     * Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
     */
    public static final int NoBackground = 1 << 7;
    /**
     * Never load/save settings in .ini file
     */
    public static final int NoSavedSettings = 1 << 8;
    /**
     * Disable catching mouse, hovering test with pass through.
     */
    public static final int NoMouseInputs = 1 << 9;
    /**
     * Has a menu-bar
     */
    public static final int MenuBar = 1 << 10;
    /**
     * Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
     */
    public static final int HorizontalScrollbar = 1 << 11;
    /**
     * Disable taking focus when transitioning from hidden to visible state
     */
    public static final int NoFocusOnAppearing = 1 << 12;
    /**
     * Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus)
     */
    public static final int NoBringToFrontOnFocus = 1 << 13;
    /**
     * Always show vertical scrollbar (even if ContentSize.y {@code <} Size.y)
     */
    public static final int AlwaysVerticalScrollbar = 1 << 14;
    /**
     * Always show horizontal scrollbar (even if ContentSize.x {@code <} Size.x)
     */
    public static final int AlwaysHorizontalScrollbar = 1 << 15;
    /**
     * Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
     */
    public static final int AlwaysUseWindowPadding = 1 << 16;
    /**
     * No gamepad/keyboard navigation within the window
     */
    public static final int NoNavInputs = 1 << 17;
    /**
     * No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
     */
    public static final int NoNavFocus = 1 << 18;
    /**
     * Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker.
     */
    public static final int UnsavedDocument = 1 << 20;
    /**
     * Disable docking of this window
     */
    public static final int NoDocking = 1 << 21;
    public static final int NoNav = NoNavInputs | NoNavFocus;
    public static final int NoDecoration = NoTitleBar | NoResize | NoScrollbar | NoCollapse;
    public static final int NoInputs = NoMouseInputs | NoNavInputs | NoNavFocus;
}
After
@BindingSource
public final class ImGuiWindowFlags {
    private ImGuiWindowFlags() {
    }

    @BindingAstEnum(file = "ast-imgui.json", qualType = "ImGuiWindowFlags_")
    public Void __;
}
Result
public final class ImGuiWindowFlags {
    private ImGuiWindowFlags() {
    }

    /**
     * Definition: {@code 0}
     */
    public static final int None = 0;

    /**
     * Disable title-bar
     *
     * <p>Definition: {@code 1 << 0}
     */
    public static final int NoTitleBar = 1;

    /**
     * Disable user resizing with the lower-right grip
     *
     * <p>Definition: {@code 1 << 1}
     */
    public static final int NoResize = 2;

    /**
     * Disable user moving the window
     *
     * <p>Definition: {@code 1 << 2}
     */
    public static final int NoMove = 4;

    /**
     * Disable scrollbars (window can still scroll with mouse or programmatically)
     *
     * <p>Definition: {@code 1 << 3}
     */
    public static final int NoScrollbar = 8;

    /**
     * Disable user vertically scrolling with mouse wheel. On child window, mouse wheel will be forwarded to the parent unless NoScrollbar is also set.
     *
     * <p>Definition: {@code 1 << 4}
     */
    public static final int NoScrollWithMouse = 16;

    /**
     * Disable user collapsing window by double-clicking on it. Also referred to as Window Menu Button (e.g. within a docking node).
     *
     * <p>Definition: {@code 1 << 5}
     */
    public static final int NoCollapse = 32;

    /**
     * Resize every window to its content every frame
     *
     * <p>Definition: {@code 1 << 6}
     */
    public static final int AlwaysAutoResize = 64;

    /**
     * Disable drawing background color (WindowBg, etc.) and outside border. Similar as using SetNextWindowBgAlpha(0.0f).
     *
     * <p>Definition: {@code 1 << 7}
     */
    public static final int NoBackground = 128;

    /**
     * Never load/save settings in .ini file
     *
     * <p>Definition: {@code 1 << 8}
     */
    public static final int NoSavedSettings = 256;

    /**
     * Disable catching mouse, hovering test with pass through.
     *
     * <p>Definition: {@code 1 << 9}
     */
    public static final int NoMouseInputs = 512;

    /**
     * Has a menu-bar
     *
     * <p>Definition: {@code 1 << 10}
     */
    public static final int MenuBar = 1024;

    /**
     * Allow horizontal scrollbar to appear (off by default). You may use SetNextWindowContentSize(ImVec2(width,0.0f)); prior to calling Begin() to specify width. Read code in imgui_demo in the "Horizontal Scrolling" section.
     *
     * <p>Definition: {@code 1 << 11}
     */
    public static final int HorizontalScrollbar = 2048;

    /**
     * Disable taking focus when transitioning from hidden to visible state
     *
     * <p>Definition: {@code 1 << 12}
     */
    public static final int NoFocusOnAppearing = 4096;

    /**
     * Disable bringing window to front when taking focus (e.g. clicking on it or programmatically giving it focus)
     *
     * <p>Definition: {@code 1 << 13}
     */
    public static final int NoBringToFrontOnFocus = 8192;

    /**
     * Always show vertical scrollbar (even if ContentSize.y{@code <}Size.y)
     *
     * <p>Definition: {@code 1 << 14}
     */
    public static final int AlwaysVerticalScrollbar = 16384;

    /**
     * Always show horizontal scrollbar (even if ContentSize.x{@code <}Size.x)
     *
     * <p>Definition: {@code 1<< 15}
     */
    public static final int AlwaysHorizontalScrollbar = 32768;

    /**
     * Ensure child windows without border uses style.WindowPadding (ignored by default for non-bordered child windows, because more convenient)
     *
     * <p>Definition: {@code 1 << 16}
     */
    public static final int AlwaysUseWindowPadding = 65536;

    /**
     * No gamepad/keyboard navigation within the window
     *
     * <p>Definition: {@code 1 << 18}
     */
    public static final int NoNavInputs = 262144;

    /**
     * No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB)
     *
     * <p>Definition: {@code 1 << 19}
     */
    public static final int NoNavFocus = 524288;

    /**
     * Display a dot next to the title. When used in a tab/docking context, tab is selected when clicking the X + closure is not assumed (will wait for user to stop submitting the tab). Otherwise closure is assumed when pressing the X, so if you keep submitting the tab may reappear at end of tab bar.
     *
     * <p>Definition: {@code 1 << 20}
     */
    public static final int UnsavedDocument = 1048576;

    /**
     * Disable docking of this window
     *
     * <p>Definition: {@code 1 << 21}
     */
    public static final int NoDocking = 2097152;

    /**
     * Definition: {@code ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus}
     */
    public static final int NoNav = 786432;

    /**
     * Definition: {@code ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoCollapse}
     */
    public static final int NoDecoration = 43;

    /**
     * Definition: {@code ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus}
     */
    public static final int NoInputs = 786944;

    /**
     * [BETA] On child window: allow gamepad/keyboard navigation to cross over parent border to this child or between sibling child windows.
     *
     * <p>Definition: {@code 1 << 23}
     */
    public static final int NavFlattened = 8388608;

    /**
     * Don't use! For internal use by BeginChild()
     *
     * <p>Definition: {@code 1 << 24}
     */
    public static final int ChildWindow = 16777216;

    /**
     * Don't use! For internal use by BeginTooltip()
     *
     * <p>Definition: {@code 1 << 25}
     */
    public static final int Tooltip = 33554432;

    /**
     * Don't use! For internal use by BeginPopup()
     *
     * <p>Definition: {@code 1 << 26}
     */
    public static final int Popup = 67108864;

    /**
     * Don't use! For internal use by BeginPopupModal()
     *
     * <p>Definition: {@code 1 << 27}
     */
    public static final int Modal = 134217728;

    /**
     * Don't use! For internal use by BeginMenu()
     *
     * <p>Definition: {@code 1 << 28}
     */
    public static final int ChildMenu = 268435456;

    /**
     * Don't use! For internal use by Begin()/NewFrame()
     *
     * <p>Definition: {@code 1 << 29}
     */
    public static final int DockNodeHost = 536870912;
}

ImGuiIO (partial example)

Before
/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public native int getBackendFlags(); /*
    return IO->BackendFlags;
*/

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public native void setBackendFlags(int backendFlags); /*
    IO->BackendFlags = backendFlags;
*/

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public void addBackendFlags(final int backendFlags) {
    setBackendFlags(getBackendFlags() | backendFlags);
}

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public void removeBackendFlags(final int backendFlags) {
    setBackendFlags(getBackendFlags() & ~(backendFlags));
}

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public boolean hasBackendFlags(final int flags) {
    return (getBackendFlags() & flags) != 0;
}

/**
 * Minimum time between saving positions/sizes to .ini file, in seconds.
 */
public native float getIniSavingRate(); /*
    return IO->IniSavingRate;
*/

/**
 * Minimum time between saving positions/sizes to .ini file, in seconds.
 */
public native void setIniSavingRate(float iniSavingRate); /*
    IO->IniSavingRate = iniSavingRate;
*/

/**
 * Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
 */
public native String getIniFilename(); /*
    return env->NewStringUTF(IO->IniFilename);
*/

/**
 * Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
 */
public native void setIniFilename(String iniFilename); /*MANUAL
    IO->IniFilename = obj_iniFilename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_iniFilename, JNI_FALSE);
*/

/**
 * Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
 */
public native String getLogFilename(); /*
    return env->NewStringUTF(IO->LogFilename);
*/

/**
 * Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
 */
public native void setLogFilename(String logFilename); /*MANUAL
    IO->LogFilename = obj_logFilename == NULL ? NULL : (char*)env->GetStringUTFChars(obj_logFilename, JNI_FALSE);
*/

/**
 * Time for a double-click, in seconds.
 */
public native float getMouseDoubleClickTime(); /*
    return IO->MouseDoubleClickTime;
*/

/**
 * Time for a double-click, in seconds.
 */
public native void setMouseDoubleClickTime(float mouseDoubleClickTime); /*
    IO->MouseDoubleClickTime = mouseDoubleClickTime;
*/
After
/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
@BindingField(isFlag = true)
public int BackendFlags;

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
@BindingField
public ImVec2 DisplaySize;

/**
 * Time elapsed since last frame, in seconds.
 */
@BindingField
public float DeltaTime;

/**
 * Minimum time between saving positions/sizes to .ini file, in seconds.
 */
@BindingField
public float IniSavingRate;

/**
 * Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
 */
@BindingField
public String IniFilename;

/**
 * Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
 */
@BindingField
public String LogFilename;
Result
/**
 * See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
 */
public int getConfigFlags() {
    return nGetConfigFlags();
}

/**
 * See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
 */
public void setConfigFlags(final int value) {
    nSetConfigFlags(value);
}

/**
 * See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
 */
public void addConfigFlags(final int flags) {
    setConfigFlags(getConfigFlags() | flags);
}

/**
 * See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
 */
public void removeConfigFlags(final int flags) {
    setConfigFlags(getConfigFlags() & ~(flags));
}

/**
 * See ImGuiConfigFlags enum. Set by user/application. Gamepad/keyboard navigation options, etc.
 */
public boolean hasConfigFlags(final int flags) {
    return (getConfigFlags() & flags) != 0;
}

private native int nGetConfigFlags(); /*
    return THIS->ConfigFlags;
*/

private native void nSetConfigFlags(int value); /*
    THIS->ConfigFlags = value;
*/

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public int getBackendFlags() {
    return nGetBackendFlags();
}

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public void setBackendFlags(final int value) {
    nSetBackendFlags(value);
}

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public void addBackendFlags(final int flags) {
    setBackendFlags(getBackendFlags() | flags);
}

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public void removeBackendFlags(final int flags) {
    setBackendFlags(getBackendFlags() & ~(flags));
}

/**
 * See ImGuiBackendFlags enum. Set by backend to communicate features supported by the backend.
 */
public boolean hasBackendFlags(final int flags) {
    return (getBackendFlags() & flags) != 0;
}

private native int nGetBackendFlags(); /*
    return THIS->BackendFlags;
*/

private native void nSetBackendFlags(int value); /*
    THIS->BackendFlags = value;
*/

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
public ImVec2 getDisplaySize() {
    final ImVec2 dst = new ImVec2();
    nGetDisplaySize(dst);
    return dst;
}

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
public float getDisplaySizeX() {
    return nGetDisplaySizeX();
}

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
public float getDisplaySizeY() {
    return nGetDisplaySizeY();
}

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
public void getDisplaySize(final ImVec2 dst) {
    nGetDisplaySize(dst);
}

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
public void setDisplaySize(final ImVec2 value) {
    nSetDisplaySize(value.x, value.y);
}

/**
 * Main display size, in pixels (generally == {@code GetMainViewport()->Size})
 */
public void setDisplaySize(final float valueX, final float valueY) {
    nSetDisplaySize(valueX, valueY);
}

private native void nGetDisplaySize(ImVec2 dst); /*
    Jni::ImVec2Cpy(env, THIS->DisplaySize, dst);
*/

private native float nGetDisplaySizeX(); /*
    return THIS->DisplaySize.x;
*/

private native float nGetDisplaySizeY(); /*
    return THIS->DisplaySize.y;
*/

private native void nSetDisplaySize(float valueX, float valueY); /*MANUAL
    ImVec2 value = ImVec2(valueX, valueY);
    THIS->DisplaySize = value;
*/

/**
 * Time elapsed since last frame, in seconds.
 */
public float getDeltaTime() {
    return nGetDeltaTime();
}

/**
 * Time elapsed since last frame, in seconds.
 */
public void setDeltaTime(final float value) {
    nSetDeltaTime(value);
}

private native float nGetDeltaTime(); /*
    return THIS->DeltaTime;
*/

private native void nSetDeltaTime(float value); /*
    THIS->DeltaTime = value;
*/

/**
 * Minimum time between saving positions/sizes to .ini file, in seconds.
 */
public float getIniSavingRate() {
    return nGetIniSavingRate();
}

/**
 * Minimum time between saving positions/sizes to .ini file, in seconds.
 */
public void setIniSavingRate(final float value) {
    nSetIniSavingRate(value);
}

private native float nGetIniSavingRate(); /*
    return THIS->IniSavingRate;
*/

private native void nSetIniSavingRate(float value); /*
    THIS->IniSavingRate = value;
*/

/**
 * Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
 */
public String getIniFilename() {
    return nGetIniFilename();
}

/**
 * Path to .ini file. Set NULL to disable automatic .ini loading/saving, if e.g. you want to manually load/save from memory.
 */
public void setIniFilename(final String value) {
    nSetIniFilename(value);
}

private native String nGetIniFilename(); /*
    return env->NewStringUTF(THIS->IniFilename);
*/

private native void nSetIniFilename(String value); /*MANUAL
    auto value = obj_value == NULL ? NULL : (char*)env->GetStringUTFChars(obj_value, JNI_FALSE);
    THIS->IniFilename = value;
    if (value != NULL) env->ReleaseStringUTFChars(obj_value, value);
*/

/**
 * Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
 */
public String getLogFilename() {
    return nGetLogFilename();
}

/**
 * Path to .log file (default parameter to ImGui::LogToFile when no file is specified).
 */
public void setLogFilename(final String value) {
    nSetLogFilename(value);
}

private native String nGetLogFilename(); /*
    return env->NewStringUTF(THIS->LogFilename);
*/

private native void nSetLogFilename(String value); /*MANUAL
    auto value = obj_value == NULL ? NULL : (char*)env->GetStringUTFChars(obj_value, JNI_FALSE);
    THIS->LogFilename = value;
    if (value != NULL) env->ReleaseStringUTFChars(obj_value, value);
*/

Type of change

  • Minor changes or tweaks (quality of life stuff)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Related issues

@SpaiR SpaiR added feat New feature or request api labels Aug 8, 2024
@SpaiR SpaiR force-pushed the feat/generate-api branch 3 times, most recently from fcb7408 to 991673b Compare August 8, 2024 07:53
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.
build(ci): make "Compare Binding Hash" job also took into account generated and include folders

build(ci): add JDK 11 to the setup-java pipeline

This is required for the buildSrc module, since it uses "spoon" library, which is compiled for JDK11.

build(ci): keep only JDK11

- Add source ant target compatibility output to the MANIFEST.mf file

build: add auto-provisioning for JDK

just in case
@SpaiR SpaiR changed the title Draft: Binding Generator API Binding Generator API Aug 8, 2024
@SpaiR SpaiR merged commit 1c396fb into main Aug 8, 2024
7 checks passed
@SpaiR SpaiR deleted the feat/generate-api branch August 8, 2024 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment