Add a simplistic C API for all unsigned data type widths as cell values to allow language interop#42
Add a simplistic C API for all unsigned data type widths as cell values to allow language interop#42KitsuneAlex wants to merge 19 commits intofacontidavide:mainfrom
Conversation
…ith Kotlin CInterop
|
Lightly tested on Windows x64, Linux x64/arm64 and macOS x64/arm64. Also confirmed working with tools like jnih and Kotlin CInterop :) |
|
Hi. Thanks for taking this initiative! My suggestions are:
|
Thanks for replying so quickly! Sounds good to me, will do :) |
|
This should do |
|
I commented on the other closed PR btw if you didn't get notified, the print was your original code, i removed it in an earlier PR which was a mistake from my end, that's why i added it back. Your serilization will likely break without it, which i didn't realize before. |
| #define BONXAI_FALSE 0 | ||
| #define BONXAI_TRUE 1 |
There was a problem hiding this comment.
As bool's and enum's are not exactly ideal for language interop scenarios because of unportable ABI an int type is usually employed, and if you have your boolean alias you might as well have fitting constants. These can be recognized by interop tools.
| sprintf( | ||
| header, "Bonxai::VoxelGrid<%s,%d,%d>(%lf)\n", type_name.c_str(), grid.innetBits(), | ||
| grid.leafBits(), grid.voxelSize()); | ||
|
|
There was a problem hiding this comment.
This was your code. I removed it in my previous PR as i assumed it was a debug line, but it wasn't. If you don't add this code back your serialization will be broken i think.
bonxai_core/src/bonxai.cpp
Outdated
| BONXAI_DEFINE_GRID_IMPL(u8, uint8_t) | ||
| BONXAI_DEFINE_GRID_IMPL(u16, uint16_t) | ||
| BONXAI_DEFINE_GRID_IMPL(u32, uint32_t) | ||
| BONXAI_DEFINE_GRID_IMPL(u64, uint64_t) No newline at end of file |
There was a problem hiding this comment.
I mean... since you are there, add int8, int16, int32, int64, float, double
| #include <streambuf> | ||
|
|
||
| namespace Bonxai { | ||
| struct PointerStreamBuffer final : public std::streambuf { |
There was a problem hiding this comment.
Add some doumentation. i don't know what the purpose of this is
There was a problem hiding this comment.
These templates allow interacting with your i/ostream based serialization APIs through C-typical slices, that is a pair made of a pointer and a size since streams are not a concept in C itself.
| #include <vector> | ||
|
|
||
| namespace Bonxai { | ||
| class VectorStreamBuffer final : public std::streambuf { |
There was a problem hiding this comment.
Can do but this is an implementation detail, not sure if it needs much documentation.
This would allow your library to be used in other languages which cannot directly interact with C++ through a simplistic C interface.
If you decide to merge this, it should be merged after my last fix PR.Thanks for your excellent work on this project :)