-
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
This is a list of changes to api.json I compiled while working on the Zig bindings. I've split them into two categories: "Improvements" for straightforward fixes, and "Proposals" for bigger changes I'd like feedback on. Also, I'm preemptively volunteering myself to do all the work accepted in this issue.
Improvements
- Json format documentation
- Json format and API versioning
- Include the version of the format and API (in that order) before any modules.
- Including the API version helps consumers validate contents and explicitly handle older or newer versions.
- Giving the json format a version helps binding generators for the same reasons as above. It's worth doing this future-proofing now rather than later.
-
Change modulebrieffield todocfor consistency - Remove unnamed enums, use
constkind instead - Add missing
OC_UNICODE_RANGEvalues- These could be added in the same manner as
OC_UI_THEMEs.
- These could be added in the same manner as
- Add missing
oc_clockAPI- Some orca samples (e.g. clock) are impossible to port correctly without this API.
- Add missing
oc_windowAPIoc_windowtypename is referenced in the API but not declared.
- Create
oc_mat2x3 oc_mat2x3_scale(f32 x, f32 y)- This one isn't even in the C API. It's useful enough that it really should be included.
- Add documentation for UI API
Proposals
- Specify pointer attributes in
api.json#117 - Merge
*_enumtypes with their "parents"- E.g. convert
oc_file_perminto an enum type and removeoc_file_perm_enum. This simplifies the API surface while still allowing consumers to separate them if desired. It would also prevent the backing integer of the enum straying from the "parent" integer type, as is the case withoc_file_perm(though that issue can be resolved regardless of this proposal).
- E.g. convert
- Differentiate bitflag enum types from normal enums
- Consumers could implement flags using a more suitable primitive without defining overrides for each typename. E.g. A Zig bindings generator would automatically generate packed structs.
- Document what errors can be triggered from individual IO API functions
- Documented errors should be the superset of possible errors for every platform.
- This would allow consumers to confidently handle all possible error cases. The Zig bindings would use this to create error sets, adding additional type safety.
The rest of these are organizational changes to modules and their contents. They're more nitpick-y but IMO feel more natural. I don't expect them to break anyone's code.
-
Remove Utility module and move it's children into the rootUtility is a poor name due to it's vagueness and redundancy (all code in the API has utility, or else it wouldn't be included). This is already reflected in function names, as none have them have anoc_util_prefix. The name "utility" usually also implies the contents are small helpers for the main API, yet it encompasses half the API surface.
- Move UI module contents (not Core or Widgets) into Application module, and move UI Core & Widgets under UI
- i.e. Move
UI/* -> Application/Input, andUI (Core|Widgets) -> UI/(Core|Widgets) - Just from looking at the API, it seems like all this is really general application state.
- i.e. Move
-
Moveoc_font(+ metrics),oc_color, andoc_image(+ region and atlas) types and functions into the Graphics moduleThese types are consumed by the Canvas API, but don't really belong to it (i.e. none of them are created or manipulated via Canvas functions). However their "usage" functions (e.g.oc_set_colororoc_image_draw) should remain in Canvas.
Metadata
Metadata
Assignees
Labels
No labels