-
Notifications
You must be signed in to change notification settings - Fork 11
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
build: generate bindings for basic types #188
Conversation
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 think the current version of the PR is fine (meaning size_t_is_usize
should remain false). I see it as a safer option - there is no way for C definition and our definition to diverge.
Note: now the types.rs
file doesn't actually define any types. We should probably remove the of the definitions from it.
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.
Great to see this fixed.
Actually we could, for each generated module, have an entry in
That way, |
Yes, please. I hate those |
95b08c2
to
3cb5dae
Compare
Done. Adjusted the names of some of the generated .rs files as well. |
3cb5dae
to
91bb984
Compare
v2: Created |
91bb984
to
12ba039
Compare
All of the numeric types were for some reason defined by us in `types.rs`. We should let `bindgen` define them. This is what this commit does. Removes basic types definitions from `types.rs` and tells bindgen to generate bindings for these types. Note: size_t type is a bit special, and will be addressed in another commit.
In this commit we tell bindgen to generate a binding for size_t type. Actually, we only tell it not to treat `size_t` as `usize` (which is done by default). Why there were no clashes with `size_t` definition, even though we used `.allowlist("size_t")`? The docstring of `.size_t_is_usize()` states: ``` Set whether size_t should be translated to usize. If size_t is translated to usize, type definitions for size_t will not be emitted. size_t is translated to usize by default. ``` This means that previously (by default), definition for `size_t` was not generated in `basic_types.rs`. What happens now is the definition is generated based on the architecture. In my case it's std::os::raw::c_ulong (equivalent to u64). I'm not really sure whether we should treat `size_t` as `usize` (i.e. create an alias `type size_t = usize`) or not (i.e. `.size_t_is_usize(false)`). This is my question to reviewers :).
Moved all of the conversions related to date and time to a separate module - date_time.rs
12ba039
to
0fd6c71
Compare
Rebased on main. I'll apply @wprzytula 's suggestion in the next push |
This is going to be used in following commits - we are planning to create a separate module per generated file. No need to repeat the concatenation logic each time.
Moved the include!(...) that defines `CassError` and `CassErrorSource` to separate module in lib.rs. Types definition are re-exported in `cass_error.rs` as well.
CassWriteType appears only in server errors. I think it's reasonable to move it to the module defining error types. We will no longer generate cppdriver_data_query_error.rs file.
0fd6c71
to
5bab5cd
Compare
Motivation
All of the numeric types were for some reason defined by us in
types.rs
. We should letbindgen
generate bindings for them.This is what this PR does. Removes basic types definitions from
types.rs
and tells bindgen to generate bindings for these types.size_t
Second commit addresses the issue with
size_t
binding. There is a question regarding whether we should treat it asusize
or not. Please, take a look at that.Modules refactor
Moved all of the
include!
s throughout code to one place -lib.rs
. Eachinclude!
now corresponds to its module.Pre-review checklist
[ ] I have implemented Rust unit tests for the features/changes introduced.[ ] I have enabled appropriate tests in.github/workflows/build.yml
ingtest_filter
.[ ] I have enabled appropriate tests in.github/workflows/cassandra.yml
ingtest_filter
.