Add sibling modules #8

Open
opened 2026-10-22 20:55:19 +01:00 by pedro-bento · 1 comment
Owner

Summary

The binding covers raylib, rlgl and raymath, but not the three headers most raylib projects use:
raygui, physac and reasings. All three are single-header libraries, so each needs a different
treatment from the current pipeline.

Why they are missing

Module What it is Why it cannot be added as-is
raygui Immediate-mode GUI, 61 functions Not vendored, not compiled, not parsed
physac 2D physics, 19 functions Not vendored, not compiled, not parsed
reasings 28 easing functions Every function is static inline, so no symbol is ever exported

Proposal

raygui and physac

  1. Add a source file per module that defines the implementation macro:
    #define RAYGUI_IMPLEMENTATION
    #include "raygui.h"
    
  2. Add that file to OBJS in the Makefile and to build.bat.
  3. Generate the API table with the right parser flags:
    $(RLPARSER) -i $(RAYGUI_SRC)/raygui.h -o $@ -f LUA -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION"
    
    physac is the same with -d PHYSACDEF and -t "PHYSAC IMPLEMENTATION".
  4. Add --no-raygui / --no-physac / --no-reasings flags, like the existing --no-rlgl.
  5. Emit raygui constants namespaced only (M.GuiControl.LABEL). raygui reuses names like
    DEFAULT and TEXTBOX, which would collide with raylib's flat constants.

reasings

Do not bind it. Since every function is static inline, there is nothing to call. Translate the
28 functions to Lua in the generator, one short function each:

function M.EaseSineIn(t, b, c, d)
  return -c * math.cos(t / d * (math.pi / 2)) + c + b
end

Keep the header's evaluation order and formula, and add M.Easings plus M.Ease(id, ...) for
data-driven use.

Generator fixes needed first

  1. Symbolic array sizes. physac has Vector2 positions[PHYSAC_MAX_VERTICES]. The parser only
    accepts numeric sizes (gen-hate-no-d.lua:165-180). Resolve the name through a defines table
    and fail if it cannot be resolved.
  2. Cycle through a pointer alias. PhysicsBodyData → PhysicsShape → PhysicsBody →
    PhysicsBodyData trips the cycle check (gen-hate-no-d.lua:388-405). Ignore the dependency
    when the field is a pointer.
  3. Duplicate struct. physac re-declares Vector2. Keep the first definition (raylib's) and
    warn if two definitions disagree.

Acceptance criteria

  • raygui: GuiButton, GuiSlider, GuiGetStyle/GuiSetStyle work in a headless test.
  • physac: create a body, step 60 frames, position changes, ClosePhysics leaves no leak.
  • reasings: Lua output matches the C header for 10 000 random inputs within 1e-4.
  • All three can be skipped with --no-* flags.
  • make check-bindings passes.

Notes

  • raygui leaks its style font when you call GuiLoadStyle. Document it; do not try to manage it.
  • physac bodies live in a fixed pool and are borrowed handles. Never attach __gc to them.
  • raylib's rcamera.h and rgestures.h are a separate decision, not part of this issue.
## Summary The binding covers raylib, rlgl and raymath, but not the three headers most raylib projects use: raygui, physac and reasings. All three are single-header libraries, so each needs a different treatment from the current pipeline. ## Why they are missing | Module | What it is | Why it cannot be added as-is | |---|---|---| | raygui | Immediate-mode GUI, 61 functions | Not vendored, not compiled, not parsed | | physac | 2D physics, 19 functions | Not vendored, not compiled, not parsed | | reasings | 28 easing functions | Every function is `static inline`, so no symbol is ever exported | ## Proposal ### raygui and physac 1. Add a source file per module that defines the implementation macro: ```c #define RAYGUI_IMPLEMENTATION #include "raygui.h" ``` 2. Add that file to `OBJS` in the `Makefile` and to `build.bat`. 3. Generate the API table with the right parser flags: ```make $(RLPARSER) -i $(RAYGUI_SRC)/raygui.h -o $@ -f LUA -d RAYGUIAPI -t "RAYGUI IMPLEMENTATION" ``` physac is the same with `-d PHYSACDEF` and `-t "PHYSAC IMPLEMENTATION"`. 4. Add `--no-raygui` / `--no-physac` / `--no-reasings` flags, like the existing `--no-rlgl`. 5. Emit raygui constants namespaced only (`M.GuiControl.LABEL`). raygui reuses names like `DEFAULT` and `TEXTBOX`, which would collide with raylib's flat constants. ### reasings Do not bind it. Since every function is `static inline`, there is nothing to call. Translate the 28 functions to Lua in the generator, one short function each: ```lua function M.EaseSineIn(t, b, c, d) return -c * math.cos(t / d * (math.pi / 2)) + c + b end ``` Keep the header's evaluation order and formula, and add `M.Easings` plus `M.Ease(id, ...)` for data-driven use. ### Generator fixes needed first 1. **Symbolic array sizes.** physac has `Vector2 positions[PHYSAC_MAX_VERTICES]`. The parser only accepts numeric sizes (`gen-hate-no-d.lua:165-180`). Resolve the name through a defines table and fail if it cannot be resolved. 2. **Cycle through a pointer alias.** `PhysicsBodyData` → `PhysicsShape` → `PhysicsBody` → `PhysicsBodyData` trips the cycle check (`gen-hate-no-d.lua:388-405`). Ignore the dependency when the field is a pointer. 3. **Duplicate struct.** physac re-declares `Vector2`. Keep the first definition (raylib's) and warn if two definitions disagree. ## Acceptance criteria - [ ] raygui: `GuiButton`, `GuiSlider`, `GuiGetStyle`/`GuiSetStyle` work in a headless test. - [ ] physac: create a body, step 60 frames, position changes, `ClosePhysics` leaves no leak. - [ ] reasings: Lua output matches the C header for 10 000 random inputs within `1e-4`. - [ ] All three can be skipped with `--no-*` flags. - [ ] `make check-bindings` passes. ## Notes - raygui leaks its style font when you call `GuiLoadStyle`. Document it; do not try to manage it. - physac bodies live in a fixed pool and are borrowed handles. Never attach `__gc` to them. - raylib's `rcamera.h` and `rgestures.h` are a separate decision, not part of this issue.
pedro-bento changed title from add raygui to Add sibling modules 2026-10-23 12:34:54 +01:00
Author
Owner

#13

https://git.pbento.pt/pedro-bento/hate-no-d/pulls/13
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: pedro-bento/hate-no-d#8
No description provided.