-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add a simplistic C API for all unsigned data type widths as cell values to allow language interop #42
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean... since you are there, add int8
, int16
, int32
, int64
, float
, double
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
#include <streambuf> | ||
|
||
namespace Bonxai { | ||
struct PointerStreamBuffer final : public std::streambuf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some doumentation. i don't know what the purpose of this is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
#include <vector> | ||
|
||
namespace Bonxai { | ||
class VectorStreamBuffer final : public std::streambuf { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do but this is an implementation detail, not sure if it needs much documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
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 :)