libmach: update the C API - expose init, update, and deinit functions #420

Merged
zack466 merged 1 commit from libmach into main 2022-07-19 16:32:52 +00:00
zack466 commented 2022-07-19 04:37:05 +00:00 (Migrated from github.com)

This pull request reworks the libmach C API.

  • Instead of working with callbacks,libmach exposes functions such as mach_init_core, mach_update, and mach_deinit to be called by users of the shared library

  • Examples using this new API can be found in the libmach/ directory.

  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.

This pull request reworks the libmach C API. - Instead of working with callbacks,`libmach` exposes functions such as `mach_init_core`, `mach_update`, and `mach_deinit` to be called by users of the shared library - Examples using this new API can be found in the `libmach/` directory. - [X] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
emidoots (Migrated from github.com) reviewed 2022-07-19 16:32:18 +00:00
@ -35,0 +82,4 @@
core.delta_time_ns = core.timer.lapPrecise();
core.delta_time = @intToFloat(f32, core.delta_time_ns) / @intToFloat(f32, std.time.ns_per_s);
emidoots (Migrated from github.com) commented 2022-07-19 16:32:17 +00:00

I think to increase the odds that libmach is always up-to-date and working, and to get higher odds of it also working on other platforms (webassembly for example), we should instead have native.zig export an API which libmach.zig calls into. Then libmach.zig becomes just rather simple C export wrappers.

@iddev5 do you agree with that?

I think to increase the odds that `libmach` is always up-to-date and working, and to get higher odds of it also working on other platforms (webassembly for example), we should instead have `native.zig` export an API which `libmach.zig` calls into. Then `libmach.zig` becomes just rather simple C export wrappers. @iddev5 do you agree with that?
emidoots (Migrated from github.com) approved these changes 2022-07-19 16:32:31 +00:00
emidoots (Migrated from github.com) left a comment

A clear improvement over what we have right now, so merging!

A clear improvement over what we have right now, so merging!
iddev5 (Migrated from github.com) reviewed 2022-07-19 17:57:53 +00:00
@ -35,0 +82,4 @@
core.delta_time_ns = core.timer.lapPrecise();
core.delta_time = @intToFloat(f32, core.delta_time_ns) / @intToFloat(f32, std.time.ns_per_s);
iddev5 (Migrated from github.com) commented 2022-07-19 17:57:53 +00:00

Yes, this was the idea all along. Plus these functions will be able to reduce the code duplication which we have with mach_update and things like that.

Yes, this was the idea all along. Plus these functions will be able to reduce the code duplication which we have with mach_update and things like that.
iddev5 commented 2022-07-19 18:00:47 +00:00 (Migrated from github.com)

Good PR. I didnt got time to review it but one minor thing I would say is that namings are odd and inconsistent. I think we should just follow the mach_<module>_<function> convention. So that makes mach_init_core as mach_core_init. Just a thought.

Good PR. I didnt got time to review it but one minor thing I would say is that namings are odd and inconsistent. I think we should just follow the ``mach_<module>_<function>`` convention. So that makes ``mach_init_core`` as ``mach_core_init``. Just a thought.
Sign in to join this conversation.
No reviewers
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
hexops/mach!420
No description provided.