Skip to content

Commit

Permalink
Rename Jlrs package to JlrsCore. Remove bindgen workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Taaitaaiger committed Apr 21, 2023
1 parent a0e4240 commit daafe1e
Show file tree
Hide file tree
Showing 25 changed files with 116 additions and 217 deletions.
97 changes: 0 additions & 97 deletions .github/workflows/bindgen.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ jobs:

- name: Run tests
run: |
julia -e "import Pkg; Pkg.add(url=\"https://github.com/Taaitaaiger/Jlrs.jl\")"
export JULIA_DIR="$(dirname $(dirname $(which julia)))"
export LD_LIBRARY_PATH="${JULIA_DIR}/lib:${JULIA_DIR}/lib/julia:${LD_LIBRARY_PATH}"
cargo test --features full,julia-1-6 --verbose
Expand All @@ -173,7 +172,6 @@ jobs:

- name: Run tests
run: |
julia -e "import Pkg; Pkg.add(url=\"https://github.com/Taaitaaiger/Jlrs.jl\")"
export JULIA_DIR="$(dirname $(dirname $(which julia)))"
export DYLD_LIBRARY_PATH="${JULIA_DIR}/lib:${JULIA_DIR}/lib/julia:${DYLD_LIBRARY_PATH}"
cargo test --features full,julia-1-6 --verbose
Expand Down Expand Up @@ -201,7 +199,6 @@ jobs:

- name: Run tests
run: |
julia -e "import Pkg; Pkg.add(url=\"https://github.com/Taaitaaiger/Jlrs.jl\")"
cargo test --features full,julia-1-6 --verbose
test-windows-msvc-lts:
Expand Down Expand Up @@ -230,7 +227,6 @@ jobs:

- name: Run tests
run: |
julia -e "import Pkg; Pkg.add(url=\"https://github.com/Taaitaaiger/Jlrs.jl\")"
cargo test --features full,julia-1-6 --verbose
docs:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

- A managed type for `Binding` has been added, this is available since Julia 1.10.

- The `Jlrs` Julia module is no longer included with jlrs, but published as a separate package.
- The `Jlrs` Julia module is no longer included with jlrs, but published as a separate package, `JlrsCore`.

- The jlrs-derive crate is now part of jlrs-macros. Two additional macros are available: `julia_version` can be used as an alternative to writing big cfgs to handle differences between Julia versions, and `julia_module` to generate the data that `Jlrs.Wrap` uses to make the exported functions, methods, types, constant and globals available in a Julia module.
- The jlrs-derive crate is now part of jlrs-macros. Two additional macros are available: `julia_version` can be used as an alternative to writing big cfgs to handle differences between Julia versions, and `julia_module` to generate the data that `JlrsCore.Wrap` uses to make the exported functions, methods, types, constant and globals available in a Julia module.

- Several traits have been added to implement the `julia_module` macro: `CCallArg`, `CCallReturn`, and `ConstructType`, the first two provide a mapping from a Rust type to the types Julia should use in generated Julia functions, the latter is used to construct the `DataType` at runtime. The managed type `TypedValue` has been added to make more types constructible, and `RustResult` to enable writing fallible `ccall`able functions. Similarly, `RankedArray` and `TypedRankedArray` have been added. A `CCallRef` type has been added to work with Julia `Ref`s that have been used as arguments of `ccall`ed functions.

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ recently released version.
## Prerequisites

Julia must be installed before jlrs can be used, jlrs is compatible with Julia 1.6 up to and
including Julia 1.9. The Jlrs package must also have been added, if this is not the case it
including Julia 1.9. The JlrsCore package must also have been added, if this is not the case it
will automatically be added when jlrs is initialized.

