Crates.io | ruby-prism-sys |
lib.rs | ruby-prism-sys |
version | 1.2.0 |
source | src |
created_at | 2023-12-15 15:42:34.272768 |
updated_at | 2024-10-10 19:20:10.383518 |
description | Rust bindings to Ruby's prism parsing library |
homepage | |
repository | https://github.com/ruby/prism |
max_upload_size | |
id | 1071080 |
size | 2,629,383 |
Rust bindings to ruby/prism's C API.
Currently the best examples are found in the integration tests (in tests/
).
Since this crate has not been released, docs are not yet online anywhere. You can generate them,
however, from this directory in this repo by running cargo doc
, then opening
target/doc/ruby_prism_sys/index.html
in your browser. (You could, instead, combine those two steps by
doing cargo doc --open
!)
In addition to the Ruby prism dependencies, you shouldn't need anything else besides Rust.
build.rs
(which gets called as part of running cargo build
, cargo test
, etc) is where we tell
bindgen
which types, functions, etc. that we want it to generate for us. It's smart enough to know
to generate dependencies for items we specify in there (ex. pm_parser_t
has fields of type
pm_token_t
, but we don't need to tell bindgen
about pm_token_t
--it'll figure it out and
generate bindings for that type too).
If you want to generate new bindings, update build.rs
accordingly, then run cargo doc
and check
the docs; that should tell you if bindgen
generated all the things you need or not.
Since almost all of the code is generated by the well-tested
bindgen
crate, we only have some cursory integration
tests in tests/
, really just validating types and functions got generated appropriately. (They
also give some hints about how to use the API from Rust!) To run the tests, run cargo test
.
Any new publicly exposed C API additions should get a test or two.