### Linux
Expand Down Expand Up @@ -171,7 +171,7 @@ In addition to these runtimes, the following utility features are available:
feature is enabled the `CCall` struct is available which offers the same functionality as
the sync runtime without initializing Julia. The `julia_module` macro is provided to
easily export functions, foreign types, and data in combination with the macros from the
`Wrap` module in the Jlrs package.
`Wrap` module in the JlrsCore package.

- `uv`

Expand Down Expand Up @@ -598,7 +598,7 @@ while on the Julia side things look like this:

```julia
module CallMe
using Jlrs.Wrap
using JlrsCore.Wrap

@wrapmodule("./path/to/libcallme.so", :callme_init_fn)

Expand Down Expand Up @@ -700,7 +700,7 @@ fn test_2() {

In order to map a struct in Rust to one in Julia you can derive several traits. You normally
shouldn't need to implement these structs or traits manually. The `reflect` function defined
in the `Jlrs.Reflect` module can generate Rust structs whose layouts match their counterparts
in the `JlrsCore.Reflect` module can generate Rust structs whose layouts match their counterparts
in Julia and automatically derive the supported traits.

The main restriction is that structs with atomic fields, and tuple or union fields with type
Expand Down
2 changes: 1 addition & 1 deletion jlrs/src/async_util/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ where
};

Module::main(&unrooted)
.submodule(&unrooted, "Jlrs")?
.submodule(&unrooted, "JlrsCore")?
.as_managed()
.global(&unrooted, "color")?
.as_value()
Expand Down
6 changes: 3 additions & 3 deletions jlrs/src/async_util/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> {
let task = unsafe {
Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "postblocking")
.expect("postblocking not available")
Expand Down Expand Up @@ -201,7 +201,7 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> {
let task = unsafe {
Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, method)
.expect(format!("{} not available", method).as_str())
Expand Down Expand Up @@ -255,7 +255,7 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> {
let task = unsafe {
Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, method)
.expect(format!("{} not available", method).as_str())
Expand Down
16 changes: 8 additions & 8 deletions jlrs/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "interactivecall")
.expect("interactivecall not available")
Expand Down Expand Up @@ -951,7 +951,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "asynccall")
.expect("asynccall not available")
Expand Down Expand Up @@ -991,7 +991,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "scheduleasynclocal")
.expect("scheduleasynclocal not available")
Expand Down Expand Up @@ -1031,7 +1031,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "scheduleasync")
.expect("scheduleasync not available")
Expand Down Expand Up @@ -1180,7 +1180,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "interactivecall")
.expect("interactivecall not available")
Expand Down Expand Up @@ -1211,7 +1211,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "asynccall")
.expect("asynccall not available")
Expand Down Expand Up @@ -1253,7 +1253,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "scheduleasynclocal")
.expect("scheduleasynclocal not available")
Expand Down Expand Up @@ -1295,7 +1295,7 @@ cfg_if::cfg_if! {

let task = Module::main(&frame)
.submodule(&frame, "JlrsThreads")
.expect("Jlrs.Threads not available")
.expect("JlrsCore.Threads not available")
.as_managed()
.function(&frame, "scheduleasync")
.expect("scheduleasync not available")
Expand Down
4 changes: 2 additions & 2 deletions jlrs/src/catch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ where
let enabled = unrooted.gc_is_enabled();
unrooted.enable_gc(false);

let caller = Module::package_root_module(&unrooted, "Jlrs")
let caller = Module::package_root_module(&unrooted, "JlrsCore")
.unwrap()
.global(&unrooted, "call_catch_wrapper")
.unwrap()
Expand Down Expand Up @@ -248,7 +248,7 @@ where
let enabled = unrooted.gc_is_enabled();
unrooted.enable_gc(false);

let caller = Module::package_root_module(&unrooted, "Jlrs")
let caller = Module::package_root_module(&unrooted, "JlrsCore")
.unwrap()
.global(&unrooted, "call_catch_wrapper")
.unwrap()
Expand Down
14 changes: 7 additions & 7 deletions jlrs/src/ccall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::{
target::{frame::GcFrame, unrooted::Unrooted, Target},
},
private::Private,
InstallJlrs,
InstallJlrsCore,
};

// The pool is lazily created either when it's first used, or when the number of threads is set.
Expand Down Expand Up @@ -257,19 +257,19 @@ impl<'context> CCall<'context> {
/// used this function is called automatically.
///
/// A module can be provided to allow setting the size of the internal thread pool from Julia
/// by calling `Jlrs.set_pool_size`.
/// by calling `JlrsCore.set_pool_size`.
#[inline(never)]
pub fn init_jlrs(&mut self, install_jlrs_jl: &InstallJlrs, module: Option<Module>) {
pub fn init_jlrs(&mut self, install_jlrs_core: &InstallJlrsCore, module: Option<Module>) {
unsafe {
init_jlrs(&mut self.frame, install_jlrs_jl);
init_jlrs(&mut self.frame, install_jlrs_core);

// Expose thread pool to Julia
if let Some(module) = module {
let unrooted = Unrooted::new();

set_pool_name(module);

let add_pool = Module::package_root_module(&unrooted, "Jlrs")
let add_pool = Module::package_root_module(&unrooted, "JlrsCore")
.unwrap()
.global(unrooted, "add_pool")
.unwrap()
Expand Down Expand Up @@ -316,7 +316,7 @@ unsafe impl ConstructType for AsyncCCall {
{
let (target, _) = target.split();
unsafe {
Module::package_root_module(&target, "Jlrs")
Module::package_root_module(&target, "JlrsCore")
.unwrap()
.submodule(&target, "Wrap")
.unwrap()
Expand All @@ -334,7 +334,7 @@ unsafe impl ConstructType for AsyncCCall {
{
unsafe {
Some(
Module::package_root_module(target, "Jlrs")
Module::package_root_module(target, "JlrsCore")
.unwrap()
.submodule(target, "Wrap")
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion jlrs/src/data/layout/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//! are available to handle the distinction.
//!
//! You shouldn't implement layouts for Julia types manually, but rather use the functionality
//! from the `Jlrs.Reflect` module to generate them and derive all applicable traits.
//! from the `JlrsCore.Reflect` module to generate them and derive all applicable traits.
//!
//! [`ValidLayout`]: crate::data::layout::valid_layout::ValidLayout
//! [`ValidField`]: crate::data::layout::valid_layout::ValidField
Expand Down
8 changes: 4 additions & 4 deletions jlrs/src/data/managed/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> {

let s = unsafe {
Module::main(&global)
.submodule(&global, "Jlrs")?
.submodule(&global, "JlrsCore")?
.as_managed()
.function(&global, "valuestring")?
.as_managed()
.call1(&global, self.as_value())
.map_err(|e| e.as_value().error_string_or(CANNOT_DISPLAY_VALUE))
.map_err(|e| JlrsError::exception(format!("Jlrs.valuestring failed: {}", e)))?
.map_err(|e| JlrsError::exception(format!("JlrsCore.valuestring failed: {}", e)))?
.as_value()
.cast::<JuliaString>()?
.as_str()?
Expand All @@ -300,13 +300,13 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> {
let s = unsafe {
// TODO: caching?
Module::main(&global)
.submodule(&global, "Jlrs")?
.submodule(&global, "JlrsCore")?
.as_managed()
.function(&global, "errorstring")?
.as_managed()
.call1(&global, self.as_value())
.map_err(|e| e.as_value().error_string_or(CANNOT_DISPLAY_VALUE))
.map_err(|e| JlrsError::exception(format!("Jlrs.errorstring failed: {}", e)))?
.map_err(|e| JlrsError::exception(format!("JlrsCore.errorstring failed: {}", e)))?
.as_value()
.cast::<JuliaString>()?
.as_str()?
Expand Down
Loading

0 comments on commit daafe1e

Please sign in to comment.