diff --git a/.cargo/config b/.cargo/config index 70f9eaeb..dfd8f157 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,2 +1,23 @@ [registries.crates-io] protocol = "sparse" + +[target.x86_64-unknown-linux-gnu] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] + +[target.i686-unknown-linux-gnu] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] + +[target.aarch64-unknown-linux-musl] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] + +[target.arm-unknown-linux-musleabihf] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] + +[target.armv7-unknown-linux-musleabihf] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] + +[target.i686-unknown-linux-musl] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] + +[target.x86_64-unknown-linux-musl] +rustflags = [ "-C", "link-args=-Wl,-export-dynamic" ] diff --git a/.gitignore b/.gitignore index 48ede788..0f4fd0fc 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ matplotlibrc releasenotes.md ARCHITECTURE.md playground -libjulia_module_test.so \ No newline at end of file +libjulia_module_test.so +expanded.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index d111afc2..c721adcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,52 @@ +#### v0.19 + +- A GC-safe `GcSafeRwLock`, `GcSafeMutex`, `GcSafeFairMutex`, and `GcSafeOnceLock` have been added. These synchronization primitives allow for garbage to be collected while waiting for access to be granted. + +- The `ConstructType` trait has gained an associated type and constant, and two new trait methods. The associated `Static` type provides a unique, static Rust type for the type constructor, which must be `Self` with static lifetimes. The associated constant `CACHEABLE` indicates whether the constructed type should be cached if it's a leaf type. The `construct_type` method uses the cached entry if it's available, or construct and cache it when supported otherwise. The `construct_type_uncached` method always constructs the type without checking if a cached entry exists. The `type_id` method returns the type id of the associated `Static` type, which is used internally as a key for the cache. + +- `Value`s can be instantiated from a layout and a type constructor with `Value::try_new_with`. This method copies the provided layout from Rust to Julia if the provided type constructor is compatible with the provided layout. This method is also available for `TypedValue`. + +- The `ValidLayout` trait has gained a `type_object` method. This method must return the Julia type object associated with this type. Its main use is correctly handling unions in `Value::try_new_with`. + +- The `ParametricBase` and `ParametricVariant` traits have been added which let you create opaque types with type parameters. + +- Opaque types, functions, methods and async functions with type parameters can be exported by iterating over an array of types with a `for` loop in `julia_module`. These loops can be nested, types provided by outer loops can be used in inner loops. Duplicate implentations are filtered as long as the item is only exported once. + +- Constantly-sized frames can be allocated on the stack by creating a local scope, all targets allow creating a new local scope. This construct is used for all functions that used to take an `ExtendedTarget`, they now only need a `Target`. This involves three new targets: `LocalGcFrame`, `LocalOutput`, and `LocalReusableSlot`. Trying to reserve a new slot when the frame is full causes a `panic`. + +- Functions and methods exported by the `julia_module` macro no longer need to return a `RustResultRet` to throw an exception. The exception can now be thrown directly from Rust. The return type of the exported function no longer needs to account for exceptions if they can only occur due to tracking `self`. If a function should throw an exception, the function can return either a `JlrsResult` or a `Result`. Such a result will either be converted to the output type or thrown as an exception. + +- The `c-unwind` feature has been added. When this feature is enabled, all C functions use the `C-unwind` ABI rather than the `C` ABI. + +- `Symbol`s and constructed types are cached. Accessing a global in a module can also be cached with `Module::typed_global_cached`. + +- Exceptions can be caught by calling `catch_exceptions`. + +- Exported functions and methods can be declared to be GC-safe with the `#[gc_safe]` attribute. + +- Exported methods that take `self` can skip tracking with the `#[untracked_self]` attribute. + +- Types that have no pointer fields can implement `IsBits`. This trait is automatically derived if appropriate by `JlrsCore.Reflect.reflect`. + +- Type constructors can be associated with their layout by implementing `HasLayout`. This trait is automatically derived if appropriate by `JlrsCore.Reflect.reflect`, or implemented by blanket implementation if the type constructor and layout are the same type. + +- `Value::new_named_tuple` takes a sized array of key-value pairs to avoid heap-allocations. + +- A `DimsExt` trait has been added to optimize creating new arrays. While `Dims` can be implemented by crates that use jlrs, `DimsExt` is sealed. + +- When a runtime feature is enabled fast TLS is enabled. Crates like rustfft-jl that don't embed Julia must not enable any runtime features. + +- Exported functions and methods that should throw can do so by returning a `JlrsResult` or `Result<_, ValueRet>`. `RustResult` has been deprecated in favor of returning one of these types. + +- Some functions need to insert additional arguments before the provided arguments. Examples include calling functions with keyword arguments and functions that call a Julia function asynchronously. These functions now take their arguments as an implementation of `Values`, which can add the extra arguments without having to allocate space for them on the heap if the number of arguments is known at compile-time. + +- `Call::call_unchecked` has been added to call a Julia function without catching the exception if one is thrown. + +- Type aliases can be defined with the `julia_module` macro. + +- The `full-no-rt` feature has been added to allow selecting all features except runtimes. + + #### v0.18 - jlrs is compatible with Julia 1.7 again, but this version isn't actively tested or supported. Version features have been added to select a particular version of Julia, picking a specific version is required. diff --git a/Cargo.toml b/Cargo.toml index f8044e79..de289a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +# members = ["benches", "examples", "jl_sys", "jlrs", "jlrs_macros", "julia_module_test"] members = ["examples", "jl_sys", "jlrs", "jlrs_macros"] -exclude = ["julia_module_test"] +exclude = ["julia_module_test", "benches"] diff --git a/README.md b/README.md index d927a675..db3b43dc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ jlrs is a crate that provides access to most of the Julia C API, it can be used to embed Julia in Rust applications and to use functionality it provides when writing `ccall`able functions in Rust. Currently this crate is only tested in combination with Julia 1.6 and 1.9, -but also supports Julia 1.7 and 1.8. Using the current stable version is highly recommended. +but also supports Julia 1.7, 1.8 and 1.10. Using the current stable version is highly recommended. The minimum supported Rust version is currently 1.65. The documentation assumes you're already familiar with the Julia and Rust programming @@ -40,7 +40,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 JlrsCore package must also have been installed, if this is not the +including Julia 1.10. The JlrsCore package must also have been installed, if this is not the case it will automatically be added when jlrs is initialized by default. jlrs has not been tested with juliaup yet on Linux and macOS. @@ -99,6 +99,7 @@ jlrs. The following version features currently exist: - `julia-1-7` - `julia-1-8` - `julia-1-9` + - `julia-1-10` Exactly one version feature must be enabled. If no version is enabled, or multiple are, jl-sys will fail to compile. @@ -112,6 +113,7 @@ julia-1-6 = ["jlrs/julia-1-6"] julia-1-7 = ["jlrs/julia-1-7"] julia-1-8 = ["jlrs/julia-1-8"] julia-1-9 = ["jlrs/julia-1-9"] +julia-1-10 = ["jlrs/julia-1-10"] ``` In this case you must provide this feature when you build or run your crate: @@ -219,7 +221,8 @@ In addition to these runtimes, the following utility features are available: Flag that must be enabled when compiling with BinaryBuilder. You can enable all features except `debug`, `i686`, `windows`, `no-link` and `yggdrasil` by -enabling the `full` feature. +enabling the `full` feature. If you don't want to enable any runtimes either, you can use +`full-no-rt`. ## Using this crate @@ -227,11 +230,11 @@ enabling the `full` feature. If you want to embed Julia in a Rust application, you must enable a runtime and a version feature: -`jlrs = {version = "0.18.0", features = ["sync-rt", "julia-1-8"]}` +`jlrs = {version = "0.19.0", features = ["sync-rt", "julia-1-8"]}` -`jlrs = {version = "0.18.0", features = ["tokio-rt", "julia-1-8"]}` +`jlrs = {version = "0.19.0", features = ["tokio-rt", "julia-1-8"]}` -`jlrs = {version = "0.18.0", features = ["async-std-rt", "julia-1-8"]}` +`jlrs = {version = "0.19.0", features = ["async-std-rt", "julia-1-8"]}` When Julia is embedded in an application, it must be initialized before it can be used. The following snippet initializes the sync runtime: @@ -483,7 +486,7 @@ impl PersistentTask for AccumulatorTask { // A `Vec` can be moved from Rust to Julia if the element type // implements `IntoJulia`. let data = vec![0usize; self.n_values]; - let array = TypedArray::from_vec(frame.as_extended_target(), data, self.n_values)? + let array = TypedArray::from_vec(&mut frame, data, self.n_values)? .into_jlrs_result()?; Ok(AccumulatorTaskState { array, offset: 0 }) @@ -587,6 +590,8 @@ to your crate's `Cargo.toml`. It's also recommended to abort on panic: panic = "abort" ``` +You must not enable any runtime features. + The easiest way to export Rust functions like `call_me` from the previous example is by using the `julia_module` macro. The content of the macro is converted to an initialization function that can be called from Julia to generate the module. @@ -622,7 +627,7 @@ function: @assert CallMe.call_me(false) == -1 ``` -This macro has many more capabilities than just exporting extern "C" functions, for more +This macro has many more capabilities than just exporting functions, for more information see the [documentation](https://docs.rs/jlrs-macros/latest/jlrs_macros/macro.julia_module.html). A practical example that uses this macro is the [rustfft-jl](https://github.com/Taaitaaiger/rustfft-jl) crate, which uses this macro to expose RustFFT to Julia. The recipe for BinaryBuilder can be found [here](https://github.com/JuliaPackaging/Yggdrasil/tree/master/R/rustfft). diff --git a/benches/Cargo.toml b/benches/Cargo.toml new file mode 100644 index 00000000..03cd3a7f --- /dev/null +++ b/benches/Cargo.toml @@ -0,0 +1,51 @@ +[package] +name = "benches" +version = "0.0.0" +publish = false +edition = "2018" + +[dependencies] +jlrs = { version = "0.19", path = "../jlrs", features = ["full"] } + +[dev-dependencies] +criterion = { version = "0.5", features = ["html_reports"] } +pprof = { version = "0.12", features = ["flamegraph", "criterion"] } + +[profile.bench] +debug = true + +[[bench]] +name = "call_function" +harness = false + +[[bench]] +name = "arrays" +harness = false + +[[bench]] +name = "array_access" +harness = false + +[[bench]] +name = "frames" +harness = false + +[[bench]] +name = "module" +harness = false + +[[bench]] +name = "symbol" +harness = false + +[[bench]] +name = "track_array" +harness = false + +[[bench]] +name = "type_construction" +harness = false + +[[bench]] +name = "value" +harness = false diff --git a/benches/benches/array_access.rs b/benches/benches/array_access.rs new file mode 100644 index 00000000..09709310 --- /dev/null +++ b/benches/benches/array_access.rs @@ -0,0 +1,231 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::{ + memory::{gc::Gc, target::frame::GcFrame}, + prelude::*, +}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn access_array_1d_index_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, 16).unwrap(); + let accessor = unsafe { arr.bits_data::().unwrap() }; + + c.bench_function("Array_access_index", |b| { + b.iter(|| accessor[black_box(12)]) + }); + Ok(()) + }) +} + +#[inline(never)] +fn set_array_1d_index_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, 16).unwrap(); + let mut accessor = unsafe { arr.bits_data_mut::().unwrap() }; + + c.bench_function("Array_set_index", |b| { + b.iter(|| accessor[black_box(12)] = 1.0) + }); + Ok(()) + }) +} + +#[inline(never)] +fn access_array_1d_get_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, 16).unwrap(); + let accessor = unsafe { arr.bits_data::().unwrap() }; + + c.bench_function("Array_access_get", |b| { + b.iter(|| accessor.get(black_box(12))) + }); + Ok(()) + }) +} + +#[inline(never)] +fn set_array_1d_set_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, 16).unwrap(); + let mut accessor = unsafe { arr.bits_data_mut::().unwrap() }; + + c.bench_function("Array_set_set", |b| { + b.iter(|| accessor.set(black_box(12), black_box(1.0))) + }); + + Ok(()) + }) +} + +#[inline(never)] +fn access_array_2d_index_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let accessor = unsafe { arr.bits_data::().unwrap() }; + + c.bench_function("Array_access_index", |b| { + b.iter(|| accessor[black_box((2, 3))]) + }); + Ok(()) + }) +} + +#[inline(never)] +fn set_array_2d_index_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let mut accessor = unsafe { arr.bits_data_mut::().unwrap() }; + + c.bench_function("Array_set_index", |b| { + b.iter(|| accessor[black_box((2, 2))] = 1.0) + }); + Ok(()) + }) +} + +#[inline(never)] +fn access_array_2d_get_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let accessor = unsafe { arr.bits_data::().unwrap() }; + + c.bench_function("Array_access_get", |b| { + b.iter(|| accessor.get(black_box((2, 3)))) + }); + Ok(()) + }) +} + +#[inline(never)] +fn set_array_2d_set_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let mut accessor = unsafe { arr.bits_data_mut::().unwrap() }; + + c.bench_function("Array_set_set", |b| { + b.iter(|| accessor.set(black_box((2, 2)), 1.0)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn access_array_2d_index_arr_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let accessor = unsafe { arr.bits_data::().unwrap() }; + + c.bench_function("Array_access_arr_index", |b| { + b.iter(|| accessor[black_box([2, 3])]) + }); + Ok(()) + }) +} + +#[inline(never)] +fn set_array_2d_index_arr_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let mut accessor = unsafe { arr.bits_data_mut::().unwrap() }; + + c.bench_function("Array_set_arr_index", |b| { + b.iter(|| accessor[black_box([2, 2])] = 1.0) + }); + Ok(()) + }) +} + +#[inline(never)] +fn access_array_2d_get_arr_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let accessor = unsafe { arr.bits_data::().unwrap() }; + + c.bench_function("Array_access_arr_get", |b| { + b.iter(|| accessor.get(black_box([2, 3]))) + }); + Ok(()) + }) +} + +#[inline(never)] +fn set_array_2d_set_arr_bits(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, (4, 4)).unwrap(); + let mut accessor = unsafe { arr.bits_data_mut::().unwrap() }; + + c.bench_function("Array_set_arr_set", |b| { + b.iter(|| accessor.set(black_box([2, 2]), 1.0)) + }); + Ok(()) + }) +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + access_array_1d_index_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + set_array_1d_index_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + access_array_1d_get_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + set_array_1d_set_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + access_array_2d_index_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + set_array_2d_index_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + access_array_2d_get_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + set_array_2d_set_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + access_array_2d_index_arr_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + set_array_2d_index_arr_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + set_array_2d_set_arr_bits(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + access_array_2d_get_arr_bits(&mut frame, c).unwrap(); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = array_access; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(array_access); diff --git a/benches/benches/arrays.rs b/benches/benches/arrays.rs new file mode 100644 index 00000000..33786136 --- /dev/null +++ b/benches/benches/arrays.rs @@ -0,0 +1,234 @@ +use std::ptr::NonNull; + +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::{ + data::{managed::array::ArrayType, types::construct_type::ConstructType}, + memory::{gc::Gc, target::frame::GcFrame}, + prelude::*, +}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn construct_array_1d_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unrooted", |b| { + b.iter(|| Array::new::(&frame, 16)) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_2d_err_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_err_unrooted", |b| { + b.iter(|| Array::new::(&frame, (16, usize::MAX / 2)).unwrap_err()) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_1d_unchecked_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unchecked_unrooted", |b| { + b.iter(|| unsafe { Array::new_unchecked::(&frame, 16) }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_2d_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unrooted", |b| { + b.iter(|| Array::new::(&frame, (4, 4))) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_2d_unchecked_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unchecked_unrooted", |b| { + b.iter(|| unsafe { Array::new_unchecked::(&frame, (4, 4)) }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_3d_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unrooted", |b| { + b.iter(|| Array::new::(&frame, (4, 2, 2))) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_3d_unchecked_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unchecked_unrooted", |b| { + b.iter(|| unsafe { Array::new_unchecked::(&frame, (4, 2, 2)) }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_3d_arrdim_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_arrdim_unrooted", |b| { + b.iter(|| Array::new::(&frame, [4, 2, 2])) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_3d_arrdim_unchecked_unrooted( + frame: &mut GcFrame, + c: &mut Criterion, +) -> JlrsResult<()> { + c.bench_function("Array_arrdim_unchecked_unrooted", |b| { + b.iter(|| unsafe { Array::new_unchecked::(&frame, [4, 2, 2]) }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_4d_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unrooted", |b| { + b.iter(|| Array::new::(&frame, (2, 2, 2, 2))) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_4d_unchecked_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_unchecked_unrooted", |b| { + b.iter(|| unsafe { Array::new_unchecked::(&frame, (2, 2, 2, 2)) }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_1d_from_slice_unrooted( + frame: &mut GcFrame, + c: &mut Criterion, +) -> JlrsResult<()> { + let mut v = [1.0; 16]; + let mut v = NonNull::from(&mut v); + c.bench_function("Array_from_slice_unrooted", |b| { + b.iter(|| { + let v = unsafe { v.as_mut() }; + Array::from_slice(&frame, v, 16) + }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_1d_from_slice_unchecked_unrooted( + frame: &mut GcFrame, + c: &mut Criterion, +) -> JlrsResult<()> { + let mut v = [1.0; 16]; + let mut v = NonNull::from(&mut v); + c.bench_function("Array_from_slice_unchecked_unrooted", |b| { + b.iter(|| { + let v = unsafe { v.as_mut() }; + unsafe { Array::from_slice_unchecked(&frame, v, 16) } + }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_1d_from_vec_unrooted(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + c.bench_function("Array_from_vec_unrooted", |b| { + b.iter(|| { + let v: Vec = Vec::new(); + Array::from_vec(&frame, v, 0) + }) + }); + Ok(()) +} + +#[inline(never)] +fn construct_array_1d_from_vec_unchecked_unrooted( + frame: &mut GcFrame, + c: &mut Criterion, +) -> JlrsResult<()> { + c.bench_function("Array_from_vec_unchecked_unrooted", |b| { + b.iter(|| { + let v: Vec = Vec::new(); + unsafe { Array::from_vec_unchecked(&frame, v, 0) } + }) + }); + Ok(()) +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_2d_err_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_1d_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_1d_unchecked_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_2d_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_2d_unchecked_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_3d_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_3d_unchecked_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_3d_arrdim_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_3d_arrdim_unchecked_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_4d_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_4d_unchecked_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_1d_from_slice_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_1d_from_slice_unchecked_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_1d_from_vec_unrooted(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + construct_array_1d_from_vec_unchecked_unrooted(&mut frame, c).unwrap(); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = arrays; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(arrays); diff --git a/benches/benches/call_function.rs b/benches/benches/call_function.rs new file mode 100644 index 00000000..60a3c948 --- /dev/null +++ b/benches/benches/call_function.rs @@ -0,0 +1,163 @@ +#[macro_use] +extern crate criterion; +use criterion::Criterion; +use jlrs::{ + memory::{gc::Gc, target::frame::GcFrame}, + prelude::{Call, JlrsResult, RuntimeBuilder, StackFrame, Value}, +}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +// Thanks to the example provided by @jebbow in his article +// https://www.jibbow.com/posts/criterion-flamegraphs/ + +#[inline(never)] +fn call_0_unchecked(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|frame| { + c.bench_function("call_0_unchecked", |b| { + b.iter(|| { + let vs = []; + unsafe { func.call_unchecked(&frame, vs) } + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn call_0(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|frame| { + c.bench_function("call_0", |b| b.iter(|| unsafe { func.call0(&frame) })); + Ok(()) + }) +} + +#[inline(never)] +fn call_1_unchecked(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|mut frame| { + let v = Value::new(&mut frame, 0usize); + c.bench_function("call_1_unchecked", |b| { + b.iter(|| { + let vs = [v]; + unsafe { func.call_unchecked(&frame, vs) } + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn call_1(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|mut frame| { + let v = Value::new(&mut frame, 0usize); + c.bench_function("call_1", |b| b.iter(|| unsafe { func.call1(&frame, v) })); + Ok(()) + }) +} + +#[inline(never)] +fn call_2_unchecked(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|mut frame| { + let v = Value::new(&mut frame, 0usize); + c.bench_function("call_2_unchecked", |b| { + b.iter(|| { + let vs = [v, v]; + unsafe { func.call_unchecked(&frame, vs) } + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn call_2(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|mut frame| { + let v = Value::new(&mut frame, 0usize); + c.bench_function("call_2", |b| b.iter(|| unsafe { func.call2(&frame, v, v) })); + Ok(()) + }) +} + +#[inline(never)] +fn call_3_unchecked(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|mut frame| { + let v = Value::new(&mut frame, 0usize); + c.bench_function("call_3_unchecked", |b| { + b.iter(|| { + let vs = [v, v, v]; + unsafe { func.call_unchecked(&frame, vs) } + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn call_3(frame: &mut GcFrame, c: &mut Criterion, func: Value) -> JlrsResult<()> { + frame.scope(|mut frame| { + let v = Value::new(&mut frame, 0usize); + c.bench_function("call_3", |b| { + b.iter(|| unsafe { func.call3(&frame, v, v, v) }) + }); + Ok(()) + }) +} + +fn bench_group(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + + let func = Value::eval_string(&frame, "function dummy(a1::Any=nothing, a2::Any=nothing, a3::Any=nothing, a4::Any=nothing, a5::Any=nothing, a6::Any=nothing) + @nospecialize a1 a2 a3 a4 a5 a6 + end").unwrap().as_value(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_0_unchecked(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_0(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_1_unchecked(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_1(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_2_unchecked(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_2(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_3_unchecked(&mut frame, c, func).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + call_3(&mut frame, c, func).unwrap(); + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = call_function; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = bench_group +} + +criterion_main!(call_function); diff --git a/benches/benches/frames.rs b/benches/benches/frames.rs new file mode 100644 index 00000000..fa1f2a94 --- /dev/null +++ b/benches/benches/frames.rs @@ -0,0 +1,72 @@ +use std::ptr::NonNull; + +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::{memory::target::frame::GcFrame, prelude::*}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn push_pop_frame_dynamic(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| unsafe { + let frame = &mut frame; + let mut frame = NonNull::new_unchecked(frame as *mut GcFrame); + + c.bench_function("push_pop_frame_dynamic", |b| { + b.iter(|| { + let frame = frame.as_mut(); + frame.scope(|_| black_box(Ok(()))) + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn push_pop_frame_local(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| unsafe { + let frame = &mut frame; + let mut frame = NonNull::new_unchecked(frame as *mut GcFrame); + + c.bench_function("push_pop_frame_local", |b| { + b.iter(|| { + let frame = frame.as_mut(); + frame.local_scope::<_, _, 0>(|_| black_box(Ok(()))) + }) + }); + Ok(()) + }) +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + push_pop_frame_dynamic(&mut frame, c).unwrap(); + push_pop_frame_local(&mut frame, c).unwrap(); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = frames; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(frames); diff --git a/benches/benches/module.rs b/benches/benches/module.rs new file mode 100644 index 00000000..d3df1aea --- /dev/null +++ b/benches/benches/module.rs @@ -0,0 +1,75 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::{data::managed::module::JlrsCore, memory::target::frame::GcFrame, prelude::*}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn module_submodule(frame: &GcFrame, c: &mut Criterion) { + c.bench_function("Module::submodule", |b| { + b.iter(|| Module::main(frame).submodule(frame, black_box("JlrsCore"))) + }); +} + +#[inline(never)] +fn module_submodule_cached(frame: &GcFrame, c: &mut Criterion) { + c.bench_function("Module::submodule cached", |b| { + b.iter(|| JlrsCore::module(&frame)) + }); +} + +#[inline(never)] +fn module_global(frame: &GcFrame, c: &mut Criterion) { + c.bench_function("Module::global", |b| { + b.iter(|| unsafe { + Module::main(frame) + .submodule(frame, black_box("Base")) + .unwrap() + .as_managed() + .global(frame, black_box("+")) + .unwrap() + }) + }); +} + +#[inline(never)] +fn module_global_cached(frame: &GcFrame, c: &mut Criterion) { + c.bench_function("Module::global_cached", |b| unsafe { + b.iter(|| Module::typed_global_cached::(frame, black_box("Main.Base.+"))) + }); +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|frame| { + module_submodule(&frame, c); + module_submodule_cached(&frame, c); + module_global(&frame, c); + module_global_cached(&frame, c); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = module; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(module); diff --git a/benches/benches/symbol.rs b/benches/benches/symbol.rs new file mode 100644 index 00000000..c00c6890 --- /dev/null +++ b/benches/benches/symbol.rs @@ -0,0 +1,55 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::prelude::*; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|frame| { + c.bench_function("Symbol::new_4", |b| { + b.iter(|| Symbol::new(&frame, black_box("1234"))) + }); + + c.bench_function("Symbol::new_8", |b| { + b.iter(|| Symbol::new(&frame, black_box("12345678"))) + }); + + c.bench_function("Symbol::new_12", |b| { + b.iter(|| Symbol::new(&frame, black_box("123456789012"))) + }); + + c.bench_function("Symbol::new_16", |b| { + b.iter(|| Symbol::new(&frame, black_box("1234567890123456"))) + }); + + c.bench_function("Symbol::new_32", |b| { + b.iter(|| Symbol::new(&frame, black_box("12345678901234561234567890123456"))) + }); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = symbol; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(symbol); diff --git a/benches/benches/track_array.rs b/benches/benches/track_array.rs new file mode 100644 index 00000000..c566e651 --- /dev/null +++ b/benches/benches/track_array.rs @@ -0,0 +1,168 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::{ + memory::{gc::Gc, target::frame::GcFrame}, + prelude::*, +}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn array_is_borrowed(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, 16).unwrap().as_value(); + + c.bench_function("Array_is_tracked", |b| { + b.iter(|| black_box(arr.is_tracked())) + }); + Ok(()) + }) +} + +#[inline(never)] +fn array_track_shared(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, 16).unwrap(); + + c.bench_function("Array_track_shared", |b| { + b.iter(|| black_box(std::mem::ManuallyDrop::new(arr.track_shared()))) + }); + Ok(()) + }) +} + +#[inline(never)] +fn array_is_tracked_shared(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, 16).unwrap(); + let b = arr.track_shared().unwrap(); + + c.bench_function("Array_is_tracked_shared", |b| { + b.iter(|| black_box(arr.as_value().is_tracked_shared())) + }); + + std::mem::drop(b); + Ok(()) + }) +} + +#[inline(never)] +fn array_track_untrack_shared(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let arr = Array::new::(&mut frame, 16).unwrap(); + + c.bench_function("Array_track_untrack_shared", |b| { + b.iter(|| black_box(arr.track_shared())) + }); + Ok(()) + }) +} + +#[inline(never)] +fn array_track_untrack_exclusive(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, 16).unwrap(); + + c.bench_function("Array_track_untrack_exclusive", |b| { + b.iter(|| unsafe { std::mem::drop(black_box(arr.track_exclusive())) }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn array_is_tracked_exclusive(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|mut frame| { + let mut arr = Array::new::(&mut frame, 16).unwrap(); + let a = arr.as_value(); + let b = unsafe { arr.track_exclusive().unwrap() }; + + c.bench_function("Array_is_tracked_exclusive", |b| { + b.iter(|| black_box(a.is_tracked_exclusive())) + }); + + std::mem::drop(b); + Ok(()) + }) +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + array_is_borrowed(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + array_track_shared(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + array_is_tracked_shared(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + array_track_untrack_shared(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + array_track_untrack_exclusive(&mut frame, c).unwrap(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + array_is_tracked_exclusive(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // set_array_1d_index_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // access_array_1d_get_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // set_array_1d_set_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // access_array_2d_index_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // set_array_2d_index_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // access_array_2d_get_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // set_array_2d_set_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // access_array_2d_index_arr_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // set_array_2d_index_arr_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // set_array_2d_set_arr_bits(&mut frame, c).unwrap(); + + // frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // access_array_2d_get_arr_bits(&mut frame, c).unwrap(); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = track_array; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(track_array); diff --git a/benches/benches/type_construction.rs b/benches/benches/type_construction.rs new file mode 100644 index 00000000..5e3a1a07 --- /dev/null +++ b/benches/benches/type_construction.rs @@ -0,0 +1,180 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use jlrs::{ + data::types::{ + abstract_types::{AbstractSet, Integer, Number}, + construct_type::{ArrayTypeConstructor, ConstantIsize, ConstructType}, + }, + memory::target::frame::GcFrame, + prelude::*, +}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn construct_primitive_type_uncached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_f64_uncached", |b| { + b.iter(|| f64::construct_type_uncached(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_primitive_type_cached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_f64_cached", |b| { + b.iter(|| f64::construct_type(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_abstract_type_uncached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_number_uncached", |b| { + b.iter(|| Number::construct_type_uncached(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_abstract_type_cached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_number_cached", |b| { + b.iter(|| Number::construct_type(&output)) + }); + Ok(()) + }) +} +#[inline(never)] +fn construct_integer_uncached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_integer_uncached", |b| { + b.iter(|| Integer::construct_type_uncached(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_integer_cached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_integer_cached", |b| { + b.iter(|| Integer::construct_type(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_abstract_parametric_type_uncached( + frame: &mut GcFrame, + c: &mut Criterion, +) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_abstract_set_uncached", |b| { + b.iter(|| AbstractSet::::construct_type_uncached(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_abstract_parametric_type_cached( + frame: &mut GcFrame, + c: &mut Criterion, +) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_abstract_set_cached", |b| { + b.iter(|| AbstractSet::::construct_type(&output)) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_array_type_uncached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_array_f64_3_uncached", |b| { + b.iter(|| { + ArrayTypeConstructor::>::construct_type_uncached(&output) + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn construct_array_type_cached(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let output = frame.reusable_slot(); + + c.bench_function("ConstructType_array_f64_3_cached", |b| { + b.iter(|| ArrayTypeConstructor::>::construct_type(&output)) + }); + Ok(()) + }) +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + construct_primitive_type_uncached(&mut frame, c).unwrap(); + construct_primitive_type_cached(&mut frame, c).unwrap(); + construct_abstract_type_uncached(&mut frame, c).unwrap(); + construct_abstract_type_cached(&mut frame, c).unwrap(); + construct_integer_uncached(&mut frame, c).unwrap(); + construct_integer_cached(&mut frame, c).unwrap(); + construct_abstract_parametric_type_uncached(&mut frame, c).unwrap(); + construct_abstract_parametric_type_cached(&mut frame, c).unwrap(); + construct_array_type_uncached(&mut frame, c).unwrap(); + construct_array_type_cached(&mut frame, c).unwrap(); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = type_construction; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(type_construction); diff --git a/benches/benches/value.rs b/benches/benches/value.rs new file mode 100644 index 00000000..c83dbc17 --- /dev/null +++ b/benches/benches/value.rs @@ -0,0 +1,80 @@ +use std::ptr::NonNull; + +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use jlrs::{memory::target::frame::GcFrame, prelude::*}; +use pprof::{ + criterion::{Output, PProfProfiler}, + flamegraph::Options, +}; + +#[inline(never)] +fn value_new_usize_unrooted(frame: &GcFrame, c: &mut Criterion) { + c.bench_function("Value::new:: unrooted", |b| { + b.iter(|| black_box(Value::new(frame, 1usize))) + }); +} + +#[inline(never)] +fn value_new_usize_reusable_slot(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.scope(|frame| { + let mut output = frame.reusable_slot(); + let mut output = NonNull::from(&mut output); + + c.bench_function("Value::new::_reusable_slot", |b| { + b.iter(|| { + let o = unsafe { output.as_mut() }; + black_box(Value::new(o, 1usize)) + }) + }); + Ok(()) + }) +} + +#[inline(never)] +fn value_new_usize_local_reusable_slot(frame: &mut GcFrame, c: &mut Criterion) -> JlrsResult<()> { + frame.local_scope::<_, _, 1>(|mut frame| { + let mut output = frame.local_reusable_slot(); + let mut output = NonNull::from(&mut output); + + c.bench_function("Value::new::_local_reusable_slot", |b| { + b.iter(|| { + let o = unsafe { output.as_mut() }; + black_box(Value::new(o, 1usize)) + }) + }); + Ok(()) + }) +} + +fn criterion_benchmark(c: &mut Criterion) { + unsafe { + let mut frame = StackFrame::new(); + let mut julia = RuntimeBuilder::new().start().unwrap(); + let mut julia = julia.instance(&mut frame); + + julia + .scope(|mut frame| { + value_new_usize_unrooted(&frame, c); + value_new_usize_reusable_slot(&mut frame, c).unwrap(); + value_new_usize_local_reusable_slot(&mut frame, c).unwrap(); + + Ok(()) + }) + .unwrap(); + } +} + +fn opts() -> Option> { + let mut opts = Options::default(); + opts.image_width = Some(1920); + opts.min_width = 0.01; + Some(opts) +} + +criterion_group! { + name = value; + config = Criterion::default().with_profiler(PProfProfiler::new(1000, Output::Flamegraph(opts()))); + targets = criterion_benchmark +} + +criterion_main!(value); diff --git a/coverage.sh b/coverage.sh index 7760fcd8..26d56764 100755 --- a/coverage.sh +++ b/coverage.sh @@ -2,14 +2,14 @@ set -euxo pipefail -export JULIA_DIR=$HOME/julia-1.8.3 +export JULIA_DIR=$HOME/julia-1.9.2 export LD_LIBRARY_PATH=$JULIA_DIR/lib:$JULIA_DIR/lib/julia echo "backend: Gtk3Agg" > matplotlibrc cargo llvm-cov clean --workspace; -cargo llvm-cov --features full,julia-1-8 --workspace --no-report -- --test-threads=1 +cargo llvm-cov --features full,julia-1-9 --workspace --no-report cargo llvm-cov --example ccall --no-report -- --test-threads=1 -cargo llvm-cov --example ccall_with_threads --no-report -- --test-threads=1 +cargo llvm-cov --example ccall_with_threads --no-report cargo llvm-cov run --example async_tasks --no-report cargo llvm-cov run --example call_julia --no-report cargo llvm-cov run --example fully_async_async_std --no-report diff --git a/examples/Cargo.toml b/examples/Cargo.toml index a04413e9..a684eaeb 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -5,7 +5,7 @@ publish = false edition = "2018" [dev-dependencies] -jlrs = { version = "0.18.0", path = "../jlrs", features = ["full"] } +jlrs = { version = "0.19.0", path = "../jlrs", features = ["full"] } crossbeam-channel = "0.5" async-std = { version = "1", features = ["unstable", "attributes"] } tokio = { version = "1", features = ["macros", "rt-multi-thread"]} diff --git a/examples/async_tasks.rs b/examples/async_tasks.rs index b8aef1eb..d96ed61b 100644 --- a/examples/async_tasks.rs +++ b/examples/async_tasks.rs @@ -23,10 +23,9 @@ impl AsyncTask for MyTask { unsafe { let path = PathBuf::from("MyModule.jl"); if path.exists() { - Value::include(frame.as_extended_target(), "MyModule.jl")?.into_jlrs_result()?; + Value::include(&mut frame, "MyModule.jl")?.into_jlrs_result()?; } else { - Value::include(frame.as_extended_target(), "examples/MyModule.jl")? - .into_jlrs_result()?; + Value::include(&mut frame, "examples/MyModule.jl")?.into_jlrs_result()?; } } Ok(()) @@ -51,7 +50,7 @@ impl AsyncTask for MyTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .into_jlrs_result()? .unbox::() diff --git a/examples/ccall.rs b/examples/ccall.rs index 7dda6c25..2db5840a 100644 --- a/examples/ccall.rs +++ b/examples/ccall.rs @@ -22,7 +22,7 @@ pub unsafe extern "C" fn incr_array(mut arr: TypedArray) { }; let Ok(mut arr) = arr.bits_data_mut() else { - return // unreachable + return; // unreachable }; for x in arr.as_mut_slice() { @@ -84,7 +84,7 @@ mod tests { ).into_jlrs_result()?; let data = vec![1.0f64, 2.0, 3.0]; - let array = TypedArray::from_vec_unchecked(frame.as_extended_target(), data, 3)?; + let array = TypedArray::from_vec_unchecked(&mut frame, data, 3)?; // Call the function and unbox the result. let output = func.call2(&frame, incr_array_ptr, array.as_value()); diff --git a/examples/ccall_throw_exception.rs b/examples/ccall_throw_exception.rs index 21cf9c47..3c5ccc0c 100644 --- a/examples/ccall_throw_exception.rs +++ b/examples/ccall_throw_exception.rs @@ -5,22 +5,29 @@ use jlrs::prelude::*; // This function returns `nothing` if a < b, throws an `AssertionError` otherwise. #[no_mangle] pub unsafe extern "C" fn assert_less_than(a: i32, b: i32) { - let mut stack_frame = StackFrame::new(); - let ccall = CCall::new(&mut stack_frame); + let res = CCall::local_scope::<_, _, 2>(|mut frame| { + if a >= b { + let msg = JuliaString::new(&mut frame, "a is larger than b").as_value(); - if a >= b { - // Safe because there are no pending drops. - ccall.throw_exception(|frame| { - let msg = JuliaString::new(frame.as_mut(), "a is larger than b").as_value(); - - Module::core(&frame) + let leaked = Module::core(&frame) .global(&frame, "AssertionError") .expect("AssertionError does not exist in Core") .as_value() .cast::() .expect("AssertionError is not a DataType") - .instantiate_unchecked(frame.as_mut(), [msg]) - }) + .instantiate_unchecked(&mut frame, [msg]) + .leak(); + + return Ok(Err(leaked)); + } + + Ok(Ok(())) + }) + .unwrap(); + + // Safe: there are no pendings drops. + if let Err(exc) = res { + CCall::throw_exception(exc) } } diff --git a/examples/ccall_with_threads.rs b/examples/ccall_with_threads.rs index 0b2e8080..3409152d 100644 --- a/examples/ccall_with_threads.rs +++ b/examples/ccall_with_threads.rs @@ -16,6 +16,7 @@ use thread::JoinHandle; #[repr(transparent)] pub struct UvHandle(*mut c_void); unsafe impl Send for UvHandle {} +unsafe impl Sync for UvHandle {} /// This function spawns a new thread, sleeps for a second, stores a result, and wakes Julia. /// diff --git a/examples/fully_async_async_std.rs b/examples/fully_async_async_std.rs index 2debd3a7..2a692527 100644 --- a/examples/fully_async_async_std.rs +++ b/examples/fully_async_async_std.rs @@ -23,10 +23,9 @@ impl AsyncTask for MyTask { unsafe { let path = PathBuf::from("MyModule.jl"); if path.exists() { - Value::include(frame.as_extended_target(), "MyModule.jl")?.into_jlrs_result()?; + Value::include(&mut frame, "MyModule.jl")?.into_jlrs_result()?; } else { - Value::include(frame.as_extended_target(), "examples/MyModule.jl")? - .into_jlrs_result()?; + Value::include(&mut frame, "examples/MyModule.jl")?.into_jlrs_result()?; } } Ok(()) @@ -51,7 +50,7 @@ impl AsyncTask for MyTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .into_jlrs_result()? .unbox::() diff --git a/examples/fully_async_tokio.rs b/examples/fully_async_tokio.rs index 26561c3e..b79e8e77 100644 --- a/examples/fully_async_tokio.rs +++ b/examples/fully_async_tokio.rs @@ -23,10 +23,9 @@ impl AsyncTask for MyTask { unsafe { let path = PathBuf::from("MyModule.jl"); if path.exists() { - Value::include(frame.as_extended_target(), "MyModule.jl")?.into_jlrs_result()?; + Value::include(&mut frame, "MyModule.jl")?.into_jlrs_result()?; } else { - Value::include(frame.as_extended_target(), "examples/MyModule.jl")? - .into_jlrs_result()?; + Value::include(&mut frame, "examples/MyModule.jl")?.into_jlrs_result()?; } } Ok(()) @@ -51,7 +50,7 @@ impl AsyncTask for MyTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .into_jlrs_result()? .unbox::() diff --git a/examples/nested_async_scopes.rs b/examples/nested_async_scopes.rs index ee927066..3bfe6a69 100644 --- a/examples/nested_async_scopes.rs +++ b/examples/nested_async_scopes.rs @@ -23,10 +23,9 @@ impl AsyncTask for MyTask { unsafe { let path = PathBuf::from("MyModule.jl"); if path.exists() { - Value::include(frame.as_extended_target(), "MyModule.jl")?.into_jlrs_result()?; + Value::include(&mut frame, "MyModule.jl")?.into_jlrs_result()?; } else { - Value::include(frame.as_extended_target(), "examples/MyModule.jl")? - .into_jlrs_result()?; + Value::include(&mut frame, "examples/MyModule.jl")?.into_jlrs_result()?; } } Ok(()) @@ -56,7 +55,7 @@ impl AsyncTask for MyTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .into_jlrs_result()? }; diff --git a/examples/plot.rs b/examples/plot.rs index 132d7246..807618bf 100644 --- a/examples/plot.rs +++ b/examples/plot.rs @@ -34,11 +34,10 @@ impl PersistentTask for MyTask { let plot_fn = Module::plots(&frame).function(&frame, "plot")?.as_managed(); let ylabel_str = JuliaString::new(&mut frame, &self.ylabel); - let ylabel = - Tuple::new_unchecked(frame.as_extended_target(), &mut [ylabel_str.as_value()]); - let kws = named_tuple!(frame.as_extended_target(), "yaxis" => ylabel); + let ylabel = Tuple::new_unchecked(&mut frame, &mut [ylabel_str.as_value()]); + let kws = named_tuple!(&mut frame, "yaxis" => ylabel); - let plot = PyPlot::new_with_keywords(&mut *frame, plot_fn, &mut [], kws)?; + let plot = PyPlot::new_with_keywords(&mut *frame, plot_fn, [], kws)?; Ok((plot, kws)) } @@ -64,7 +63,7 @@ impl PersistentTask for MyTask { state .0 - .update_with_keywords(&mut frame, plot_fn, &mut [data], state.1)?; + .update_with_keywords(&mut frame, plot_fn, [data], state.1)?; } Ok(()) diff --git a/jl_sys/Cargo.toml b/jl_sys/Cargo.toml index 3d379a92..3e9a2dbe 100644 --- a/jl_sys/Cargo.toml +++ b/jl_sys/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jl-sys" -version = "0.21.1" +version = "0.22.0" authors = ["Thomas van Doornmalen "] description = """ jl-sys contains the generated bindings for the Julia C API used by jlrs. @@ -22,6 +22,9 @@ julia-1-7 = [] julia-1-8 = [] julia-1-9 = [] julia-1-10 = [] +julia-1-11 = [] + +fast-tls = [] no-link = [] uv = [] @@ -30,9 +33,10 @@ i686 = [] debug = [] macos = [] windows = [] +c-unwind = [] use-bindgen = ["bindgen", "syn", "quote", "proc-macro2"] -docs = ["julia-1-9"] +docs = ["julia-1-10"] [dependencies] atomic = "0.5" diff --git a/jl_sys/build.rs b/jl_sys/build.rs index 40364375..72295ec6 100644 --- a/jl_sys/build.rs +++ b/jl_sys/build.rs @@ -284,6 +284,9 @@ fn compile_jlrs_cc(julia_dir: &str, target: Option) { #[cfg(feature = "julia-1-10")] c.define("JULIA_1_10", None); + #[cfg(feature = "fast-tls")] + c.define("JLRS_FAST_TLS", None); + c.compile("jlrs_cc"); } @@ -330,6 +333,11 @@ fn generate_bindings(julia_dir: &str) { builder = builder.clang_arg("-DJULIA_1_10"); } + #[cfg(feature = "julia-1-11")] + { + builder = builder.clang_arg("-DJULIA_1_11"); + } + #[cfg(all(feature = "julia-1-6", any(windows, feature = "windows")))] { builder = builder.clang_arg("-DJLRS_WINDOWS_LTS"); @@ -415,6 +423,7 @@ fn generate_bindings(julia_dir: &str) { .allowlist_function("jl_get_ptls_states") .allowlist_function("jl_get_ARCH") .allowlist_function("jl_get_UNAME") + .allowlist_function("jl_get_world_counter") .allowlist_function("jl_getallocationgranularity") .allowlist_function("jl_getpagesize") .allowlist_function("jl_git_branch") @@ -491,6 +500,12 @@ fn generate_bindings(julia_dir: &str) { .allowlist_function("jl_current_exception") .allowlist_function("jl_restore_excstack") .allowlist_function("jl_get_pgcstack") + .allowlist_function("jlrs_gc_safe_enter") + .allowlist_function("jlrs_gc_unsafe_enter") + .allowlist_function("jlrs_gc_safe_leave") + .allowlist_function("jlrs_gc_unsafe_leave") + .allowlist_function("jlrs_dimtuple_type") + .allowlist_function("jlrs_tuple_of") .allowlist_type("jl_binding_t") .allowlist_type("jl_callptr_t") .allowlist_type("jl_code_instance_t") @@ -506,6 +521,7 @@ fn generate_bindings(julia_dir: &str) { .allowlist_type("jl_options_t") .allowlist_type("jl_taggedvalue_t") .allowlist_type("jl_task_t") + .allowlist_type("jl_gcframe_t") .allowlist_type("jl_typemap_t") .allowlist_type("jl_typemap_entry_t") .allowlist_type("jl_typemap_level_t") @@ -643,12 +659,29 @@ fn generate_bindings(julia_dir: &str) { .opaque_type("uv_mutex_t") .opaque_type("uv_cond_t"); - #[cfg(feature = "julia-1-10")] + #[cfg(feature = "c-unwind")] + { + builder = builder + .override_abi(bindgen::Abi::CUnwind, "jl(rs)?_.*") + .rust_target(bindgen::RustTarget::Nightly); + } + + #[cfg(not(any( + feature = "julia-1-6", + feature = "julia-1-7", + feature = "julia-1-8", + feature = "julia-1-9" + )))] { builder = builder.allowlist_var("jl_binding_type"); } - #[cfg(not(feature = "julia-1-10"))] + #[cfg(any( + feature = "julia-1-6", + feature = "julia-1-7", + feature = "julia-1-8", + feature = "julia-1-9" + ))] { builder = builder.allowlist_function("jl_binding_type"); } diff --git a/jl_sys/generate_bindings.sh b/jl_sys/generate_bindings.sh index 64d16271..0b17c4af 100755 --- a/jl_sys/generate_bindings.sh +++ b/jl_sys/generate_bindings.sh @@ -65,7 +65,7 @@ function print_help() { echo "default paths can be overridden with environment variables:" echo "" echo -e "\033[1m Version Default path${spacing}Override\033[0m" - echo " Linux 64-bit 1.9 $HOME/julia-1.9.0 JULIA_1_9_DIR" + echo " Linux 64-bit 1.9 $HOME/julia-1.9.2 JULIA_1_9_DIR" echo " Linux 64-bit 1.8 $HOME/julia-1.8.5 JULIA_1_8_DIR" echo " Linux 64-bit 1.7 $HOME/julia-1.7.3 JULIA_1_7_DIR" echo " Linux 64-bit 1.6 $HOME/julia-1.6.7 JULIA_1_6_DIR" @@ -80,7 +80,7 @@ function print_help() { echo "When the beta flag is set, the following is expected:" echo "" echo -e "\033[1m Version Default path${spacing}Override\033[0m" - echo " - - -" + echo " Linux 64-bit 1.10 $HOME/julia-1.10.0-beta1 JULIA_1_10_DIR" echo "" echo "" echo "All dependencies must have been installed before running this script. The" @@ -108,14 +108,14 @@ if [ "${NIGHTLY}" = "y" -o "${ALL}" = "y" ]; then JULIA_VERSION=$($JULIA_NIGHTLY_DIR/bin/julia --version) JULIA_COMMIT=$($JULIA_NIGHTLY_DIR/bin/julia -E "Base.GIT_VERSION_INFO.commit_short" | grep -oEe "[^\"]+") JULIA_COMMIT_DATE=$($JULIA_NIGHTLY_DIR/bin/julia -E "Base.GIT_VERSION_INFO.date_string" | grep -oEe "[^\"]+") - JULIA_DIR=$JULIA_NIGHTLY_DIR cargo build --features use-bindgen,julia-1-10 - echo "/* generated from $JULIA_VERSION (Commit: $JULIA_COMMIT $JULIA_COMMIT_DATE) */" > ./src/bindings/bindings_1_10_64.rs - cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_10_64.rs + JULIA_DIR=$JULIA_NIGHTLY_DIR cargo build --features use-bindgen,julia-1-11 + echo "/* generated from $JULIA_VERSION (Commit: $JULIA_COMMIT $JULIA_COMMIT_DATE) */" > ./src/bindings/bindings_1_11_64.rs + cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_11_64.rs cargo clean - JULIA_DIR=$JULIA_NIGHTLY_DIR cargo build --features use-bindgen,i686,julia-1-10 --target i686-unknown-linux-gnu - echo "/* generated from $JULIA_VERSION (Commit: $JULIA_COMMIT $JULIA_COMMIT_DATE) */" > ./src/bindings/bindings_1_10_32.rs - cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_10_32.rs + JULIA_DIR=$JULIA_NIGHTLY_DIR cargo build --features use-bindgen,i686,julia-1-11 --target i686-unknown-linux-gnu + echo "/* generated from $JULIA_VERSION (Commit: $JULIA_COMMIT $JULIA_COMMIT_DATE) */" > ./src/bindings/bindings_1_11_32.rs + cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_11_32.rs if [ "${BETA}" != "y" -a "${ALL}" != "y" ]; then cargo +nightly fmt -- ./src/bindings/bindings_* @@ -124,34 +124,34 @@ if [ "${NIGHTLY}" = "y" -o "${ALL}" = "y" ]; then fi if [ "${BETA}" = "y" -o "${ALL}" = "y" ]; then - # if [ -z "$JULIA_BETA_DIR" ]; then - # JULIA_BETA_DIR=${HOME}/julia-1.9.0-rc3 - # fi - # if [ ! -d "$JULIA_BETA_DIR" ]; then - # echo "Error: $JULIA_BETA_DIR does not exist" >&2 - # exit 1 - # fi - - # cargo clean - # JULIA_VERSION=$($JULIA_BETA_DIR/bin/julia --version) - # JULIA_DIR=$JULIA_BETA_DIR cargo build --features use-bindgen,julia-1-9 - # echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_64.rs - # cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_64.rs - - # cargo clean - # JULIA_DIR=$JULIA_BETA_DIR cargo build --features use-bindgen,i686,julia-1-9 --target i686-unknown-linux-gnu - # echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_9_32.rs - # cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_9_32.rs - - echo "Warning: there is no known beta version. Skipping beta bindings" >&2 + if [ -z "$JULIA_BETA_DIR" ]; then + JULIA_BETA_DIR=${HOME}/julia-1.10.0-beta1 + fi + if [ ! -d "$JULIA_BETA_DIR" ]; then + echo "Error: $JULIA_BETA_DIR does not exist" >&2 + exit 1 + fi + + cargo clean + JULIA_VERSION=$($JULIA_BETA_DIR/bin/julia --version) + JULIA_DIR=$JULIA_BETA_DIR cargo build --features use-bindgen,julia-1-10 + echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_10_64.rs + cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_10_64.rs + + cargo clean + JULIA_DIR=$JULIA_BETA_DIR cargo build --features use-bindgen,i686,julia-1-10 --target i686-unknown-linux-gnu + echo "/* generated from $JULIA_VERSION */" > ./src/bindings/bindings_1_10_32.rs + cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings/bindings_1_10_32.rs + + # echo "Warning: there is no known beta version. Skipping beta bindings" >&2 if [ "${ALL}" != "y" ]; then - # cargo +nightly fmt -- ./src/bindings/bindings_* + cargo +nightly fmt -- ./src/bindings/bindings_* exit fi fi if [ -z "$JULIA_1_9_DIR" ]; then - JULIA_1_9_DIR=${HOME}/julia-1.9.0 + JULIA_1_9_DIR=${HOME}/julia-1.9.2 fi if [ ! -d "$JULIA_1_9_DIR" ]; then echo "Error: $JULIA_1_9_DIR does not exist" >&2 diff --git a/jl_sys/generate_bindings_unwind_c.sh b/jl_sys/generate_bindings_unwind_c.sh new file mode 100755 index 00000000..1b7b4b44 --- /dev/null +++ b/jl_sys/generate_bindings_unwind_c.sh @@ -0,0 +1,229 @@ +#!/usr/bin/env bash + +export RUST_BACKTRACE=1 +LD_LIBRARY_PATH= +NIGHTLY="n" +BETA="n" +ALL="n" + +function parse_args() { + local help="n" + + while [ -n "$1" ]; do + case $1 in + --nightly) + NIGHTLY="y" + shift + ;; + --beta) + BETA="y" + shift + ;; + --all) + ALL="y" + shift + ;; + -h | --help) + help="y" + shift + ;; + *) + echo "Unknown option: $1" >&2 + print_help + exit 1 + ;; + esac + done + + if [ $help = "y" ]; then + print_help + exit + fi +} + +function check_dir() { + local target_dir=$(readlink -f $(dirname $0)) + local current_dir=$(readlink -f $(pwd)) + + if [ "$current_dir" != "$target_dir" ]; then + echo "Error: generate_bindings.sh must be called from ${target_dir}" >&2 + exit 1 + fi +} + +function print_help() { + local spacing=$(printf %$((13 + ${#HOME}))s) + + echo " generate_bindings.sh [--nightly] [--beta] [--all]" + echo "" + echo "This script can be used to generate Rust bindings to the Julia C API with" + echo "bindgen. It can either generate bindings for all supported versions of Julia," + echo "or for the nightly version specifically with the --nightly flag." + echo "" + echo "To use it without the nightly flag, all versions of Julia supported by jlrs" + echo "must be available. The following versions and default paths are expected, the" + echo "default paths can be overridden with environment variables:" + echo "" + echo -e "\033[1m Version Default path${spacing}Override\033[0m" + echo " Linux 64-bit 1.9 $HOME/julia-1.9.2 JULIA_1_9_DIR" + echo " Linux 64-bit 1.8 $HOME/julia-1.8.5 JULIA_1_8_DIR" + echo " Linux 64-bit 1.7 $HOME/julia-1.7.3 JULIA_1_7_DIR" + echo " Linux 64-bit 1.6 $HOME/julia-1.6.7 JULIA_1_6_DIR" + echo "" + echo "" + echo "When the nightly flag is set, the following is expected:" + echo "" + echo -e "\033[1m Version Default path${spacing}Override\033[0m" + echo " Linux 64-bit dev $HOME/Projects/C/julia/usr JULIA_NIGHTLY_DIR" + echo "" + echo "" + echo "When the beta flag is set, the following is expected:" + echo "" + echo -e "\033[1m Version Default path${spacing}Override\033[0m" + echo " Linux 64-bit 1.10 $HOME/julia-1.10.0-beta1 JULIA_1_10_DIR" + echo "" + echo "" + echo "All dependencies must have been installed before running this script. The" + echo "following should be sufficient on Ubuntu:" + echo "" + echo " apt install llvm-dev libclang-dev clang g++-multilib-i686-linux-gnu" + echo " rustup target add i686-unknown-linux-gnu" + echo " rustup toolchain install nightly" + echo " rustup toolchain install stable-i686-unknown-linux-gnu" +} + +parse_args $@ +check_dir + +if [ "${NIGHTLY}" = "y" -o "${ALL}" = "y" ]; then + if [ -z "$JULIA_NIGHTLY_DIR" ]; then + JULIA_NIGHTLY_DIR=${HOME}/Projects/C/julia/usr + fi + if [ ! -d "$JULIA_NIGHTLY_DIR" ]; then + echo "Error: $JULIA_NIGHTLY_DIR does not exist" >&2 + exit 1 + fi + + cargo clean + JULIA_VERSION=$($JULIA_NIGHTLY_DIR/bin/julia --version) + JULIA_COMMIT=$($JULIA_NIGHTLY_DIR/bin/julia -E "Base.GIT_VERSION_INFO.commit_short" | grep -oEe "[^\"]+") + JULIA_COMMIT_DATE=$($JULIA_NIGHTLY_DIR/bin/julia -E "Base.GIT_VERSION_INFO.date_string" | grep -oEe "[^\"]+") + JULIA_DIR=$JULIA_NIGHTLY_DIR cargo +nightly build --features use-bindgen,c-unwind,julia-1-11 + echo "/* generated from $JULIA_VERSION (Commit: $JULIA_COMMIT $JULIA_COMMIT_DATE) */" > ./src/bindings_unwind/bindings_unwind_1_11_64.rs + cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_11_64.rs + + cargo clean + JULIA_DIR=$JULIA_NIGHTLY_DIR RUSTC_BOOTSTRAP=1 cargo build --features use-bindgen,c-unwind,i686,julia-1-11 --target i686-unknown-linux-gnu + echo "/* generated from $JULIA_VERSION (Commit: $JULIA_COMMIT $JULIA_COMMIT_DATE) */" > ./src/bindings_unwind/bindings_unwind_1_11_32.rs + cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_11_32.rs + + if [ "${BETA}" != "y" -a "${ALL}" != "y" ]; then + cargo +nightly fmt -- ./src/bindings_unwind/bindings_unwind_* + exit + fi +fi + +if [ "${BETA}" = "y" -o "${ALL}" = "y" ]; then + if [ -z "$JULIA_BETA_DIR" ]; then + JULIA_BETA_DIR=${HOME}/julia-1.10.0-beta1 + fi + if [ ! -d "$JULIA_BETA_DIR" ]; then + echo "Error: $JULIA_BETA_DIR does not exist" >&2 + exit 1 + fi + + cargo clean + JULIA_VERSION=$($JULIA_BETA_DIR/bin/julia --version) + JULIA_DIR=$JULIA_BETA_DIR cargo +nightly build --features use-bindgen,c-unwind,julia-1-10 + echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_10_64.rs + cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_10_64.rs + + cargo clean + JULIA_DIR=$JULIA_BETA_DIR RUSTC_BOOTSTRAP=1 cargo build --features use-bindgen,c-unwind,i686,julia-1-10 --target i686-unknown-linux-gnu + echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_10_32.rs + cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_10_32.rs + + # echo "Warning: there is no known beta version. Skipping beta bindings" >&2 + if [ "${ALL}" != "y" ]; then + cargo +nightly fmt -- ./src/bindings_unwind/bindings_unwind_* + exit + fi +fi + +if [ -z "$JULIA_1_9_DIR" ]; then + JULIA_1_9_DIR=${HOME}/julia-1.9.2 +fi +if [ ! -d "$JULIA_1_9_DIR" ]; then + echo "Error: $JULIA_1_9_DIR does not exist" >&2 + exit 1 +fi + +if [ -z "$JULIA_1_8_DIR" ]; then + JULIA_1_8_DIR=${HOME}/julia-1.8.5 +fi +if [ ! -d "$JULIA_1_8_DIR" ]; then + echo "Error: $JULIA_1_8_DIR does not exist" >&2 + exit 1 +fi + +if [ -z "$JULIA_1_7_DIR" ]; then + JULIA_1_7_DIR=${HOME}/julia-1.7.3 +fi +if [ ! -d "$JULIA_1_7_DIR" ]; then + echo "Error: $JULIA_1_7_DIR does not exist" >&2 + exit 1 +fi + +if [ -z "$JULIA_1_6_DIR" ]; then + JULIA_1_6_DIR=${HOME}/julia-1.6.7 +fi +if [ ! -d "$JULIA_1_6_DIR" ]; then + echo "Error: $JULIA_1_6_DIR does not exist" >&2 + exit 1 +fi + +cargo clean +JULIA_VERSION=$($JULIA_1_6_DIR/bin/julia --version) +JULIA_DIR=$JULIA_1_6_DIR cargo +nightly build --features use-bindgen,c-unwind,julia-1-6 +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_6_64.rs +cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_6_64.rs + +cargo clean +JULIA_DIR=$JULIA_1_6_DIR RUSTC_BOOTSTRAP=1 cargo build --features use-bindgen,c-unwind,julia-1-6,i686 --target i686-unknown-linux-gnu +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_6_32.rs +cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_6_32.rs + +cargo clean +JULIA_VERSION=$($JULIA_1_7_DIR/bin/julia --version) +JULIA_DIR=$JULIA_1_7_DIR cargo +nightly build --features use-bindgen,c-unwind,julia-1-7 +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_7_64.rs +cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_7_64.rs + +cargo clean +JULIA_DIR=$JULIA_1_7_DIR RUSTC_BOOTSTRAP=1 cargo build --features use-bindgen,c-unwind,i686,julia-1-7 --target i686-unknown-linux-gnu +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_7_32.rs +cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_7_32.rs + +cargo clean +JULIA_VERSION=$($JULIA_1_8_DIR/bin/julia --version) +JULIA_DIR=$JULIA_1_8_DIR cargo +nightly build --features use-bindgen,c-unwind,julia-1-8 +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_8_64.rs +cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_8_64.rs + +cargo clean +JULIA_DIR=$JULIA_1_8_DIR RUSTC_BOOTSTRAP=1 cargo build --features use-bindgen,c-unwind,i686,julia-1-8 --target i686-unknown-linux-gnu +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_8_32.rs +cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_8_32.rs + +cargo clean +JULIA_VERSION=$($JULIA_1_9_DIR/bin/julia --version) +JULIA_DIR=$JULIA_1_9_DIR cargo +nightly build --features use-bindgen,c-unwind,julia-1-9 +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_9_64.rs +cat ../target/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_9_64.rs + +cargo clean +JULIA_DIR=$JULIA_1_9_DIR RUSTC_BOOTSTRAP=1 cargo build --features use-bindgen,c-unwind,i686,julia-1-9 --target i686-unknown-linux-gnu +echo "/* generated from $JULIA_VERSION */" > ./src/bindings_unwind/bindings_unwind_1_9_32.rs +cat ../target/i686-unknown-linux-gnu/debug/build/jl-sys*/out/bindings.rs >> ./src/bindings_unwind/bindings_unwind_1_9_32.rs + +cargo +nightly fmt -- ./src/bindings_unwind/bindings_unwind_* diff --git a/jl_sys/src/bindings.rs b/jl_sys/src/bindings.rs index 5d37da11..e82907a3 100644 --- a/jl_sys/src/bindings.rs +++ b/jl_sys/src/bindings.rs @@ -31,6 +31,9 @@ bindings_for!(bindings_1_9_32, "julia-1-9", "32"); bindings_for!(bindings_1_10_64, "julia-1-10", "64"); bindings_for!(bindings_1_10_32, "julia-1-10", "32"); +bindings_for!(bindings_1_11_64, "julia-1-11", "64"); +bindings_for!(bindings_1_11_32, "julia-1-11", "32"); + #[cfg(target_os = "windows")] mod bindings_ext_windows; diff --git a/jl_sys/src/bindings/bindings_1_10_32.rs b/jl_sys/src/bindings/bindings_1_10_32.rs index cc48e002..9cb2a707 100644 --- a/jl_sys/src/bindings/bindings_1_10_32.rs +++ b/jl_sys/src/bindings/bindings_1_10_32.rs @@ -1,4 +1,4 @@ -/* generated from julia version 1.10.0-DEV (Commit: 0a05a5b05d 2023-05-13 14:18 UTC) */ +/* generated from julia version 1.10.0-beta1 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct __BindgenBitfieldUnit { @@ -536,6 +536,7 @@ pub struct _jl_method_t { pub nkw: u32, pub isva: u8, pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, pub constprop: u8, pub max_varargs: u8, pub purity: _jl_purity_overrides_t, @@ -1856,6 +1857,9 @@ extern "C" { extern "C" { pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; } +extern "C" { + pub fn jl_get_world_counter() -> usize; +} extern "C" { pub fn jl_box_bool(x: i8) -> *mut jl_value_t; } @@ -2187,7 +2191,8 @@ pub struct jl_options_t { pub cpu_target: *const ::std::os::raw::c_char, pub nthreadpools: i8, pub nthreads: i16, - pub ngcthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, pub nthreads_per_pool: *const i16, pub nprocs: i32, pub machine_file: *const ::std::os::raw::c_char, @@ -2230,6 +2235,7 @@ pub struct jl_options_t { pub rr_detach: i8, pub strip_metadata: i8, pub strip_ir: i8, + pub permalloc_pkgimg: i8, pub heap_size_hint: u64, } extern "C" { @@ -2344,9 +2350,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -2358,7 +2363,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -2366,7 +2370,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -2379,6 +2382,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_10_64.rs b/jl_sys/src/bindings/bindings_1_10_64.rs index 7dd6aa15..6bd405cc 100644 --- a/jl_sys/src/bindings/bindings_1_10_64.rs +++ b/jl_sys/src/bindings/bindings_1_10_64.rs @@ -1,4 +1,4 @@ -/* generated from julia version 1.10.0-DEV (Commit: 0a05a5b05d 2023-05-13 14:18 UTC) */ +/* generated from julia version 1.10.0-beta1 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct __BindgenBitfieldUnit { @@ -543,6 +543,7 @@ pub struct _jl_method_t { pub nkw: u32, pub isva: u8, pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, pub constprop: u8, pub max_varargs: u8, pub purity: _jl_purity_overrides_t, @@ -2927,6 +2928,16 @@ extern "C" { ), link(name = "libjulia", kind = "raw-dylib") )] +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] extern "C" { pub fn jl_box_bool(x: i8) -> *mut jl_value_t; } @@ -3881,7 +3892,8 @@ pub struct jl_options_t { pub cpu_target: *const ::std::os::raw::c_char, pub nthreadpools: i8, pub nthreads: i16, - pub ngcthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, pub nthreads_per_pool: *const i16, pub nprocs: i32, pub machine_file: *const ::std::os::raw::c_char, @@ -3924,6 +3936,7 @@ pub struct jl_options_t { pub rr_detach: i8, pub strip_metadata: i8, pub strip_ir: i8, + pub permalloc_pkgimg: i8, pub heap_size_hint: u64, } #[cfg_attr( @@ -4143,9 +4156,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -4157,7 +4169,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -4165,7 +4176,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -4178,6 +4188,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_11_32.rs b/jl_sys/src/bindings/bindings_1_11_32.rs new file mode 100644 index 00000000..88045ae4 --- /dev/null +++ b/jl_sys/src/bindings/bindings_1_11_32.rs @@ -0,0 +1,2422 @@ +/* generated from julia version 1.11.0-DEV (Commit: 62605cc40f 2023-07-27 17:35 UTC) */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +extern "C" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn unused(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } + } + #[inline] + pub fn set_unused(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn tag(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 28u8) as u32) } + } + #[inline] + pub fn set_tag(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 28u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + gc: usize, + in_image: usize, + unused: usize, + tag: usize, + ) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u32 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let unused: u32 = unsafe { ::std::mem::transmute(unused) }; + unused as u64 + }); + __bindgen_bitfield_unit.set(4usize, 28u8, { + let tag: u32 = unsafe { ::std::mem::transmute(tag) }; + tag as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_method_instance_t = _jl_method_instance_t; +pub type jl_globalref_t = _jl_globalref_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, + pub constprop: u8, + pub max_varargs: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: ::std::sync::atomic::AtomicPtr, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: ::std::sync::atomic::AtomicU8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +pub type jl_opaque_closure_t = _jl_opaque_closure_t; +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 13u8) as u16) } + } + #[inline] + pub fn set_padding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 13u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + padding: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit.set(3usize, 13u8, { + let padding: u16 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub __bindgen_padding_0: u16, +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn maybe_subtype_of_cache(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } + } + #[inline] + pub fn set_maybe_subtype_of_cache(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn ismutationfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } + } + #[inline] + pub fn set_ismutationfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn isidentityfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } + } + #[inline] + pub fn set_isidentityfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn smalltag(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) } + } + #[inline] + pub fn set_smalltag(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u16, + isconcretetype: u16, + isdispatchtuple: u16, + isbitstype: u16, + zeroinit: u16, + has_concrete_subtype: u16, + maybe_subtype_of_cache: u16, + isprimitivetype: u16, + ismutationfree: u16, + isidentityfree: u16, + smalltag: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u16 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u16 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u16 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u16 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u16 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u16 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let maybe_subtype_of_cache: u16 = + unsafe { ::std::mem::transmute(maybe_subtype_of_cache) }; + maybe_subtype_of_cache as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u16 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let ismutationfree: u16 = unsafe { ::std::mem::transmute(ismutationfree) }; + ismutationfree as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let isidentityfree: u16 = unsafe { ::std::mem::transmute(isidentityfree) }; + isidentityfree as u64 + }); + __bindgen_bitfield_unit.set(10usize, 6u8, { + let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) }; + smalltag as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_weakref_t { + pub value: *mut jl_value_t, +} +pub type jl_weakref_t = _jl_weakref_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_binding_t { + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: *mut jl_globalref_t, + pub owner: ::std::sync::atomic::AtomicPtr<_jl_binding_t>, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn usingfailed(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_usingfailed(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 2u8) as u8) } + } + #[inline] + pub fn set_padding(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + usingfailed: u8, + deprecated: u8, + padding: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let usingfailed: u8 = unsafe { ::std::mem::transmute(usingfailed) }; + usingfailed as u64 + }); + __bindgen_bitfield_unit.set(4usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit.set(6usize, 2u8, { + let padding: u8 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_binding_t = _jl_binding_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: ::std::sync::atomic::AtomicPtr, + pub bindingkeyset: ::std::sync::atomic::AtomicPtr, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, + pub hash: isize, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_globalref_t { + pub mod_: *mut jl_module_t, + pub name: *mut jl_sym_t, + pub binding: *mut jl_binding_t, +} +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: ::std::sync::atomic::AtomicIsize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_binding_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +extern "C" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C" { + pub fn jl_gc_set_max_memory(max_mem: u64); +} +extern "C" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +extern "C" { + pub fn jl_gc_safepoint(); +} +extern "C" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +extern "C" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +extern "C" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C" { + pub fn jl_new_module(name: *mut jl_sym_t, parent: *mut jl_module_t) -> *mut jl_module_t; +} +extern "C" { + pub fn jl_get_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +extern "C" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C" { + pub fn jl_init(); +} +extern "C" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +extern "C" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +extern "C" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +extern "C" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C" { + pub fn jl_excstack_state() -> usize; +} +extern "C" { + pub fn jl_restore_excstack(state: usize); +} +extern "C" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = + ::std::option::Option usize>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 5usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub reentrant_timing: u8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +extern "C" { + pub fn jl_enter_threaded_region(); +} +extern "C" { + pub fn jl_exit_threaded_region(); +} +extern "C" { + pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings/bindings_1_11_64.rs b/jl_sys/src/bindings/bindings_1_11_64.rs new file mode 100644 index 00000000..63ebc401 --- /dev/null +++ b/jl_sys/src/bindings/bindings_1_11_64.rs @@ -0,0 +1,4242 @@ +/* generated from julia version 1.11.0-DEV (Commit: 62605cc40f 2023-07-27 17:35 UTC) */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u64; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn unused(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + } + #[inline] + pub fn set_unused(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn tag(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 60u8) as u64) } + } + #[inline] + pub fn set_tag(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 60u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + gc: usize, + in_image: usize, + unused: usize, + tag: usize, + ) -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u64 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let unused: u64 = unsafe { ::std::mem::transmute(unused) }; + unused as u64 + }); + __bindgen_bitfield_unit.set(4usize, 60u8, { + let tag: u64 = unsafe { ::std::mem::transmute(tag) }; + tag as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_method_instance_t = _jl_method_instance_t; +pub type jl_globalref_t = _jl_globalref_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, + pub constprop: u8, + pub max_varargs: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: ::std::sync::atomic::AtomicPtr, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: ::std::sync::atomic::AtomicU8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +pub type jl_opaque_closure_t = _jl_opaque_closure_t; +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 13u8) as u16) } + } + #[inline] + pub fn set_padding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 13u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + padding: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit.set(3usize, 13u8, { + let padding: u16 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub __bindgen_padding_0: u16, +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn maybe_subtype_of_cache(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } + } + #[inline] + pub fn set_maybe_subtype_of_cache(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn ismutationfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } + } + #[inline] + pub fn set_ismutationfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn isidentityfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } + } + #[inline] + pub fn set_isidentityfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn smalltag(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) } + } + #[inline] + pub fn set_smalltag(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u16, + isconcretetype: u16, + isdispatchtuple: u16, + isbitstype: u16, + zeroinit: u16, + has_concrete_subtype: u16, + maybe_subtype_of_cache: u16, + isprimitivetype: u16, + ismutationfree: u16, + isidentityfree: u16, + smalltag: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u16 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u16 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u16 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u16 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u16 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u16 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let maybe_subtype_of_cache: u16 = + unsafe { ::std::mem::transmute(maybe_subtype_of_cache) }; + maybe_subtype_of_cache as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u16 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let ismutationfree: u16 = unsafe { ::std::mem::transmute(ismutationfree) }; + ismutationfree as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let isidentityfree: u16 = unsafe { ::std::mem::transmute(isidentityfree) }; + isidentityfree as u64 + }); + __bindgen_bitfield_unit.set(10usize, 6u8, { + let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) }; + smalltag as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_weakref_t { + pub value: *mut jl_value_t, +} +pub type jl_weakref_t = _jl_weakref_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_binding_t { + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: *mut jl_globalref_t, + pub owner: ::std::sync::atomic::AtomicPtr<_jl_binding_t>, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn usingfailed(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_usingfailed(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 2u8) as u8) } + } + #[inline] + pub fn set_padding(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + usingfailed: u8, + deprecated: u8, + padding: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let usingfailed: u8 = unsafe { ::std::mem::transmute(usingfailed) }; + usingfailed as u64 + }); + __bindgen_bitfield_unit.set(4usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit.set(6usize, 2u8, { + let padding: u8 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_binding_t = _jl_binding_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: ::std::sync::atomic::AtomicPtr, + pub bindingkeyset: ::std::sync::atomic::AtomicPtr, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, + pub hash: isize, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_globalref_t { + pub mod_: *mut jl_module_t, + pub name: *mut jl_sym_t, + pub binding: *mut jl_binding_t, +} +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: ::std::sync::atomic::AtomicIsize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_binding_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_set_max_memory(max_mem: u64); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_safepoint(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_module(name: *mut jl_sym_t, parent: *mut jl_module_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_init(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = + ::std::option::Option usize>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 5usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub reentrant_timing: u8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_enter_threaded_region(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub fn jl_exit_threaded_region(); +} +extern "C" { + pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings/bindings_1_6_32.rs b/jl_sys/src/bindings/bindings_1_6_32.rs index 9178ade7..fbe54a2b 100644 --- a/jl_sys/src/bindings/bindings_1_6_32.rs +++ b/jl_sys/src/bindings/bindings_1_6_32.rs @@ -1131,6 +1131,13 @@ extern "C" { extern "C" { pub static mut jl_nothing: *mut jl_value_t; } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +pub type jl_gcframe_t = _jl_gcframe_t; extern "C" { pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; } @@ -1260,6 +1267,9 @@ extern "C" { extern "C" { pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; } +extern "C" { + pub fn jl_get_world_counter() -> usize; +} extern "C" { pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; } @@ -1687,7 +1697,8 @@ extern "C" { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct _jl_tls_states_t { - _unused: [u8; 0], + pub pgcstack: *mut ::std::os::raw::c_void, + pub world_age: usize, } #[doc = "
"] #[repr(C)] @@ -1718,9 +1729,8 @@ pub struct _jl_task_t { pub _isexception: u8, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1732,7 +1742,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -1740,7 +1749,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -1754,7 +1762,25 @@ extern "C" { ); } extern "C" { - pub fn jlrs_pgcstack(ptls: *mut jl_tls_states_t) -> *mut *mut ::std::os::raw::c_void; + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jlrs_pgcstack(ptls: *mut jl_tls_states_t) -> *mut *mut jl_gcframe_t; } #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/jl_sys/src/bindings/bindings_1_6_64.rs b/jl_sys/src/bindings/bindings_1_6_64.rs index 9fadc549..bb5c2b1b 100644 --- a/jl_sys/src/bindings/bindings_1_6_64.rs +++ b/jl_sys/src/bindings/bindings_1_6_64.rs @@ -1908,6 +1908,13 @@ extern "C" { extern "C" { pub static mut jl_nothing: *mut jl_value_t; } +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +pub type jl_gcframe_t = _jl_gcframe_t; #[cfg_attr( all( any(windows, target_os = "windows", feature = "windows"), @@ -2254,6 +2261,16 @@ extern "C" { ), link(name = "libjulia", kind = "raw-dylib") )] +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] extern "C" { pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; } @@ -3388,7 +3405,8 @@ extern "C" { #[repr(C)] #[derive(Debug, Copy, Clone)] pub struct _jl_tls_states_t { - _unused: [u8; 0], + pub pgcstack: *mut ::std::os::raw::c_void, + pub world_age: usize, } #[doc = "
"] #[repr(C)] @@ -3419,9 +3437,8 @@ pub struct _jl_task_t { pub _isexception: u8, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3433,7 +3450,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -3441,7 +3457,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -3455,7 +3470,25 @@ extern "C" { ); } extern "C" { - pub fn jlrs_pgcstack(ptls: *mut jl_tls_states_t) -> *mut *mut ::std::os::raw::c_void; + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C" { + pub fn jlrs_pgcstack(ptls: *mut jl_tls_states_t) -> *mut *mut jl_gcframe_t; } #[repr(C)] #[derive(Debug, Copy, Clone)] diff --git a/jl_sys/src/bindings/bindings_1_7_32.rs b/jl_sys/src/bindings/bindings_1_7_32.rs index ab26b183..3eb94495 100644 --- a/jl_sys/src/bindings/bindings_1_7_32.rs +++ b/jl_sys/src/bindings/bindings_1_7_32.rs @@ -1523,6 +1523,9 @@ extern "C" { extern "C" { pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; } +extern "C" { + pub fn jl_get_world_counter() -> usize; +} extern "C" { pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; } @@ -1994,9 +1997,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -2008,7 +2010,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -2016,7 +2017,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -2029,6 +2029,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_7_64.rs b/jl_sys/src/bindings/bindings_1_7_64.rs index 6bfa828e..b3453a80 100644 --- a/jl_sys/src/bindings/bindings_1_7_64.rs +++ b/jl_sys/src/bindings/bindings_1_7_64.rs @@ -2580,6 +2580,16 @@ extern "C" { ), link(name = "libjulia", kind = "raw-dylib") )] +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] extern "C" { pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; } @@ -3765,9 +3775,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3779,7 +3788,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -3787,7 +3795,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -3800,6 +3807,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_8_32.rs b/jl_sys/src/bindings/bindings_1_8_32.rs index cd15f4e8..d778a669 100644 --- a/jl_sys/src/bindings/bindings_1_8_32.rs +++ b/jl_sys/src/bindings/bindings_1_8_32.rs @@ -1637,6 +1637,9 @@ extern "C" { extern "C" { pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; } +extern "C" { + pub fn jl_get_world_counter() -> usize; +} extern "C" { pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; } @@ -2111,9 +2114,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -2125,7 +2127,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -2133,7 +2134,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -2146,6 +2146,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_8_64.rs b/jl_sys/src/bindings/bindings_1_8_64.rs index 63bf3bc2..cfa44876 100644 --- a/jl_sys/src/bindings/bindings_1_8_64.rs +++ b/jl_sys/src/bindings/bindings_1_8_64.rs @@ -2701,6 +2701,16 @@ extern "C" { ), link(name = "libjulia", kind = "raw-dylib") )] +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] extern "C" { pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; } @@ -3896,9 +3906,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -3910,7 +3919,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -3918,7 +3926,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -3931,6 +3938,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_9_32.rs b/jl_sys/src/bindings/bindings_1_9_32.rs index de05f57c..36a908da 100644 --- a/jl_sys/src/bindings/bindings_1_9_32.rs +++ b/jl_sys/src/bindings/bindings_1_9_32.rs @@ -1,4 +1,4 @@ -/* generated from julia version 1.9.0 */ +/* generated from julia version 1.9.2 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct __BindgenBitfieldUnit { @@ -1721,6 +1721,9 @@ extern "C" { extern "C" { pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; } +extern "C" { + pub fn jl_get_world_counter() -> usize; +} extern "C" { pub fn jl_box_bool(x: i8) -> *mut jl_value_t; } @@ -2094,6 +2097,7 @@ pub struct jl_options_t { pub rr_detach: i8, pub strip_metadata: i8, pub strip_ir: i8, + pub permalloc_pkgimg: i8, pub heap_size_hint: u64, } extern "C" { @@ -2207,9 +2211,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -2221,7 +2224,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -2229,7 +2231,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -2242,6 +2243,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings/bindings_1_9_64.rs b/jl_sys/src/bindings/bindings_1_9_64.rs index 42e5a367..e88185db 100644 --- a/jl_sys/src/bindings/bindings_1_9_64.rs +++ b/jl_sys/src/bindings/bindings_1_9_64.rs @@ -1,4 +1,4 @@ -/* generated from julia version 1.9.0 */ +/* generated from julia version 1.9.2 */ #[repr(C)] #[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct __BindgenBitfieldUnit { @@ -2792,6 +2792,16 @@ extern "C" { ), link(name = "libjulia", kind = "raw-dylib") )] +extern "C" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] extern "C" { pub fn jl_box_bool(x: i8) -> *mut jl_value_t; } @@ -3788,6 +3798,7 @@ pub struct jl_options_t { pub rr_detach: i8, pub strip_metadata: i8, pub strip_ir: i8, + pub permalloc_pkgimg: i8, pub heap_size_hint: u64, } #[cfg_attr( @@ -4006,9 +4017,8 @@ pub struct _jl_task_t { pub ptls: jl_ptls_t, } pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; -pub const jlrs_catch_tag_t_JLRS_CATCH_ERR: jlrs_catch_tag_t = 1; -pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 2; -pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 3; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -4020,7 +4030,6 @@ pub type jlrs_callback_caller_t = ::std::option::Option< unsafe extern "C" fn( arg1: *mut ::std::os::raw::c_void, arg2: *mut ::std::os::raw::c_void, - arg3: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t, >; extern "C" { @@ -4028,7 +4037,6 @@ extern "C" { callback: *mut ::std::os::raw::c_void, caller: jlrs_callback_caller_t, result: *mut ::std::os::raw::c_void, - frame_slice: *mut ::std::os::raw::c_void, ) -> jlrs_catch_t; } extern "C" { @@ -4041,6 +4049,24 @@ extern "C" { ptr: *const ::std::os::raw::c_void, ); } +extern "C" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} extern "C" { pub fn jlrs_lock(v: *mut jl_value_t); } diff --git a/jl_sys/src/bindings_unwind.rs b/jl_sys/src/bindings_unwind.rs new file mode 100644 index 00000000..b5268acf --- /dev/null +++ b/jl_sys/src/bindings_unwind.rs @@ -0,0 +1,41 @@ +#[rustfmt::skip] +macro_rules! bindings_for { + ($bindings:tt, $version:literal, $pointer_width:literal) => { + #[cfg(all( + not(feature = "use-bindgen"), + feature = $version, + target_pointer_width = $pointer_width + ))] + mod $bindings; + #[cfg(all( + not(feature = "use-bindgen"), + feature = $version, + target_pointer_width = $pointer_width + ))] + pub use $bindings::*; + }; +} + +bindings_for!(bindings_unwind_1_6_64, "julia-1-6", "64"); +bindings_for!(bindings_unwind_1_6_32, "julia-1-6", "32"); + +bindings_for!(bindings_unwind_1_7_64, "julia-1-7", "64"); +bindings_for!(bindings_unwind_1_7_32, "julia-1-7", "32"); + +bindings_for!(bindings_unwind_1_8_64, "julia-1-8", "64"); +bindings_for!(bindings_unwind_1_8_32, "julia-1-8", "32"); + +bindings_for!(bindings_unwind_1_9_64, "julia-1-9", "64"); +bindings_for!(bindings_unwind_1_9_32, "julia-1-9", "32"); + +bindings_for!(bindings_unwind_1_10_64, "julia-1-10", "64"); +bindings_for!(bindings_unwind_1_10_32, "julia-1-10", "32"); + +bindings_for!(bindings_unwind_1_11_64, "julia-1-11", "64"); +bindings_for!(bindings_unwind_1_11_32, "julia-1-11", "32"); + +#[cfg(target_os = "windows")] +mod bindings_unwind_ext_windows; + +#[cfg(target_os = "windows")] +pub use bindings_unwind_ext_windows::*; diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_10_32.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_10_32.rs new file mode 100644 index 00000000..236d9d8b --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_10_32.rs @@ -0,0 +1,2423 @@ +/* generated from julia version 1.10.0-beta1 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn unused(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } + } + #[inline] + pub fn set_unused(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn tag(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 28u8) as u32) } + } + #[inline] + pub fn set_tag(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 28u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + gc: usize, + in_image: usize, + unused: usize, + tag: usize, + ) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u32 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let unused: u32 = unsafe { ::std::mem::transmute(unused) }; + unused as u64 + }); + __bindgen_bitfield_unit.set(4usize, 28u8, { + let tag: u32 = unsafe { ::std::mem::transmute(tag) }; + tag as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_method_instance_t = _jl_method_instance_t; +pub type jl_globalref_t = _jl_globalref_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, + pub constprop: u8, + pub max_varargs: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: ::std::sync::atomic::AtomicPtr, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: ::std::sync::atomic::AtomicU8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +pub type jl_opaque_closure_t = _jl_opaque_closure_t; +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 13u8) as u16) } + } + #[inline] + pub fn set_padding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 13u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + padding: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit.set(3usize, 13u8, { + let padding: u16 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub __bindgen_padding_0: u16, +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn maybe_subtype_of_cache(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } + } + #[inline] + pub fn set_maybe_subtype_of_cache(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn ismutationfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } + } + #[inline] + pub fn set_ismutationfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn isidentityfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } + } + #[inline] + pub fn set_isidentityfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn smalltag(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) } + } + #[inline] + pub fn set_smalltag(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u16, + isconcretetype: u16, + isdispatchtuple: u16, + isbitstype: u16, + zeroinit: u16, + has_concrete_subtype: u16, + maybe_subtype_of_cache: u16, + isprimitivetype: u16, + ismutationfree: u16, + isidentityfree: u16, + smalltag: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u16 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u16 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u16 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u16 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u16 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u16 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let maybe_subtype_of_cache: u16 = + unsafe { ::std::mem::transmute(maybe_subtype_of_cache) }; + maybe_subtype_of_cache as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u16 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let ismutationfree: u16 = unsafe { ::std::mem::transmute(ismutationfree) }; + ismutationfree as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let isidentityfree: u16 = unsafe { ::std::mem::transmute(isidentityfree) }; + isidentityfree as u64 + }); + __bindgen_bitfield_unit.set(10usize, 6u8, { + let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) }; + smalltag as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_weakref_t { + pub value: *mut jl_value_t, +} +pub type jl_weakref_t = _jl_weakref_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_binding_t { + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: *mut jl_globalref_t, + pub owner: ::std::sync::atomic::AtomicPtr<_jl_binding_t>, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn usingfailed(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_usingfailed(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 2u8) as u8) } + } + #[inline] + pub fn set_padding(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + usingfailed: u8, + deprecated: u8, + padding: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let usingfailed: u8 = unsafe { ::std::mem::transmute(usingfailed) }; + usingfailed as u64 + }); + __bindgen_bitfield_unit.set(4usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit.set(6usize, 2u8, { + let padding: u8 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_binding_t = _jl_binding_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: ::std::sync::atomic::AtomicPtr, + pub bindingkeyset: ::std::sync::atomic::AtomicPtr, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, + pub hash: isize, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_globalref_t { + pub mod_: *mut jl_module_t, + pub name: *mut jl_sym_t, + pub binding: *mut jl_binding_t, +} +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: ::std::sync::atomic::AtomicIsize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_binding_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jl_gc_set_max_memory(max_mem: u64); +} +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t, parent: *mut jl_module_t) -> *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_get_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_init(); +} +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C-unwind" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 5usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub reentrant_timing: u8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_enter_threaded_region(); +} +extern "C-unwind" { + pub fn jl_exit_threaded_region(); +} +extern "C-unwind" { + pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_10_64.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_10_64.rs new file mode 100644 index 00000000..5886fba5 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_10_64.rs @@ -0,0 +1,4243 @@ +/* generated from julia version 1.10.0-beta1 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u64; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn unused(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + } + #[inline] + pub fn set_unused(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn tag(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 60u8) as u64) } + } + #[inline] + pub fn set_tag(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 60u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + gc: usize, + in_image: usize, + unused: usize, + tag: usize, + ) -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u64 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let unused: u64 = unsafe { ::std::mem::transmute(unused) }; + unused as u64 + }); + __bindgen_bitfield_unit.set(4usize, 60u8, { + let tag: u64 = unsafe { ::std::mem::transmute(tag) }; + tag as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_method_instance_t = _jl_method_instance_t; +pub type jl_globalref_t = _jl_globalref_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, + pub constprop: u8, + pub max_varargs: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: ::std::sync::atomic::AtomicPtr, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: ::std::sync::atomic::AtomicU8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +pub type jl_opaque_closure_t = _jl_opaque_closure_t; +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 13u8) as u16) } + } + #[inline] + pub fn set_padding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 13u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + padding: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit.set(3usize, 13u8, { + let padding: u16 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub __bindgen_padding_0: u16, +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn maybe_subtype_of_cache(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } + } + #[inline] + pub fn set_maybe_subtype_of_cache(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn ismutationfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } + } + #[inline] + pub fn set_ismutationfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn isidentityfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } + } + #[inline] + pub fn set_isidentityfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn smalltag(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) } + } + #[inline] + pub fn set_smalltag(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u16, + isconcretetype: u16, + isdispatchtuple: u16, + isbitstype: u16, + zeroinit: u16, + has_concrete_subtype: u16, + maybe_subtype_of_cache: u16, + isprimitivetype: u16, + ismutationfree: u16, + isidentityfree: u16, + smalltag: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u16 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u16 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u16 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u16 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u16 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u16 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let maybe_subtype_of_cache: u16 = + unsafe { ::std::mem::transmute(maybe_subtype_of_cache) }; + maybe_subtype_of_cache as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u16 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let ismutationfree: u16 = unsafe { ::std::mem::transmute(ismutationfree) }; + ismutationfree as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let isidentityfree: u16 = unsafe { ::std::mem::transmute(isidentityfree) }; + isidentityfree as u64 + }); + __bindgen_bitfield_unit.set(10usize, 6u8, { + let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) }; + smalltag as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_weakref_t { + pub value: *mut jl_value_t, +} +pub type jl_weakref_t = _jl_weakref_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_binding_t { + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: *mut jl_globalref_t, + pub owner: ::std::sync::atomic::AtomicPtr<_jl_binding_t>, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn usingfailed(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_usingfailed(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 2u8) as u8) } + } + #[inline] + pub fn set_padding(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + usingfailed: u8, + deprecated: u8, + padding: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let usingfailed: u8 = unsafe { ::std::mem::transmute(usingfailed) }; + usingfailed as u64 + }); + __bindgen_bitfield_unit.set(4usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit.set(6usize, 2u8, { + let padding: u8 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_binding_t = _jl_binding_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: ::std::sync::atomic::AtomicPtr, + pub bindingkeyset: ::std::sync::atomic::AtomicPtr, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, + pub hash: isize, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_globalref_t { + pub mod_: *mut jl_module_t, + pub name: *mut jl_sym_t, + pub binding: *mut jl_binding_t, +} +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: ::std::sync::atomic::AtomicIsize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_binding_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_set_max_memory(max_mem: u64); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t, parent: *mut jl_module_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 5usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub reentrant_timing: u8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_threaded_region(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exit_threaded_region(); +} +extern "C-unwind" { + pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_11_32.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_11_32.rs new file mode 100644 index 00000000..1f96985b --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_11_32.rs @@ -0,0 +1,2423 @@ +/* generated from julia version 1.11.0-DEV (Commit: 62605cc40f 2023-07-27 17:35 UTC) */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn unused(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u32) } + } + #[inline] + pub fn set_unused(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn tag(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 28u8) as u32) } + } + #[inline] + pub fn set_tag(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 28u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + gc: usize, + in_image: usize, + unused: usize, + tag: usize, + ) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u32 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let unused: u32 = unsafe { ::std::mem::transmute(unused) }; + unused as u64 + }); + __bindgen_bitfield_unit.set(4usize, 28u8, { + let tag: u32 = unsafe { ::std::mem::transmute(tag) }; + tag as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_method_instance_t = _jl_method_instance_t; +pub type jl_globalref_t = _jl_globalref_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, + pub constprop: u8, + pub max_varargs: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: ::std::sync::atomic::AtomicPtr, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: ::std::sync::atomic::AtomicU8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +pub type jl_opaque_closure_t = _jl_opaque_closure_t; +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 13u8) as u16) } + } + #[inline] + pub fn set_padding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 13u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + padding: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit.set(3usize, 13u8, { + let padding: u16 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub __bindgen_padding_0: u16, +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn maybe_subtype_of_cache(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } + } + #[inline] + pub fn set_maybe_subtype_of_cache(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn ismutationfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } + } + #[inline] + pub fn set_ismutationfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn isidentityfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } + } + #[inline] + pub fn set_isidentityfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn smalltag(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) } + } + #[inline] + pub fn set_smalltag(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u16, + isconcretetype: u16, + isdispatchtuple: u16, + isbitstype: u16, + zeroinit: u16, + has_concrete_subtype: u16, + maybe_subtype_of_cache: u16, + isprimitivetype: u16, + ismutationfree: u16, + isidentityfree: u16, + smalltag: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u16 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u16 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u16 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u16 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u16 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u16 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let maybe_subtype_of_cache: u16 = + unsafe { ::std::mem::transmute(maybe_subtype_of_cache) }; + maybe_subtype_of_cache as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u16 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let ismutationfree: u16 = unsafe { ::std::mem::transmute(ismutationfree) }; + ismutationfree as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let isidentityfree: u16 = unsafe { ::std::mem::transmute(isidentityfree) }; + isidentityfree as u64 + }); + __bindgen_bitfield_unit.set(10usize, 6u8, { + let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) }; + smalltag as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_weakref_t { + pub value: *mut jl_value_t, +} +pub type jl_weakref_t = _jl_weakref_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_binding_t { + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: *mut jl_globalref_t, + pub owner: ::std::sync::atomic::AtomicPtr<_jl_binding_t>, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn usingfailed(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_usingfailed(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 2u8) as u8) } + } + #[inline] + pub fn set_padding(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + usingfailed: u8, + deprecated: u8, + padding: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let usingfailed: u8 = unsafe { ::std::mem::transmute(usingfailed) }; + usingfailed as u64 + }); + __bindgen_bitfield_unit.set(4usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit.set(6usize, 2u8, { + let padding: u8 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_binding_t = _jl_binding_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: ::std::sync::atomic::AtomicPtr, + pub bindingkeyset: ::std::sync::atomic::AtomicPtr, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, + pub hash: isize, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_globalref_t { + pub mod_: *mut jl_module_t, + pub name: *mut jl_sym_t, + pub binding: *mut jl_binding_t, +} +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: ::std::sync::atomic::AtomicIsize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_binding_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jl_gc_set_max_memory(max_mem: u64); +} +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t, parent: *mut jl_module_t) -> *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_get_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_init(); +} +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C-unwind" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 5usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub reentrant_timing: u8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_enter_threaded_region(); +} +extern "C-unwind" { + pub fn jl_exit_threaded_region(); +} +extern "C-unwind" { + pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_11_64.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_11_64.rs new file mode 100644 index 00000000..d58770df --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_11_64.rs @@ -0,0 +1,4243 @@ +/* generated from julia version 1.11.0-DEV (Commit: 62605cc40f 2023-07-27 17:35 UTC) */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u64; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 8usize]>, +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn unused(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u64) } + } + #[inline] + pub fn set_unused(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn tag(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 60u8) as u64) } + } + #[inline] + pub fn set_tag(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 60u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + gc: usize, + in_image: usize, + unused: usize, + tag: usize, + ) -> __BindgenBitfieldUnit<[u8; 8usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 8usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u64 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let unused: u64 = unsafe { ::std::mem::transmute(unused) }; + unused as u64 + }); + __bindgen_bitfield_unit.set(4usize, 60u8, { + let tag: u64 = unsafe { ::std::mem::transmute(tag) }; + tag as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_method_instance_t = _jl_method_instance_t; +pub type jl_globalref_t = _jl_globalref_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub is_for_opaque_closure: u8, + pub nospecializeinfer: u8, + pub constprop: u8, + pub max_varargs: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: ::std::sync::atomic::AtomicPtr, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: ::std::sync::atomic::AtomicU8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +pub type jl_opaque_closure_t = _jl_opaque_closure_t; +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 13u8) as u16) } + } + #[inline] + pub fn set_padding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 13u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + padding: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit.set(3usize, 13u8, { + let padding: u16 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub __bindgen_padding_0: u16, +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u16) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u16) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u16) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u16) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u16) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn maybe_subtype_of_cache(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u16) } + } + #[inline] + pub fn set_maybe_subtype_of_cache(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u16) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn ismutationfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(8usize, 1u8) as u16) } + } + #[inline] + pub fn set_ismutationfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(8usize, 1u8, val as u64) + } + } + #[inline] + pub fn isidentityfree(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(9usize, 1u8) as u16) } + } + #[inline] + pub fn set_isidentityfree(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(9usize, 1u8, val as u64) + } + } + #[inline] + pub fn smalltag(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(10usize, 6u8) as u16) } + } + #[inline] + pub fn set_smalltag(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(10usize, 6u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u16, + isconcretetype: u16, + isdispatchtuple: u16, + isbitstype: u16, + zeroinit: u16, + has_concrete_subtype: u16, + maybe_subtype_of_cache: u16, + isprimitivetype: u16, + ismutationfree: u16, + isidentityfree: u16, + smalltag: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u16 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u16 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u16 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u16 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u16 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u16 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let maybe_subtype_of_cache: u16 = + unsafe { ::std::mem::transmute(maybe_subtype_of_cache) }; + maybe_subtype_of_cache as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u16 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit.set(8usize, 1u8, { + let ismutationfree: u16 = unsafe { ::std::mem::transmute(ismutationfree) }; + ismutationfree as u64 + }); + __bindgen_bitfield_unit.set(9usize, 1u8, { + let isidentityfree: u16 = unsafe { ::std::mem::transmute(isidentityfree) }; + isidentityfree as u64 + }); + __bindgen_bitfield_unit.set(10usize, 6u8, { + let smalltag: u16 = unsafe { ::std::mem::transmute(smalltag) }; + smalltag as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_weakref_t { + pub value: *mut jl_value_t, +} +pub type jl_weakref_t = _jl_weakref_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_binding_t { + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: *mut jl_globalref_t, + pub owner: ::std::sync::atomic::AtomicPtr<_jl_binding_t>, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn usingfailed(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_usingfailed(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 2u8, val as u64) + } + } + #[inline] + pub fn padding(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 2u8) as u8) } + } + #[inline] + pub fn set_padding(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + usingfailed: u8, + deprecated: u8, + padding: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let usingfailed: u8 = unsafe { ::std::mem::transmute(usingfailed) }; + usingfailed as u64 + }); + __bindgen_bitfield_unit.set(4usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit.set(6usize, 2u8, { + let padding: u8 = unsafe { ::std::mem::transmute(padding) }; + padding as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_binding_t = _jl_binding_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: ::std::sync::atomic::AtomicPtr, + pub bindingkeyset: ::std::sync::atomic::AtomicPtr, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, + pub hash: isize, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_globalref_t { + pub mod_: *mut jl_module_t, + pub name: *mut jl_sym_t, + pub binding: *mut jl_binding_t, +} +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: ::std::sync::atomic::AtomicIsize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_binding_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_set_max_memory(max_mem: u64); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t, parent: *mut jl_module_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nmarkthreads: i16, + pub nsweepthreads: i8, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 5usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub reentrant_timing: u8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_threaded_region(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exit_threaded_region(); +} +extern "C-unwind" { + pub fn jlrs_typeof(v: *mut jl_value_t) -> *mut jl_datatype_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_6_32.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_6_32.rs new file mode 100644 index 00000000..4d752dc6 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_6_32.rs @@ -0,0 +1,1790 @@ +/* generated from julia version 1.6.7 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_tls_states_t = _jl_tls_states_t; +pub type jl_ptls_t = *mut jl_tls_states_t; +extern "C-unwind" { + pub fn jl_get_ptls_states() -> jl_ptls_t; +} +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_sym_t { + pub left: *mut _jl_sym_t, + pub right: *mut _jl_sym_t, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_generic_specptr_t { + pub fptr: *mut ::std::os::raw::c_void, + pub fptr1: jl_fptr_args_t, + pub fptr3: jl_fptr_sparam_t, +} +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: *mut jl_svec_t, + pub speckeyset: *mut jl_array_t, + pub slot_syms: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: *mut _jl_method_instance_t, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub ccallable: *mut jl_svec_t, + pub invokes: *mut jl_typemap_t, + pub nargs: i32, + pub called: i32, + pub nospecialize: i32, + pub nkw: i32, + pub isva: u8, + pub pure_: u8, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: *mut _jl_code_instance_t, + pub inInference: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: *mut _jl_code_instance_t, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: *mut jl_value_t, + pub isspecsig: u8, + pub precompile: u8, + pub invoke: jl_callptr_t, + pub specptr: jl_generic_specptr_t, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub wrapper: *mut jl_value_t, + pub cache: *mut jl_svec_t, + pub linearcache: *mut jl_svec_t, + pub hash: isize, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub names: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub size: i32, + pub ninitialized: i32, + pub hash: u32, + pub abstract_: u8, + pub mutabl: u8, + pub hasfreetypevars: u8, + pub isconcretetype: u8, + pub isdispatchtuple: u8, + pub isbitstype: u8, + pub zeroinit: u8, + pub isinlinealloc: u8, + pub has_concrete_subtype: u8, + pub cached_by_hash: u8, +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: *mut jl_value_t, + pub globalref: *mut jl_value_t, + pub owner: *mut _jl_module_t, + pub constp: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u16, +} +impl jl_binding_t { + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(2usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: u64, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: u32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_typemap_entry_t { + pub next: *mut _jl_typemap_entry_t, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_typemap_level_t { + pub arg1: *mut jl_array_t, + pub targ: *mut jl_array_t, + pub name1: *mut jl_array_t, + pub tname: *mut jl_array_t, + pub linear: *mut jl_typemap_entry_t, + pub any: *mut jl_typemap_t, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: *mut jl_typemap_t, + pub leafcache: *mut jl_array_t, + pub cache: *mut jl_typemap_t, + pub max_args: isize, + pub kwsorter: *mut jl_value_t, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +pub type jl_gcframe_t = _jl_gcframe_t; +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_egal(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +extern "C-unwind" { + pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; +} +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_init__threading(); +} +extern "C-unwind" { + pub fn jl_init_with_image__threading( + julia_bindir: *const ::std::os::raw::c_char, + image_relative_path: *const ::std::os::raw::c_char, + ); +} +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: i32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreads: i32, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub opt_level: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_value_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + pub pgcstack: *mut ::std::os::raw::c_void, + pub world_age: usize, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_mutex_t { + pub owner: ::std::os::raw::c_ulong, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub _state: u8, + pub sticky: u8, + pub _isexception: u8, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_pgcstack(ptls: *mut jl_tls_states_t) -> *mut *mut jl_gcframe_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_6_64.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_6_64.rs new file mode 100644 index 00000000..dbd5ed82 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_6_64.rs @@ -0,0 +1,3498 @@ +/* generated from julia version 1.6.7 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_tls_states_t = _jl_tls_states_t; +pub type jl_ptls_t = *mut jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ptls_states() -> jl_ptls_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_sym_t { + pub left: *mut _jl_sym_t, + pub right: *mut _jl_sym_t, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_generic_specptr_t { + pub fptr: *mut ::std::os::raw::c_void, + pub fptr1: jl_fptr_args_t, + pub fptr3: jl_fptr_sparam_t, +} +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: *mut jl_svec_t, + pub speckeyset: *mut jl_array_t, + pub slot_syms: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: *mut _jl_method_instance_t, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub ccallable: *mut jl_svec_t, + pub invokes: *mut jl_typemap_t, + pub nargs: i32, + pub called: i32, + pub nospecialize: i32, + pub nkw: i32, + pub isva: u8, + pub pure_: u8, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: *mut _jl_code_instance_t, + pub inInference: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: *mut _jl_code_instance_t, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: *mut jl_value_t, + pub isspecsig: u8, + pub precompile: u8, + pub invoke: jl_callptr_t, + pub specptr: jl_generic_specptr_t, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub wrapper: *mut jl_value_t, + pub cache: *mut jl_svec_t, + pub linearcache: *mut jl_svec_t, + pub hash: isize, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub names: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub size: i32, + pub ninitialized: i32, + pub hash: u32, + pub abstract_: u8, + pub mutabl: u8, + pub hasfreetypevars: u8, + pub isconcretetype: u8, + pub isdispatchtuple: u8, + pub isbitstype: u8, + pub zeroinit: u8, + pub isinlinealloc: u8, + pub has_concrete_subtype: u8, + pub cached_by_hash: u8, +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: *mut jl_value_t, + pub globalref: *mut jl_value_t, + pub owner: *mut _jl_module_t, + pub constp: u8, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u16; 3usize], +} +impl jl_binding_t { + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(2usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: u64, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: u32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_typemap_entry_t { + pub next: *mut _jl_typemap_entry_t, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_typemap_level_t { + pub arg1: *mut jl_array_t, + pub targ: *mut jl_array_t, + pub name1: *mut jl_array_t, + pub tname: *mut jl_array_t, + pub linear: *mut jl_typemap_entry_t, + pub any: *mut jl_typemap_t, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: *mut jl_typemap_t, + pub leafcache: *mut jl_array_t, + pub cache: *mut jl_typemap_t, + pub max_args: isize, + pub kwsorter: *mut jl_value_t, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +pub type jl_gcframe_t = _jl_gcframe_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_egal(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init__threading(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init_with_image__threading( + julia_bindir: *const ::std::os::raw::c_char, + image_relative_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: i32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreads: i32, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub opt_level: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_value_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + pub pgcstack: *mut ::std::os::raw::c_void, + pub world_age: usize, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_mutex_t { + pub owner: ::std::os::raw::c_ulong, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub _state: u8, + pub sticky: u8, + pub _isexception: u8, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_pgcstack(ptls: *mut jl_tls_states_t) -> *mut *mut jl_gcframe_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_7_32.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_7_32.rs new file mode 100644 index 00000000..65021e78 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_7_32.rs @@ -0,0 +1,2061 @@ +/* generated from julia version 1.7.3 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_tls_states_t = _jl_tls_states_t; +pub type jl_ptls_t = *mut jl_tls_states_t; +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr<_jl_method_instance_t>, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: i32, + pub called: i32, + pub nospecialize: i32, + pub nkw: i32, + pub isva: u8, + pub pure_: u8, + pub is_for_opaque_closure: u8, + pub aggressive_constprop: u8, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub isva: u8, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: *mut jl_value_t, + pub isspecsig: u8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub wrapper: *mut jl_value_t, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub size: i32, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn cached_by_hash(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_cached_by_hash(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u8, + isconcretetype: u8, + isdispatchtuple: u8, + isbitstype: u8, + zeroinit: u8, + has_concrete_subtype: u8, + cached_by_hash: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u8 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u8 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u8 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u8 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u8 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u8 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let cached_by_hash: u8 = unsafe { ::std::mem::transmute(cached_by_hash) }; + cached_by_hash as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: ::std::sync::atomic::AtomicPtr, + pub owner: *mut _jl_module_t, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: u64, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: isize, + pub kwsorter: *mut jl_value_t, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +extern "C-unwind" { + pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; +} +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_init(); +} +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_relative_path: *const ::std::os::raw::c_char, + ); +} +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: i32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreads: i32, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState0: u64, + pub rngState1: u64, + pub rngState2: u64, + pub rngState3: u64, + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub tid: ::std::sync::atomic::AtomicI16, + pub prio: i16, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_7_64.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_7_64.rs new file mode 100644 index 00000000..be3e1c67 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_7_64.rs @@ -0,0 +1,3839 @@ +/* generated from julia version 1.7.3 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_tls_states_t = _jl_tls_states_t; +pub type jl_ptls_t = *mut jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr<_jl_method_instance_t>, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: i32, + pub called: i32, + pub nospecialize: i32, + pub nkw: i32, + pub isva: u8, + pub pure_: u8, + pub is_for_opaque_closure: u8, + pub aggressive_constprop: u8, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub isva: u8, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: *mut jl_value_t, + pub isspecsig: u8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub wrapper: *mut jl_value_t, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub size: i32, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn cached_by_hash(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_cached_by_hash(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u8, + isconcretetype: u8, + isdispatchtuple: u8, + isbitstype: u8, + zeroinit: u8, + has_concrete_subtype: u8, + cached_by_hash: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u8 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u8 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u8 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u8 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u8 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u8 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let cached_by_hash: u8 = unsafe { ::std::mem::transmute(cached_by_hash) }; + cached_by_hash as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: ::std::sync::atomic::AtomicPtr, + pub owner: *mut _jl_module_t, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: u64, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: isize, + pub kwsorter: *mut jl_value_t, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_relative_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: i32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreads: i32, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState0: u64, + pub rngState1: u64, + pub rngState2: u64, + pub rngState3: u64, + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub tid: ::std::sync::atomic::AtomicI16, + pub prio: i16, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_8_32.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_8_32.rs new file mode 100644 index 00000000..e6e425fb --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_8_32.rs @@ -0,0 +1,2178 @@ +/* generated from julia version 1.8.5 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_tls_states_t = _jl_tls_states_t; +pub type jl_ptls_t = *mut jl_tls_states_t; +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates: u8, + ipo_terminates_locally: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates: u8 = unsafe { ::std::mem::transmute(ipo_terminates) }; + ipo_terminates as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr<_jl_method_instance_t>, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub pure_: u8, + pub is_for_opaque_closure: u8, + pub constprop: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub precompiled: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: *mut jl_value_t, + pub ipo_purity_bits: u32, + pub purity_bits: u32, + pub argescapes: *mut jl_value_t, + pub isspecsig: u8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, + pub relocatability: u8, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub size: i32, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn cached_by_hash(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_cached_by_hash(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u8, + isconcretetype: u8, + isdispatchtuple: u8, + isbitstype: u8, + zeroinit: u8, + has_concrete_subtype: u8, + cached_by_hash: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u8 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u8 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u8 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u8 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u8 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u8 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let cached_by_hash: u8 = unsafe { ::std::mem::transmute(cached_by_hash) }; + cached_by_hash as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: ::std::sync::atomic::AtomicPtr, + pub owner: *mut _jl_module_t, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: u64, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: isize, + pub kwsorter: *mut jl_value_t, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +extern "C-unwind" { + pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; +} +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_init(); +} +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_relative_path: *const ::std::os::raw::c_char, + ); +} +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreads: i32, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 4usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub tid: ::std::sync::atomic::AtomicI16, + pub prio: i16, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_8_64.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_8_64.rs new file mode 100644 index 00000000..30137933 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_8_64.rs @@ -0,0 +1,3970 @@ +/* generated from julia version 1.8.5 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_tls_states_t = _jl_tls_states_t; +pub type jl_ptls_t = *mut jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates: u8, + ipo_terminates_locally: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates: u8 = unsafe { ::std::mem::transmute(ipo_terminates) }; + ipo_terminates as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr<_jl_method_instance_t>, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub pure_: u8, + pub is_for_opaque_closure: u8, + pub constprop: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub precompiled: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: *mut jl_value_t, + pub ipo_purity_bits: u32, + pub purity_bits: u32, + pub argescapes: *mut jl_value_t, + pub isspecsig: u8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, + pub relocatability: u8, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub size: i32, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn cached_by_hash(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_cached_by_hash(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u8, + isconcretetype: u8, + isdispatchtuple: u8, + isbitstype: u8, + zeroinit: u8, + has_concrete_subtype: u8, + cached_by_hash: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u8 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u8 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u8 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u8 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u8 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u8 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let cached_by_hash: u8 = unsafe { ::std::mem::transmute(cached_by_hash) }; + cached_by_hash as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: ::std::sync::atomic::AtomicPtr, + pub owner: *mut _jl_module_t, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: u64, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: isize, + pub kwsorter: *mut jl_value_t, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_kwsorter(ty: *mut jl_value_t) -> *mut jl_function_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_relative_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreads: i32, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 4usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub tid: ::std::sync::atomic::AtomicI16, + pub prio: i16, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_9_32.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_9_32.rs new file mode 100644 index 00000000..77945107 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_9_32.rs @@ -0,0 +1,2281 @@ +/* generated from julia version 1.9.2 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u32; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(4))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u32) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u32) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize, in_image: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u32 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u32 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr<_jl_method_instance_t>, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub pure_: u8, + pub is_for_opaque_closure: u8, + pub constprop: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn cached_by_hash(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_cached_by_hash(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u8) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u8, + isconcretetype: u8, + isdispatchtuple: u8, + isbitstype: u8, + zeroinit: u8, + has_concrete_subtype: u8, + cached_by_hash: u8, + isprimitivetype: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u8 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u8 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u8 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u8 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u8 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u8 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let cached_by_hash: u8 = unsafe { ::std::mem::transmute(cached_by_hash) }; + cached_by_hash as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u8 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: ::std::sync::atomic::AtomicPtr, + pub owner: *mut _jl_module_t, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: isize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +extern "C-unwind" { + pub fn jl_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_init(); +} +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +extern "C-unwind" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +extern "C" { + pub static mut jl_options: jl_options_t; +} +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 4usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jl_enter_threaded_region(); +} +extern "C-unwind" { + pub fn jl_exit_threaded_region(); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_1_9_64.rs b/jl_sys/src/bindings_unwind/bindings_unwind_1_9_64.rs new file mode 100644 index 00000000..12c29895 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_1_9_64.rs @@ -0,0 +1,4101 @@ +/* generated from julia version 1.9.2 */ +#[repr(C)] +#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct __BindgenBitfieldUnit { + storage: Storage, +} +impl __BindgenBitfieldUnit { + #[inline] + pub const fn new(storage: Storage) -> Self { + Self { storage } + } +} +impl __BindgenBitfieldUnit +where + Storage: AsRef<[u8]> + AsMut<[u8]>, +{ + #[inline] + pub fn get_bit(&self, index: usize) -> bool { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = self.storage.as_ref()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + byte & mask == mask + } + #[inline] + pub fn set_bit(&mut self, index: usize, val: bool) { + debug_assert!(index / 8 < self.storage.as_ref().len()); + let byte_index = index / 8; + let byte = &mut self.storage.as_mut()[byte_index]; + let bit_index = if cfg!(target_endian = "big") { + 7 - (index % 8) + } else { + index % 8 + }; + let mask = 1 << bit_index; + if val { + *byte |= mask; + } else { + *byte &= !mask; + } + } + #[inline] + pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + let mut val = 0; + for i in 0..(bit_width as usize) { + if self.get_bit(i + bit_offset) { + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + val |= 1 << index; + } + } + val + } + #[inline] + pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) { + debug_assert!(bit_width <= 64); + debug_assert!(bit_offset / 8 < self.storage.as_ref().len()); + debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len()); + for i in 0..(bit_width as usize) { + let mask = 1 << i; + let val_bit_is_set = val & mask == mask; + let index = if cfg!(target_endian = "big") { + bit_width as usize - 1 - i + } else { + i + }; + self.set_bit(index + bit_offset, val_bit_is_set); + } + } +} +pub type jl_gcframe_t = _jl_gcframe_t; +pub type uint_t = u64; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct htable_t { + pub size: usize, + pub table: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 32usize], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct arraylist_t { + pub len: usize, + pub max: usize, + pub items: *mut *mut ::std::os::raw::c_void, + pub _space: [*mut ::std::os::raw::c_void; 29usize], +} +pub type jl_taggedvalue_t = _jl_taggedvalue_t; +pub type jl_ptls_t = *mut _jl_tls_states_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ptls_states() -> *mut ::std::os::raw::c_void; +} +pub type jl_value_t = _jl_value_t; +#[repr(C)] +#[repr(align(8))] +#[derive(Debug, Copy, Clone)] +pub struct _jl_taggedvalue_bits { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl _jl_taggedvalue_bits { + #[inline] + pub fn gc(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u64) } + } + #[inline] + pub fn set_gc(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn in_image(&self) -> usize { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u64) } + } + #[inline] + pub fn set_in_image(&mut self, val: usize) { + unsafe { + let val: u64 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(gc: usize, in_image: usize) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let gc: u64 = unsafe { ::std::mem::transmute(gc) }; + gc as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let in_image: u64 = unsafe { ::std::mem::transmute(in_image) }; + in_image as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct _jl_taggedvalue_t { + pub __bindgen_anon_1: _jl_taggedvalue_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_taggedvalue_t__bindgen_ty_1 { + pub header: usize, + pub next: *mut jl_taggedvalue_t, + pub type_: *mut jl_value_t, + pub bits: _jl_taggedvalue_bits, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_sym_t { + pub left: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub right: ::std::sync::atomic::AtomicPtr<_jl_sym_t>, + pub hash: usize, +} +pub type jl_sym_t = _jl_sym_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_svec_t { + pub length: usize, +} +#[repr(C)] +#[repr(align(2))] +#[derive(Debug, Copy, Clone)] +pub struct jl_array_flags_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, +} +impl jl_array_flags_t { + #[inline] + pub fn how(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 2u8) as u16) } + } + #[inline] + pub fn set_how(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 2u8, val as u64) + } + } + #[inline] + pub fn ndims(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 9u8) as u16) } + } + #[inline] + pub fn set_ndims(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 9u8, val as u64) + } + } + #[inline] + pub fn pooled(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(11usize, 1u8) as u16) } + } + #[inline] + pub fn set_pooled(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(11usize, 1u8, val as u64) + } + } + #[inline] + pub fn ptrarray(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(12usize, 1u8) as u16) } + } + #[inline] + pub fn set_ptrarray(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(12usize, 1u8, val as u64) + } + } + #[inline] + pub fn hasptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(13usize, 1u8) as u16) } + } + #[inline] + pub fn set_hasptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(13usize, 1u8, val as u64) + } + } + #[inline] + pub fn isshared(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(14usize, 1u8) as u16) } + } + #[inline] + pub fn set_isshared(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(14usize, 1u8, val as u64) + } + } + #[inline] + pub fn isaligned(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(15usize, 1u8) as u16) } + } + #[inline] + pub fn set_isaligned(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(15usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + how: u16, + ndims: u16, + pooled: u16, + ptrarray: u16, + hasptr: u16, + isshared: u16, + isaligned: u16, + ) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 2u8, { + let how: u16 = unsafe { ::std::mem::transmute(how) }; + how as u64 + }); + __bindgen_bitfield_unit.set(2usize, 9u8, { + let ndims: u16 = unsafe { ::std::mem::transmute(ndims) }; + ndims as u64 + }); + __bindgen_bitfield_unit.set(11usize, 1u8, { + let pooled: u16 = unsafe { ::std::mem::transmute(pooled) }; + pooled as u64 + }); + __bindgen_bitfield_unit.set(12usize, 1u8, { + let ptrarray: u16 = unsafe { ::std::mem::transmute(ptrarray) }; + ptrarray as u64 + }); + __bindgen_bitfield_unit.set(13usize, 1u8, { + let hasptr: u16 = unsafe { ::std::mem::transmute(hasptr) }; + hasptr as u64 + }); + __bindgen_bitfield_unit.set(14usize, 1u8, { + let isshared: u16 = unsafe { ::std::mem::transmute(isshared) }; + isshared as u64 + }); + __bindgen_bitfield_unit.set(15usize, 1u8, { + let isaligned: u16 = unsafe { ::std::mem::transmute(isaligned) }; + isaligned as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Copy, Clone)] +pub struct jl_array_t { + pub data: *mut ::std::os::raw::c_void, + pub length: usize, + pub flags: jl_array_flags_t, + pub elsize: u16, + pub offset: u32, + pub nrows: usize, + pub __bindgen_anon_1: jl_array_t__bindgen_ty_1, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union jl_array_t__bindgen_ty_1 { + pub maxsize: usize, + pub ncols: usize, +} +pub type jl_tupletype_t = _jl_datatype_t; +pub type jl_typemap_t = jl_value_t; +pub type jl_call_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut _jl_code_instance_t, + ) -> *mut jl_value_t, +>; +pub type jl_callptr_t = jl_call_t; +pub type jl_fptr_args_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + ) -> *mut jl_value_t, +>; +pub type jl_fptr_sparam_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut jl_value_t, + arg2: *mut *mut jl_value_t, + arg3: u32, + arg4: *mut jl_svec_t, + ) -> *mut jl_value_t, +>; +pub type jl_method_instance_t = _jl_method_instance_t; +#[repr(C)] +#[derive(Copy, Clone)] +pub union __jl_purity_overrides_t { + pub overrides: __jl_purity_overrides_t__bindgen_ty_1, + pub bits: u8, +} +#[repr(C, packed)] +#[derive(Debug, Copy, Clone)] +pub struct __jl_purity_overrides_t__bindgen_ty_1 { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, +} +impl __jl_purity_overrides_t__bindgen_ty_1 { + #[inline] + pub fn ipo_consistent(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_consistent(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_effect_free(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_effect_free(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_nothrow(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_nothrow(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_globally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_globally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_terminates_locally(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_terminates_locally(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_notaskstate(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_notaskstate(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn ipo_inaccessiblememonly(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_ipo_inaccessiblememonly(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + ipo_consistent: u8, + ipo_effect_free: u8, + ipo_nothrow: u8, + ipo_terminates_globally: u8, + ipo_terminates_locally: u8, + ipo_notaskstate: u8, + ipo_inaccessiblememonly: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let ipo_consistent: u8 = unsafe { ::std::mem::transmute(ipo_consistent) }; + ipo_consistent as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let ipo_effect_free: u8 = unsafe { ::std::mem::transmute(ipo_effect_free) }; + ipo_effect_free as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let ipo_nothrow: u8 = unsafe { ::std::mem::transmute(ipo_nothrow) }; + ipo_nothrow as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let ipo_terminates_globally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_globally) }; + ipo_terminates_globally as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let ipo_terminates_locally: u8 = + unsafe { ::std::mem::transmute(ipo_terminates_locally) }; + ipo_terminates_locally as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let ipo_notaskstate: u8 = unsafe { ::std::mem::transmute(ipo_notaskstate) }; + ipo_notaskstate as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let ipo_inaccessiblememonly: u8 = + unsafe { ::std::mem::transmute(ipo_inaccessiblememonly) }; + ipo_inaccessiblememonly as u64 + }); + __bindgen_bitfield_unit + } +} +pub type _jl_purity_overrides_t = __jl_purity_overrides_t; +#[repr(C)] +pub struct _jl_method_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub file: *mut jl_sym_t, + pub line: i32, + pub primary_world: usize, + pub deleted_world: usize, + pub sig: *mut jl_value_t, + pub specializations: ::std::sync::atomic::AtomicPtr, + pub speckeyset: ::std::sync::atomic::AtomicPtr, + pub slot_syms: *mut jl_value_t, + pub external_mt: *mut jl_value_t, + pub source: *mut jl_value_t, + pub unspecialized: ::std::sync::atomic::AtomicPtr<_jl_method_instance_t>, + pub generator: *mut jl_value_t, + pub roots: *mut jl_array_t, + pub root_blocks: *mut jl_array_t, + pub nroots_sysimg: i32, + pub ccallable: *mut jl_svec_t, + pub invokes: ::std::sync::atomic::AtomicPtr, + pub recursion_relation: *mut jl_value_t, + pub nargs: u32, + pub called: u32, + pub nospecialize: u32, + pub nkw: u32, + pub isva: u8, + pub pure_: u8, + pub is_for_opaque_closure: u8, + pub constprop: u8, + pub purity: _jl_purity_overrides_t, + pub writelock: jl_mutex_t, +} +pub type jl_method_t = _jl_method_t; +#[repr(C)] +pub struct _jl_method_instance_t { + pub def: _jl_method_instance_t__bindgen_ty_1, + pub specTypes: *mut jl_value_t, + pub sparam_vals: *mut jl_svec_t, + pub uninferred: *mut jl_value_t, + pub backedges: *mut jl_array_t, + pub callbacks: *mut jl_array_t, + pub cache: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub inInference: u8, + pub cache_with_orig: u8, + pub precompiled: u8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_method_instance_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub module: *mut _jl_module_t, + pub method: *mut jl_method_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_opaque_closure_t { + pub captures: *mut jl_value_t, + pub world: usize, + pub source: *mut jl_method_t, + pub invoke: jl_fptr_args_t, + pub specptr: *mut ::std::os::raw::c_void, +} +#[repr(C)] +pub struct _jl_code_instance_t { + pub def: *mut jl_method_instance_t, + pub next: ::std::sync::atomic::AtomicPtr<_jl_code_instance_t>, + pub min_world: usize, + pub max_world: usize, + pub rettype: *mut jl_value_t, + pub rettype_const: *mut jl_value_t, + pub inferred: ::std::sync::atomic::AtomicPtr, + pub ipo_purity_bits: u32, + pub purity_bits: ::std::sync::atomic::AtomicU32, + pub argescapes: *mut jl_value_t, + pub specsigflags: ::std::sync::atomic::AtomicU8, + pub precompile: ::std::sync::atomic::AtomicU8, + pub relocatability: u8, + pub invoke: ::atomic::Atomic, + pub specptr: _jl_code_instance_t__jl_generic_specptr_t, +} +#[repr(C)] +pub union _jl_code_instance_t__jl_generic_specptr_t { + pub fptr: ::std::mem::ManuallyDrop<::std::sync::atomic::AtomicPtr<::std::ffi::c_void>>, + pub fptr1: ::std::mem::ManuallyDrop<::atomic::Atomic>, + pub fptr3: ::std::mem::ManuallyDrop<::atomic::Atomic>, +} +pub type jl_code_instance_t = _jl_code_instance_t; +pub type jl_function_t = jl_value_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_tvar_t { + pub name: *mut jl_sym_t, + pub lb: *mut jl_value_t, + pub ub: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_unionall_t { + pub var: *mut jl_tvar_t, + pub body: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_typename_t { + pub name: *mut jl_sym_t, + pub module: *mut _jl_module_t, + pub names: *mut jl_svec_t, + pub atomicfields: *const u32, + pub constfields: *const u32, + pub wrapper: *mut jl_value_t, + pub Typeofwrapper: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub linearcache: ::std::sync::atomic::AtomicPtr, + pub mt: *mut _jl_methtable_t, + pub partial: *mut jl_array_t, + pub hash: isize, + pub n_uninitialized: i32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub max_methods: u8, +} +impl jl_typename_t { + #[inline] + pub fn abstract_(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_abstract(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn mutabl(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_mutabl(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn mayinlinealloc(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_mayinlinealloc(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn _reserved(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 5u8) as u8) } + } + #[inline] + pub fn set__reserved(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 5u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + abstract_: u8, + mutabl: u8, + mayinlinealloc: u8, + _reserved: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let abstract_: u8 = unsafe { ::std::mem::transmute(abstract_) }; + abstract_ as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let mutabl: u8 = unsafe { ::std::mem::transmute(mutabl) }; + mutabl as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let mayinlinealloc: u8 = unsafe { ::std::mem::transmute(mayinlinealloc) }; + mayinlinealloc as u64 + }); + __bindgen_bitfield_unit.set(3usize, 5u8, { + let _reserved: u8 = unsafe { ::std::mem::transmute(_reserved) }; + _reserved as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uniontype_t { + pub a: *mut jl_value_t, + pub b: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc8_t { + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub offset: u8, +} +impl jl_fielddesc8_t { + #[inline] + pub fn isptr(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_isptr(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 7u8) as u8) } + } + #[inline] + pub fn set_size(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 7u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u8, size: u8) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u8 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 7u8, { + let size: u8 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc16_t { + pub _bitfield_align_1: [u16; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 2usize]>, + pub offset: u16, +} +impl jl_fielddesc16_t { + #[inline] + pub fn isptr(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_isptr(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 15u8) as u16) } + } + #[inline] + pub fn set_size(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 15u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u16, size: u16) -> __BindgenBitfieldUnit<[u8; 2usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 2usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u16 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 15u8, { + let size: u16 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_fielddesc32_t { + pub _bitfield_align_1: [u32; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize]>, + pub offset: u32, +} +impl jl_fielddesc32_t { + #[inline] + pub fn isptr(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u32) } + } + #[inline] + pub fn set_isptr(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn size(&self) -> u32 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 31u8) as u32) } + } + #[inline] + pub fn set_size(&mut self, val: u32) { + unsafe { + let val: u32 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 31u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1(isptr: u32, size: u32) -> __BindgenBitfieldUnit<[u8; 4usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 4usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let isptr: u32 = unsafe { ::std::mem::transmute(isptr) }; + isptr as u64 + }); + __bindgen_bitfield_unit.set(1usize, 31u8, { + let size: u32 = unsafe { ::std::mem::transmute(size) }; + size as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_datatype_layout_t { + pub size: u32, + pub nfields: u32, + pub npointers: u32, + pub first_ptr: i32, + pub alignment: u16, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: u8, +} +impl jl_datatype_layout_t { + #[inline] + pub fn haspadding(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u16) } + } + #[inline] + pub fn set_haspadding(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn fielddesc_type(&self) -> u16 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 2u8) as u16) } + } + #[inline] + pub fn set_fielddesc_type(&mut self, val: u16) { + unsafe { + let val: u16 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + haspadding: u16, + fielddesc_type: u16, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let haspadding: u16 = unsafe { ::std::mem::transmute(haspadding) }; + haspadding as u64 + }); + __bindgen_bitfield_unit.set(1usize, 2u8, { + let fielddesc_type: u16 = unsafe { ::std::mem::transmute(fielddesc_type) }; + fielddesc_type as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_datatype_t { + pub name: *mut jl_typename_t, + pub super_: *mut _jl_datatype_t, + pub parameters: *mut jl_svec_t, + pub types: *mut jl_svec_t, + pub instance: *mut jl_value_t, + pub layout: *const jl_datatype_layout_t, + pub hash: u32, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 3usize], +} +impl _jl_datatype_t { + #[inline] + pub fn hasfreetypevars(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_hasfreetypevars(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn isconcretetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_isconcretetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn isdispatchtuple(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_isdispatchtuple(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn isbitstype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 1u8) as u8) } + } + #[inline] + pub fn set_isbitstype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 1u8, val as u64) + } + } + #[inline] + pub fn zeroinit(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(4usize, 1u8) as u8) } + } + #[inline] + pub fn set_zeroinit(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(4usize, 1u8, val as u64) + } + } + #[inline] + pub fn has_concrete_subtype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(5usize, 1u8) as u8) } + } + #[inline] + pub fn set_has_concrete_subtype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(5usize, 1u8, val as u64) + } + } + #[inline] + pub fn cached_by_hash(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(6usize, 1u8) as u8) } + } + #[inline] + pub fn set_cached_by_hash(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(6usize, 1u8, val as u64) + } + } + #[inline] + pub fn isprimitivetype(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(7usize, 1u8) as u8) } + } + #[inline] + pub fn set_isprimitivetype(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(7usize, 1u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + hasfreetypevars: u8, + isconcretetype: u8, + isdispatchtuple: u8, + isbitstype: u8, + zeroinit: u8, + has_concrete_subtype: u8, + cached_by_hash: u8, + isprimitivetype: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let hasfreetypevars: u8 = unsafe { ::std::mem::transmute(hasfreetypevars) }; + hasfreetypevars as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let isconcretetype: u8 = unsafe { ::std::mem::transmute(isconcretetype) }; + isconcretetype as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let isdispatchtuple: u8 = unsafe { ::std::mem::transmute(isdispatchtuple) }; + isdispatchtuple as u64 + }); + __bindgen_bitfield_unit.set(3usize, 1u8, { + let isbitstype: u8 = unsafe { ::std::mem::transmute(isbitstype) }; + isbitstype as u64 + }); + __bindgen_bitfield_unit.set(4usize, 1u8, { + let zeroinit: u8 = unsafe { ::std::mem::transmute(zeroinit) }; + zeroinit as u64 + }); + __bindgen_bitfield_unit.set(5usize, 1u8, { + let has_concrete_subtype: u8 = unsafe { ::std::mem::transmute(has_concrete_subtype) }; + has_concrete_subtype as u64 + }); + __bindgen_bitfield_unit.set(6usize, 1u8, { + let cached_by_hash: u8 = unsafe { ::std::mem::transmute(cached_by_hash) }; + cached_by_hash as u64 + }); + __bindgen_bitfield_unit.set(7usize, 1u8, { + let isprimitivetype: u8 = unsafe { ::std::mem::transmute(isprimitivetype) }; + isprimitivetype as u64 + }); + __bindgen_bitfield_unit + } +} +pub type jl_datatype_t = _jl_datatype_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_vararg_t { + pub T: *mut jl_value_t, + pub N: *mut jl_value_t, +} +pub type jl_vararg_t = _jl_vararg_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_weakref_t { + pub value: *mut jl_value_t, +} +#[repr(C)] +#[derive(Debug)] +pub struct jl_binding_t { + pub name: *mut jl_sym_t, + pub value: ::std::sync::atomic::AtomicPtr, + pub globalref: ::std::sync::atomic::AtomicPtr, + pub owner: *mut _jl_module_t, + pub ty: ::std::sync::atomic::AtomicPtr, + pub _bitfield_align_1: [u8; 0], + pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize]>, + pub __bindgen_padding_0: [u8; 7usize], +} +impl jl_binding_t { + #[inline] + pub fn constp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) } + } + #[inline] + pub fn set_constp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(0usize, 1u8, val as u64) + } + } + #[inline] + pub fn exportp(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(1usize, 1u8) as u8) } + } + #[inline] + pub fn set_exportp(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(1usize, 1u8, val as u64) + } + } + #[inline] + pub fn imported(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(2usize, 1u8) as u8) } + } + #[inline] + pub fn set_imported(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(2usize, 1u8, val as u64) + } + } + #[inline] + pub fn deprecated(&self) -> u8 { + unsafe { ::std::mem::transmute(self._bitfield_1.get(3usize, 2u8) as u8) } + } + #[inline] + pub fn set_deprecated(&mut self, val: u8) { + unsafe { + let val: u8 = ::std::mem::transmute(val); + self._bitfield_1.set(3usize, 2u8, val as u64) + } + } + #[inline] + pub fn new_bitfield_1( + constp: u8, + exportp: u8, + imported: u8, + deprecated: u8, + ) -> __BindgenBitfieldUnit<[u8; 1usize]> { + let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize]> = Default::default(); + __bindgen_bitfield_unit.set(0usize, 1u8, { + let constp: u8 = unsafe { ::std::mem::transmute(constp) }; + constp as u64 + }); + __bindgen_bitfield_unit.set(1usize, 1u8, { + let exportp: u8 = unsafe { ::std::mem::transmute(exportp) }; + exportp as u64 + }); + __bindgen_bitfield_unit.set(2usize, 1u8, { + let imported: u8 = unsafe { ::std::mem::transmute(imported) }; + imported as u64 + }); + __bindgen_bitfield_unit.set(3usize, 2u8, { + let deprecated: u8 = unsafe { ::std::mem::transmute(deprecated) }; + deprecated as u64 + }); + __bindgen_bitfield_unit + } +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_uuid_t { + pub hi: u64, + pub lo: u64, +} +#[repr(C)] +#[derive(Debug)] +pub struct _jl_module_t { + pub name: *mut jl_sym_t, + pub parent: *mut _jl_module_t, + pub bindings: htable_t, + pub usings: arraylist_t, + pub build_id: jl_uuid_t, + pub uuid: jl_uuid_t, + pub primary_world: usize, + pub counter: ::std::sync::atomic::AtomicU32, + pub nospecialize: i32, + pub optlevel: i8, + pub compile: i8, + pub infer: i8, + pub istopmod: u8, + pub max_methods: i8, + pub lock: jl_mutex_t, +} +pub type jl_module_t = _jl_module_t; +#[repr(C)] +pub struct _jl_typemap_entry_t { + pub next: ::std::sync::atomic::AtomicPtr<_jl_typemap_entry_t>, + pub sig: *mut jl_tupletype_t, + pub simplesig: *mut jl_tupletype_t, + pub guardsigs: *mut jl_svec_t, + pub min_world: usize, + pub max_world: usize, + pub func: _jl_typemap_entry_t__bindgen_ty_1, + pub isleafsig: i8, + pub issimplesig: i8, + pub va: i8, +} +#[repr(C)] +#[derive(Copy, Clone)] +pub union _jl_typemap_entry_t__bindgen_ty_1 { + pub value: *mut jl_value_t, + pub linfo: *mut jl_method_instance_t, + pub method: *mut jl_method_t, +} +pub type jl_typemap_entry_t = _jl_typemap_entry_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_typemap_level_t { + pub arg1: ::std::sync::atomic::AtomicPtr, + pub targ: ::std::sync::atomic::AtomicPtr, + pub name1: ::std::sync::atomic::AtomicPtr, + pub tname: ::std::sync::atomic::AtomicPtr, + pub linear: ::std::sync::atomic::AtomicPtr, + pub any: ::std::sync::atomic::AtomicPtr, +} +pub type jl_typemap_level_t = _jl_typemap_level_t; +#[repr(C)] +#[derive(Debug)] +pub struct _jl_methtable_t { + pub name: *mut jl_sym_t, + pub defs: ::std::sync::atomic::AtomicPtr, + pub leafcache: ::std::sync::atomic::AtomicPtr, + pub cache: ::std::sync::atomic::AtomicPtr, + pub max_args: isize, + pub module: *mut jl_module_t, + pub backedges: *mut jl_array_t, + pub writelock: jl_mutex_t, + pub offs: u8, + pub frozen: u8, +} +pub type jl_methtable_t = _jl_methtable_t; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_expr_t { + pub head: *mut jl_sym_t, + pub args: *mut jl_array_t, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_method_match_t { + pub spec_types: *mut jl_tupletype_t, + pub sparams: *mut jl_svec_t, + pub method: *mut jl_method_t, + pub fully_covers: u8, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeofbottom_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_datatype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uniontype_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_unionall_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tvar_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_any_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typename_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_type_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_symbol_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ssavalue_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_slotnumber_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typedslot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argument_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_const_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_struct_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_partial_opaque_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interconditional_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_match_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_simplevector_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_tuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vecelement_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_anytuple_type_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_vararg_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_function_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_builtin_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_opaque_closure_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bottom_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_instance_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_code_info_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_method_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_module_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractarray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_densearray_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_weakref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_abstractstring_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_string_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_errorexception_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_argumenterror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_loaderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_initerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typeerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methoderror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefvarerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_atomicerror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_lineinfonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_stackovf_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_memory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_readonlymemory_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_diverror_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_undefref_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_interrupt_exception: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_boundserror_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_vec_any: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_an_empty_string: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_bool_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_char_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint8_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_int64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_uint64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float16_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float32_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_float64_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_floatingpoint_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_number_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_signed_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_voidpointer_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_ref_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_llvmpointer_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_typename: *mut jl_typename_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_namedtuple_type: *mut jl_unionall_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_task_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pair_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_uint8_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_any_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_symbol_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_array_int32_type: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_expr_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_globalref_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_linenumbernode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotonode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_gotoifnot_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_returnnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_pinode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_phicnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_upsilonnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_quotenode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_newvarnode_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_intrinsic_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_methtable_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_level_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_typemap_entry_type: *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptysvec: *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_emptytuple: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_true: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_false: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_nothing: *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_kwcall_func: *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_gcframe_t { + pub nroots: usize, + pub prev: *mut _jl_gcframe_t, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_enable(on: ::std::os::raw::c_int) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_is_enabled() -> ::std::os::raw::c_int; +} +pub const jl_gc_collection_t_JL_GC_AUTO: jl_gc_collection_t = 0; +pub const jl_gc_collection_t_JL_GC_FULL: jl_gc_collection_t = 1; +pub const jl_gc_collection_t_JL_GC_INCREMENTAL: jl_gc_collection_t = 2; +pub type jl_gc_collection_t = ::std::os::raw::c_uint; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_collect(arg1: jl_gc_collection_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_finalizer(v: *mut jl_value_t, f: *mut jl_function_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_add_ptr_finalizer( + ptls: jl_ptls_t, + v: *mut jl_value_t, + f: *mut ::std::os::raw::c_void, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_queue_root(root: *const jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_safepoint(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_typetagdata(a: *mut jl_array_t) -> *mut ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_compute_fieldtypes( + st: *mut jl_datatype_t, + stack: *mut ::std::os::raw::c_void, + ) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_subtype(a: *mut jl_value_t, b: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_egal(a: *const jl_value_t, b: *const jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_object_id(v: *mut jl_value_t) -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_has_free_typevars(v: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_isa(a: *mut jl_value_t, t: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_union(ts: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_type_unionall(v: *mut jl_tvar_t, body: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typename_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_typeof_str(v: *mut jl_value_t) -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_typevar( + name: *mut jl_sym_t, + lb: *mut jl_value_t, + ub: *mut jl_value_t, + ) -> *mut jl_tvar_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_type( + tc: *mut jl_value_t, + params: *mut *mut jl_value_t, + n: usize, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_tuple_type_v(p: *mut *mut jl_value_t, np: usize) -> *mut jl_tupletype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_datatype( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + fnames: *mut jl_svec_t, + ftypes: *mut jl_svec_t, + fattrs: *mut jl_svec_t, + abstract_: ::std::os::raw::c_int, + mutabl: ::std::os::raw::c_int, + ninitialized: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_primitivetype( + name: *mut jl_value_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + parameters: *mut jl_svec_t, + nbits: usize, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_new_bits( + dt: *mut jl_value_t, + src: *const ::std::os::raw::c_char, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_store_bits( + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_swap_bits( + dt: *mut jl_value_t, + dst: *mut ::std::os::raw::c_char, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_bool_cmpswap_bits( + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atomic_cmpswap_bits( + dt: *mut jl_datatype_t, + rettype: *mut jl_datatype_t, + dst: *mut ::std::os::raw::c_char, + expected: *const jl_value_t, + src: *const jl_value_t, + nb: ::std::os::raw::c_int, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_structv( + type_: *mut jl_datatype_t, + args: *mut *mut jl_value_t, + na: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_struct_uninit(type_: *mut jl_datatype_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_svec_uninit(n: usize) -> *mut jl_svec_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol(str_: *const ::std::os::raw::c_char) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_symbol_n(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gensym() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_tagged_gensym(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_world_counter() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_bool(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int8(x: i8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint8(x: u8) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int16(x: i16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint16(x: u16) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int32(x: i32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint32(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_char(x: u32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_int64(x: i64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_uint64(x: u64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float32(x: f32) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_float64(x: f64) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_box_voidpointer(x: *mut ::std::os::raw::c_void) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int8(v: *mut jl_value_t) -> i8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint8(v: *mut jl_value_t) -> u8; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int16(v: *mut jl_value_t) -> i16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint16(v: *mut jl_value_t) -> u16; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int32(v: *mut jl_value_t) -> i32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint32(v: *mut jl_value_t) -> u32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_int64(v: *mut jl_value_t) -> i64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_uint64(v: *mut jl_value_t) -> u64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float32(v: *mut jl_value_t) -> f32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_float64(v: *mut jl_value_t) -> f64; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_unbox_voidpointer(v: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_field_index( + t: *mut jl_datatype_t, + fld: *mut jl_sym_t, + err: ::std::os::raw::c_int, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_nth_field_noalloc(v: *mut jl_value_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_nth_field(v: *mut jl_value_t, i: usize, rhs: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_islayout_inline( + eltype: *mut jl_value_t, + fsz: *mut usize, + al: *mut usize, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_array(atype: *mut jl_value_t, dims: *mut jl_value_t) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reshape_array( + atype: *mut jl_value_t, + data: *mut jl_array_t, + dims: *mut jl_value_t, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array_1d( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + nel: usize, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ptr_to_array( + atype: *mut jl_value_t, + data: *mut ::std::os::raw::c_void, + dims: *mut jl_value_t, + own_buffer: ::std::os::raw::c_int, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_1d(atype: *mut jl_value_t, nr: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_2d(atype: *mut jl_value_t, nr: usize, nc: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_alloc_array_3d( + atype: *mut jl_value_t, + nr: usize, + nc: usize, + z: usize, + ) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_array(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_array_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_pchar_to_string(str_: *const ::std::os::raw::c_char, len: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayref(a: *mut jl_array_t, i: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_arrayset(a: *mut jl_array_t, v: *mut jl_value_t, i: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_end(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_end(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_grow_beg(a: *mut jl_array_t, inc: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_del_beg(a: *mut jl_array_t, dec: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_push(a: *mut jl_array_t, item: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_ptr_1d_append(a: *mut jl_array_t, a2: *mut jl_array_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_array_type(type_: *mut jl_value_t, dim: usize) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_array_eltype(a: *mut jl_value_t) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_main_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_core_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_base_module: *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_module(name: *mut jl_sym_t) -> *mut jl_module_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_binding_type(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_global(m: *mut jl_module_t, var: *mut jl_sym_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_global(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_set_const(m: *mut jl_module_t, var: *mut jl_sym_t, val: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_imported(m: *mut jl_module_t, s: *mut jl_sym_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_cpu_threads() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getpagesize() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_getallocationgranularity() -> ::std::os::raw::c_long; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_debugbuild() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_UNAME() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_ARCH() -> *mut jl_sym_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_libllvm() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_n_threads: ::std::sync::atomic::AtomicI32; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_environ(i: ::std::os::raw::c_int) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_current_exception() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exception_occurred() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_init_with_image( + julia_bindir: *const ::std::os::raw::c_char, + image_path: *const ::std::os::raw::c_char, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_is_initialized() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_atexit_hook(status: ::std::os::raw::c_int); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_adopt_thread() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eval_string(str_: *const ::std::os::raw::c_char) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_apply_generic( + F: *mut jl_value_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call( + f: *mut jl_function_t, + args: *mut *mut jl_value_t, + nargs: u32, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call0(f: *mut jl_function_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call1(f: *mut jl_function_t, a: *mut jl_value_t) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call2( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_call3( + f: *mut jl_function_t, + a: *mut jl_value_t, + b: *mut jl_value_t, + c: *mut jl_value_t, + ) -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_yield(); +} +pub type jl_handler_t = _jl_handler_t; +pub type jl_task_t = _jl_task_t; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_throw(e: *mut jl_value_t) -> !; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_pgcstack() -> *mut *mut jl_gcframe_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_handler(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_eh_restore_state(eh: *mut jl_handler_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_excstack_state() -> usize; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_restore_excstack(state: usize); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_process_events() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stdout_obj() -> *mut jl_value_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_stderr_obj() -> *mut jl_value_t; +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jl_options_t { + pub quiet: i8, + pub banner: i8, + pub julia_bindir: *const ::std::os::raw::c_char, + pub julia_bin: *const ::std::os::raw::c_char, + pub cmds: *mut *const ::std::os::raw::c_char, + pub image_file: *const ::std::os::raw::c_char, + pub cpu_target: *const ::std::os::raw::c_char, + pub nthreadpools: i8, + pub nthreads: i16, + pub nthreads_per_pool: *const i16, + pub nprocs: i32, + pub machine_file: *const ::std::os::raw::c_char, + pub project: *const ::std::os::raw::c_char, + pub isinteractive: i8, + pub color: i8, + pub historyfile: i8, + pub startupfile: i8, + pub compile_enabled: i8, + pub code_coverage: i8, + pub malloc_log: i8, + pub tracked_path: *const ::std::os::raw::c_char, + pub opt_level: i8, + pub opt_level_min: i8, + pub debug_level: i8, + pub check_bounds: i8, + pub depwarn: i8, + pub warn_overwrite: i8, + pub can_inline: i8, + pub polly: i8, + pub trace_compile: *const ::std::os::raw::c_char, + pub fast_math: i8, + pub worker: i8, + pub cookie: *const ::std::os::raw::c_char, + pub handle_signals: i8, + pub use_sysimage_native_code: i8, + pub use_compiled_modules: i8, + pub use_pkgimages: i8, + pub bindto: *const ::std::os::raw::c_char, + pub outputbc: *const ::std::os::raw::c_char, + pub outputunoptbc: *const ::std::os::raw::c_char, + pub outputo: *const ::std::os::raw::c_char, + pub outputasm: *const ::std::os::raw::c_char, + pub outputji: *const ::std::os::raw::c_char, + pub output_code_coverage: *const ::std::os::raw::c_char, + pub incremental: i8, + pub image_file_specified: i8, + pub warn_scope: i8, + pub image_codegen: i8, + pub rr_detach: i8, + pub strip_metadata: i8, + pub strip_ir: i8, + pub permalloc_pkgimg: i8, + pub heap_size_hint: u64, +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C" { + pub static mut jl_options: jl_options_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_major() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_minor() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_patch() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_is_release() -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_ver_string() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_branch() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_git_commit() -> *const ::std::os::raw::c_char; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_get_current_task() -> *mut jl_task_t; +} +pub type jl_markfunc_t = ::std::option::Option< + unsafe extern "C-unwind" fn(arg1: jl_ptls_t, obj: *mut jl_value_t) -> usize, +>; +pub type jl_sweepfunc_t = ::std::option::Option; +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_new_foreign_type( + name: *mut jl_sym_t, + module: *mut jl_module_t, + super_: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + haspointers: ::std::os::raw::c_int, + large: ::std::os::raw::c_int, + ) -> *mut jl_datatype_t; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_reinit_foreign_type( + dt: *mut jl_datatype_t, + markfunc: jl_markfunc_t, + sweepfunc: jl_sweepfunc_t, + ) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_alloc_typed( + ptls: jl_ptls_t, + sz: usize, + ty: *mut ::std::os::raw::c_void, + ) -> *mut ::std::os::raw::c_void; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_obj(ptls: jl_ptls_t, obj: *mut jl_value_t) -> ::std::os::raw::c_int; +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_mark_queue_objarray( + ptls: jl_ptls_t, + parent: *mut jl_value_t, + objs: *mut *mut jl_value_t, + nobjs: usize, + ); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_gc_schedule_foreign_sweepfunc(ptls: jl_ptls_t, bj: *mut jl_value_t); +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_tls_states_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_handler_t { + _unused: [u8; 0], +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct jl_mutex_t { + pub owner: ::std::sync::atomic::AtomicPtr, + pub count: u32, +} +#[doc = "
"] +#[repr(C)] +#[derive(Debug)] +pub struct _jl_task_t { + pub next: *mut jl_value_t, + pub queue: *mut jl_value_t, + pub tls: *mut jl_value_t, + pub donenotify: *mut jl_value_t, + pub result: *mut jl_value_t, + pub logstate: *mut jl_value_t, + pub start: *mut jl_function_t, + pub rngState: [u64; 4usize], + pub _state: ::std::sync::atomic::AtomicU8, + pub sticky: u8, + pub _isexception: ::std::sync::atomic::AtomicU8, + pub priority: u16, + pub tid: ::std::sync::atomic::AtomicI16, + pub threadpoolid: i8, + pub gcstack: *mut jl_gcframe_t, + pub world_age: usize, + pub ptls: jl_ptls_t, +} +pub const jlrs_catch_tag_t_JLRS_CATCH_OK: jlrs_catch_tag_t = 0; +pub const jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION: jlrs_catch_tag_t = 1; +pub const jlrs_catch_tag_t_JLRS_CATCH_PANIC: jlrs_catch_tag_t = 2; +pub type jlrs_catch_tag_t = ::std::os::raw::c_uint; +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct jlrs_catch_t { + pub tag: jlrs_catch_tag_t, + pub error: *mut ::std::os::raw::c_void, +} +pub type jlrs_callback_caller_t = ::std::option::Option< + unsafe extern "C-unwind" fn( + arg1: *mut ::std::os::raw::c_void, + arg2: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t, +>; +extern "C-unwind" { + pub fn jlrs_catch_wrapper( + callback: *mut ::std::os::raw::c_void, + caller: jlrs_callback_caller_t, + result: *mut ::std::os::raw::c_void, + ) -> jlrs_catch_t; +} +extern "C-unwind" { + pub fn jlrs_array_data_owner_offset(n_dims: u16) -> uint_t; +} +extern "C-unwind" { + pub fn jlrs_gc_queue_multiroot( + parent: *mut jl_value_t, + dt: *mut jl_datatype_t, + ptr: *const ::std::os::raw::c_void, + ); +} +extern "C-unwind" { + pub fn jlrs_gc_safe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_enter(ptls: jl_ptls_t) -> i8; +} +extern "C-unwind" { + pub fn jlrs_gc_safe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_gc_unsafe_leave(ptls: jl_ptls_t, state: i8); +} +extern "C-unwind" { + pub fn jlrs_dimtuple_type(rank: usize) -> *mut jl_datatype_t; +} +extern "C-unwind" { + pub fn jlrs_tuple_of(values: *mut *mut jl_value_t, n: usize) -> *mut jl_value_t; +} +extern "C-unwind" { + pub fn jlrs_lock(v: *mut jl_value_t); +} +extern "C-unwind" { + pub fn jlrs_unlock(v: *mut jl_value_t); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_enter_threaded_region(); +} +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil") + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_exit_threaded_region(); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct _jl_value_t { + pub _address: u8, +} diff --git a/jl_sys/src/bindings_unwind/bindings_unwind_ext_windows.rs b/jl_sys/src/bindings_unwind/bindings_unwind_ext_windows.rs new file mode 100644 index 00000000..549d2545 --- /dev/null +++ b/jl_sys/src/bindings_unwind/bindings_unwind_ext_windows.rs @@ -0,0 +1,11 @@ +#[cfg(not(feature = "julia-1-6"))] +#[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil"), + ), + link(name = "libjulia", kind = "raw-dylib") +)] +extern "C-unwind" { + pub fn jl_setjmp(ptr: *mut ::std::ffi::c_void); +} diff --git a/jl_sys/src/jlrs_cc.c b/jl_sys/src/jlrs_cc.c index b8803b69..ce1087b4 100644 --- a/jl_sys/src/jlrs_cc.c +++ b/jl_sys/src/jlrs_cc.c @@ -1,25 +1,33 @@ #include "jlrs_cc.h" +#ifdef JLRS_FAST_TLS +#ifdef JULIA_1_6 +JULIA_DEFINE_FAST_TLS() +#else +JULIA_DEFINE_FAST_TLS +#endif +#endif + #ifdef __cplusplus extern "C" { #endif - jlrs_catch_t jlrs_catch_wrapper(void *callback, jlrs_callback_caller_t caller, void *result, void *frame_slice) + jlrs_catch_t jlrs_catch_wrapper(void *callback, jlrs_callback_caller_t caller, void *result) { jlrs_catch_t res = {.tag = JLRS_CATCH_OK, .error = NULL}; -#if !defined(JLRS_WINDOWS_LTS) +#ifndef JLRS_WINDOWS_LTS JL_TRY { -#endif - res = caller(callback, frame_slice, result); -#if !defined(JLRS_WINDOWS_LTS) + res = caller(callback, result); } JL_CATCH { res.tag = JLRS_CATCH_EXCEPTION; res.error = jl_current_exception(); } +#else + res = caller(callback, result); #endif return res; } @@ -73,7 +81,63 @@ extern "C" } } -#if !defined(JULIA_1_6) + int8_t jlrs_gc_safe_enter(jl_ptls_t ptls) + { + return jl_gc_safe_enter(ptls); + } + + int8_t jlrs_gc_unsafe_enter(jl_ptls_t ptls) + { + return jl_gc_unsafe_enter(ptls); + } + + void jlrs_gc_safe_leave(jl_ptls_t ptls, int8_t state) + { + jl_gc_safe_leave(ptls, state); + } + + void jlrs_gc_unsafe_leave(jl_ptls_t ptls, int8_t state) + { + jl_gc_unsafe_leave(ptls, state); + } + + jl_datatype_t *jlrs_dimtuple_type(size_t rank) + { + jl_value_t **params = (jl_value_t **)alloca(rank); + if (sizeof(void *) == 4) + { + + for (size_t i = 0; i < rank; ++i) + { + params[i] = (jl_value_t *)jl_int32_type; + } + } + else + { + for (size_t i = 0; i < rank; ++i) + { + params[i] = (jl_value_t *)jl_int64_type; + } + } + + return (jl_datatype_t *)jl_apply_tuple_type_v(params, rank); + } + + jl_value_t *jlrs_tuple_of(jl_value_t **values, size_t n) + { + jl_value_t **types = (jl_value_t **)alloca(n); + for (size_t i = 0; i < n; ++i) + { + types[i] = jl_typeof(values[i]); + } + + // Should be a leaf type + jl_datatype_t *tupty = (jl_datatype_t *)jl_apply_tuple_type_v(types, n); + + return jl_new_structv(tupty, values, n); + } + +#ifndef JULIA_1_6 void jlrs_lock(jl_value_t *v) { jl_task_t *self = jl_current_task; @@ -110,15 +174,16 @@ extern "C" } #endif -#if defined(JULIA_1_6) - void **jlrs_pgcstack(jl_tls_states_t *ptls) +#ifdef JULIA_1_6 + jl_gcframe_t **jlrs_pgcstack(jl_tls_states_t *ptls) { - return (void **)&(ptls->pgcstack); + return &(ptls->pgcstack); } #endif #if !defined(JULIA_1_6) && !defined(JULIA_1_7) && !defined(JULIA_1_8) && !defined(JULIA_1_9) - jl_datatype_t *jlrs_typeof(jl_value_t *v) { + jl_datatype_t *jlrs_typeof(jl_value_t *v) + { return (jl_datatype_t *)jl_typeof(v); } #endif diff --git a/jl_sys/src/jlrs_cc.h b/jl_sys/src/jlrs_cc.h index e711654b..ece67bc8 100644 --- a/jl_sys/src/jlrs_cc.h +++ b/jl_sys/src/jlrs_cc.h @@ -28,206 +28,276 @@ extern "C" { #endif -// A few types are replaced to get rid of any platform-specific fields, we don't care about them. + // A few types are replaced to get rid of any platform-specific fields, we don't care about them. +#ifndef JULIA_1_6 + /** + *
+ */ + struct jlrs_tls_states_t; +#else /** *
*/ -struct jlrs_tls_states_t; +struct jlrs_tls_states_t +{ + void *pgcstack; + size_t world_age; +}; +#endif -/** - *
- */ -struct jlrs_handler_t; + /** + *
+ */ + struct jlrs_handler_t; #ifndef JULIA_1_6 -/** - *
- */ -struct jlrs_mutex_t { - // This field is atomic! Special handling in fix_bindings.rs is required because this struct - // is not defined in julia.h - jl_task_t *owner; - uint32_t count; -}; + /** + *
+ */ + struct jlrs_mutex_t + { + // This field is atomic! Special handling in fix_bindings.rs is required because this struct + // is not defined in julia.h + jl_task_t *owner; + uint32_t count; + }; #else /** *
*/ -struct jlrs_mutex_t { +struct jlrs_mutex_t +{ // Use unsigned long to avoid generating bindings for DWORD on Windows. unsigned long owner; uint32_t count; }; #endif -#ifdef JULIA_1_10 +#ifdef JULIA_1_11 + + /** + *
+ */ + struct jlrs_task_t + { + JL_DATA_TYPE + jl_value_t *next; // invasive linked list for scheduler + jl_value_t *queue; // invasive linked list for scheduler + jl_value_t *tls; + jl_value_t *donenotify; + jl_value_t *result; + jl_value_t *logstate; + jl_function_t *start; + // 4 byte padding on 32-bit systems + // uint32_t padding0; + uint64_t rngState[JL_RNG_SIZE]; + _Atomic(uint8_t) _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with + // 1 byte padding + // uint8_t padding1; + // multiqueue priority + uint16_t priority; + + // hidden state: -#ifndef JL_RNG_SIZE -#define JL_RNG_SIZE 5 +#ifdef USE_TRACY + const char *name; #endif -/** - *
- */ -struct jlrs_task_t { - JL_DATA_TYPE - jl_value_t *next; // invasive linked list for scheduler - jl_value_t *queue; // invasive linked list for scheduler - jl_value_t *tls; - jl_value_t *donenotify; - jl_value_t *result; - jl_value_t *logstate; - jl_function_t *start; - // 4 byte padding on 32-bit systems - // uint32_t padding0; - uint64_t rngState[JL_RNG_SIZE]; - _Atomic(uint8_t) _state; - uint8_t sticky; // record whether this Task can be migrated to a new thread - _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with - // 1 byte padding - // uint8_t padding1; - // multiqueue priority - uint16_t priority; - -// hidden state: - // id of owning thread - does not need to be defined until the task runs - _Atomic(int16_t) tid; - // threadpool id - int8_t threadpoolid; - // Reentrancy bits - // Bit 0: 1 if we are currently running inference/codegen - // Bit 1-2: 0-3 counter of how many times we've reentered inference - // Bit 3: 1 if we are writing the image and inference is illegal - uint8_t reentrant_timing; - // 2 bytes of padding on 32-bit, 6 bytes on 64-bit - // uint16_t padding2_32; - // uint48_t padding2_64; - // saved gc stack top for context switches - jl_gcframe_t *gcstack; - size_t world_age; - // quick lookup for current ptls - jl_ptls_t ptls; // == jl_all_tls_states[tid] -}; + // id of owning thread - does not need to be defined until the task runs + _Atomic(int16_t) tid; + // threadpool id + int8_t threadpoolid; + // Reentrancy bits + // Bit 0: 1 if we are currently running inference/codegen + // Bit 1-2: 0-3 counter of how many times we've reentered inference + // Bit 3: 1 if we are writing the image and inference is illegal + uint8_t reentrant_timing; + // 2 bytes of padding on 32-bit, 6 bytes on 64-bit + // uint16_t padding2_32; + // uint48_t padding2_64; + // saved gc stack top for context switches + jl_gcframe_t *gcstack; + size_t world_age; + // quick lookup for current ptls + jl_ptls_t ptls; // == jl_all_tls_states[tid] + }; #endif + +#ifdef JULIA_1_10 + + /** + *
+ */ + struct jlrs_task_t + { + JL_DATA_TYPE + jl_value_t *next; // invasive linked list for scheduler + jl_value_t *queue; // invasive linked list for scheduler + jl_value_t *tls; + jl_value_t *donenotify; + jl_value_t *result; + jl_value_t *logstate; + jl_function_t *start; + // 4 byte padding on 32-bit systems + // uint32_t padding0; + uint64_t rngState[JL_RNG_SIZE]; + _Atomic(uint8_t) _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with + // 1 byte padding + // uint8_t padding1; + // multiqueue priority + uint16_t priority; + + // hidden state: + // id of owning thread - does not need to be defined until the task runs + _Atomic(int16_t) tid; + // threadpool id + int8_t threadpoolid; + // Reentrancy bits + // Bit 0: 1 if we are currently running inference/codegen + // Bit 1-2: 0-3 counter of how many times we've reentered inference + // Bit 3: 1 if we are writing the image and inference is illegal + uint8_t reentrant_timing; + // 2 bytes of padding on 32-bit, 6 bytes on 64-bit + // uint16_t padding2_32; + // uint48_t padding2_64; + // saved gc stack top for context switches + jl_gcframe_t *gcstack; + size_t world_age; + // quick lookup for current ptls + jl_ptls_t ptls; // == jl_all_tls_states[tid] + }; +#endif + #ifdef JULIA_1_9 -/** - *
- */ -struct jlrs_task_t { - JL_DATA_TYPE - jl_value_t *next; // invasive linked list for scheduler - jl_value_t *queue; // invasive linked list for scheduler - jl_value_t *tls; - jl_value_t *donenotify; - jl_value_t *result; - jl_value_t *logstate; - jl_function_t *start; - uint64_t rngState[4]; - _Atomic(uint8_t) _state; - uint8_t sticky; // record whether this Task can be migrated to a new thread - _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with - // multiqueue priority - uint16_t priority; - -// hidden state: - // id of owning thread - does not need to be defined until the task runs - _Atomic(int16_t) tid; - // threadpool id - int8_t threadpoolid; - // saved gc stack top for context switches - jl_gcframe_t *gcstack; - size_t world_age; - // quick lookup for current ptls - jl_ptls_t ptls; // == jl_all_tls_states[tid] -}; + /** + *
+ */ + struct jlrs_task_t + { + JL_DATA_TYPE + jl_value_t *next; // invasive linked list for scheduler + jl_value_t *queue; // invasive linked list for scheduler + jl_value_t *tls; + jl_value_t *donenotify; + jl_value_t *result; + jl_value_t *logstate; + jl_function_t *start; + uint64_t rngState[4]; + _Atomic(uint8_t) _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with + // multiqueue priority + uint16_t priority; + + // hidden state: + // id of owning thread - does not need to be defined until the task runs + _Atomic(int16_t) tid; + // threadpool id + int8_t threadpoolid; + // saved gc stack top for context switches + jl_gcframe_t *gcstack; + size_t world_age; + // quick lookup for current ptls + jl_ptls_t ptls; // == jl_all_tls_states[tid] + }; #endif + #ifdef JULIA_1_8 -/** - *
- */ -struct jlrs_task_t { - JL_DATA_TYPE - jl_value_t *next; // invasive linked list for scheduler - jl_value_t *queue; // invasive linked list for scheduler - jl_value_t *tls; - jl_value_t *donenotify; - jl_value_t *result; - jl_value_t *logstate; - jl_function_t *start; - uint64_t rngState[4]; - _Atomic(uint8_t) _state; - uint8_t sticky; // record whether this Task can be migrated to a new thread - _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with - -// hidden state: - // id of owning thread - does not need to be defined until the task runs - _Atomic(int16_t) tid; - // multiqueue priority - int16_t prio; - // saved gc stack top for context switches - jl_gcframe_t *gcstack; - size_t world_age; - // quick lookup for current ptls - jl_ptls_t ptls; // == jl_all_tls_states[tid] -}; + /** + *
+ */ + struct jlrs_task_t + { + JL_DATA_TYPE + jl_value_t *next; // invasive linked list for scheduler + jl_value_t *queue; // invasive linked list for scheduler + jl_value_t *tls; + jl_value_t *donenotify; + jl_value_t *result; + jl_value_t *logstate; + jl_function_t *start; + uint64_t rngState[4]; + _Atomic(uint8_t) _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with + + // hidden state: + // id of owning thread - does not need to be defined until the task runs + _Atomic(int16_t) tid; + // multiqueue priority + int16_t prio; + // saved gc stack top for context switches + jl_gcframe_t *gcstack; + size_t world_age; + // quick lookup for current ptls + jl_ptls_t ptls; // == jl_all_tls_states[tid] + }; #endif + #ifdef JULIA_1_7 -/** - *
- */ -struct jlrs_task_t { - JL_DATA_TYPE - jl_value_t *next; // invasive linked list for scheduler - jl_value_t *queue; // invasive linked list for scheduler - jl_value_t *tls; - jl_value_t *donenotify; - jl_value_t *result; - jl_value_t *logstate; - jl_function_t *start; - uint64_t rngState0; // really rngState[4], but more convenient to split - uint64_t rngState1; - uint64_t rngState2; - uint64_t rngState3; - _Atomic(uint8_t) _state; - uint8_t sticky; // record whether this Task can be migrated to a new thread - _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with - -// hidden state: - // id of owning thread - does not need to be defined until the task runs - _Atomic(int16_t) tid; - // multiqueue priority - int16_t prio; - // saved gc stack top for context switches - jl_gcframe_t *gcstack; - size_t world_age; - // quick lookup for current ptls - jl_ptls_t ptls; // == jl_all_tls_states[tid] -}; + /** + *
+ */ + struct jlrs_task_t + { + JL_DATA_TYPE + jl_value_t *next; // invasive linked list for scheduler + jl_value_t *queue; // invasive linked list for scheduler + jl_value_t *tls; + jl_value_t *donenotify; + jl_value_t *result; + jl_value_t *logstate; + jl_function_t *start; + uint64_t rngState0; // really rngState[4], but more convenient to split + uint64_t rngState1; + uint64_t rngState2; + uint64_t rngState3; + _Atomic(uint8_t) _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + _Atomic(uint8_t) _isexception; // set if `result` is an exception to throw or that we exited with + + // hidden state: + // id of owning thread - does not need to be defined until the task runs + _Atomic(int16_t) tid; + // multiqueue priority + int16_t prio; + // saved gc stack top for context switches + jl_gcframe_t *gcstack; + size_t world_age; + // quick lookup for current ptls + jl_ptls_t ptls; // == jl_all_tls_states[tid] + }; #endif + #ifdef JULIA_1_6 -/** - *
- */ -struct jlrs_task_t { - JL_DATA_TYPE - jl_value_t *next; // invasive linked list for scheduler - jl_value_t *queue; // invasive linked list for scheduler - jl_value_t *tls; - jl_value_t *donenotify; - jl_value_t *result; - jl_value_t *logstate; - jl_function_t *start; - uint8_t _state; - uint8_t sticky; // record whether this Task can be migrated to a new thread - uint8_t _isexception; // set if `result` is an exception to throw or that we exited with -}; + /** + *
+ */ + struct jlrs_task_t + { + JL_DATA_TYPE + jl_value_t *next; // invasive linked list for scheduler + jl_value_t *queue; // invasive linked list for scheduler + jl_value_t *tls; + jl_value_t *donenotify; + jl_value_t *result; + jl_value_t *logstate; + jl_function_t *start; + uint8_t _state; + uint8_t sticky; // record whether this Task can be migrated to a new thread + uint8_t _isexception; // set if `result` is an exception to throw or that we exited with + }; #endif + typedef enum { JLRS_CATCH_OK = 0, - JLRS_CATCH_ERR = 1, - JLRS_CATCH_EXCEPTION = 2, - JLRS_CATCH_PANIC = 3, + JLRS_CATCH_EXCEPTION = 1, + JLRS_CATCH_PANIC = 2, } jlrs_catch_tag_t; typedef struct @@ -236,17 +306,25 @@ struct jlrs_task_t { void *error; } jlrs_catch_t; - typedef jlrs_catch_t (*jlrs_callback_caller_t)(void *, void *, void *); - jlrs_catch_t jlrs_catch_wrapper(void *callback, jlrs_callback_caller_t caller, void *result, void *frame_slice); + typedef jlrs_catch_t (*jlrs_callback_caller_t)(void *, void *); + jlrs_catch_t jlrs_catch_wrapper(void *callback, jlrs_callback_caller_t caller, void *result); uint_t jlrs_array_data_owner_offset(uint16_t n_dims); void jlrs_gc_queue_multiroot(jl_value_t *parent, jl_datatype_t *dt, const void *ptr) JL_NOTSAFEPOINT; -#if defined(JULIA_1_6) - void **jlrs_pgcstack(jl_tls_states_t *ptls); + int8_t jlrs_gc_safe_enter(jl_ptls_t ptls); + int8_t jlrs_gc_unsafe_enter(jl_ptls_t ptls); + void jlrs_gc_safe_leave(jl_ptls_t ptls, int8_t state); + void jlrs_gc_unsafe_leave(jl_ptls_t ptls, int8_t state); + + jl_datatype_t *jlrs_dimtuple_type(size_t rank); + jl_value_t *jlrs_tuple_of(jl_value_t **values, size_t n); + +#ifdef JULIA_1_6 + jl_gcframe_t **jlrs_pgcstack(jl_tls_states_t *ptls); #endif -#if !defined(JULIA_1_6) +#ifndef JULIA_1_6 void jlrs_lock(jl_value_t *v); void jlrs_unlock(jl_value_t *v); #endif diff --git a/jl_sys/src/lib.rs b/jl_sys/src/lib.rs index 9a6e96fd..e151b8e0 100644 --- a/jl_sys/src/lib.rs +++ b/jl_sys/src/lib.rs @@ -1,6 +1,7 @@ #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] +#![cfg_attr(feature = "c-unwind", feature(c_unwind))] use cfg_if::cfg_if; cfg_if! { @@ -9,12 +10,17 @@ cfg_if! { all(feature = "julia-1-6", feature = "julia-1-8"), all(feature = "julia-1-6", feature = "julia-1-9"), all(feature = "julia-1-6", feature = "julia-1-10"), + all(feature = "julia-1-6", feature = "julia-1-11"), all(feature = "julia-1-7", feature = "julia-1-8"), all(feature = "julia-1-7", feature = "julia-1-9"), all(feature = "julia-1-7", feature = "julia-1-10"), + all(feature = "julia-1-7", feature = "julia-1-11"), all(feature = "julia-1-8", feature = "julia-1-9"), all(feature = "julia-1-8", feature = "julia-1-10"), + all(feature = "julia-1-8", feature = "julia-1-11"), all(feature = "julia-1-9", feature = "julia-1-10"), + all(feature = "julia-1-9", feature = "julia-1-11"), + all(feature = "julia-1-10", feature = "julia-1-11"), ))] { compile_error!("Cannot enable multiple Julia version features simultaneously"); } else if #[cfg(not(any( @@ -23,6 +29,7 @@ cfg_if! { feature = "julia-1-8", feature = "julia-1-9", feature = "julia-1-10", + feature = "julia-1-11", )))] { compile_error!("A Julia version feature must be enabled"); } @@ -38,34 +45,82 @@ use std::{ #[cfg(feature = "julia-1-6")] use ::std::os::raw::c_char; -pub mod bindings; -pub use bindings::*; +cfg_if! { + if #[cfg(feature = "c-unwind")] { + pub mod bindings_unwind; + pub use bindings_unwind as bindings; + pub use bindings::*; + + #[cfg(feature = "julia-1-6")] + pub const jl_init: unsafe extern "C-unwind" fn() = jl_init__threading; + + #[cfg(feature = "julia-1-6")] + pub const jl_init_with_image: unsafe extern "C-unwind" fn(*const c_char, *const c_char) = + jl_init_with_image__threading; + + #[cfg(feature = "uv")] + #[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil"), + target_pointer_width = "64" + ), + link(name = "libuv-2", kind = "raw-dylib") + )] + extern "C-unwind" { + pub fn uv_async_send(async_: *mut c_void) -> ::std::os::raw::c_int; + } + } else { + pub mod bindings; + pub use bindings::*; + + #[cfg(feature = "julia-1-6")] + pub const jl_init: unsafe extern "C" fn() = jl_init__threading; + + #[cfg(feature = "julia-1-6")] + pub const jl_init_with_image: unsafe extern "C" fn(*const c_char, *const c_char) = + jl_init_with_image__threading; + + #[cfg(feature = "uv")] + #[cfg_attr( + all( + any(windows, target_os = "windows", feature = "windows"), + any(target_env = "msvc", feature = "yggdrasil"), + target_pointer_width = "64" + ), + link(name = "libuv-2", kind = "raw-dylib") + )] + extern "C" { + pub fn uv_async_send(async_: *mut c_void) -> ::std::os::raw::c_int; + } + } +} #[cfg(feature = "use-bindgen")] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); -#[inline(always)] +#[inline] fn llt_align(x: usize, sz: usize) -> usize { (x + sz - 1) & !(sz - 1) } -#[inline(always)] +#[inline] pub unsafe fn jl_astaggedvalue(v: *mut jl_value_t) -> *mut jl_taggedvalue_t { let sz = size_of::() / size_of::(); v.cast::().sub(sz).cast::() } -#[inline(always)] +#[inline] pub unsafe fn jl_typeof(v: *mut jl_value_t) -> *mut jl_value_t { ((*jl_astaggedvalue(v)).__bindgen_anon_1.header as usize & !15usize) as *mut jl_value_t } -#[inline(always)] +#[inline] pub unsafe fn jl_svec_data(t: *mut jl_svec_t) -> *mut *mut jl_value_t { t.cast::().add(size_of::()).cast() } -#[inline(always)] +#[inline] pub unsafe fn jl_array_data(array: *mut jl_value_t) -> *mut c_void { NonNull::new_unchecked(array) .cast::() @@ -74,19 +129,19 @@ pub unsafe fn jl_array_data(array: *mut jl_value_t) -> *mut c_void { .cast() } -#[inline(always)] +#[inline] pub unsafe fn jl_array_ndims(array: *mut jl_array_t) -> u16 { NonNull::new_unchecked(array).as_ref().flags.ndims() } -#[inline(always)] +#[inline] pub unsafe fn jl_array_data_owner(a: *mut jl_array_t) -> *mut jl_value_t { a.cast::() .add(jlrs_array_data_owner_offset(jl_array_ndims(a)) as usize) .cast::() } -#[inline(always)] +#[inline] pub unsafe fn jl_get_fieldtypes(st: *mut jl_datatype_t) -> *mut jl_svec_t { let tys = NonNull::new_unchecked(st).as_ref().types; if tys.is_null() { @@ -96,12 +151,12 @@ pub unsafe fn jl_get_fieldtypes(st: *mut jl_datatype_t) -> *mut jl_svec_t { } } -#[inline(always)] +#[inline] pub unsafe fn jl_dt_layout_fields(d: *const u8) -> *const u8 { d.add(size_of::()) } -#[inline(always)] +#[inline] pub unsafe fn jl_array_ndimwords(ndims: u32) -> i32 { if ndims < 3 { 0 @@ -110,7 +165,7 @@ pub unsafe fn jl_array_ndimwords(ndims: u32) -> i32 { } } -#[inline(always)] +#[inline] pub unsafe fn jl_gc_wb(parent: *mut jl_value_t, ptr: *mut jl_value_t) { let parent_tagged = NonNull::new_unchecked(jl_astaggedvalue(parent)).as_ref(); let ptr = NonNull::new_unchecked(jl_astaggedvalue(ptr)).as_ref(); @@ -120,18 +175,18 @@ pub unsafe fn jl_gc_wb(parent: *mut jl_value_t, ptr: *mut jl_value_t) { } } -#[inline(always)] +#[inline] pub unsafe fn jl_symbol_name_(s: *mut jl_sym_t) -> *mut u8 { s.cast::() .add(llt_align(size_of::(), size_of::<*mut c_void>())) } -#[inline(always)] +#[inline] pub unsafe fn jl_fielddesc_size(fielddesc_type: i8) -> u32 { 2 << fielddesc_type } -#[inline(always)] +#[inline] pub unsafe fn jl_field_isptr(st: *mut jl_datatype_t, i: i32) -> bool { let ly = NonNull::new_unchecked( NonNull::new_unchecked(st).as_ref().layout as *mut jl_datatype_layout_t, @@ -148,7 +203,7 @@ pub unsafe fn jl_field_isptr(st: *mut jl_datatype_t, i: i32) -> bool { != 0 } -#[inline(always)] +#[inline] pub unsafe fn jl_field_size(st: *mut jl_datatype_t, i: isize) -> u32 { let ly = NonNull::new_unchecked( NonNull::new_unchecked(st).as_ref().layout as *mut jl_datatype_layout_t, @@ -171,7 +226,7 @@ pub unsafe fn jl_field_size(st: *mut jl_datatype_t, i: isize) -> u32 { } } -#[inline(always)] +#[inline] pub unsafe fn jl_field_offset(st: *mut jl_datatype_t, i: isize) -> u32 { let ly = &*(&*st).layout; assert!(i >= 0 && (i as u32) < ly.nfields); @@ -197,12 +252,12 @@ pub unsafe fn jl_field_offset(st: *mut jl_datatype_t, i: isize) -> u32 { } } -#[inline(always)] +#[inline] pub unsafe fn jl_array_dims_ptr<'a>(array: *mut jl_array_t) -> *mut usize { &mut NonNull::new_unchecked(array).as_mut().nrows } -#[inline(always)] +#[inline] pub unsafe fn jl_array_ptr_set(a: *mut jl_array_t, i: usize, x: *mut c_void) -> *mut jl_value_t { assert!(NonNull::new_unchecked(a).as_ref().flags.ptrarray() != 0); let a_data: *mut AtomicPtr = jl_array_data(a.cast()).cast(); @@ -222,26 +277,6 @@ pub unsafe fn jl_array_ptr_set(a: *mut jl_array_t, i: usize, x: *mut c_void) -> x.cast() } -#[cfg(feature = "julia-1-6")] -pub const jl_init: unsafe extern "C" fn() = jl_init__threading; - -#[cfg(feature = "julia-1-6")] -pub const jl_init_with_image: unsafe extern "C" fn(*const c_char, *const c_char) = - jl_init_with_image__threading; - -#[cfg(feature = "uv")] -#[cfg_attr( - all( - any(windows, target_os = "windows", feature = "windows"), - any(target_env = "msvc", feature = "yggdrasil"), - target_pointer_width = "64" - ), - link(name = "libuv-2", kind = "raw-dylib") -)] -extern "C" { - pub fn uv_async_send(async_: *mut c_void) -> ::std::os::raw::c_int; -} - #[cfg(test)] mod tests { use std::ffi::CString; diff --git a/jlrs/Cargo.toml b/jlrs/Cargo.toml index 8d0f83ec..1059c707 100644 --- a/jlrs/Cargo.toml +++ b/jlrs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jlrs" -version = "0.18.0" +version = "0.19.0" authors = ["Thomas van Doornmalen "] description = """ jlrs provides bindings to the Julia C API that enables Julia code to be called from Rust and more. @@ -22,13 +22,15 @@ default = ["prelude"] # Enable all features except any version features full = ["prelude", "sync-rt", "tokio-rt", "async-std-rt", "jlrs-ndarray", "f16", "pyplot", "internal-types", "uv", "jlrs-derive"] +# Enable all features except any version features or runtimes +full-no-rt = ["prelude", "async", "jlrs-ndarray", "f16", "pyplot", "internal-types", "uv", "jlrs-derive"] # Runtimes # Enable sync runtime -sync-rt = [] +sync-rt = ["jl-sys/fast-tls"] # Enable async runtime -async-rt = ["async", "deadqueue", "futures-concurrency"] +async-rt = ["async", "deadqueue", "futures-concurrency", "jl-sys/fast-tls"] # Enable async-std as backing runtime async-std-rt = ["async-rt", "async-std"] # Enable tokio as backing runtime @@ -59,6 +61,8 @@ pyplot = [] # Enable `ccall` feature, link `libuv`, and enable `CCall::us_async_send` uv = ["jl-sys/uv", "ccall"] +c-unwind = ["jl-sys/c-unwind"] + # Julia version # Link Julia 1.6 @@ -71,6 +75,8 @@ julia-1-8 = ["jl-sys/julia-1-8", "jlrs-macros/julia-1-8"] julia-1-9 = ["jl-sys/julia-1-9", "jlrs-macros/julia-1-9"] # Link Julia 1.10 julia-1-10 = ["jl-sys/julia-1-10", "jlrs-macros/julia-1-10"] +# Link Julia 1.11 +julia-1-11 = ["jl-sys/julia-1-11", "jlrs-macros/julia-1-11"] # Target or link a specific Julia build or arch. @@ -94,17 +100,21 @@ mem-debug = [] # Internal # Used to generate docs for docs.rs -docs = ["jl-sys/docs", "full", "julia-1-9"] +docs = ["jl-sys/docs", "full", "julia-1-10"] [dependencies] cfg-if = "1" -jl-sys = { version = "0.21", path = "../jl_sys" } -jlrs-macros = { version = "0.1", path = "../jlrs_macros" } -smallvec = "1" +jl-sys = { version = "0.22", path = "../jl_sys" } +jlrs-macros = { version = "0.2", path = "../jlrs_macros" } +smallvec = {version = "1", features = ["const_generics"]} thiserror = "1" atomic = "0.5" hashers = "1" once_cell = "1" +parking_lot = "0.12" +fxhash = "0.2" +lock_api = "0.4" +fnv = "1" threadpool = { version = "1", optional = true } async-std = { version = "1.12", features = ["unstable"], optional = true } @@ -119,7 +129,6 @@ futures-concurrency = { version = "7", optional = true } [dev-dependencies] tokio = { version = "1", features = ["macros", "rt-multi-thread", "rt", "time", "sync"]} -once_cell = "1" [package.metadata.docs.rs] features = ["docs"] diff --git a/jlrs/src/args.rs b/jlrs/src/args.rs new file mode 100644 index 00000000..4c036946 --- /dev/null +++ b/jlrs/src/args.rs @@ -0,0 +1,331 @@ +//! Julia function arguments +//! +//! Calling some functions requires adding one or more additional arguments before the provided +//! arguments. Functions that require this take the arguments as an implementation of [`Values`], +//! which can add these extra arguments without requiring any heap allocations as long as the +//! number of arguments is known at compile-time. + +use self::private::ValuesPriv; +use crate::data::managed::value::Value; + +const MAX_SIZE: usize = 8; +const UMAX: usize = usize::MAX; + +/// A number of `Value`s. +/// +/// This trait is implemented for sized and unsized arrays and array slices, if the number of +/// `Value`s is indeterminate `N` is `usize::MAX`. In this case allocating may be required to +/// add additional values so you should always prefer using constantly-sized array. +pub trait Values<'scope, 'data, const N: usize>: ValuesPriv<'scope, 'data, N> {} + +impl<'scope, 'data, const N: usize> Values<'scope, 'data, N> for &[Value<'scope, 'data>; N] {} +impl<'scope, 'data, const N: usize> Values<'scope, 'data, N> for &mut [Value<'scope, 'data>; N] {} +impl<'scope, 'data, const N: usize> Values<'scope, 'data, N> for [Value<'scope, 'data>; N] {} + +impl<'scope, 'data> Values<'scope, 'data, UMAX> for &[Value<'scope, 'data>] {} +impl<'scope, 'data> Values<'scope, 'data, UMAX> for &mut [Value<'scope, 'data>] {} +impl<'scope, 'data, 'borrow, const SIZE: usize> Values<'scope, 'data, UMAX> + for WithSmallVecSize<'scope, 'data, 'borrow, SIZE> +{ +} + +/// Use a custom size for the internal `SmallVec` when extra items are added. +/// +/// When a slice of `Value`s is used as `Values`, the internal `SmallVec` has capacity for 8 +/// values. By using `WithSmallVecSize` you can use a custom size. +#[repr(transparent)] +pub struct WithSmallVecSize<'scope, 'data, 'borrow, const SIZE: usize>( + &'borrow [Value<'scope, 'data>], +); + +/// Convert a slice of `Value`s to `WithSmallVecSize`. +#[inline] +pub fn with_small_vec_size<'scope, 'data, 'borrow, const SIZE: usize>( + values: &'borrow [Value<'scope, 'data>], +) -> WithSmallVecSize<'scope, 'data, 'borrow, SIZE> { + WithSmallVecSize(values) +} + +pub(crate) mod private { + use std::slice; + + use jl_sys::jl_value_t; + use smallvec::SmallVec; + + use super::{WithSmallVecSize, MAX_SIZE, UMAX}; + use crate::{ + data::managed::{private::ManagedPriv, value::Value}, + private::Private, + }; + + #[repr(C)] + #[derive(Copy, Clone)] + pub struct ExtendedArray { + a: [T; N], + b: [T; M], + } + + impl ExtendedArray { + #[inline] + fn new(a: [T; N], b: [T; M]) -> Self { + ExtendedArray { a, b } + } + } + + impl AsRef<[T]> for ExtendedArray { + #[inline] + fn as_ref(&self) -> &[T] { + unsafe { slice::from_raw_parts(self as *const _ as *const _, N + M) } + } + } + + pub trait ValuesPriv<'scope, 'data, const N: usize> { + type ExtendedPointers: AsRef<[*mut jl_value_t]>; + + type Extended: AsRef<[Value<'scope, 'data>]>; + + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>]; + + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; A], + _: Private, + ) -> Self::Extended; + + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t]; + + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers; + } + + impl<'scope, 'data> ValuesPriv<'scope, 'data, UMAX> for &[Value<'scope, 'data>] { + type ExtendedPointers = + SmallVec<[*mut jl_value_t; MAX_SIZE]>; + + type Extended = SmallVec<[Value<'scope, 'data>; MAX_SIZE]>; + + #[inline] + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>] { + self + } + + #[inline] + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; N2], + _: Private, + ) -> Self::Extended { + let mut sv: SmallVec<[Value<'scope, 'data>; MAX_SIZE]> = SmallVec::from_slice(&start); + sv.extend(self.iter().copied()); + sv + } + + #[inline] + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t] { + let ptr = self.as_ptr(); + unsafe { slice::from_raw_parts(ptr.cast(), self.len()) } + } + + #[inline] + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers { + let mut sv: SmallVec<[*mut jl_value_t; MAX_SIZE]> = SmallVec::from_slice(&start); + sv.extend(self.as_pointers(Private).into_iter().copied()); + sv + } + } + + impl<'scope, 'data, 'borrow, const SIZE: usize> ValuesPriv<'scope, 'data, UMAX> + for WithSmallVecSize<'scope, 'data, 'borrow, SIZE> + { + type ExtendedPointers = SmallVec<[*mut jl_value_t; SIZE]>; + + type Extended = SmallVec<[Value<'scope, 'data>; SIZE]>; + + #[inline] + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>] { + self.0 + } + + #[inline] + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; N2], + _: Private, + ) -> Self::Extended { + let mut sv: SmallVec<[Value<'scope, 'data>; SIZE]> = SmallVec::from_slice(&start); + sv.extend(self.0.iter().copied()); + sv + } + + #[inline] + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t] { + let ptr = self.0.as_ptr(); + unsafe { slice::from_raw_parts(ptr.cast(), self.0.len()) } + } + + #[inline] + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers { + let mut sv: SmallVec<[*mut jl_value_t; SIZE]> = SmallVec::from_slice(&start); + sv.extend(self.as_pointers(Private).into_iter().copied()); + sv + } + } + + impl<'scope, 'data> ValuesPriv<'scope, 'data, UMAX> for &mut [Value<'scope, 'data>] { + type ExtendedPointers = + SmallVec<[*mut jl_value_t; MAX_SIZE]>; + + type Extended = SmallVec<[Value<'scope, 'data>; MAX_SIZE]>; + + #[inline] + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>] { + self + } + + #[inline] + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; N2], + _: Private, + ) -> Self::Extended { + let mut sv: SmallVec<[Value<'scope, 'data>; MAX_SIZE]> = SmallVec::from_slice(&start); + sv.extend(self.iter().copied()); + sv + } + + #[inline] + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t] { + let ptr = self.as_ptr(); + unsafe { slice::from_raw_parts(ptr.cast(), self.len()) } + } + + #[inline] + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers { + let mut sv: SmallVec<[*mut jl_value_t; MAX_SIZE]> = SmallVec::from_slice(&start); + sv.extend(self.as_pointers(Private).into_iter().copied()); + sv + } + } + + impl<'scope, 'data, const N: usize> ValuesPriv<'scope, 'data, N> for [Value<'scope, 'data>; N] { + type ExtendedPointers = + ExtendedArray<*mut jl_value_t, A, B>; + + type Extended = ExtendedArray, A, B>; + + #[inline] + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>] { + &self[..] + } + + #[inline] + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; A], + _: Private, + ) -> Self::Extended { + Self::Extended::::new(start, self) + } + + #[inline] + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t] { + unsafe { std::mem::transmute(&self[..]) } + } + + #[inline] + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers { + Self::ExtendedPointers::::new(start, self.map(|x| x.unwrap(Private))) + } + } + + impl<'scope, 'data, const N: usize> ValuesPriv<'scope, 'data, N> for &[Value<'scope, 'data>; N] { + type ExtendedPointers = + ExtendedArray<*mut jl_value_t, A, B>; + + type Extended = ExtendedArray, A, B>; + + #[inline] + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>] { + &self[..] + } + + #[inline] + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; A], + _: Private, + ) -> Self::Extended { + Self::Extended::::new(start, *self) + } + + #[inline] + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t] { + unsafe { std::mem::transmute(&self[..]) } + } + + #[inline] + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers { + Self::ExtendedPointers::::new(start, self.map(|x| x.unwrap(Private))) + } + } + + impl<'scope, 'data, const N: usize> ValuesPriv<'scope, 'data, N> + for &mut [Value<'scope, 'data>; N] + { + type ExtendedPointers = + ExtendedArray<*mut jl_value_t, A, B>; + + type Extended = ExtendedArray, A, B>; + + #[inline] + fn as_slice(&self, _: Private) -> &[Value<'scope, 'data>] { + &self[..] + } + + #[inline] + fn into_extended_with_start( + self, + start: [Value<'scope, 'data>; A], + _: Private, + ) -> Self::Extended { + Self::Extended::::new(start, *self) + } + + #[inline] + fn as_pointers(&self, _: Private) -> &[*mut jl_value_t] { + unsafe { std::mem::transmute(&self[..]) } + } + + #[inline] + fn into_extended_pointers_with_start( + self, + start: [*mut jl_value_t; A], + _: Private, + ) -> Self::ExtendedPointers { + Self::ExtendedPointers::::new(start, self.map(|x| x.unwrap(Private))) + } + } +} diff --git a/jlrs/src/async_util/channel.rs b/jlrs/src/async_util/channel.rs index 0a90aaed..8ebf3b6f 100644 --- a/jlrs/src/async_util/channel.rs +++ b/jlrs/src/async_util/channel.rs @@ -101,8 +101,8 @@ pub trait OneshotSender: 'static + Send + Sync { fn send(self, msg: M); } -#[async_trait::async_trait] impl OneshotSender for crossbeam_channel::Sender { + #[inline] fn send(self, msg: M) { (&self).send(msg).ok(); } diff --git a/jlrs/src/async_util/envelope.rs b/jlrs/src/async_util/envelope.rs index 0174e7d1..25032f18 100644 --- a/jlrs/src/async_util/envelope.rs +++ b/jlrs/src/async_util/envelope.rs @@ -58,6 +58,7 @@ trait AsyncTaskEnvelope: Send { #[async_trait(?Send)] impl AsyncTaskEnvelope for A { type A = Self; + #[inline] async fn call_run<'inner>( &'inner mut self, frame: AsyncGcFrame<'static>, @@ -90,6 +91,7 @@ where { type P = Self; + #[inline] async fn call_init<'inner>( &'inner mut self, frame: AsyncGcFrame<'static>, @@ -135,10 +137,12 @@ where type Input = I; type Output = O; + #[inline] fn respond(self: Box, result: JlrsResult) { Box::new(self.sender).send(result) } + #[inline] fn input(&mut self) -> Self::Input { self.input.take().unwrap() } @@ -156,6 +160,7 @@ where P: PersistentTask, O: OneshotSender>>, { + #[inline] pub(crate) fn new(sender: O) -> Self { PersistentComms { sender, @@ -171,6 +176,7 @@ where P: PersistentTask, O: OneshotSender>>, { + #[inline] pub(crate) fn new(task: P, sender: PersistentComms) -> Self { PendingTask { task: Some(task), @@ -179,6 +185,7 @@ where } } + #[inline] fn split(self) -> (P, PersistentComms) { (self.task.unwrap(), self.sender) } @@ -195,6 +202,7 @@ where O: OneshotSender>, A: AsyncTask, { + #[inline] pub(crate) fn new(task: A, sender: O) -> Self { PendingTask { task: Some(task), @@ -203,6 +211,7 @@ where } } + #[inline] fn split(self) -> (A, O) { (self.task.unwrap(), self.sender) } @@ -213,6 +222,7 @@ where O: OneshotSender>, A: AsyncTask, { + #[inline] pub(crate) fn new(sender: O) -> Self { PendingTask { task: None, @@ -221,6 +231,7 @@ where } } + #[inline] fn sender(self) -> O { self.sender } @@ -231,6 +242,7 @@ where O: OneshotSender>, P: PersistentTask, { + #[inline] pub(crate) fn new(sender: O) -> Self { PendingTask { task: None, @@ -239,6 +251,7 @@ where } } + #[inline] fn sender(self) -> O { self.sender } @@ -377,6 +390,7 @@ where O: OneshotSender>, T: Send + 'static, { + #[inline] pub(crate) fn new(func: F, sender: O) -> Self { Self { func, @@ -385,6 +399,7 @@ where } } + #[inline] fn call<'scope>(self: Box, frame: GcFrame<'scope>) -> (JlrsResult, O) { // Safety: this method is called from a thread known to Julia, the lifetime is limited to // 'scope. @@ -458,10 +473,12 @@ impl IncludeTask where O: OneshotSender>, { + #[inline] pub(crate) fn new(path: PathBuf, sender: O) -> Self { Self { path, sender } } + #[inline] unsafe fn call_inner<'scope>(mut frame: GcFrame<'scope>, path: PathBuf) -> JlrsResult<()> { match path.to_str() { Some(path) => { @@ -521,10 +538,12 @@ impl SetErrorColorTask where O: OneshotSender>, { + #[inline] pub(crate) fn new(enable: bool, sender: O) -> Self { Self { enable, sender } } + #[inline] unsafe fn call_inner<'scope>(frame: GcFrame<'scope>, enable: bool) -> JlrsResult<()> { let unrooted = frame.unrooted(); diff --git a/jlrs/src/async_util/future.rs b/jlrs/src/async_util/future.rs index d78ff38e..65542823 100644 --- a/jlrs/src/async_util/future.rs +++ b/jlrs/src/async_util/future.rs @@ -1,30 +1,26 @@ -use std::{ - ffi::c_void, - marker::PhantomData, - pin::Pin, - ptr::NonNull, - sync::{Arc, Mutex}, -}; +use std::{ffi::c_void, fmt::Display, marker::PhantomData, pin::Pin, ptr::NonNull, sync::Arc}; use futures::{ task::{Context, Poll, Waker}, Future, }; -use jl_sys::{jl_call1, jl_exception_occurred}; +use jl_sys::{jl_call, jl_call1, jl_exception_occurred}; use jlrs_macros::julia_version; -use smallvec::SmallVec; use crate::{ - call::{Call, ProvideKeywords, WithKeywords}, + args::Values, + call::{Call, WithKeywords}, data::managed::{ - module::Module, + erase_scope_lifetime, + module::{JlrsCore, Module}, private::ManagedPriv, task::Task, - value::{Value, MAX_SIZE}, + value::Value, Managed, }, error::{JuliaResult, CANNOT_DISPLAY_VALUE}, - memory::target::{frame::AsyncGcFrame, unrooted::Unrooted}, + gc_safe::GcSafeMutex, + memory::target::{frame::AsyncGcFrame, private::TargetPriv, unrooted::Unrooted}, private::Private, }; @@ -35,50 +31,78 @@ pub(crate) struct TaskState<'frame, 'data> { _marker: PhantomData<&'data ()>, } +enum AsyncMethod { + AsyncCall, + #[cfg(not(any(feature = "julia-1-6", feature = "julia-1-7", feature = "julia-1-8")))] + InteractiveCall, + ScheduleAsync, + ScheduleAsyncLocal, +} + +impl Display for AsyncMethod { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + AsyncMethod::AsyncCall => f.write_str("asynccall"), + #[cfg(not(any(feature = "julia-1-6", feature = "julia-1-7", feature = "julia-1-8")))] + AsyncMethod::InteractiveCall => f.write_str("interactivecall"), + AsyncMethod::ScheduleAsync => f.write_str("scheduleasync"), + AsyncMethod::ScheduleAsyncLocal => f.write_str("scheduleasynclocal"), + } + } +} + pub(crate) struct JuliaFuture<'frame, 'data> { - shared_state: Arc>>, + shared_state: Arc>>, } impl<'frame, 'data> JuliaFuture<'frame, 'data> { - pub(crate) fn new<'value, V>(frame: &mut AsyncGcFrame<'frame>, func: Value, values: V) -> Self + #[inline] + pub(crate) fn new<'value, V, const N: usize>( + frame: &mut AsyncGcFrame<'frame>, + func: Value<'value, 'data>, + values: V, + ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future(frame, func, values, "asynccall") + Self::new_future(frame, func, values, AsyncMethod::AsyncCall) } + #[inline] #[julia_version(since = "1.9")] - pub(crate) fn new_interactive<'value, V>( + pub(crate) fn new_interactive<'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: Value, + func: Value<'value, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future(frame, func, values, "interactivecall") + Self::new_future(frame, func, values, AsyncMethod::InteractiveCall) } - pub(crate) fn new_local<'value, V>( + #[inline] + pub(crate) fn new_local<'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: Value, + func: Value<'value, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future(frame, func, values, "scheduleasynclocal") + Self::new_future(frame, func, values, AsyncMethod::ScheduleAsyncLocal) } - pub(crate) fn new_main<'value, V>( + #[inline] + pub(crate) fn new_main<'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: Value, + func: Value<'value, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future(frame, func, values, "scheduleasync") + Self::new_future(frame, func, values, AsyncMethod::ScheduleAsync) } pub(crate) fn new_posted( @@ -86,7 +110,7 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> { fn_ptr: Value<'_, '_>, task_ptr: Value<'_, '_>, ) -> Self { - let shared_state = Arc::new(Mutex::new(TaskState { + let shared_state = Arc::new(GcSafeMutex::new(TaskState { completed: false, waker: None, task: None, @@ -99,13 +123,7 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> { // Safety: module contents are globally rooted, and the function is guaranteed to be safe // by the caller. let task = unsafe { - Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "postblocking") - .expect("postblocking not available") - .as_managed() + JlrsCore::post_blocking(&frame) .call3(&mut *frame, fn_ptr, task_ptr, state_ptr_boxed) .unwrap_or_else(|e| { let msg = e.display_string_or(CANNOT_DISPLAY_VALUE); @@ -115,98 +133,104 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> { }; { - let locked = shared_state.lock(); - match locked { - Ok(mut data) => data.task = Some(task), - _ => panic!("Lock poisoned"), - } + let mut locked = shared_state.lock(); + locked.task = Some(task); } JuliaFuture { shared_state } } - pub(crate) fn new_with_keywords<'value, V>( + #[inline] + pub(crate) fn new_with_keywords<'kw, 'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: WithKeywords, + func: WithKeywords<'kw, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future_with_keywords(frame, func, values, "asynccall") + Self::new_future_with_keywords(frame, func, values, AsyncMethod::AsyncCall) } + #[inline] #[julia_version(since = "1.9")] - pub(crate) fn new_interactive_with_keywords<'value, V>( + pub(crate) fn new_interactive_with_keywords<'kw, 'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: WithKeywords, + func: WithKeywords<'kw, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future_with_keywords(frame, func, values, "interactivecall") + Self::new_future_with_keywords(frame, func, values, AsyncMethod::InteractiveCall) } - pub(crate) fn new_local_with_keywords<'value, V>( + #[inline] + pub(crate) fn new_local_with_keywords<'kw, 'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: WithKeywords, + func: WithKeywords<'kw, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future_with_keywords(frame, func, values, "scheduleasynclocal") + Self::new_future_with_keywords(frame, func, values, AsyncMethod::ScheduleAsyncLocal) } - pub(crate) fn new_main_with_keywords<'value, V>( + #[inline] + pub(crate) fn new_main_with_keywords<'kw, 'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: WithKeywords, + func: WithKeywords<'kw, 'data>, values: V, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - Self::new_future_with_keywords(frame, func, values, "scheduleasync") + Self::new_future_with_keywords(frame, func, values, AsyncMethod::ScheduleAsync) } - fn new_future<'value, V>( + fn new_future<'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: Value, + func: Value<'value, 'data>, values: V, - method: &str, + method: AsyncMethod, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let shared_state = Arc::new(Mutex::new(TaskState { + let shared_state = Arc::new(GcSafeMutex::new(TaskState { completed: false, waker: None, task: None, _marker: PhantomData, })); - - let values = values.as_ref(); let state_ptr = Arc::into_raw(shared_state.clone()) as *mut c_void; let state_ptr_boxed = Value::new(&mut *frame, state_ptr); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(2 + values.len()); - - vals.push(func); - vals.push(state_ptr_boxed); - vals.extend_from_slice(values); - // Safety: module contents are globally rooted, and the function is guaranteed to be safe // by the caller. let task = unsafe { - Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, method) - .expect(format!("{} not available", method).as_str()) - .as_managed() - .call(&mut *frame, &mut vals) + let values = values.into_extended_with_start( + [ + erase_scope_lifetime(func), + erase_scope_lifetime(state_ptr_boxed), + ], + Private, + ); + + let f = match method { + AsyncMethod::AsyncCall => JlrsCore::async_call(&frame), + #[cfg(not(any( + feature = "julia-1-6", + feature = "julia-1-7", + feature = "julia-1-8" + )))] + AsyncMethod::InteractiveCall => JlrsCore::interactive_call(&frame), + AsyncMethod::ScheduleAsync => JlrsCore::schedule_async(&frame), + AsyncMethod::ScheduleAsyncLocal => JlrsCore::schedule_async_local(&frame), + }; + + f.call(&mut *frame, values.as_ref()) .unwrap_or_else(|e| { let msg = e.display_string_or(CANNOT_DISPLAY_VALUE); panic!("{} threw an exception: {}", method, msg) @@ -215,54 +239,76 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> { }; { - let locked = shared_state.lock(); - match locked { - Ok(mut data) => data.task = Some(task), - _ => panic!("Lock poisoned"), - } + let mut locked = shared_state.lock(); + locked.task = Some(task); } JuliaFuture { shared_state } } - fn new_future_with_keywords<'value, V>( + fn new_future_with_keywords<'kw, 'value, V, const N: usize>( frame: &mut AsyncGcFrame<'frame>, - func: WithKeywords, + func: WithKeywords<'kw, 'data>, values: V, - method: &str, + method: AsyncMethod, ) -> Self where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let shared_state = Arc::new(Mutex::new(TaskState { + let shared_state = Arc::new(GcSafeMutex::new(TaskState { completed: false, waker: None, task: None, _marker: PhantomData, })); - let values = values.as_ref(); let state_ptr = Arc::into_raw(shared_state.clone()) as *mut c_void; let state_ptr_boxed = Value::new(&mut *frame, state_ptr); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(2 + values.len()); - vals.push(func.function()); - vals.push(state_ptr_boxed); - vals.extend_from_slice(values); - // Safety: module contents are globally rooted, and the function is guaranteed to be safe // by the caller. let task = unsafe { - Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, method) - .expect(format!("{} not available", method).as_str()) - .as_managed() - .provide_keywords(func.keywords()) - .expect("Keywords invalid") - .call(&mut *frame, &mut vals) + let f = match method { + AsyncMethod::AsyncCall => JlrsCore::async_call(&frame), + #[cfg(not(any( + feature = "julia-1-6", + feature = "julia-1-7", + feature = "julia-1-8" + )))] + AsyncMethod::InteractiveCall => JlrsCore::interactive_call(&frame), + AsyncMethod::ScheduleAsync => JlrsCore::schedule_async(&frame), + AsyncMethod::ScheduleAsyncLocal => JlrsCore::schedule_async_local(&frame), + }; + + #[cfg(not(any(feature = "julia-1-10", feature = "julia-1-9")))] + let kw_call = jl_sys::jl_get_kwsorter(f.datatype().unwrap(Private).cast()); + #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] + let kw_call = jl_sys::jl_kwcall_func; + + // WithKeywords::call has to extend the provided arguments, it has been inlined so + // we only need to extend them once. + let values = values.into_extended_pointers_with_start( + [ + func.keywords().unwrap(Private), + f.unwrap(Private), + func.function().unwrap(Private), + state_ptr_boxed.unwrap(Private), + ], + Private, + ); + + let values = values.as_ref(); + let res = jl_call(kw_call, values.as_ptr() as *mut _, values.len() as _); + let exc = jl_exception_occurred(); + + let res = if exc.is_null() { + Ok(NonNull::new_unchecked(res)) + } else { + Err(NonNull::new_unchecked(exc)) + }; + + frame + .result_from_ptr::(res, Private) .unwrap_or_else(|e| { let msg = e.display_string_or(CANNOT_DISPLAY_VALUE); panic!("{} threw an exception: {}", method, msg) @@ -271,11 +317,8 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> { }; { - let locked = shared_state.lock(); - match locked { - Ok(mut data) => data.task = Some(task), - _ => panic!("Lock poisoned"), - } + let mut locked = shared_state.lock(); + locked.task = Some(task); } JuliaFuture { shared_state } @@ -285,7 +328,7 @@ impl<'frame, 'data> JuliaFuture<'frame, 'data> { impl<'frame, 'data> Future for JuliaFuture<'frame, 'data> { type Output = JuliaResult<'frame, 'data>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let mut shared_state = self.shared_state.lock().unwrap(); + let mut shared_state = self.shared_state.lock(); if shared_state.completed { if let Some(task) = shared_state.task { // Safety: module contents are globally rooted, and fetch is safe to call. The @@ -327,14 +370,9 @@ impl<'frame, 'data> Future for JuliaFuture<'frame, 'data> { // This function is called using `ccall` to indicate a task has completed. #[cfg(feature = "async-rt")] -pub(crate) unsafe extern "C" fn wake_task(state: *const Mutex) { +pub(crate) unsafe extern "C" fn wake_task(state: *const GcSafeMutex) { let state = Arc::from_raw(state); - let shared_state = state.lock(); - match shared_state { - Ok(mut state) => { - state.completed = true; - state.waker.take().map(|waker| waker.wake()); - } - Err(_) => (), - } + let mut state = state.lock(); + state.completed = true; + state.waker.take().map(|waker| waker.wake()); } diff --git a/jlrs/src/async_util/task.rs b/jlrs/src/async_util/task.rs index 20f62405..6d9d9b2a 100644 --- a/jlrs/src/async_util/task.rs +++ b/jlrs/src/async_util/task.rs @@ -58,7 +58,7 @@ use crate::{ /// let b = Value::new(&mut frame, self.b); /// /// let func = Module::base(&frame).function(&mut frame, "+")?; -/// unsafe { func.call_async(&mut frame, &mut [a, b]) } +/// unsafe { func.call_async(&mut frame, [a, b]) } /// .await /// .into_jlrs_result()? /// .unbox::() @@ -149,8 +149,8 @@ pub trait AsyncTask: 'static + Send { /// // A `Vec` can be moved from Rust to Julia if the element type /// // implements `IntoJulia`. /// let data = vec![0usize; self.n_values]; -/// let array = TypedArray::from_vec(frame.as_extended_target(), data, self.n_values)? -/// .into_jlrs_result()?; +/// let array = +/// TypedArray::from_vec(&mut frame, data, self.n_values)?.into_jlrs_result()?; /// /// Ok(AccumulatorTaskState { array, offset: 0 }) /// } @@ -270,102 +270,11 @@ pub trait PersistentTask: 'static + Send { } } -/* -/// The thread-affinity of a task. -/// -/// If the affinity of a task is set to `Main` the task is always scheduled on the main runtime -/// thread. If no worker threads are used the affinity is irrelevant. -#[derive(Copy, Clone, Debug, PartialEq)] -pub enum Affinity { - Main, - Any, -} - -#[cfg(feature = "async-rt")] -impl Affinity { - pub(crate) async fn schedule( - self, - sender: &Sender, - msg: Box, - ) { - match self { - Affinity::Any => sender.send(MessageInner::Task(msg).wrap()).await, - Affinity::Main => sender.send_main(MessageInner::Task(msg).wrap()).await, - } - } - - pub(crate) fn try_schedule( - self, - sender: &Sender, - msg: Box, - ) -> JlrsResult<()> { - match self { - Affinity::Any => sender.try_send(MessageInner::Task(msg).wrap()), - Affinity::Main => sender.try_send_main(MessageInner::Task(msg).wrap()), - } - } - - pub(crate) async fn schedule_blocking( - self, - sender: &Sender, - msg: Box, - ) { - match self { - Affinity::Any => sender.send(MessageInner::BlockingTask(msg).wrap()).await, - Affinity::Main => { - sender - .send_main(MessageInner::BlockingTask(msg).wrap()) - .await - } - } - } - - pub(crate) fn try_schedule_blocking( - self, - sender: &Sender, - msg: Box, - ) -> JlrsResult<()> { - match self { - Affinity::Any => sender.try_send(MessageInner::BlockingTask(msg).wrap()), - Affinity::Main => sender.try_send_main(MessageInner::BlockingTask(msg).wrap()), - } - } - - pub(crate) async fn schedule_post_blocking( - self, - sender: &Sender, - msg: Box, - ) { - match self { - Affinity::Any => { - sender - .send(MessageInner::PostBlockingTask(msg).wrap()) - .await - } - Affinity::Main => { - sender - .send_main(MessageInner::PostBlockingTask(msg).wrap()) - .await - } - } - } - - pub(crate) fn try_schedule_post_blocking( - self, - sender: &Sender, - msg: Box, - ) -> JlrsResult<()> { - match self { - Affinity::Any => sender.try_send(MessageInner::PostBlockingTask(msg).wrap()), - Affinity::Main => sender.try_send_main(MessageInner::PostBlockingTask(msg).wrap()), - } - } -} - */ /// Yield the current Julia task. /// /// Calling this function allows Julia to switch to another Julia task scheduled on the same /// thread. +#[inline] pub fn yield_task(_: &mut AsyncGcFrame) { // Safety: this function can only be called from a thread known to Julia. unsafe { @@ -384,15 +293,13 @@ pub fn sleep<'scope, 'data, T: Target<'scope>>(target: &T, duration: Duration) { return; } + let func = Module::typed_global_cached::(target, "Base.sleep") + .expect("sleep not found"); + // Is rooted when sleep is called. let secs = duration.as_millis() as usize as f64 / 1000.; let secs = Value::new(target, secs).as_value(); - Module::base(target) - .global(target, "sleep") - .expect("sleep not found") - .as_value() - .call1(target, secs) - .expect("sleep threw an exception"); + func.call1(target, secs).expect("sleep threw an exception"); } } diff --git a/jlrs/src/call.rs b/jlrs/src/call.rs index d2e4c69a..303869d8 100644 --- a/jlrs/src/call.rs +++ b/jlrs/src/call.rs @@ -4,26 +4,31 @@ //! can be used to call Julia functions, including inner and outer constructors; schedule a //! function call as a new Julia task; and provide keyword arguments respectively. -use std::ptr::NonNull; +use std::{mem::ManuallyDrop, ptr::NonNull}; #[julia_version(until = "1.8")] use jl_sys::jl_get_kwsorter; #[julia_version(since = "1.9")] use jl_sys::jl_kwcall_func; -use jl_sys::{jl_call, jl_exception_occurred}; +use jl_sys::{jl_apply_generic, jl_call, jl_exception_occurred, jl_get_world_counter}; use jlrs_macros::julia_version; -use smallvec::SmallVec; -#[julia_version(until = "1.8")] -use crate::data::managed::private::ManagedPriv as _; -#[cfg(feature = "async")] -use crate::error::JuliaResult; use crate::{ - data::managed::value::{Value, ValueResult, MAX_SIZE}, + args::Values, + data::managed::{ + private::ManagedPriv, + value::{Value, ValueResult}, + }, error::{AccessError, JlrsResult}, memory::{context::ledger::Ledger, target::Target}, + prelude::ValueData, private::Private, }; +#[cfg(feature = "async")] +use crate::{ + data::managed::{erase_scope_lifetime, module::JlrsCore}, + error::JuliaResult, +}; /// A function and its keyword arguments. pub struct WithKeywords<'scope, 'data> { @@ -74,6 +79,15 @@ pub trait Call<'data>: private::CallPriv { where T: Target<'target>; + unsafe fn call_unchecked<'target, 'value, V, Tgt, const N: usize>( + self, + target: Tgt, + args: V, + ) -> ValueData<'target, 'data, Tgt> + where + V: Values<'value, 'data, N>, + Tgt: Target<'target>; + /// Call a function with one argument. /// /// Safety: this method lets you call arbitrary Julia functions which can't be checked for @@ -129,13 +143,13 @@ pub trait Call<'data>: private::CallPriv { /// check if any of the arguments is currently borrowed from Rust. /// /// [`safety`]: crate::safety - unsafe fn call<'target, 'value, V, T>( + unsafe fn call<'target, 'value, V, T, const N: usize>( self, target: T, args: V, ) -> ValueResult<'target, 'data, T> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>; /// Call a function with an arbitrary number arguments. @@ -201,7 +215,7 @@ pub trait ProvideKeywords<'value, 'data>: Call<'data> { /// /// let a = Value::new(&mut frame, 1isize); /// let b = Value::new(&mut frame, 2isize); - /// let nt = named_tuple!(frame.as_extended_target(), "a" => a, "b" => b); + /// let nt = named_tuple!(&mut frame, "a" => a, "b" => b); /// /// // Call the previously defined function. This function simply sums its three /// // keyword arguments and has no side effects, so it's safe to call. @@ -226,28 +240,15 @@ pub trait ProvideKeywords<'value, 'data>: Call<'data> { } impl<'data> Call<'data> for WithKeywords<'_, 'data> { + #[inline] unsafe fn call0<'target, T>(self, target: T) -> ValueResult<'target, 'data, T> where T: Target<'target>, { - #[cfg(not(any(feature = "julia-1-10", feature = "julia-1-9")))] - let func = jl_get_kwsorter(self.func.datatype().unwrap(Private).cast()); - #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] - let func = jl_kwcall_func; - let args = &mut [self.keywords, self.func]; - - let res = jl_call(func, args.as_mut_ptr().cast(), 2); - let exc = jl_exception_occurred(); - - let res = if exc.is_null() { - Ok(NonNull::new_unchecked(res)) - } else { - Err(NonNull::new_unchecked(exc)) - }; - - target.result_from_ptr(res, Private) + self.call(target, []) } + #[inline] unsafe fn call1<'target, T>( self, target: T, @@ -256,24 +257,10 @@ impl<'data> Call<'data> for WithKeywords<'_, 'data> { where T: Target<'target>, { - #[cfg(not(any(feature = "julia-1-10", feature = "julia-1-9")))] - let func = jl_get_kwsorter(self.func.datatype().unwrap(Private).cast()); - #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] - let func = jl_kwcall_func; - let args = &mut [self.keywords, self.func, arg0]; - - let res = jl_call(func, args.as_mut_ptr().cast(), 3); - let exc = jl_exception_occurred(); - - let res = if exc.is_null() { - Ok(NonNull::new_unchecked(res)) - } else { - Err(NonNull::new_unchecked(exc)) - }; - - target.result_from_ptr(res, Private) + self.call(target, [arg0]) } + #[inline] unsafe fn call2<'target, T>( self, target: T, @@ -283,24 +270,10 @@ impl<'data> Call<'data> for WithKeywords<'_, 'data> { where T: Target<'target>, { - #[cfg(not(any(feature = "julia-1-10", feature = "julia-1-9")))] - let func = jl_get_kwsorter(self.func.datatype().unwrap(Private).cast()); - #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] - let func = jl_kwcall_func; - let args = &mut [self.keywords, self.func, arg0, arg1]; - - let res = jl_call(func, args.as_mut_ptr().cast(), 4); - let exc = jl_exception_occurred(); - - let res = if exc.is_null() { - Ok(NonNull::new_unchecked(res)) - } else { - Err(NonNull::new_unchecked(exc)) - }; - - target.result_from_ptr(res, Private) + self.call(target, [arg0, arg1]) } + #[inline] unsafe fn call3<'target, T>( self, target: T, @@ -310,14 +283,35 @@ impl<'data> Call<'data> for WithKeywords<'_, 'data> { ) -> ValueResult<'target, 'data, T> where T: Target<'target>, + { + self.call(target, [arg0, arg1, arg2]) + } + + #[inline] + unsafe fn call<'target, 'value, V, T, const N: usize>( + self, + target: T, + args: V, + ) -> ValueResult<'target, 'data, T> + where + V: Values<'value, 'data, N>, + T: Target<'target>, { #[cfg(not(any(feature = "julia-1-10", feature = "julia-1-9")))] let func = jl_get_kwsorter(self.func.datatype().unwrap(Private).cast()); #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] let func = jl_kwcall_func; - let args = &mut [self.keywords, self.func, arg0, arg1, arg2]; - let res = jl_call(func, args.as_mut_ptr().cast(), 5); + let values = args.into_extended_pointers_with_start( + [ + self.keywords().unwrap(Private), + self.function().unwrap(Private), + ], + Private, + ); + let values = values.as_ref(); + + let res = jl_call(func, values.as_ptr() as *mut _, values.len() as _); let exc = jl_exception_occurred(); let res = if exc.is_null() { @@ -329,36 +323,51 @@ impl<'data> Call<'data> for WithKeywords<'_, 'data> { target.result_from_ptr(res, Private) } - unsafe fn call<'target, 'value, V, T>( + #[inline] + unsafe fn call_unchecked<'target, 'value, V, T, const N: usize>( self, target: T, args: V, - ) -> ValueResult<'target, 'data, T> + ) -> ValueData<'target, 'data, T> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { #[cfg(not(any(feature = "julia-1-10", feature = "julia-1-9")))] let func = jl_get_kwsorter(self.func.datatype().unwrap(Private).cast()); #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] let func = jl_kwcall_func; - let args = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(2 + args.len()); - vals.push(self.keywords); - vals.push(self.func); - vals.extend_from_slice(args); - let n = vals.len(); - let res = jl_call(func, vals.as_mut_ptr().cast(), n as _); - let exc = jl_exception_occurred(); + let values = args.into_extended_pointers_with_start( + [self.keywords.unwrap(Private), self.func.unwrap(Private)], + Private, + ); - let res = if exc.is_null() { - Ok(NonNull::new_unchecked(res)) - } else { - Err(NonNull::new_unchecked(exc)) + // Manually drop to keep this a pof. + let mut values = ManuallyDrop::new(values); + + #[cfg(feature = "julia-1-6")] + let mut task = NonNull::new_unchecked(jl_sys::jl_get_ptls_states()); + #[cfg(not(feature = "julia-1-6"))] + let mut task = NonNull::new_unchecked(jl_sys::jl_get_current_task()); + + let last_age = { + let task = task.as_mut(); + let last_age = task.world_age; + task.world_age = jl_get_world_counter(); + last_age }; - target.result_from_ptr(res, Private) + let args = values.as_ref(); + let v = jl_apply_generic(func, args.as_ptr() as *mut _, args.len() as _); + + { + let task = task.as_mut(); + task.world_age = last_age; + } + + ManuallyDrop::drop(&mut values); + target.data_from_ptr(NonNull::new_unchecked(v), Private) } } @@ -370,7 +379,6 @@ cfg_if::cfg_if! { data::managed::{ Managed, task::Task, - module::Module, function::Function }, async_util::{ @@ -395,13 +403,13 @@ cfg_if::cfg_if! { /// check if any of the arguments is currently borrowed from Rust. /// /// [`safety`]: crate::safety - async unsafe fn call_async<'target, 'value, V>( + async unsafe fn call_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; /// Creates and schedules a new task with `Base.Threads.@spawn`, and returns a future /// that resolves when this task is finished. @@ -415,15 +423,15 @@ cfg_if::cfg_if! { /// correctness. More information can be found in the [`safety`] module. /// /// [`safety`]: crate::safety - async unsafe fn call_async_tracked<'target, 'value, V>( + async unsafe fn call_async_tracked<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult> where - V: AsRef<[Value<'value, 'data>]> + V: Values<'value, 'data, N> { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -455,13 +463,13 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async<'target, 'value, V>( + unsafe fn schedule_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; /// Does the same thing as [`CallAsync::call_async`], but the task is returned rather than an /// awaitable `Future`. This method should only be called in [`PersistentTask::init`], @@ -477,16 +485,16 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_tracked<'target, 'value, V, T>( + unsafe fn schedule_async_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult, 'target, 'data>> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -518,13 +526,13 @@ cfg_if::cfg_if! { /// check if any of the arguments is currently borrowed from Rust. /// /// [`safety`]: crate::safety - async unsafe fn call_async_interactive<'target, 'value, V>( + async unsafe fn call_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; #[julia_version(since = "1.9")] /// Call a function on another thread with the given arguments. This method uses @@ -541,15 +549,15 @@ cfg_if::cfg_if! { /// returns an `AccessError::BorrowError` if any of the arguments is. /// /// [`safety`]: crate::safety - async unsafe fn call_async_interactive_tracked<'target, 'value, V>( + async unsafe fn call_async_interactive_tracked<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult> where - V: AsRef<[Value<'value, 'data>]> + V: Values<'value, 'data, N> { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -581,13 +589,13 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_interactive<'target, 'value, V>( + unsafe fn schedule_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; #[julia_version(since = "1.9")] @@ -605,16 +613,16 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_interactive_tracked<'target, 'value, V, T>( + unsafe fn schedule_async_interactive_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult, 'target, 'data>> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -645,13 +653,13 @@ cfg_if::cfg_if! { /// check if any of the arguments is currently borrowed from Rust. /// /// [`safety`]: crate::safety - async unsafe fn call_async_local<'target, 'value, V>( + async unsafe fn call_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; /// Call a function with the given arguments in an `@async` block. Like `call_async`, the /// function is not called on the main thread, but on a separate thread that handles all @@ -667,15 +675,15 @@ cfg_if::cfg_if! { /// returns an `AccessError::BorrowError` if any of the arguments is. /// /// [`safety`]: crate::safety - async unsafe fn call_async_local_tracked<'target, 'value, V>( + async unsafe fn call_async_local_tracked<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult> where - V: AsRef<[Value<'value, 'data>]> + V: Values<'value, 'data, N> { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -706,13 +714,13 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_local<'target, 'value, V>( + unsafe fn schedule_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; /// Does the same thing as [`CallAsync::call_async_local`], but the task is returned rather @@ -729,16 +737,16 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_local_tracked<'target, 'value, V, T>( + unsafe fn schedule_async_local_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult, 'target, 'data>> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -768,13 +776,13 @@ cfg_if::cfg_if! { /// check if any of the arguments is currently borrowed from Rust. /// /// [`safety`]: crate::safety - async unsafe fn call_async_main<'target, 'value, V>( + async unsafe fn call_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; /// Call a function with the given arguments in an `@async` block. The task is scheduled on @@ -790,15 +798,15 @@ cfg_if::cfg_if! { /// returns an `AccessError::BorrowError` if any of the arguments is. /// /// [`safety`]: crate::safety - async unsafe fn call_async_main_tracked<'target, 'value, V>( + async unsafe fn call_async_main_tracked<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult> where - V: AsRef<[Value<'value, 'data>]> + V: Values<'value, 'data, N> { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -829,13 +837,13 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_main<'target, 'value, V>( + unsafe fn schedule_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) ->JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>; + V: Values<'value, 'data, N>; /// Does the same thing as [`CallAsync::call_async_main`], but the task is returned rather /// than an awaitable `Future`. This method should only be called in [`PersistentTask::init`], @@ -851,16 +859,16 @@ cfg_if::cfg_if! { /// /// [`safety`]: crate::safety /// [`PersistentTask::init`]: crate::async_util::task::PersistentTask::init - unsafe fn schedule_async_main_tracked<'target, 'value, V, T>( + unsafe fn schedule_async_main_tracked<'target, 'value, V, T, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JlrsResult, 'target, 'data>> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { - let args = args.as_ref(); + let args = args.as_slice(Private); let res = args .iter() .copied() @@ -882,52 +890,45 @@ cfg_if::cfg_if! { #[async_trait(?Send)] impl<'data> CallAsync<'data> for Value<'_, 'data> { - async unsafe fn call_async<'target, 'value, V>( + #[inline] + async unsafe fn call_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new(frame, self, args).await + JuliaFuture::new(frame, erase_scope_lifetime(self), args).await } #[julia_version(since = "1.9")] - async unsafe fn call_async_interactive<'target, 'value, V>( + #[inline] + async unsafe fn call_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]> + V: Values<'value, 'data, N> { - JuliaFuture::new_interactive(frame, self, args).await + JuliaFuture::new_interactive(frame, erase_scope_lifetime(self), args).await } #[julia_version(since = "1.9")] - unsafe fn schedule_async_interactive<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); - - vals.push(self); - vals.extend_from_slice(values); + let args = args.into_extended_with_start([erase_scope_lifetime(self)], Private); - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "interactivecall") - .expect("interactivecall not available") - .as_managed() - .call(&mut *frame, &mut vals); + let task = JlrsCore::interactive_call(&frame) + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -935,28 +936,19 @@ cfg_if::cfg_if! { } } - unsafe fn schedule_async<'target, 'value, V>( + #[inline] + unsafe fn schedule_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); + let args = args.into_extended_with_start([erase_scope_lifetime(self)], Private); - vals.push(self); - vals.extend_from_slice(values); - - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "asynccall") - .expect("asynccall not available") - .as_managed() - .call(&mut *frame, &mut vals); + let task = JlrsCore::async_call(&frame) + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -964,39 +956,31 @@ cfg_if::cfg_if! { } } - async unsafe fn call_async_local<'target, 'value, V>( + #[inline] + async unsafe fn call_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new_local(frame, self, args).await + JuliaFuture::new_local(frame, erase_scope_lifetime(self), args).await } - unsafe fn schedule_async_local<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); - - vals.push(self); - vals.extend_from_slice(values); + let args = args.into_extended_with_start([erase_scope_lifetime(self)], Private); - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "scheduleasynclocal") - .expect("scheduleasynclocal not available") - .as_managed() - .call(&mut *frame, &mut vals); + let task = JlrsCore::schedule_async_local(&frame) + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -1004,39 +988,31 @@ cfg_if::cfg_if! { } } - async unsafe fn call_async_main<'target, 'value, V>( + #[inline] + async unsafe fn call_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new_main(frame, self, args).await + JuliaFuture::new_main(frame, erase_scope_lifetime(self), args).await } - unsafe fn schedule_async_main<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); + let args = args.into_extended_with_start([erase_scope_lifetime(self)], Private); - vals.push(self); - vals.extend_from_slice(values); - - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "scheduleasync") - .expect("scheduleasync not available") - .as_managed() - .call(&mut *frame, &mut vals); + let task = JlrsCore::schedule_async(&frame) + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -1047,92 +1023,100 @@ cfg_if::cfg_if! { #[async_trait(?Send)] impl<'data> CallAsync<'data> for Function<'_, 'data> { - async unsafe fn call_async<'target, 'value, V>( + #[inline] + async unsafe fn call_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new(frame, self.as_value(), args).await + JuliaFuture::new(frame, erase_scope_lifetime(self.as_value()), args).await } #[julia_version(since = "1.9")] - async unsafe fn call_async_interactive<'target, 'value, V>( + #[inline] + async unsafe fn call_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new_interactive(frame, self.as_value(), args).await + JuliaFuture::new_interactive(frame, erase_scope_lifetime(self.as_value()), args).await } #[julia_version(since = "1.9")] - unsafe fn schedule_async_interactive<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { self.as_value().schedule_async_interactive(frame, args) } - unsafe fn schedule_async<'target, 'value, V>( + #[inline] + unsafe fn schedule_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { self.as_value().schedule_async(frame, args) } - async unsafe fn call_async_local<'target, 'value, V>( + #[inline] + async unsafe fn call_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new_local(frame, self.as_value(), args).await + JuliaFuture::new_local(frame, erase_scope_lifetime(self.as_value()), args).await } - unsafe fn schedule_async_local<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { self.as_value().schedule_async_local(frame, args) } - async unsafe fn call_async_main<'target, 'value, V>( + #[inline] + async unsafe fn call_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - JuliaFuture::new_main(frame, self.as_value(), args).await + JuliaFuture::new_main(frame, erase_scope_lifetime(self.as_value()), args).await } - unsafe fn schedule_async_main<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { self.as_value().schedule_async_main(frame, args) } @@ -1140,54 +1124,47 @@ cfg_if::cfg_if! { #[async_trait(?Send)] impl<'data> CallAsync<'data> for WithKeywords<'_, 'data> { - async unsafe fn call_async<'target, 'value, V>( + #[inline] + async unsafe fn call_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { JuliaFuture::new_with_keywords(frame, self, args).await } #[julia_version(since = "1.9")] - async unsafe fn call_async_interactive<'target, 'value, V>( + #[inline] + async unsafe fn call_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { JuliaFuture::new_interactive_with_keywords(frame, self, args).await } #[julia_version(since = "1.9")] - unsafe fn schedule_async_interactive<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_interactive<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); - - vals.push(self.function()); - vals.extend_from_slice(values); - - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "interactivecall") - .expect("interactivecall not available") - .as_managed() + let args = args.into_extended_with_start([erase_scope_lifetime(self.function())], Private); + + let task = JlrsCore::interactive_call(&frame) .provide_keywords(self.keywords()) .expect("Keywords invalid") - .call(&mut *frame, &mut vals); + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -1195,30 +1172,21 @@ cfg_if::cfg_if! { } } - unsafe fn schedule_async<'target, 'value, V>( + #[inline] + unsafe fn schedule_async<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); - - vals.push(self.function()); - vals.extend_from_slice(values); - - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "asynccall") - .expect("asynccall not available") - .as_managed() + let args = args.into_extended_with_start([erase_scope_lifetime(self.function())], Private); + + let task = JlrsCore::schedule_async(&frame) .provide_keywords(self.keywords()) .expect("Keywords invalid") - .call(&mut *frame, &mut vals); + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -1226,41 +1194,33 @@ cfg_if::cfg_if! { } } - async unsafe fn call_async_local<'target, 'value, V>( + #[inline] + async unsafe fn call_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { JuliaFuture::new_local_with_keywords(frame, self, args).await } - unsafe fn schedule_async_local<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_local<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); - - vals.push(self.function()); - vals.extend_from_slice(values); - - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "scheduleasynclocal") - .expect("scheduleasynclocal not available") - .as_managed() + let args = args.into_extended_with_start([erase_scope_lifetime(self.function())], Private); + + let task = JlrsCore::schedule_async_local(&frame) .provide_keywords(self.keywords()) .expect("Keywords invalid") - .call(&mut *frame, &mut vals); + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), @@ -1268,41 +1228,33 @@ cfg_if::cfg_if! { } } - async unsafe fn call_async_main<'target, 'value, V>( + #[inline] + async unsafe fn call_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult<'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { JuliaFuture::new_main_with_keywords(frame, self, args).await } - unsafe fn schedule_async_main<'target, 'value, V>( + #[inline] + unsafe fn schedule_async_main<'target, 'value, V, const N: usize>( self, frame: &mut AsyncGcFrame<'target>, args: V, ) -> JuliaResult, 'target, 'data> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, { - let values = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + values.len()); - - vals.push(self.function()); - vals.extend_from_slice(values); - - let task = Module::main(&frame) - .submodule(&frame, "JlrsThreads") - .expect("JlrsCore.Threads not available") - .as_managed() - .function(&frame, "scheduleasync") - .expect("scheduleasync not available") - .as_managed() + let args = args.into_extended_with_start([erase_scope_lifetime(self.function())], Private); + + let task = JlrsCore::schedule_async(&frame) .provide_keywords(self.keywords()) .expect("Keywords invalid") - .call(&mut *frame, &mut vals); + .call(&mut *frame, args.as_ref()); match task { Ok(t) => Ok(t.cast_unchecked::()), diff --git a/jlrs/src/catch.rs b/jlrs/src/catch.rs deleted file mode 100644 index d65bd139..00000000 --- a/jlrs/src/catch.rs +++ /dev/null @@ -1,290 +0,0 @@ -use std::{ - any::Any, - ffi::c_void, - mem::MaybeUninit, - panic::{catch_unwind, AssertUnwindSafe}, - ptr::{null_mut, NonNull}, -}; - -use jl_sys::{ - jlrs_catch_t, jlrs_catch_tag_t_JLRS_CATCH_ERR, jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION, - jlrs_catch_tag_t_JLRS_CATCH_OK, jlrs_catch_tag_t_JLRS_CATCH_PANIC, jlrs_catch_wrapper, -}; -use jlrs_macros::julia_version; - -#[julia_version(windows_lts = true)] -use crate::{ - call::Call, - data::managed::{module::Module, value::Value}, - memory::{gc::Gc, target::unrooted::Unrooted}, -}; -use crate::{ - data::managed::value::ValueRef, - error::{JlrsResult, JuliaResultRef}, - memory::target::frame::GcFrame, -}; - -unsafe extern "C" fn trampoline_with_slots<'frame, F, T>( - func: &mut F, - frame_slice: &mut GcFrame<'frame>, - result: &mut MaybeUninit, -) -> jlrs_catch_t -where - F: FnMut(&mut GcFrame<'frame>, &mut MaybeUninit) -> JlrsResult<()>, -{ - let res = catch_unwind(AssertUnwindSafe(|| func(frame_slice, result))); - - match res { - Ok(Ok(())) => jlrs_catch_t { - tag: jlrs_catch_tag_t_JLRS_CATCH_OK, - error: null_mut(), - }, - Ok(Err(e)) => jlrs_catch_t { - tag: jlrs_catch_tag_t_JLRS_CATCH_ERR, - error: Box::leak(e) as *mut _ as *mut _, - }, - Err(e) => { - // extra box because it's a fat pointer - jlrs_catch_t { - tag: jlrs_catch_tag_t_JLRS_CATCH_PANIC, - error: Box::leak(Box::new(e)) as *mut _ as *mut _, - } - } - } -} - -fn trampoline_with_slots_for< - 'frame, - F: FnMut(&mut GcFrame<'frame>, &mut MaybeUninit) -> JlrsResult<()>, - T, ->( - _: &mut F, -) -> Option jlrs_catch_t> { - unsafe { - std::mem::transmute::< - Option< - unsafe extern "C" fn( - &mut F, - &mut GcFrame<'frame>, - &mut MaybeUninit, - ) -> jlrs_catch_t, - >, - Option jlrs_catch_t>, - >(Some(trampoline_with_slots::)) - } -} - -#[julia_version(windows_lts = false)] -pub(crate) unsafe fn catch_exceptions_with_slots<'frame, 'borrow, 'data, G, T>( - frame: &'borrow mut GcFrame<'frame>, - func: &'borrow mut G, -) -> JlrsResult> -where - T: 'frame, - G: FnMut(&mut GcFrame<'frame>, &mut MaybeUninit) -> JlrsResult<()>, -{ - let trampoline = trampoline_with_slots_for(func); - let mut result = MaybeUninit::::uninit(); - - let res = jlrs_catch_wrapper( - func as *mut _ as *mut _, - trampoline, - (&mut result) as *mut _ as *mut _, - frame as *mut _ as *mut _, - ); - - match res.tag { - x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(Ok(result.assume_init())), - x if x == jlrs_catch_tag_t_JLRS_CATCH_ERR => Err(Box::from_raw(res.error.cast())), - x if x == jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION => Ok(Err(ValueRef::wrap( - NonNull::new_unchecked(res.error.cast()), - ))), - x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { - let err: Box> = Box::from_raw(res.error.cast()); - std::panic::resume_unwind(err) - } - _ => unreachable!(), - } -} - -#[julia_version(windows_lts = true)] -pub(crate) unsafe fn catch_exceptions_with_slots<'frame, 'borrow, 'data, G, T>( - frame: &'borrow mut GcFrame<'frame>, - func: &'borrow mut G, -) -> JlrsResult> -where - T: 'frame, - G: FnMut(&mut GcFrame<'frame>, &mut MaybeUninit) -> JlrsResult<()>, -{ - let trampoline = trampoline_with_slots_for(func); - let mut result = MaybeUninit::::uninit(); - - let unrooted = Unrooted::new(); - let enabled = unrooted.gc_is_enabled(); - unrooted.enable_gc(false); - - let caller = Module::package_root_module(&unrooted, "JlrsCore") - .unwrap() - .global(&unrooted, "call_catch_wrapper") - .unwrap() - .as_value(); - - let func = Value::new(unrooted, func as *mut _ as *mut c_void).as_value(); - let cw = Value::new(unrooted, jlrs_catch_wrapper as *mut c_void).as_value(); - let trampoline = - Value::new(unrooted, std::mem::transmute::<_, *mut c_void>(trampoline)).as_value(); - { - let result_ref = &mut result; - let result_v = Value::new(unrooted, result_ref as *mut _ as *mut c_void).as_value(); - let frame_slice = Value::new(unrooted, frame as *mut _ as *mut c_void).as_value(); - let res = caller.call(unrooted, [cw, func, trampoline, result_v, frame_slice]); - - unrooted.enable_gc(enabled); - - match res { - Ok(res) => { - let res = res.data_ptr().cast::().as_ref(); - match res.tag { - x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(Ok(result.assume_init())), - x if x == jlrs_catch_tag_t_JLRS_CATCH_ERR => { - Err(Box::from_raw(res.error.cast())) - } - x if x == jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION => Ok(Err(ValueRef::wrap( - NonNull::new_unchecked(res.error.cast()), - ))), - x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { - let err: Box> = Box::from_raw(res.error.cast()); - std::panic::resume_unwind(err) - } - _ => unreachable!(), - } - } - Err(err) => Ok(Err(err)), - } - } -} - -unsafe extern "C" fn trampoline<'frame, F: FnMut(&mut MaybeUninit) -> JlrsResult<()>, T>( - func: &mut F, - _: *mut c_void, - result: &mut MaybeUninit, -) -> jlrs_catch_t { - let res = catch_unwind(AssertUnwindSafe(|| func(result))); - - match res { - Ok(Ok(())) => jlrs_catch_t { - tag: jlrs_catch_tag_t_JLRS_CATCH_OK, - error: null_mut(), - }, - Ok(Err(e)) => jlrs_catch_t { - tag: jlrs_catch_tag_t_JLRS_CATCH_ERR, - error: Box::leak(e) as *mut _ as *mut _, - }, - Err(e) => { - // extra box because it's a fat pointer - jlrs_catch_t { - tag: jlrs_catch_tag_t_JLRS_CATCH_PANIC, - error: Box::leak(Box::new(e)) as *mut _ as *mut _, - } - } - } -} - -fn trampoline_for<'frame, F: FnMut(&mut MaybeUninit) -> JlrsResult<()>, T>( - _: &mut F, -) -> Option jlrs_catch_t> { - unsafe { - std::mem::transmute::< - Option) -> jlrs_catch_t>, - Option jlrs_catch_t>, - >(Some(trampoline::)) - } -} - -#[julia_version(windows_lts = false)] -pub(crate) unsafe fn catch_exceptions<'frame, 'borrow, 'data, G, T>( - func: &'borrow mut G, -) -> JlrsResult> -where - T: 'frame, - G: FnMut(&mut MaybeUninit) -> JlrsResult<()>, -{ - let trampoline = trampoline_for(func); - let mut result = MaybeUninit::::uninit(); - - let res = jlrs_catch_wrapper( - func as *mut _ as *mut _, - trampoline, - (&mut result) as *mut _ as *mut _, - null_mut(), - ); - - match res.tag { - x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(Ok(result.assume_init())), - x if x == jlrs_catch_tag_t_JLRS_CATCH_ERR => Err(Box::from_raw(res.error.cast())), - x if x == jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION => Ok(Err(ValueRef::wrap( - NonNull::new_unchecked(res.error.cast()), - ))), - x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { - let err: Box> = Box::from_raw(res.error.cast()); - std::panic::resume_unwind(err) - } - _ => unreachable!(), - } -} - -#[julia_version(windows_lts = true)] -pub(crate) unsafe fn catch_exceptions<'frame, 'borrow, 'data, G, T>( - func: &'borrow mut G, -) -> JlrsResult> -where - T: 'frame, - G: FnMut(&mut MaybeUninit) -> JlrsResult<()>, -{ - let trampoline = trampoline_for(func); - let mut result = MaybeUninit::::uninit(); - - let unrooted = Unrooted::new(); - let enabled = unrooted.gc_is_enabled(); - unrooted.enable_gc(false); - - let caller = Module::package_root_module(&unrooted, "JlrsCore") - .unwrap() - .global(&unrooted, "call_catch_wrapper") - .unwrap() - .as_value(); - - let func = Value::new(unrooted, func as *mut _ as *mut c_void).as_value(); - let cw = Value::new(unrooted, jlrs_catch_wrapper as *mut c_void).as_value(); - let trampoline = - Value::new(unrooted, std::mem::transmute::<_, *mut c_void>(trampoline)).as_value(); - { - let result_ref = &mut result; - let result_v = Value::new(unrooted, result_ref as *mut _ as *mut c_void).as_value(); - let frame_slice = Value::new(unrooted, null_mut::()).as_value(); - let res = caller.call(unrooted, [cw, func, trampoline, result_v, frame_slice]); - - unrooted.enable_gc(enabled); - - match res { - Ok(res) => { - let res = res.data_ptr().cast::().as_ref(); - match res.tag { - x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(Ok(result.assume_init())), - x if x == jlrs_catch_tag_t_JLRS_CATCH_ERR => { - Err(Box::from_raw(res.error.cast())) - } - x if x == jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION => Ok(Err(ValueRef::wrap( - NonNull::new_unchecked(res.error.cast()), - ))), - x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { - let err: Box> = Box::from_raw(res.error.cast()); - std::panic::resume_unwind(err) - } - _ => unreachable!(), - } - } - Err(err) => Ok(Err(err)), - } - } -} diff --git a/jlrs/src/catch/impl_nightly.rs b/jlrs/src/catch/impl_nightly.rs new file mode 100644 index 00000000..10a1a1c7 --- /dev/null +++ b/jlrs/src/catch/impl_nightly.rs @@ -0,0 +1,170 @@ +#[julia_version(windows_lts = false)] +use std::ptr::NonNull; +use std::{ + any::Any, + ffi::c_void, + hint::unreachable_unchecked, + mem::MaybeUninit, + panic::{catch_unwind, AssertUnwindSafe}, + ptr::null_mut, +}; + +#[julia_version(windows_lts = false)] +use jl_sys::jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION; +use jl_sys::{ + jlrs_catch_t, jlrs_catch_tag_t_JLRS_CATCH_OK, jlrs_catch_tag_t_JLRS_CATCH_PANIC, + jlrs_catch_wrapper, +}; +use jlrs_macros::julia_version; + +#[julia_version(windows_lts = true)] +use crate::{ + call::Call, + data::managed::module::JlrsCore, + prelude::{Target, Value}, +}; +#[julia_version(windows_lts = false)] +use crate::{ + data::managed::{Managed, private::ManagedPriv}, + memory::target::unrooted::Unrooted, + prelude::{Target, Value}, + private::Private, +}; + +/// Call `func`, if an exception is thrown it is caught and `exception_handler` is called. The +/// exception is guaranteed to be rooted inside the exception handler. +/// +/// Safety: +/// +/// If an exception is thrown, there must be no pending drops. Only local scopes may be created in +/// `func`. +#[julia_version(windows_lts = false)] +pub unsafe fn catch_exceptions(mut func: G, exception_handler: H) -> Result +where + G: FnMut() -> T, + H: for<'exc> FnOnce(Value<'exc, 'static>) -> E, +{ + let func = &mut func; + let trampoline = trampoline_for(func); + let mut result = MaybeUninit::::uninit(); + + let res = jlrs_catch_wrapper( + func as *mut _ as *mut _, + trampoline, + (&mut result) as *mut _ as *mut _, + ); + + match res.tag { + x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(result.assume_init()), + x if x == jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION => { + let ptr = NonNull::new_unchecked(res.error.cast()); + let unrooted = Unrooted::new(); + unrooted + .local_scope::<_, _, 1>(|frame| { + // Root the exception because we're not in an actual catch block. + let v = Value::wrap_non_null(ptr, Private).root(frame); + Ok(Err(exception_handler(v))) + }) + .unwrap_unchecked() + } + x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { + let err: Box> = Box::from_raw(res.error.cast()); + std::panic::resume_unwind(err) + } + _ => unreachable_unchecked(), + } +} + +/// Call `func`, if an exception is thrown it is caught and `exception_handler` is called. The +/// exception is guaranteed to be rooted inside the exception handler. +/// +/// Safety: +/// +/// If an exception is thrown, there must be no pending drops. Only local scopes may be created in +/// `func`. +#[julia_version(windows_lts = true)] +pub unsafe fn catch_exceptions(mut func: G, exception_handler: H) -> Result +where + G: FnMut() -> T, + H: for<'exc> FnOnce(Value<'exc, 'static>) -> E, +{ + let func = &mut func; + let trampoline = trampoline_for(func); + let mut result = MaybeUninit::::uninit(); + let unrooted = crate::memory::target::unrooted::Unrooted::new(); + + // The JL_TRY and JL_CATCH macros don't work when Julia 1.6 is used on Windows, so we're + // going to jump back to Rust code from Julia rather than C. + let caller = JlrsCore::call_catch_wrapper(&unrooted); + let trampoline = std::mem::transmute::<_, *mut c_void>(trampoline); + + let res = unrooted + .with_local_scope::<_, _, 4>(|target, mut frame| { + let result = &mut result; + + let catch_wrapper = Value::new(&mut frame, jlrs_catch_wrapper as *mut c_void); + let func = Value::new(&mut frame, func as *mut _ as *mut c_void); + let trampoline = Value::new(&mut frame, trampoline); + let result = Value::new(&mut frame, result as *mut _ as *mut c_void); + + Ok(caller.call(target, [catch_wrapper, func, trampoline, result])) + }) + .unwrap_unchecked(); + + match res { + Ok(res) => { + let res = res.ptr().cast::().as_ref(); + match res.tag { + x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(result.assume_init()), + x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { + let err: Box> = Box::from_raw(res.error.cast()); + std::panic::resume_unwind(err) + } + _ => unreachable_unchecked(), + } + } + Err(exc) => unrooted + .local_scope::<_, _, 1>(|frame| { + let value = exc.root(frame); + Ok(Err(exception_handler(value))) + }) + .unwrap_unchecked(), + } +} + +#[inline] +unsafe extern "C-unwind" fn trampoline<'frame, F: FnMut() -> T, T>( + func: &mut F, + result: &mut MaybeUninit, +) -> jlrs_catch_t { + let res = catch_unwind(AssertUnwindSafe(|| func())); + + match res { + Ok(v) => { + result.write(v); + jlrs_catch_t { + tag: jlrs_catch_tag_t_JLRS_CATCH_OK, + error: null_mut(), + } + } + Err(e) => { + // extra box because it's a fat pointer + jlrs_catch_t { + tag: jlrs_catch_tag_t_JLRS_CATCH_PANIC, + error: Box::leak(Box::new(e)) as *mut _ as *mut _, + } + } + } +} + +#[inline] +fn trampoline_for<'frame, F: FnMut() -> T, T>( + _: &mut F, +) -> Option jlrs_catch_t> { + unsafe { + std::mem::transmute::< + Option) -> jlrs_catch_t>, + Option jlrs_catch_t>, + >(Some(trampoline::)) + } +} diff --git a/jlrs/src/catch/impl_stable.rs b/jlrs/src/catch/impl_stable.rs new file mode 100644 index 00000000..af9b1917 --- /dev/null +++ b/jlrs/src/catch/impl_stable.rs @@ -0,0 +1,170 @@ +#[julia_version(windows_lts = false)] +use std::ptr::NonNull; +use std::{ + any::Any, + ffi::c_void, + hint::unreachable_unchecked, + mem::MaybeUninit, + panic::{catch_unwind, AssertUnwindSafe}, + ptr::null_mut, +}; + +#[julia_version(windows_lts = false)] +use jl_sys::jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION; +use jl_sys::{ + jlrs_catch_t, jlrs_catch_tag_t_JLRS_CATCH_OK, jlrs_catch_tag_t_JLRS_CATCH_PANIC, + jlrs_catch_wrapper, +}; +use jlrs_macros::julia_version; + +#[julia_version(windows_lts = true)] +use crate::{ + call::Call, + data::managed::module::JlrsCore, + prelude::{Target, Value}, +}; +#[julia_version(windows_lts = false)] +use crate::{ + data::managed::{Managed, private::ManagedPriv}, + memory::target::unrooted::Unrooted, + prelude::{Target, Value}, + private::Private, +}; + +/// Call `func`, if an exception is thrown it is caught and `exception_handler` is called. The +/// exception is guaranteed to be rooted inside the exception handler. +/// +/// Safety: +/// +/// If an exception is thrown, there must be no pending drops. Only local scopes may be created in +/// `func`. +#[julia_version(windows_lts = false)] +pub unsafe fn catch_exceptions(mut func: G, exception_handler: H) -> Result +where + G: FnMut() -> T, + H: for<'exc> FnOnce(Value<'exc, 'static>) -> E, +{ + let func = &mut func; + let trampoline = trampoline_for(func); + let mut result = MaybeUninit::::uninit(); + + let res = jlrs_catch_wrapper( + func as *mut _ as *mut _, + trampoline, + (&mut result) as *mut _ as *mut _, + ); + + match res.tag { + x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(result.assume_init()), + x if x == jlrs_catch_tag_t_JLRS_CATCH_EXCEPTION => { + let ptr = NonNull::new_unchecked(res.error.cast()); + let unrooted = Unrooted::new(); + unrooted + .local_scope::<_, _, 1>(|frame| { + // Root the exception because we're not in an actual catch block. + let v = Value::wrap_non_null(ptr, Private).root(frame); + Ok(Err(exception_handler(v))) + }) + .unwrap_unchecked() + } + x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { + let err: Box> = Box::from_raw(res.error.cast()); + std::panic::resume_unwind(err) + } + _ => unreachable_unchecked(), + } +} + +/// Call `func`, if an exception is thrown it is caught and `exception_handler` is called. The +/// exception is guaranteed to be rooted inside the exception handler. +/// +/// Safety: +/// +/// If an exception is thrown, there must be no pending drops. Only local scopes may be created in +/// `func`. +#[julia_version(windows_lts = true)] +pub unsafe fn catch_exceptions(mut func: G, exception_handler: H) -> Result +where + G: FnMut() -> T, + H: for<'exc> FnOnce(Value<'exc, 'static>) -> E, +{ + let func = &mut func; + let trampoline = trampoline_for(func); + let mut result = MaybeUninit::::uninit(); + let unrooted = crate::memory::target::unrooted::Unrooted::new(); + + // The JL_TRY and JL_CATCH macros don't work when Julia 1.6 is used on Windows, so we're + // going to jump back to Rust code from Julia rather than C. + let caller = JlrsCore::call_catch_wrapper(&unrooted); + let trampoline = std::mem::transmute::<_, *mut c_void>(trampoline); + + let res = unrooted + .with_local_scope::<_, _, 4>(|target, mut frame| { + let result = &mut result; + + let catch_wrapper = Value::new(&mut frame, jlrs_catch_wrapper as *mut c_void); + let func = Value::new(&mut frame, func as *mut _ as *mut c_void); + let trampoline = Value::new(&mut frame, trampoline); + let result = Value::new(&mut frame, result as *mut _ as *mut c_void); + + Ok(caller.call(target, [catch_wrapper, func, trampoline, result])) + }) + .unwrap_unchecked(); + + match res { + Ok(res) => { + let res = res.ptr().cast::().as_ref(); + match res.tag { + x if x == jlrs_catch_tag_t_JLRS_CATCH_OK => Ok(result.assume_init()), + x if x == jlrs_catch_tag_t_JLRS_CATCH_PANIC => { + let err: Box> = Box::from_raw(res.error.cast()); + std::panic::resume_unwind(err) + } + _ => unreachable_unchecked(), + } + } + Err(exc) => unrooted + .local_scope::<_, _, 1>(|frame| { + let value = exc.root(frame); + Ok(Err(exception_handler(value))) + }) + .unwrap_unchecked(), + } +} + +#[inline] +unsafe extern "C" fn trampoline<'frame, F: FnMut() -> T, T>( + func: &mut F, + result: &mut MaybeUninit, +) -> jlrs_catch_t { + let res = catch_unwind(AssertUnwindSafe(|| func())); + + match res { + Ok(v) => { + result.write(v); + jlrs_catch_t { + tag: jlrs_catch_tag_t_JLRS_CATCH_OK, + error: null_mut(), + } + } + Err(e) => { + // extra box because it's a fat pointer + jlrs_catch_t { + tag: jlrs_catch_tag_t_JLRS_CATCH_PANIC, + error: Box::leak(Box::new(e)) as *mut _ as *mut _, + } + } + } +} + +#[inline] +fn trampoline_for<'frame, F: FnMut() -> T, T>( + _: &mut F, +) -> Option jlrs_catch_t> { + unsafe { + std::mem::transmute::< + Option) -> jlrs_catch_t>, + Option jlrs_catch_t>, + >(Some(trampoline::)) + } +} diff --git a/jlrs/src/catch/mod.rs b/jlrs/src/catch/mod.rs new file mode 100644 index 00000000..ef6f9cdb --- /dev/null +++ b/jlrs/src/catch/mod.rs @@ -0,0 +1,36 @@ +//! Try-catch blocks. +//! +//! Many functions in Julia can throw exceptions, jlrs provides checked and unchecked variants of +//! such functions. The checked variant calls the function in a try-catch block and returns a +//! `Result` to indicate whether or not the operation succeeded, while the unchecked variant +//! simply calls the function. If an exception is thrown and it isn't caught the application is +//! aborted. The main disadvantage of the checked variants is that a new try-catch block is +//! created every time the function is called and creating such a block is relatively expensive. +//! +//! Instead of using the checked variants you can create a try-catch block from Rust with +//! [`catch_exceptions`]. This function takes two closures, think of them as the content of the +//! try and catch blocks respectively. +//! +//! Because exceptions work by jumping to the nearest enclosing catch block, you must guarantee +//! that there are no pending drops when an exception is thrown. See this [blog post] for more +//! information. +//! +//! Only local scopes may be created in the try-block, Julia's unwinding mechanism ensures that +//! any scope we jump out of is removed from the GC stack. Dynamic scopes (i.e. scopes that +//! provide a `GcFrame`) depend on `Drop` so jumping out of them is not sound. +//! +//! [blog post]: https://blog.rust-lang.org/inside-rust/2021/01/26/ffi-unwind-longjmp.html#pofs-and-stack-deallocating-functions + +use cfg_if::cfg_if; + +cfg_if! { + if #[cfg(feature = "c-unwind")] { + #[path ="impl_nightly.rs"] + mod imp; + } else { + #[path ="impl_stable.rs"] + mod imp; + } +} + +pub use imp::catch_exceptions; diff --git a/jlrs/src/ccall.rs b/jlrs/src/ccall.rs index eb4b5cb3..28433753 100644 --- a/jlrs/src/ccall.rs +++ b/jlrs/src/ccall.rs @@ -2,20 +2,21 @@ //! //! This module is only available if the `ccall` feature is enabled. +// TODO + use std::{ cell::UnsafeCell, ffi::c_void, fmt::Debug, hint::spin_loop, ptr::NonNull, - sync::{atomic::AtomicBool, Arc, Mutex}, + sync::{atomic::AtomicBool, Arc}, }; use atomic::Ordering; #[cfg(feature = "uv")] use jl_sys::uv_async_send; use jl_sys::{jl_tagged_gensym, jl_throw}; -use once_cell::sync::OnceCell; use threadpool::{Builder, ThreadPool}; use crate::{ @@ -23,21 +24,24 @@ use crate::{ convert::{ccall_types::CCallReturn, into_julia::IntoJulia}, data::{ managed::{ - module::Module, + module::{JlrsCore, Module}, private::ManagedPriv, - rust_result::{RustResult, RustResultRet}, symbol::Symbol, - value::{Value, ValueRef}, + value::{Value, ValueRet}, Managed, }, types::construct_type::ConstructType, }, error::{JlrsError, JlrsResult}, + gc_safe::{GcSafeMutex, GcSafeOnceLock}, init_jlrs, memory::{ - context::stack::Stack, stack_frame::{PinnedFrame, StackFrame}, - target::{frame::GcFrame, unrooted::Unrooted, Target}, + target::{ + frame::{GcFrame, LocalFrame, LocalGcFrame}, + unrooted::Unrooted, + Target, + }, }, private::Private, InstallJlrsCore, @@ -47,15 +51,15 @@ use crate::{ // ThreadPool is !Sync, but it is safe to clone it (which creates a new handle to the pool) and // use that handle to schedule new jobs to avoid having to lock the pool whenever a new job is // scheduled. -static POOL: OnceCell> = OnceCell::new(); -static POOL_NAME: OnceCell = OnceCell::new(); +static POOL: GcSafeOnceLock> = GcSafeOnceLock::new(); +static POOL_NAME: GcSafeOnceLock = GcSafeOnceLock::new(); thread_local! { static LOCAL_POOL: ThreadPool = unsafe { - init_pool().lock().unwrap().clone() + init_pool().lock().clone() } } -unsafe fn init_pool() -> &'static Mutex { +unsafe fn init_pool() -> &'static GcSafeMutex { POOL.get_or_init(|| { let name = POOL_NAME.get_or_init(|| { let pool_name = "jlrs-pool"; @@ -70,12 +74,12 @@ unsafe fn init_pool() -> &'static Mutex { .thread_name(name.clone()) .build(); - Mutex::new(pool) + GcSafeMutex::new(pool) }) } unsafe extern "C" fn set_pool_size(size: usize) { - init_pool().lock().unwrap().set_num_threads(size); + init_pool().lock().set_num_threads(size); } unsafe extern "C" fn set_pool_name(module: Module) { @@ -91,8 +95,6 @@ unsafe extern "C" fn set_pool_name(module: Module) { /// initialize it again causes a crash. In order to still be able to call Julia from Rust /// you must create a scope first. You can use this struct to do so. It must never be used outside /// functions called through `ccall`, and only once for each `ccall`ed function. -/// -/// Exceptions must only be thrown indirectly by returning a `RustResult`. pub struct CCall<'context> { frame: PinnedFrame<'context, 0>, } @@ -102,6 +104,7 @@ impl<'context> CCall<'context> { /// /// Safety: This function must never be called outside a function called through `ccall` from /// Julia and must only be called once during that call. + #[inline] pub unsafe fn new(frame: &'context mut StackFrame<0>) -> Self { CCall { frame: frame.pin() } } @@ -117,6 +120,7 @@ impl<'context> CCall<'context> { /// /// Safety: the handle must be acquired from an `AsyncCondition`. #[cfg(feature = "uv")] + #[inline] pub unsafe fn uv_async_send(handle: *mut std::ffi::c_void) -> bool { uv_async_send(handle.cast()) == 0 } @@ -135,6 +139,52 @@ impl<'context> CCall<'context> { } } + /// Create a [`LocalGcFrame`], call the given closure, and return its result. + #[inline] + pub unsafe fn local_scope(func: F) -> JlrsResult + where + for<'scope> F: FnOnce(LocalGcFrame<'scope, N>) -> JlrsResult, + { + let mut local_frame = LocalFrame::new(); + #[cfg(not(feature = "julia-1-6"))] + let pgcstack = NonNull::new_unchecked(jl_sys::jl_get_pgcstack()); + + #[cfg(feature = "julia-1-6")] + let pgcstack = { + let ptls = jl_sys::jl_get_ptls_states(); + NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)) + }; + + let pinned = local_frame.pin(pgcstack); + let res = func(LocalGcFrame::new(&pinned)); + pinned.pop(pgcstack); + + res + } + + /// Create a [`LocalGcFrame`], call the given closure, and return its result. + #[inline] + pub unsafe fn infallible_local_scope(func: F) -> T + where + for<'scope> F: FnOnce(LocalGcFrame<'scope, N>) -> T, + { + let mut local_frame = LocalFrame::new(); + #[cfg(not(feature = "julia-1-6"))] + let pgcstack = NonNull::new_unchecked(jl_sys::jl_get_pgcstack()); + + #[cfg(feature = "julia-1-6")] + let pgcstack = { + let ptls = jl_sys::jl_get_ptls_states(); + NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)) + }; + + let pinned = local_frame.pin(pgcstack); + let res = func(LocalGcFrame::new(&pinned)); + pinned.pop(pgcstack); + + res + } + /// Create an instance of `CCall` and use it to invoke the provided closure. /// /// Safety: this method must only be called from `ccall`ed functions. The returned data is @@ -160,10 +210,10 @@ impl<'context> CCall<'context> { /// /// Safety: this method must only be called from `ccall`ed functions. The returned data is /// unrooted and must be returned to Julia immediately. - pub unsafe fn invoke_fallible(func: F) -> RustResultRet + pub unsafe fn invoke_fallible(func: F) -> JlrsResult where T: ConstructType, - for<'scope> F: FnOnce(GcFrame<'scope>) -> JlrsResult>, + for<'scope> F: FnOnce(GcFrame<'scope>) -> JlrsResult, { let mut frame = StackFrame::new(); let mut ccall = CCall::new(&mut frame); @@ -171,15 +221,7 @@ impl<'context> CCall<'context> { let stack = ccall.frame.stack_frame().sync_stack(); let (owner, frame) = GcFrame::base(stack); - let ret = match func(frame) { - Ok(res) => res, - Err(e) => { - let mut frame = owner.restore(); - RustResult::::jlrs_error(frame.as_extended_target(), *e) - .as_ref() - .leak() - } - }; + let ret = func(frame); std::mem::drop(owner); std::mem::drop(ccall); ret @@ -189,6 +231,7 @@ impl<'context> CCall<'context> { /// /// Safety: this method must only be called from `ccall`ed functions. The returned data is /// unrooted and must be returned to Julia immediately. + #[inline] pub unsafe fn stackless_invoke(func: F) -> T where T: 'static + CCallReturn, @@ -197,33 +240,31 @@ impl<'context> CCall<'context> { func(Unrooted::new()) } - /// Create and throw an exception. - /// - /// This method calls `func` and throws the result as a Julia exception. + /// Throw an exception. /// /// Safety: /// - /// Julia exceptions are implemented with `setjmp` / `longjmp`. This means that when an - /// exception is thrown, control flow is returned to a `catch` block by jumping over - /// intermediate stack frames. It's undefined behaviour to jump over frames that have pending - /// drops, so you must take care to structure your code such that none of the intermediate - /// frames have any pending drops. - #[inline(never)] - pub unsafe fn throw_exception(mut self, func: F) -> ! - where - F: for<'scope> FnOnce(&mut GcFrame<'scope>) -> Value<'scope, 'static>, - { - let exception = construct_exception(self.frame.stack_frame().sync_stack(), func); - // catch unwinds the GC stack, so it's okay to forget self. - std::mem::forget(self); + /// Don't jump over any frames that have pendings drops. Julia exceptions are implemented with + /// `setjmp` / `longjmp`. This means that when an exception is thrown, control flow is + /// returned to a `catch` block by jumping over intermediate stack frames. + #[inline] + pub unsafe fn throw_exception(exception: ValueRet) -> ! { jl_throw(exception.ptr().as_ptr()) } + #[inline] + pub unsafe fn throw_borrow_exception() -> ! { + let unrooted = Unrooted::new(); + let err = JlrsCore::borrow_error(&unrooted).instance().unwrap(); + jl_throw(err.unwrap(Private)) + } + /// Create an [`Unrooted`], call the given closure, and return its result. /// /// Unlike [`CCall::scope`] this method doesn't allocate a stack. /// /// Safety: must only be called from a `ccall`ed function that doesn't need to root any data. + #[inline] pub unsafe fn stackless_scope(func: F) -> JlrsResult where for<'scope> F: FnOnce(Unrooted<'scope>) -> JlrsResult, @@ -232,6 +273,7 @@ impl<'context> CCall<'context> { } /// Set the size of the internal thread pool. + #[inline] pub fn set_pool_size(&self, size: usize) { unsafe { set_pool_size(size) } } @@ -280,25 +322,6 @@ impl<'context> CCall<'context> { } } -impl Drop for CCall<'_> { - fn drop(&mut self) { - #[cfg(feature = "mem-debug")] - eprintln!("Drop CCall"); - } -} - -#[inline(never)] -unsafe fn construct_exception<'stack, F>(stack: &'stack Stack, func: F) -> ValueRef<'stack, 'static> -where - for<'scope> F: FnOnce(&mut GcFrame<'scope>) -> Value<'scope, 'static>, -{ - let (owner, mut frame) = GcFrame::base(stack); - let ret = func(&mut frame); - let rewrapped = ValueRef::wrap(ret.unwrap_non_null(Private)); - std::mem::drop(owner); - rewrapped -} - #[doc(hidden)] #[repr(transparent)] pub struct AsyncConditionHandle(pub *mut c_void); @@ -313,22 +336,15 @@ pub struct AsyncCCall { } unsafe impl ConstructType for AsyncCCall { - fn construct_type<'target, T>( - target: crate::memory::target::ExtendedTarget<'target, '_, '_, T>, - ) -> crate::data::managed::value::ValueData<'target, 'static, T> + type Static = AsyncCCall; + + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> crate::data::managed::value::ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, _) = target.split(); - unsafe { - Module::package_root_module(&target, "JlrsCore") - .unwrap() - .submodule(&target, "Wrap") - .unwrap() - .as_managed() - .global(target, "AsyncCCall") - .unwrap() - } + unsafe { Self::base_type(&target).unwrap_unchecked().root(target) } } fn base_type<'target, Tgt>( @@ -337,18 +353,13 @@ unsafe impl ConstructType for AsyncCCall { where Tgt: crate::memory::target::Target<'target>, { - unsafe { - Some( - Module::package_root_module(target, "JlrsCore") - .unwrap() - .submodule(target, "Wrap") - .unwrap() - .as_managed() - .global(target, "AsyncCCall") - .unwrap() - .as_value(), - ) - } + /*Some(inline_static_ref!( + ASYNC_CCALL, + Value, + "JlrsCore.Wrap.AsyncCCall", + target + ))*/ + unsafe { Module::typed_global_cached(target, "JlrsCore.Wrap.AsyncCCall").ok() } } } @@ -401,6 +412,7 @@ impl DispatchHandle { /// /// Safety: this method must only be called once. pub unsafe fn join(self: Arc) -> JlrsResult { + // TODO: enter GC-safe? while !self.flag.load(Ordering::Acquire) { spin_loop(); } diff --git a/jlrs/src/convert/ccall_types.rs b/jlrs/src/convert/ccall_types.rs index bee4ae15..6e26d66f 100644 --- a/jlrs/src/convert/ccall_types.rs +++ b/jlrs/src/convert/ccall_types.rs @@ -10,23 +10,32 @@ //! ``` //! //! These types depend on the type used in Rust, which must implement [`CCallArg`] or -//! [`CCallReturn`] depending on their position. Both these traits have two associated types that -//! are used to construct the appropriate types to be used in the function and ccall signature -//! respectively. +//! [`CCallReturn`] depending on their position. Both these traits have several associated types +//! that are used to construct the appropriate types to be used in the function and ccall +//! signatures. //! //! You shoudldn't manually implement these traits, they're automatically implemented -//! derived by `JlrsReflect`. +//! by `JlrsCore.Reflect` if supported. //! //! [`julia_module`]: ::jlrs_macros::julia_module -use crate::data::types::construct_type::ConstructType; +use crate::{ + data::{ + managed::{module::JlrsCore, value::ValueRet}, + types::construct_type::ConstructType, + }, + prelude::{JlrsResult, JuliaString, Managed, Nothing}, +}; /// Trait implemented by types that can be used as argument types of Rust functions exposed by the /// [`julia_module`] macro. /// /// [`julia_module`]: ::jlrs_macros::julia_module pub unsafe trait CCallArg { + /// Type constructor for the type taken by the generated Julia function. type CCallArgType: ConstructType; + + /// Type constructor for the type taken by the `ccall`ed function. type FunctionArgType: ConstructType; } @@ -35,8 +44,25 @@ pub unsafe trait CCallArg { /// /// [`julia_module`]: ::jlrs_macros::julia_module pub unsafe trait CCallReturn { + /// Type constructor for the type returned by the generated Julia function. type FunctionReturnType: ConstructType; + + /// Type constructor for the type returned by the `ccall`ed function. type CCallReturnType: ConstructType; + + /// Type returned to Julia after calling `Self::return_or_throw`. + type ReturnAs: CCallReturn; + + /// Convert `self` to data that can be returned to Julia, or throw an exception. + /// + /// You should never need to call this method manually. It is called automatically by the glue + /// code generated by the `julia_module` macro just before returning to Julia. + /// + /// Safety: + /// + /// This method must only be called just before returning from Rust to Julia. There must be no + /// pending drops in any of the Rust frames between Julia and the current frame. + unsafe fn return_or_throw(self) -> Self::ReturnAs; } macro_rules! impl_ccall_arg { @@ -49,6 +75,18 @@ macro_rules! impl_ccall_arg { unsafe impl CCallReturn for $type { type FunctionReturnType = Self; type CCallReturnType = Self; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + #[cfg(feature = "ccall")] + return self; + + #[cfg(not(feature = "ccall"))] + unimplemented!( + "CCallReturn::return_or_throw can only be called if the `ccall` feature is enabled" + ) + } } }; } @@ -65,3 +103,66 @@ impl_ccall_arg!(i64); impl_ccall_arg!(isize); impl_ccall_arg!(f32); impl_ccall_arg!(f64); + +unsafe impl CCallReturn for Result { + type FunctionReturnType = T::FunctionReturnType; + type CCallReturnType = T::CCallReturnType; + type ReturnAs = T; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + #[cfg(feature = "ccall")] + { + match self { + Ok(t) => t, + Err(e) => crate::ccall::CCall::throw_exception(e), + } + } + + #[cfg(not(feature = "ccall"))] + unimplemented!( + "CCallReturn::return_or_throw can only be called if the `ccall` feature is enabled" + ) + } +} + +unsafe impl CCallReturn for () { + type FunctionReturnType = Nothing; + type CCallReturnType = Nothing; + type ReturnAs = (); + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + () + } +} + +unsafe impl CCallReturn for JlrsResult { + type FunctionReturnType = T::FunctionReturnType; + type CCallReturnType = T::CCallReturnType; + type ReturnAs = T; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + #[cfg(feature = "ccall")] + { + match self { + Ok(t) => t, + Err(e) => { + let e = crate::ccall::CCall::local_scope::<_, _, 1>(|mut frame| { + let msg = JuliaString::new(&mut frame, format!("{}", e)).as_value(); + let err = JlrsCore::jlrs_error(&frame).instantiate_unchecked(&frame, [msg]); + Ok(err.leak()) + }) + .unwrap(); + crate::ccall::CCall::throw_exception(e) + } + } + } + + #[cfg(not(feature = "ccall"))] + unimplemented!( + "CCallReturn::return_or_throw can only be called if the `ccall` feature is enabled" + ) + } +} diff --git a/jlrs/src/convert/compatible.rs b/jlrs/src/convert/compatible.rs index b7a3c98d..910748aa 100644 --- a/jlrs/src/convert/compatible.rs +++ b/jlrs/src/convert/compatible.rs @@ -53,7 +53,7 @@ impl CompatibleCast for T { type Inner = T; type Output = U; - #[inline(always)] + #[inline] fn compatible_cast(&self) -> &Self::Output where T: Compatible, @@ -63,7 +63,7 @@ impl CompatibleCast for T { unsafe { std::mem::transmute(self) } } - #[inline(always)] + #[inline] fn compatible_cast_mut(&mut self) -> &mut Self::Output where T: Compatible, @@ -78,7 +78,7 @@ impl CompatibleCast for [T] { type Inner = T; type Output = [U]; - #[inline(always)] + #[inline] fn compatible_cast(&self) -> &Self::Output where T: Compatible, @@ -88,7 +88,7 @@ impl CompatibleCast for [T] { unsafe { std::mem::transmute(self) } } - #[inline(always)] + #[inline] fn compatible_cast_mut(&mut self) -> &mut Self::Output where T: Compatible, @@ -103,7 +103,7 @@ impl CompatibleCast for [T; N] { type Inner = T; type Output = [U; N]; - #[inline(always)] + #[inline] fn compatible_cast(&self) -> &Self::Output where T: Compatible, @@ -113,7 +113,7 @@ impl CompatibleCast for [T; N] { unsafe { std::mem::transmute(self) } } - #[inline(always)] + #[inline] fn compatible_cast_mut(&mut self) -> &mut Self::Output where T: Compatible, @@ -157,6 +157,12 @@ mod tests { fn valid_layout(_: Value) -> bool { unimplemented!() } + + fn type_object<'target, Tgt: crate::prelude::Target<'target>>( + _target: &Tgt, + ) -> Value<'target, 'static> { + unimplemented!() + } } unsafe impl Compatible for A {} diff --git a/jlrs/src/convert/into_julia.rs b/jlrs/src/convert/into_julia.rs index 4a639124..f943d661 100644 --- a/jlrs/src/convert/into_julia.rs +++ b/jlrs/src/convert/into_julia.rs @@ -51,6 +51,7 @@ pub unsafe trait IntoJulia: Sized + 'static { T: Target<'scope>; #[doc(hidden)] + #[inline] fn into_julia<'scope, T>(self, target: T) -> ValueData<'scope, 'static, T> where T: Target<'scope>, @@ -58,7 +59,6 @@ pub unsafe trait IntoJulia: Sized + 'static { // Safety: trait is implemented incorrectly if this is incorrect. A new instance of the // associated unsafe { - // TODO: root this data until the data has been instantiated. let ty = Self::julia_type(&target).as_managed(); debug_assert!(ty.is_bits()); @@ -78,7 +78,7 @@ macro_rules! impl_into_julia { ($type:ty, $boxer:ident, $julia_type:expr) => { // Safety: These implemetations use a boxing function provided by Julia unsafe impl IntoJulia for $type { - #[inline(always)] + #[inline] fn julia_type<'scope, T>( target: T, ) -> $crate::data::managed::datatype::DataTypeData<'scope, T> @@ -93,7 +93,7 @@ macro_rules! impl_into_julia { } } - #[inline(always)] + #[inline] fn into_julia<'scope, T>( self, target: T, @@ -150,9 +150,8 @@ unsafe impl IntoJulia for *mut U { let params = &mut [inner_ty]; let param_ptr = params.as_mut_ptr().cast(); - // Safety: Not rooting the result should be fine. The result must be a concrete type, - // which is globally rooted. - // TODO: investigate if this is true + // Safety: Not rooting the result is fine. The result must be a concrete type which is + // globally rooted. unsafe { let applied = jl_apply_type(ptr_ua.unwrap(Private).cast(), param_ptr, 1); debug_assert!(!applied.is_null()); diff --git a/jlrs/src/convert/into_result.rs b/jlrs/src/convert/into_result.rs index 5ae0cb43..9dc7fdd2 100644 --- a/jlrs/src/convert/into_result.rs +++ b/jlrs/src/convert/into_result.rs @@ -9,24 +9,28 @@ pub trait IntoResult { } impl IntoResult<(), E> for () { + #[inline] fn into_result(self) -> Result<(), E> { Ok(self) } } impl IntoResult, E> for JlrsResult<()> { + #[inline] fn into_result(self) -> Result, E> { Ok(self) } } impl IntoResult<(), E> for Result<(), E> { + #[inline] fn into_result(self) -> Result<(), E> { self } } impl IntoResult, E> for Result, E> { + #[inline] fn into_result(self) -> Result, E> { self } diff --git a/jlrs/src/convert/to_symbol.rs b/jlrs/src/convert/to_symbol.rs index cea1bf30..50164bef 100644 --- a/jlrs/src/convert/to_symbol.rs +++ b/jlrs/src/convert/to_symbol.rs @@ -14,6 +14,7 @@ pub trait ToSymbol: private::ToSymbolPriv { /// Convert `self` to a `Symbol`. /// /// This method only needs a reference to a target because `Symbol` are globally rooted. + #[inline] fn to_symbol<'target, T: Target<'target>>(&self, _: &T) -> Symbol<'target> { // Safety: Requiring a reference to a target guarantees this method can only be called // from a thread known to Julia. @@ -26,12 +27,9 @@ impl ToSymbol for Symbol<'_> {} impl ToSymbol for JuliaString<'_> {} pub(crate) mod private { - use std::ptr::NonNull; - - use jl_sys::{jl_symbol, jl_symbol_n}; - use crate::{ data::managed::{private::ManagedPriv, string::JuliaString, symbol::Symbol}, + memory::target::unrooted::Unrooted, private::Private, }; @@ -43,18 +41,17 @@ pub(crate) mod private { impl> ToSymbolPriv for T { #[inline] unsafe fn to_symbol_priv<'symbol>(&self, _: Private) -> Symbol<'symbol> { - let symbol_ptr = self.as_ref().as_ptr().cast(); - let symbol = jl_symbol_n(symbol_ptr, self.as_ref().len()); - Symbol::wrap_non_null(NonNull::new_unchecked(symbol), Private) + let unrooted = Unrooted::new(); + Symbol::new(&unrooted, self) } } impl ToSymbolPriv for JuliaString<'_> { #[inline] unsafe fn to_symbol_priv<'symbol>(&self, _: Private) -> Symbol<'symbol> { - let symbol_ptr = self.as_c_str(); - let symbol = jl_symbol(symbol_ptr.as_ptr()); - Symbol::wrap_non_null(NonNull::new_unchecked(symbol), Private) + let symbol_ptr = self.as_bytes(); + let unrooted = Unrooted::new(); + Symbol::new_bytes(&unrooted, symbol_ptr).unwrap() } } diff --git a/jlrs/src/convert/unbox.rs b/jlrs/src/convert/unbox.rs index 5254757b..77373b24 100644 --- a/jlrs/src/convert/unbox.rs +++ b/jlrs/src/convert/unbox.rs @@ -56,7 +56,7 @@ pub unsafe trait Unbox { /// /// Safety: The default implementation assumes that `Self::Output` is the correct layout for /// the data that `value` points to. - #[inline(always)] + #[inline] unsafe fn unbox(value: Value) -> Self::Output { value.data_ptr().cast::().as_ref().clone() } @@ -66,7 +66,7 @@ macro_rules! impl_unboxer { ($type:ty, $unboxer:expr) => { unsafe impl Unbox for $type { type Output = Self; - #[inline(always)] + #[inline] unsafe fn unbox(value: Value) -> $type { $unboxer( ::unwrap( diff --git a/jlrs/src/data/layout/bool.rs b/jlrs/src/data/layout/bool.rs index 8535a719..3eb62566 100644 --- a/jlrs/src/data/layout/bool.rs +++ b/jlrs/src/data/layout/bool.rs @@ -7,6 +7,7 @@ use std::fmt::{Debug, Formatter, Result as FmtResult}; use jl_sys::{jl_bool_type, jl_unbox_int8}; +use super::is_bits::IsBits; use crate::{ convert::unbox::Unbox, data::managed::{private::ManagedPriv, value::Value}, @@ -20,18 +21,18 @@ use crate::{ pub struct Bool(i8); impl Bool { - #[inline(always)] + #[inline] pub fn new(val: bool) -> Self { Bool(val as i8) } - #[inline(always)] + #[inline] /// Returns the value of the `Bool` as a `i8`. pub fn as_i8(self) -> i8 { self.0 } - #[inline(always)] + #[inline] /// Returns the value of the `Bool` as a `bool` if it's 0 or 1, `None` if it isn't. pub fn try_as_bool(self) -> Option { match self.0 { @@ -42,7 +43,7 @@ impl Bool { } /// Returns the value of the `Bool` as a `bool`. - #[inline(always)] + #[inline] pub fn as_bool(self) -> bool { self.0 != 0 } @@ -59,12 +60,12 @@ impl<'scope> Debug for Bool { } impl_julia_typecheck!(Bool, jl_bool_type); -impl_valid_layout!(Bool); +impl_valid_layout!(Bool, jl_bool_type); unsafe impl Unbox for Bool { type Output = Self; - #[inline(always)] + #[inline] unsafe fn unbox(value: Value) -> Bool { Bool(jl_unbox_int8(value.unwrap(Private).cast())) } @@ -73,7 +74,7 @@ unsafe impl Unbox for Bool { unsafe impl Unbox for bool { type Output = Bool; - #[inline(always)] + #[inline] unsafe fn unbox(value: Value) -> Bool { Bool(jl_unbox_int8(value.unwrap(Private).cast())) } @@ -81,3 +82,5 @@ unsafe impl Unbox for bool { impl_ccall_arg!(Bool); impl_construct_julia_type!(Bool, jl_bool_type); + +unsafe impl IsBits for Bool {} diff --git a/jlrs/src/data/layout/char.rs b/jlrs/src/data/layout/char.rs index 0b8d288c..cb4e9cc6 100644 --- a/jlrs/src/data/layout/char.rs +++ b/jlrs/src/data/layout/char.rs @@ -7,6 +7,7 @@ use std::fmt::{Debug, Formatter, Result as FmtResult, Write}; use jl_sys::{jl_char_type, jl_unbox_uint32}; +use super::is_bits::IsBits; use crate::{ convert::unbox::Unbox, data::managed::{private::ManagedPriv, value::Value}, @@ -20,19 +21,19 @@ use crate::{ pub struct Char(u32); impl Char { - #[inline(always)] + #[inline] pub fn new(val: char) -> Self { Char(val as u32) } /// Returns the value of the `Char` as a `u32`. - #[inline(always)] + #[inline] pub fn as_u32(self) -> u32 { self.0 } /// Returns the value of the `Char` as a `char` if it's valid, `None` if it isn't. - #[inline(always)] + #[inline] pub fn try_as_char(self) -> Option { char::from_u32(self.0) } @@ -40,7 +41,7 @@ impl Char { /// Returns the value of the `Char` as a `char`. /// /// Safety: the `Char` must be a valid `char`. - #[inline(always)] + #[inline] pub unsafe fn try_as_char_unchecked(self) -> char { char::from_u32_unchecked(self.0) } @@ -57,11 +58,11 @@ impl<'scope> Debug for Char { } impl_julia_typecheck!(Char, jl_char_type); -impl_valid_layout!(Char); +impl_valid_layout!(Char, jl_char_type); unsafe impl Unbox for Char { type Output = Self; - #[inline(always)] + #[inline] unsafe fn unbox(value: Value) -> Char { Char(jl_unbox_uint32(value.unwrap(Private).cast())) } @@ -69,7 +70,7 @@ unsafe impl Unbox for Char { unsafe impl Unbox for char { type Output = Char; - #[inline(always)] + #[inline] unsafe fn unbox(value: Value) -> Char { Char(jl_unbox_uint32(value.unwrap(Private).cast())) } @@ -77,3 +78,5 @@ unsafe impl Unbox for char { impl_ccall_arg!(Char); impl_construct_julia_type!(Char, jl_char_type); + +unsafe impl IsBits for Char {} diff --git a/jlrs/src/data/layout/f16.rs b/jlrs/src/data/layout/f16.rs index a4b166da..439c408c 100644 --- a/jlrs/src/data/layout/f16.rs +++ b/jlrs/src/data/layout/f16.rs @@ -5,6 +5,7 @@ use half::f16; use jl_sys::jl_float16_type; +use super::is_bits::IsBits; use crate::{ convert::{into_julia::IntoJulia, unbox::Unbox}, data::managed::{ @@ -17,13 +18,14 @@ use crate::{ }; impl_julia_typecheck!(f16, jl_float16_type); -impl_valid_layout!(f16); +impl_valid_layout!(f16, jl_float16_type); unsafe impl Unbox for f16 { type Output = Self; } unsafe impl IntoJulia for f16 { + #[inline] fn julia_type<'scope, T>(target: T) -> DataTypeData<'scope, T> where T: Target<'scope>, @@ -35,3 +37,5 @@ unsafe impl IntoJulia for f16 { impl_ccall_arg!(f16); impl_construct_julia_type!(f16, jl_float16_type); + +unsafe impl IsBits for f16 {} diff --git a/jlrs/src/data/layout/is_bits.rs b/jlrs/src/data/layout/is_bits.rs new file mode 100644 index 00000000..0c2584f0 --- /dev/null +++ b/jlrs/src/data/layout/is_bits.rs @@ -0,0 +1,33 @@ +//! Marker trait for layouts that only use `isbits` types. +//! +//! An `isbits` type is an immutable type that doesn't contain any references to Julia data. The +//! layout of such a type is compatible with C, which means that the low-level layout of such a +//! type is just a `repr(C)` struct in Rust which contains the fields in the same order as the +//! Julia type, where all primitive types have been replaced with their Rusty counterparts. +//! +//! When every field of a layout is an `isbits` type we can assume that they contain valid data +//! and avoid performing any validity checks when converting it from Rust to Julia data. Types can +//! implement [`IsBits`] to indicate this. + +use std::ffi::c_void; + +use super::valid_layout::ValidLayout; + +/// Indicate that all fields are `isbits` types. +pub unsafe trait IsBits: 'static {} + +unsafe impl IsBits for bool {} +unsafe impl IsBits for i8 {} +unsafe impl IsBits for i16 {} +unsafe impl IsBits for i32 {} +unsafe impl IsBits for i64 {} +unsafe impl IsBits for isize {} +unsafe impl IsBits for u8 {} +unsafe impl IsBits for u16 {} +unsafe impl IsBits for u32 {} +unsafe impl IsBits for u64 {} +unsafe impl IsBits for usize {} +unsafe impl IsBits for f32 {} +unsafe impl IsBits for f64 {} +unsafe impl IsBits for *mut c_void {} +unsafe impl IsBits for *mut T {} diff --git a/jlrs/src/data/layout/mod.rs b/jlrs/src/data/layout/mod.rs index a5235aec..e99d1b41 100644 --- a/jlrs/src/data/layout/mod.rs +++ b/jlrs/src/data/layout/mod.rs @@ -29,13 +29,15 @@ macro_rules! impl_ccall_arg { macro_rules! impl_construct_julia_type { ($ty:ty, $jl_ty:ident) => { unsafe impl $crate::data::types::construct_type::ConstructType for $ty { - fn construct_type<'target, T>( - target: $crate::memory::target::ExtendedTarget<'target, '_, '_, T>, - ) -> $crate::data::managed::value::ValueData<'target, 'static, T> + type Static = $ty; + + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> $crate::data::managed::value::ValueData<'target, 'static, Tgt> where - T: $crate::memory::target::Target<'target>, + Tgt: $crate::memory::target::Target<'target>, { - let (target, _) = target.split(); unsafe { let ptr = ::std::ptr::NonNull::new_unchecked($jl_ty.cast::<::jl_sys::jl_value_t>()); @@ -43,6 +45,7 @@ macro_rules! impl_construct_julia_type { } } + #[inline] fn base_type<'target, Tgt>(_target: &Tgt) -> Option<$crate::data::managed::value::Value<'target, 'static>> where Tgt: $crate::memory::target::Target<'target>, @@ -61,9 +64,11 @@ pub mod bool; pub mod char; #[cfg(feature = "f16")] pub mod f16; +pub mod is_bits; pub mod nothing; #[cfg(feature = "internal-types")] pub mod ssa_value; pub mod tuple; +pub mod typed_layout; pub mod union; pub mod valid_layout; diff --git a/jlrs/src/data/layout/nothing.rs b/jlrs/src/data/layout/nothing.rs index 02cdf314..9eed7a86 100644 --- a/jlrs/src/data/layout/nothing.rs +++ b/jlrs/src/data/layout/nothing.rs @@ -2,6 +2,7 @@ use jl_sys::jl_nothing_type; +use super::is_bits::IsBits; use crate::{ convert::{ccall_types::CCallReturn, into_julia::IntoJulia, unbox::Unbox}, data::managed::{ @@ -17,13 +18,14 @@ use crate::{ pub struct Nothing; impl_julia_typecheck!(Nothing, jl_nothing_type); -impl_valid_layout!(Nothing); +impl_valid_layout!(Nothing, jl_nothing_type); unsafe impl Unbox for Nothing { type Output = Self; } unsafe impl IntoJulia for Nothing { + #[inline] fn julia_type<'scope, T>(target: T) -> DataTypeData<'scope, T> where T: Target<'scope>, @@ -35,6 +37,14 @@ unsafe impl IntoJulia for Nothing { unsafe impl CCallReturn for Nothing { type FunctionReturnType = Nothing; type CCallReturnType = Nothing; + type ReturnAs = Nothing; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } impl_construct_julia_type!(Nothing, jl_nothing_type); + +unsafe impl IsBits for Nothing {} diff --git a/jlrs/src/data/layout/ssa_value.rs b/jlrs/src/data/layout/ssa_value.rs index e74bf96c..6db17350 100644 --- a/jlrs/src/data/layout/ssa_value.rs +++ b/jlrs/src/data/layout/ssa_value.rs @@ -4,6 +4,7 @@ use std::fmt::{Debug, Formatter, Result as FmtResult}; use jl_sys::jl_ssavalue_type; +use super::is_bits::IsBits; use crate::{convert::unbox::Unbox, impl_julia_typecheck, impl_valid_layout}; /// A Julia `SSAValue`. @@ -13,6 +14,7 @@ pub struct SSAValue(isize); impl SSAValue { /// Returns the id of the `SSAValue`. + #[inline] pub fn id(self) -> isize { self.0 } @@ -25,7 +27,7 @@ impl<'scope> Debug for SSAValue { } impl_julia_typecheck!(SSAValue, jl_ssavalue_type); -impl_valid_layout!(SSAValue); +impl_valid_layout!(SSAValue, jl_ssavalue_type); unsafe impl Unbox for SSAValue { type Output = Self; @@ -33,3 +35,5 @@ unsafe impl Unbox for SSAValue { impl_ccall_arg!(SSAValue); impl_construct_julia_type!(SSAValue, jl_ssavalue_type); + +unsafe impl IsBits for SSAValue {} diff --git a/jlrs/src/data/layout/tuple.rs b/jlrs/src/data/layout/tuple.rs index c585796a..90a37f1c 100644 --- a/jlrs/src/data/layout/tuple.rs +++ b/jlrs/src/data/layout/tuple.rs @@ -25,21 +25,24 @@ //! # } //! ``` //! -//! Additionally, [`Tuple` ] can be used to create a tuple from an arbitrary number of `Value`s. +//! [`Tuple::new`] can be used to create a tuple from an arbitrary number of `Value`s. -use jl_sys::jl_tuple_typename; +use std::{marker::PhantomData, ptr::NonNull}; + +use jl_sys::{jl_apply_tuple_type_v, jl_tuple_typename, jlrs_tuple_of}; use crate::{ + catch::catch_exceptions, data::{ managed::{ datatype::DataType, private::ManagedPriv as _, - value::{Value, ValueData, ValueResult, MAX_SIZE}, + value::{Value, ValueData, ValueResult}, Managed as _, }, - types::typecheck::Typecheck, + types::{construct_type::ConstructType, typecheck::Typecheck}, }, - memory::target::{ExtendedTarget, Target}, + memory::target::Target, private::Private, }; @@ -51,82 +54,46 @@ pub struct Tuple; impl Tuple { /// Create a new tuple from the contents of `values`. pub fn new<'target, 'current, 'borrow, 'value, 'data, V, T>( - target: ExtendedTarget<'target, '_, '_, T>, + target: T, values: V, ) -> ValueResult<'target, 'data, T> where V: AsRef<[Value<'value, 'data>]>, T: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let types: smallvec::SmallVec<[_; MAX_SIZE]> = values - .as_ref() - .iter() - .copied() - .map(|v| v.datatype().as_value()) - .collect(); - - let tuple_ty = DataType::tuple_type(&frame) - .as_value() - .apply_type(&mut frame, types); - - unsafe { - match tuple_ty { - Ok(ty) => { - debug_assert!(ty.is::()); - ty.cast_unchecked::().instantiate(output, values) - } - Err(exc) => { - return Ok( - output.result_from_ptr(Err(exc.unwrap_non_null(Private)), Private) - ); - } - } - } - }) - .unwrap() + unsafe { + let values = values.as_ref(); + let callback = || Self::new_unchecked(&target, values); + let exc = |err: Value| err.unwrap_non_null(Private); + + match catch_exceptions(callback, exc) { + Ok(tup) => Ok(target.data_from_ptr(tup.ptr(), Private)), + Err(err) => Err(target.data_from_ptr(err, Private)), + } + } } /// Create a new tuple from the contents of `values`. pub unsafe fn new_unchecked<'target, 'current, 'borrow, 'value, 'data, V, T>( - target: ExtendedTarget<'target, '_, '_, T>, + target: T, values: V, ) -> ValueData<'target, 'data, T> where V: AsRef<[Value<'value, 'data>]>, T: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let types: smallvec::SmallVec<[_; MAX_SIZE]> = values - .as_ref() - .iter() - .copied() - .map(|v| v.datatype().as_value()) - .collect(); - - // The tuple type is constructed with the types of the values as its type - // parameters, since only concrete types can have instances, all types are - // concrete so the tuple type is concrete, too. - let tuple_ty = DataType::tuple_type(&frame) - .as_value() - .apply_type_unchecked(&mut frame, types); - - { - debug_assert!(tuple_ty.is::()); - Ok(tuple_ty - .cast_unchecked::() - .instantiate_unchecked(output, values)) - } - }) - .unwrap() + let values = values.as_ref(); + let n = values.len(); + let values_ptr = values.as_ptr(); + let tuple: *mut jl_sys::_jl_value_t = + jlrs_tuple_of(values_ptr as *const _ as *mut _, n as _); + + target.data_from_ptr(NonNull::new_unchecked(tuple), Private) } } unsafe impl Typecheck for Tuple { + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.unwrap_non_null(Private).as_ref().name == jl_tuple_typename } } @@ -161,25 +128,24 @@ macro_rules! impl_tuple { $($types: $crate::convert::into_julia::IntoJulia + ::std::fmt::Debug + Copy),+ {} + unsafe impl<$($types),+> $crate::data::layout::is_bits::IsBits for $name<$($types),+> + where + $($types: $crate::data::layout::is_bits::IsBits),+ + {} + unsafe impl<$($types),+> $crate::convert::into_julia::IntoJulia for $name<$($types),+> where - $($types: $crate::convert::into_julia::IntoJulia + ::std::fmt::Debug + Clone),+ + $($types: $crate::convert::into_julia::IntoJulia + $crate::data::types::construct_type::ConstructType + ::std::fmt::Debug + Clone),+ { + #[inline] fn julia_type<'scope, T>( target: T, ) -> $crate::data::managed::datatype::DataTypeData<'scope, T> where T: $crate::memory::target::Target<'scope> { - let types = &mut [ - $(<$types as $crate::convert::into_julia::IntoJulia>::julia_type(&target)),+ - ]; - unsafe { - target.data_from_ptr( - ::std::ptr::NonNull::new_unchecked(::jl_sys::jl_apply_tuple_type_v(types.as_mut_ptr().cast(), types.len()).cast()), - $crate::private::Private, - ) + ::construct_type(&target).as_value().cast_unchecked::().root(target) } } } @@ -190,7 +156,8 @@ macro_rules! impl_tuple { { fn valid_layout(v: $crate::data::managed::value::Value) -> bool { unsafe { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { + if v.is::<$crate::data::managed::datatype::DataType>() { + let dt = v.cast_unchecked::<$crate::data::managed::datatype::DataType>(); let global = v.unrooted_target(); let fieldtypes = dt.field_types(global); let n = count!($($types),+); @@ -212,6 +179,21 @@ macro_rules! impl_tuple { } } + #[inline] + fn type_object<'target, Tgt>( + _: &Tgt + ) -> $crate::data::managed::value::Value<'target, 'static> + where + Tgt: $crate::memory::target::Target<'target> + { + unsafe { + <$crate::data::managed::value::Value as $crate::data::managed::private::ManagedPriv>::wrap_non_null( + std::ptr::NonNull::new_unchecked(jl_sys::jl_anytuple_type.cast()), + $crate::private::Private + ) + } + } + const IS_REF: bool = false; } @@ -221,7 +203,8 @@ macro_rules! impl_tuple { { fn valid_field(v: $crate::data::managed::value::Value) -> bool { unsafe { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { + if v.is::<$crate::data::managed::datatype::DataType>() { + let dt = v.cast_unchecked::<$crate::data::managed::datatype::DataType>(); let global = v.unrooted_target(); let fieldtypes = dt.field_types(global); let n = count!($($types),+); @@ -255,6 +238,7 @@ macro_rules! impl_tuple { where $($types: $crate::data::layout::valid_layout::ValidField + Clone + ::std::fmt::Debug),+ { + #[inline] fn typecheck(t: $crate::data::managed::datatype::DataType) -> bool { ::valid_layout(t.as_value()) } @@ -264,17 +248,19 @@ macro_rules! impl_tuple { where $($types: $crate::data::types::construct_type::ConstructType),+ { - fn construct_type<'target, Tgt>( - target: $crate::memory::target::ExtendedTarget<'target, '_, '_, Tgt>, + type Static = $name<$($types :: Static),*>; + + fn construct_type_uncached<'target, Tgt>( + target: Tgt, ) -> $crate::data::managed::value::ValueData<'target, 'static, Tgt> where Tgt: $crate::memory::target::Target<'target>, { - let (target, frame) = target.split(); + const N: usize = count!($($types),*); - frame.scope(|mut frame| { + target.with_local_scope::<_, _, N>(|target, mut frame| { let types = &mut [ - $(<$types as $crate::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target())),+ + $(<$types as $crate::data::types::construct_type::ConstructType>::construct_type(&mut frame)),+ ]; unsafe { @@ -286,6 +272,7 @@ macro_rules! impl_tuple { }).unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option<$crate::data::managed::value::Value<'target, 'static>> where Tgt: $crate::memory::target::Target<'target>, @@ -299,8 +286,11 @@ macro_rules! impl_tuple { #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct $name(); + unsafe impl $crate::data::layout::is_bits::IsBits for $name {} + unsafe impl $crate::convert::into_julia::IntoJulia for $name { + #[inline] fn julia_type<'scope, T>( target: T, ) -> $crate::data::managed::datatype::DataTypeData<'scope, T> @@ -313,6 +303,7 @@ macro_rules! impl_tuple { } } + #[inline] fn into_julia<'scope, T>(self, target: T) -> $crate::data::managed::value::ValueData<'scope, 'static, T> where T: $crate::memory::target::Target<'scope>, @@ -325,8 +316,10 @@ macro_rules! impl_tuple { } unsafe impl $crate::data::layout::valid_layout::ValidLayout for $name { + #[inline] fn valid_layout(v: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { + if v.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { v.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; let global = unsafe {$crate::memory::target::unrooted::Unrooted::new()}; return dt == $crate::data::managed::datatype::DataType::emptytuple_type(&global) } @@ -334,12 +327,29 @@ macro_rules! impl_tuple { false } + #[inline] + fn type_object<'target, Tgt>( + _: &Tgt + ) -> $crate::data::managed::value::Value<'target, 'static> + where + Tgt: $crate::memory::target::Target<'target> + { + unsafe { + <$crate::data::managed::value::Value as $crate::data::managed::private::ManagedPriv>::wrap_non_null( + std::ptr::NonNull::new_unchecked(jl_sys::jl_emptytuple_type.cast()), + $crate::private::Private + ) + } + } + const IS_REF: bool = false; } unsafe impl $crate::data::layout::valid_layout::ValidField for $name { + #[inline] fn valid_field(v: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { + if v.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { v.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; let global = unsafe {$crate::memory::target::unrooted::Unrooted::new()}; return dt == $crate::data::managed::datatype::DataType::emptytuple_type(&global) } @@ -351,28 +361,35 @@ macro_rules! impl_tuple { unsafe impl $crate::convert::unbox::Unbox for $name { type Output = Self; + #[inline] unsafe fn unbox(_: $crate::data::managed::value::Value) -> Self::Output { Tuple0() } } unsafe impl $crate::data::types::typecheck::Typecheck for $name { + #[inline] fn typecheck(t: $crate::data::managed::datatype::DataType) -> bool { ::valid_layout(t.as_value()) } } unsafe impl $crate::data::types::construct_type::ConstructType for $name { - fn construct_type<'target, Tgt>( - target: $crate::memory::target::ExtendedTarget<'target, '_, '_, Tgt>, + type Static = $name; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, ) -> $crate::data::managed::value::ValueData<'target, 'static, Tgt> where Tgt: $crate::memory::target::Target<'target>, { - let (target, _) = target.split(); $crate::data::managed::datatype::DataType::emptytuple_type(&target).as_value().root(target) } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option<$crate::data::managed::value::Value<'target, 'static>> where Tgt: $crate::memory::target::Target<'target>, @@ -459,3 +476,34 @@ impl_tuple!( Tuple32, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30, T31, T32 ); + +pub struct NTuple { + _marker: PhantomData<[T; N]>, +} + +unsafe impl ConstructType for NTuple { + type Static = NTuple; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let ty = T::construct_type(&mut frame); + let types = [ty; N]; + let applied = jl_apply_tuple_type_v(&types as *const _ as *mut _, N); + Ok(target.data_from_ptr(NonNull::new_unchecked(applied.cast()), Private)) + }) + .unwrap_unchecked() + } + } + + fn base_type<'target, Tgt>(_target: &Tgt) -> Option> + where + Tgt: Target<'target>, + { + None + } +} diff --git a/jlrs/src/data/layout/typed_layout.rs b/jlrs/src/data/layout/typed_layout.rs new file mode 100644 index 00000000..bcfb12b1 --- /dev/null +++ b/jlrs/src/data/layout/typed_layout.rs @@ -0,0 +1,81 @@ +//! Fully-typed layout. +//! +//! Layouts don't necessarily use all type parameters of a Julia type, for example when a +//! parameter is a value type or is only used by fields which have a mutable type. This means the +//! layout can't implement [`ConstructType`], which is necessary to convert that data into a +//! [`Value`]. +//! +//! For this purpose [`TypedLayout`] and [`HasLayout`] exist. A `TypedLayout` wraps a layout and +//! a type constructor, `HasLayout` declares what layouts are associated with a type constructor. +//! This trait is automatically implemented when a type implements both [`ValidLayout`] and +//! [`ConstructType`], +//! +//! [`Value`]: crate::data::managed::value::Value + +use std::marker::PhantomData; + +use super::{is_bits::IsBits, valid_layout::ValidLayout}; +use crate::data::types::construct_type::ConstructType; + +/// Associate a layout with a type constructor. +/// +/// Safety: +/// +/// `Layout` must be a valid layout for the type constructor. +pub unsafe trait HasLayout<'scope, 'data>: ConstructType { + /// The layout associated with this type constructor. + type Layout: ValidLayout; +} + +unsafe impl<'scope, 'data, T: ConstructType + ValidLayout> HasLayout<'scope, 'data> for T { + type Layout = T; +} + +/// A layout annotated with its type constructor. +#[repr(transparent)] +pub struct TypedLayout { + data: L, + _ty: PhantomData, +} + +impl TypedLayout +where + L: ValidLayout, + T: ConstructType, +{ + /// Convert `data` to a `TypedLayout` with an arbitrary type constructor `T`. + #[inline] + pub const fn new_relaxed(data: L) -> Self { + TypedLayout { + data, + _ty: PhantomData, + } + } + + /// Convert a typed layout to its layout. + #[inline] + pub fn into_layout(self) -> L { + self.data + } +} + +impl<'scope, 'data, T> TypedLayout +where + T: HasLayout<'scope, 'data>, +{ + /// Convert `data` to a `TypedLayout`. + #[inline] + pub const fn new(data: T::Layout) -> Self { + TypedLayout { + data, + _ty: PhantomData, + } + } +} + +unsafe impl> IsBits + for TypedLayout +{ +} + +// TODO: other traits diff --git a/jlrs/src/data/layout/union.rs b/jlrs/src/data/layout/union.rs index 7a9f9fc1..0baf88c9 100644 --- a/jlrs/src/data/layout/union.rs +++ b/jlrs/src/data/layout/union.rs @@ -20,6 +20,7 @@ use std::{ ffi::c_void, fmt::{Debug, Formatter, Result as FmtResult}, mem::MaybeUninit, + ptr::NonNull, }; use jl_sys::jl_bottom_type; @@ -170,20 +171,29 @@ impl Debug for EmptyUnion { } unsafe impl ValidLayout for EmptyUnion { + #[inline] fn valid_layout(ty: Value) -> bool { unsafe { ty.unwrap(Private) == jl_bottom_type } } const IS_REF: bool = true; + + fn type_object<'target, Tgt: crate::prelude::Target<'target>>( + _target: &Tgt, + ) -> Value<'target, 'static> { + unsafe { Value::wrap_non_null(NonNull::new_unchecked(jl_bottom_type), Private) } + } } unsafe impl ValidField for EmptyUnion { + #[inline] fn valid_field(ty: Value) -> bool { unsafe { ty.unwrap(Private) == jl_bottom_type } } } unsafe impl Typecheck for EmptyUnion { + #[inline] fn typecheck(t: DataType) -> bool { ::valid_layout(t.as_value()) } diff --git a/jlrs/src/data/layout/valid_layout.rs b/jlrs/src/data/layout/valid_layout.rs index b8fc1095..4171d5b4 100644 --- a/jlrs/src/data/layout/valid_layout.rs +++ b/jlrs/src/data/layout/valid_layout.rs @@ -10,62 +10,66 @@ use std::ffi::c_void; +use jl_sys::{ + jl_bool_type, jl_char_type, jl_float32_type, jl_float64_type, jl_int16_type, jl_int32_type, + jl_int64_type, jl_int8_type, jl_uint16_type, jl_uint32_type, jl_uint64_type, jl_uint8_type, + jl_voidpointer_type, +}; + use crate::{ convert::into_julia::IntoJulia, - data::managed::{datatype::DataType, value::Value}, + data::managed::{datatype::DataType, union_all::UnionAll, value::Value}, + prelude::{Managed, Target}, }; /// Trait used to check if a Rust type and Julia type have matching layouts. /// /// All layouts generated by JlrsReflect.jl derive this trait. In this case all fields are /// checked recursively to determine if the value can be unboxed as that type. -// Safety: TODO +/// +/// Safety: implementations of [`ValidLayout::valid_layout`] must not trigger the GC. This means +/// no function can be called that allocates Julia data, calls Julia functions, or can trigger the +/// GC some other way. pub unsafe trait ValidLayout { /// Must be `true` if the Rust type is a managed type. const IS_REF: bool = false; - /// Check if the layout of the implementor is compatible with the layout of `ty`. This - /// argument is a `Value` to account for the fact that a field type can be a `Union`, - /// `UnionAll` or `Union{}`. + /// Check if the layout of the implementor is compatible with the layout of `ty`. + /// + /// The argument is a `Value` to account for the fact that a field type can be a `Union`, + /// `UnionAll` or `Union{}`. Calling this method will not trigger the GC. fn valid_layout(ty: Value) -> bool; + + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static>; } #[doc(hidden)] #[macro_export] macro_rules! impl_valid_layout { - ($type:ty, $($lt:lifetime),+) => { - unsafe impl<$($lt),+> $crate::layout::valid_layout::ValidLayout for $type { - #[inline(always)] + ($t:ty, $type_obj:ident) => { + unsafe impl $crate::data::layout::valid_layout::ValidLayout for $t { + #[inline] fn valid_layout(v: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { - dt.is::<$type>() + if v.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { v.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; + dt.is::<$t>() } else { false } } - const IS_REF: bool = true; - } - - unsafe impl<$($lt),+> $crate::layout::valid_layout::ValidField for $type { - #[inline(always)] - fn valid_field(v: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { - dt.is::<$type>() - } else { - false - } - } - } - }; - ($t:ty) => { - unsafe impl $crate::data::layout::valid_layout::ValidLayout for $t { - #[inline(always)] - fn valid_layout(v: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { - dt.is::<$t>() - } else { - false + #[inline] + fn type_object<'target, Tgt>( + _: &Tgt + ) -> $crate::data::managed::value::Value<'target, 'static> + where + Tgt: $crate::memory::target::Target<'target> + { + unsafe { + <$crate::data::managed::value::Value as $crate::data::managed::private::ManagedPriv>::wrap_non_null( + std::ptr::NonNull::new_unchecked($type_obj.cast()), + $crate::private::Private + ) } } @@ -73,9 +77,10 @@ macro_rules! impl_valid_layout { } unsafe impl $crate::data::layout::valid_layout::ValidField for $t { - #[inline(always)] + #[inline] fn valid_field(v: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = v.cast::<$crate::data::managed::datatype::DataType>() { + if v.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { v.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; dt.is::<$t>() } else { false @@ -85,32 +90,44 @@ macro_rules! impl_valid_layout { } } -impl_valid_layout!(bool); -impl_valid_layout!(char); -impl_valid_layout!(i8); -impl_valid_layout!(i16); -impl_valid_layout!(i32); -impl_valid_layout!(i64); -impl_valid_layout!(isize); -impl_valid_layout!(u8); -impl_valid_layout!(u16); -impl_valid_layout!(u32); -impl_valid_layout!(u64); -impl_valid_layout!(usize); -impl_valid_layout!(f32); -impl_valid_layout!(f64); -impl_valid_layout!(*mut c_void); +impl_valid_layout!(bool, jl_bool_type); +impl_valid_layout!(char, jl_char_type); +impl_valid_layout!(i8, jl_int8_type); +impl_valid_layout!(i16, jl_int16_type); +impl_valid_layout!(i32, jl_int32_type); +impl_valid_layout!(i64, jl_int64_type); +#[cfg(target_pointer_width = "64")] +impl_valid_layout!(isize, jl_int64_type); +#[cfg(target_pointer_width = "32")] +impl_valid_layout!(isize, jl_int32_type); +impl_valid_layout!(u8, jl_uint8_type); +impl_valid_layout!(u16, jl_uint16_type); +impl_valid_layout!(u32, jl_uint32_type); +impl_valid_layout!(u64, jl_uint64_type); +#[cfg(target_pointer_width = "64")] +impl_valid_layout!(usize, jl_uint64_type); +#[cfg(target_pointer_width = "32")] +impl_valid_layout!(usize, jl_uint32_type); +impl_valid_layout!(f32, jl_float32_type); +impl_valid_layout!(f64, jl_float64_type); +impl_valid_layout!(*mut c_void, jl_voidpointer_type); unsafe impl ValidLayout for *mut T { - #[inline(always)] + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::<*mut T>() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + UnionAll::pointer_type(target).as_value() + } + const IS_REF: bool = false; } diff --git a/jlrs/src/data/managed/array/data/accessor.rs b/jlrs/src/data/managed/array/data/accessor.rs index fe306a71..8fe12fca 100644 --- a/jlrs/src/data/managed/array/data/accessor.rs +++ b/jlrs/src/data/managed/array/data/accessor.rs @@ -10,6 +10,7 @@ use std::{ use jl_sys::{jl_array_ptr_set, jl_array_typetagdata, jl_arrayref, jl_arrayset}; use crate::{ + catch::catch_exceptions, data::{ layout::valid_layout::ValidField, managed::{ @@ -25,7 +26,7 @@ use crate::{ }, }, error::{AccessError, JlrsResult, TypeError, CANNOT_DISPLAY_TYPE}, - memory::target::Target, + memory::target::{Target, TargetException}, private::Private, }; @@ -174,6 +175,7 @@ pub type IndeterminateArrayAccessorMut<'borrow, 'array, 'data> = impl<'borrow, 'array, 'data, T, L: ArrayLayout> Clone for ArrayAccessor<'borrow, 'array, 'data, T, L, Immutable<'borrow, T>> { + #[inline] fn clone(&self) -> Self { ArrayAccessor { array: self.array, @@ -188,6 +190,7 @@ impl<'borrow, 'array, 'data, T, L: ArrayLayout> Clone impl<'borrow, 'array, 'data, U, L: ArrayLayout, M: Mutability> ArrayAccessor<'borrow, 'array, 'data, U, L, M> { + #[inline] pub(crate) unsafe fn new(array: &'borrow Array<'array, 'data>) -> Self { ArrayAccessor { array: *array, @@ -211,23 +214,14 @@ impl<'borrow, 'array, 'data, U, L: ArrayLayout, M: Mutability> D: Dims, T: Target<'frame>, { - use std::mem::MaybeUninit; - - use jl_sys::jl_value_t; - - use crate::catch::catch_exceptions; - let idx = self.dimensions().index_of(&index)?; // Safety: exceptions are caught, the result is immediately rooted unsafe { - let mut callback = |result: &mut MaybeUninit<*mut jl_value_t>| { - let res = jl_arrayref(self.array.unwrap(Private), idx); - result.write(res); - Ok(()) - }; + let callback = || jl_arrayref(self.array.unwrap(Private), idx); + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback)? { + let res = match catch_exceptions(callback, exc) { Ok(ptr) => { if ptr.is_null() { return Ok(None); @@ -235,7 +229,7 @@ impl<'borrow, 'array, 'data, U, L: ArrayLayout, M: Mutability> Ok(NonNull::new_unchecked(ptr)) } } - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; Ok(Some(target.result_from_ptr(res, Private))) @@ -245,6 +239,7 @@ impl<'borrow, 'array, 'data, U, L: ArrayLayout, M: Mutability> /// Access the element at `index` and convert it to a `Value` rooted in `scope`. /// /// Safety: If an error is thrown by Julia it's not caught. + #[inline] pub unsafe fn get_value_unchecked<'frame, D, T>( &mut self, target: T, @@ -282,29 +277,23 @@ impl<'borrow, 'array, 'data, U, L: ArrayLayout> target: T, index: D, value: Option>, - ) -> JlrsResult> + ) -> JlrsResult> where D: Dims, T: Target<'target>, { - use std::mem::MaybeUninit; - - use crate::catch::catch_exceptions; - let idx = self.dimensions().index_of(&index)?; let ptr = value.map(|v| v.unwrap(Private)).unwrap_or(null_mut()); // Safety: exceptions are caught, if one is thrown it's immediately rooted unsafe { - let mut callback = |result: &mut MaybeUninit<()>| { - jl_arrayset(self.array.unwrap(Private), ptr, idx); - result.write(()); - Ok(()) - }; + let callback = || jl_arrayset(self.array.unwrap(Private), ptr, idx); + + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(()) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; Ok(target.exception_from_ptr(res, Private)) @@ -314,6 +303,7 @@ impl<'borrow, 'array, 'data, U, L: ArrayLayout> /// Set the element at `index` to `value`. /// /// Safety: If an error is thrown by Julia it's not caught. + #[inline] pub unsafe fn set_value_unchecked( &mut self, index: D, @@ -330,6 +320,7 @@ impl<'borrow, 'array, 'data, W: ManagedRef<'array, 'data>, M: Mutability> PtrArrayAccessor<'borrow, 'array, 'data, W, M> { /// Get a reference to the value at `index`, or `None` if the index is out of bounds. + #[inline] pub fn get<'target, D, T>( &self, target: T, @@ -355,6 +346,7 @@ impl<'borrow, 'array, 'data, W: ManagedRef<'array, 'data>, M: Mutability> } /// Returns the array's data as a slice, the data is in column-major order. + #[inline] pub fn as_slice(&self) -> &[Option] { let n_elems = self.dimensions().size(); let arr_data = self.array.data_ptr().cast::>(); @@ -363,6 +355,7 @@ impl<'borrow, 'array, 'data, W: ManagedRef<'array, 'data>, M: Mutability> } /// Returns the array's data as a slice, the data is in column-major order. + #[inline] pub fn into_slice(self) -> &'borrow [Option] { let n_elems = self.dimensions().size(); let arr_data = self.array.data_ptr().cast::>(); @@ -375,6 +368,7 @@ impl<'borrow, 'array, 'data, T: ManagedRef<'array, 'data>> PtrArrayAccessor<'borrow, 'array, 'data, T, Mutable<'borrow, T>> { /// Set the value at `index` to `value` if `value` has a type that's compatible with this array. + #[inline] pub fn set(&mut self, index: D, value: Option>) -> JlrsResult<()> where D: Dims, @@ -403,6 +397,19 @@ impl<'borrow, 'array, 'data, T: ManagedRef<'array, 'data>> Ok(()) } + + /// Add capacity for `inc` more elements at the end of the array. The array must be + /// one-dimensional. If the array isn't one-dimensional an exception is thrown. + /// + /// Safety: Mutating things that should absolutely not be mutated is not prevented. If an + /// exception is thrown, it isn't caught. + #[inline] + pub unsafe fn grow_end_unchecked(&mut self, inc: usize) + where + 'data: 'static, + { + self.array.grow_end_unchecked(inc); + } } impl<'borrow, 'array, 'data, D, T, M> Index for PtrArrayAccessor<'borrow, 'array, 'data, T, M> @@ -412,6 +419,8 @@ where M: Mutability, { type Output = Option; + + #[inline] fn index(&self, index: D) -> &Self::Output { let idx = self.dimensions().index_of(&index).unwrap(); // Safety: the index is in bounds @@ -428,6 +437,7 @@ where impl<'borrow, 'array, 'data, T, M: Mutability> BitsArrayAccessor<'borrow, 'array, 'data, T, M> { /// Get a reference to the value at `index`, or `None` if the index is out of bounds. + #[inline] pub fn get(&self, index: D) -> Option<&T> where D: Dims, @@ -438,6 +448,7 @@ impl<'borrow, 'array, 'data, T, M: Mutability> BitsArrayAccessor<'borrow, 'array } /// Returns the array's data as a slice, the data is in column-major order. + #[inline] pub fn as_slice(&self) -> &[T] { let len = self.dimensions().size(); let data = self.array.data_ptr().cast::(); @@ -446,6 +457,7 @@ impl<'borrow, 'array, 'data, T, M: Mutability> BitsArrayAccessor<'borrow, 'array } /// Returns the array's data as a slice, the data is in column-major order. + #[inline] pub fn into_slice(self) -> &'borrow [T] { let len = self.dimensions().size(); let data = self.array.data_ptr().cast::(); @@ -456,6 +468,7 @@ impl<'borrow, 'array, 'data, T, M: Mutability> BitsArrayAccessor<'borrow, 'array impl<'borrow, 'array, 'data, T> BitsArrayAccessor<'borrow, 'array, 'data, T, Mutable<'borrow, T>> { /// Set the value at `index` to `value` if `value` has a type that's compatible with this array. + #[inline] pub fn set(&mut self, index: D, value: T) -> JlrsResult<()> where D: Dims, @@ -468,6 +481,7 @@ impl<'borrow, 'array, 'data, T> BitsArrayAccessor<'borrow, 'array, 'data, T, Mut } /// Get a mutable reference to the element stored at `index`. + #[inline] pub fn get_mut(&mut self, index: D) -> Option<&mut T> where D: Dims, @@ -478,6 +492,7 @@ impl<'borrow, 'array, 'data, T> BitsArrayAccessor<'borrow, 'array, 'data, T, Mut } /// Returns the array's data as a mutable slice, the data is in column-major order. + #[inline] pub fn as_mut_slice(&mut self) -> &mut [T] { let len = self.dimensions().size(); let data = self.array.data_ptr().cast::(); @@ -486,12 +501,26 @@ impl<'borrow, 'array, 'data, T> BitsArrayAccessor<'borrow, 'array, 'data, T, Mut } /// Returns the array's data as a mutable slice, the data is in column-major order. + #[inline] pub fn into_mut_slice(self) -> &'borrow mut [T] { let len = self.dimensions().size(); let data = self.array.data_ptr().cast::(); // Safety: the layout is compatible and the lifetime is limited. unsafe { slice::from_raw_parts_mut(data, len) } } + + /// Add capacity for `inc` more elements at the end of the array. The array must be + /// one-dimensional. If the array isn't one-dimensional an exception is thrown. + /// + /// Safety: Mutating things that should absolutely not be mutated is not prevented. If an + /// exception is thrown, it isn't caught. + #[inline] + pub unsafe fn grow_end_unchecked(&mut self, inc: usize) + where + 'data: 'static, + { + self.array.grow_end_unchecked(inc); + } } impl<'borrow, 'array, 'data, T, M, D> Index for BitsArrayAccessor<'borrow, 'array, 'data, T, M> @@ -500,6 +529,8 @@ where M: Mutability, { type Output = T; + + #[inline] fn index(&self, index: D) -> &Self::Output { let idx = self.dimensions().index_of(&index).unwrap(); // Safety: the layout is compatible and the index is in bounds. @@ -519,6 +550,7 @@ impl<'borrow, 'array, 'data, T, D> IndexMut where D: Dims, { + #[inline] fn index_mut(&mut self, index: D) -> &mut Self::Output { let idx = self.dimensions().index_of(&index).unwrap(); // Safety: the layout is compatible and the index is in bounds. @@ -537,6 +569,7 @@ impl<'borrow, 'array, 'data, T, M: Mutability> InlinePtrArrayAccessor<'borrow, 'array, 'data, T, M> { /// Get a reference to the value at `index`, or `None` if the index is out of bounds. + #[inline] pub fn get(&self, index: D) -> Option<&T> where D: Dims, @@ -547,6 +580,7 @@ impl<'borrow, 'array, 'data, T, M: Mutability> } /// Returns the array's data as a slice, the data is in column-major order. + #[inline] pub fn as_slice(&self) -> &[T] { let len = self.dimensions().size(); let data = self.array.data_ptr().cast::(); @@ -555,6 +589,7 @@ impl<'borrow, 'array, 'data, T, M: Mutability> } /// Returns the array's data as a slice, the data is in column-major order. + #[inline] pub fn into_slice(self) -> &'borrow [T] { let len = self.dimensions().size(); let data = self.array.data_ptr().cast::(); @@ -570,6 +605,8 @@ where M: Mutability, { type Output = T; + + #[inline] fn index(&self, index: D) -> &Self::Output { let idx = self.dimensions().index_of(&index).unwrap(); // Safety: the layout is compatible and the index is in bounds. @@ -586,12 +623,14 @@ where impl<'borrow, 'array, 'data, M: Mutability> UnionArrayAccessor<'borrow, 'array, 'data, M> { /// Returns `true` if `ty` if a value of that type can be stored in this array. + #[inline] pub fn contains(&self, ty: DataType) -> bool { let mut tag = 0; find_union_component(self.array.element_type(), ty.as_value(), &mut tag) } /// Returns the type of the element at index `idx`. + #[inline] pub fn element_type(&self, index: D) -> JlrsResult>> where D: Dims, @@ -610,6 +649,7 @@ impl<'borrow, 'array, 'data, M: Mutability> UnionArrayAccessor<'borrow, 'array, /// Get the element at index `idx`. The type `T` must be a valid layout for the type of the /// element stored there. + #[inline] pub fn get(&self, index: D) -> JlrsResult where T: 'static + ValidField + Clone, @@ -647,6 +687,7 @@ impl<'borrow, 'array, 'data> UnionArrayAccessor<'borrow, 'array, 'data, Mutable< /// /// The type `T` must be a valid layout for the value, and `ty` must be a member of the union /// of all possible element types. + #[inline] pub unsafe fn set(&mut self, index: D, ty: DataType, value: T) -> JlrsResult<()> where T: 'static + ValidField + Clone, diff --git a/jlrs/src/data/managed/array/dimensions.rs b/jlrs/src/data/managed/array/dimensions.rs index 57aaa129..3ad56623 100644 --- a/jlrs/src/data/managed/array/dimensions.rs +++ b/jlrs/src/data/managed/array/dimensions.rs @@ -7,24 +7,35 @@ //! if you want to access the third column of the second row of an array, you can use both //! `[1, 2]` or `(1, 2)`. Note that unlike Julia, array indexing starts at 0. +// TODO: IntoDimensions traiit +// TODO: clean up use std::{ + ffi::c_void, fmt::{Debug, Display, Formatter, Result as FmtResult}, marker::PhantomData, + mem::MaybeUninit, + ptr::NonNull, }; -use jl_sys::{jl_array_dims_ptr, jl_array_ndims}; +use jl_sys::{ + jl_alloc_array_1d, jl_alloc_array_2d, jl_alloc_array_3d, jl_array_dims_ptr, jl_array_ndims, + jl_array_t, jl_new_array, jl_ptr_to_array, jl_ptr_to_array_1d, jl_value_t, jlrs_dimtuple_type, +}; +use self::private::DimsPriv; +use super::ArrayData; use crate::{ - data::managed::{array::Array, private::ManagedPriv as _}, + data::{ + managed::{array::Array, datatype::DataTypeData, private::ManagedPriv as _}, + types::construct_type::{ArrayTypeConstructor, ConstantIsize, ConstantSize, ConstructType}, + }, error::{AccessError, JlrsResult}, + prelude::{DataType, Managed, NTuple, Target, Tuple0, Tuple1, Tuple2, Tuple3, Tuple4, Value}, private::Private, }; -/// Trait implemented by types that can be used as n-dimensional indices. pub trait Dims: Sized + Debug { - const SIZE: isize; - - /// Returns the number of dimensions. + /// Returns the rank if this index. fn rank(&self) -> usize; /// Returns the number of elements of the nth dimension. Indexing starts at 0. @@ -32,13 +43,9 @@ pub trait Dims: Sized + Debug { /// The total number of elements in the arry, i.e. the product of the number of elements of /// each dimension. + #[inline] fn size(&self) -> usize { - let mut acc = 1; - for i in 0..self.rank() { - acc *= self.n_elements(i); - } - - acc + (0..self.rank()).map(|i| self.n_elements(i)).product() } /// Calculate the linear index for `dim_index` in an array with dimensions `self`. @@ -82,6 +89,107 @@ pub trait Dims: Sized + Debug { } } +/// Trait implemented by types that can be used as n-dimensional indices. +pub trait DimsExt: DimsPriv + Dims { + /// The rank of array that can use this type as an index. + /// + /// This constant is -1 if the rank is not known at compile-time. + const RANK: isize; + + type DimTupleConstructor: ConstructType; + + /// The type constructor for an array type with these dimesions. + /// + /// This constructor may only be used if `Self::Rank` is not equal to `-1`. + type ArrayContructor: ConstructType; + + #[doc(hidden)] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private); + + #[doc(hidden)] + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + let array_type = array_type.unwrap(Private); + + let arr = match self.rank() { + 1 => jl_alloc_array_1d(array_type, self.n_elements(0)), + 2 => jl_alloc_array_2d(array_type, self.n_elements(0), self.n_elements(1)), + 3 => jl_alloc_array_3d( + array_type, + self.n_elements(0), + self.n_elements(1), + self.n_elements(2), + ), + _ => self.alloc_large(array_type, &target), + }; + + Array::wrap_non_null(NonNull::new_unchecked(arr), Private).root(target) + } + + #[cold] + #[doc(hidden)] + #[inline(never)] + unsafe fn alloc_large<'target, Tgt>( + &self, + array_type: *mut jl_value_t, + target: &Tgt, + ) -> *mut jl_array_t + where + Tgt: Target<'target>, + { + target + .local_scope::<_, _, 1>(|mut frame| { + let tuple = super::sized_dim_tuple(&frame, self); + tuple.root(&mut frame); + Ok(jl_new_array(array_type, tuple.ptr().as_ptr())) + }) + .unwrap_unchecked() + } + + #[doc(hidden)] + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + let array_type = array_type.unwrap(Private); + + let arr = match self.rank() { + 1 => jl_ptr_to_array_1d(array_type, data, self.n_elements(0), 0), + _ => target + .local_scope::<_, _, 1>(|frame| { + let tuple = super::sized_dim_tuple(frame, self); + Ok(jl_ptr_to_array(array_type, data, tuple.unwrap(Private), 0)) + }) + .unwrap_unchecked(), + }; + + target.data_from_ptr(NonNull::new_unchecked(arr), Private) + } + + #[doc(hidden)] + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + let rank = self.rank(); + unsafe { + let raw = jlrs_dimtuple_type(rank as _); + target.data_from_ptr(NonNull::new_unchecked(raw), Private) + } + } +} + /// Dimensions of a Julia array. #[derive(Copy, Clone, Debug)] pub struct ArrayDimensions<'scope> { @@ -91,6 +199,7 @@ pub struct ArrayDimensions<'scope> { } impl<'scope> ArrayDimensions<'scope> { + #[inline] pub(crate) fn new(array: Array<'scope, '_>) -> Self { let array_ptr = array.unwrap(Private); // Safety: The array's dimensions exists as long as the array does. @@ -116,12 +225,12 @@ impl<'scope> ArrayDimensions<'scope> { } impl<'scope> Dims for ArrayDimensions<'scope> { - const SIZE: isize = -1; - + #[inline] fn rank(&self) -> usize { self.n } + #[inline] fn n_elements(&self, dimension: usize) -> usize { if dimension >= self.n { return 0; @@ -132,25 +241,133 @@ impl<'scope> Dims for ArrayDimensions<'scope> { } } -impl Dims for () { - const SIZE: isize = 0; +impl DimsExt for () { + const RANK: isize = 0; + + type DimTupleConstructor = Tuple0; + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, _tup: &mut [MaybeUninit], _: Private) {} + + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let array_type = array_type.unwrap(Private); + let tuple = super::sized_dim_tuple(&target, self); + tuple.root(&mut frame); + let arr = jl_new_array(array_type, tuple.ptr().as_ptr()); + Ok(Array::wrap_non_null(NonNull::new_unchecked(arr), Private).root(target)) + }) + .unwrap() + } + } + + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + let array_type = array_type.unwrap(Private); + let tuple = Value::emptytuple(&target); + let arr = jl_ptr_to_array(array_type, data, tuple.unwrap(Private), 0); + target.data_from_ptr(NonNull::new_unchecked(arr), Private) + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + DataType::emptytuple_type(&target).root(target) + } +} + +impl Dims for () { + #[inline] fn rank(&self) -> usize { 0 } + #[inline] fn n_elements(&self, _: usize) -> usize { 0 } } -impl Dims for usize { - const SIZE: isize = 1; +impl DimsExt for usize { + const RANK: isize = 1; + + type DimTupleConstructor = Tuple1; + + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + tup[0].write(*self); + } + + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + let array_type = array_type.unwrap(Private); + let arr = jl_alloc_array_1d(array_type, *self); + Array::wrap_non_null(NonNull::new_unchecked(arr), Private).root(target) + } + } + + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + let array_type = array_type.unwrap(Private); + let arr = jl_ptr_to_array_1d(array_type, data, *self, 0); + target.data_from_ptr(NonNull::new_unchecked(arr), Private) + } + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} + +impl Dims for usize { + #[inline] fn rank(&self) -> usize { 1 } + #[inline] fn n_elements(&self, dimension: usize) -> usize { if dimension == 0 { *self @@ -160,13 +377,67 @@ impl Dims for usize { } } -impl Dims for (usize,) { - const SIZE: isize = 1; +impl DimsExt for (usize,) { + const RANK: isize = 1; + + type DimTupleConstructor = Tuple1; + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + tup[0].write(self.0); + } + + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + let array_type = array_type.unwrap(Private); + let arr = jl_alloc_array_1d(array_type, self.0); + Array::wrap_non_null(NonNull::new_unchecked(arr), Private).root(target) + } + } + + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + let array_type = array_type.unwrap(Private); + let arr = jl_ptr_to_array_1d(array_type, data, self.0, 0); + target.data_from_ptr(NonNull::new_unchecked(arr), Private) + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} + +impl Dims for (usize,) { + #[inline] fn rank(&self) -> usize { 1 } + #[inline] fn n_elements(&self, dimension: usize) -> usize { if dimension == 0 { self.0 @@ -176,13 +447,74 @@ impl Dims for (usize,) { } } -impl Dims for (usize, usize) { - const SIZE: isize = 2; +impl DimsExt for (usize, usize) { + const RANK: isize = 2; + type DimTupleConstructor = Tuple2; + + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + tup[0].write(self.0); + tup[1].write(self.1); + } + + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + let array_type = array_type.unwrap(Private); + let arr = jl_alloc_array_2d(array_type, self.0, self.1); + Array::wrap_non_null(NonNull::new_unchecked(arr), Private).root(target) + } + } + + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + target + .with_local_scope::<_, _, 1>(|target, frame| { + let array_type = array_type.unwrap(Private); + let tuple = super::sized_dim_tuple(frame, self); + let arr = jl_ptr_to_array(array_type, data, tuple.unwrap(Private), 0); + + Ok(target.data_from_ptr(NonNull::new_unchecked(arr), Private)) + }) + .unwrap_unchecked() + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} + +impl Dims for (usize, usize) { + #[inline] fn rank(&self) -> usize { 2 } + #[inline] fn n_elements(&self, dimension: usize) -> usize { match dimension { 0 => self.0, @@ -192,13 +524,75 @@ impl Dims for (usize, usize) { } } -impl Dims for (usize, usize, usize) { - const SIZE: isize = 3; +impl DimsExt for (usize, usize, usize) { + const RANK: isize = 3; + + type DimTupleConstructor = Tuple3; + + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + tup[0].write(self.0); + tup[1].write(self.1); + tup[2].write(self.2); + } + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + let array_type = array_type.unwrap(Private); + let arr = jl_alloc_array_3d(array_type, self.0, self.1, self.2); + Array::wrap_non_null(NonNull::new_unchecked(arr), Private).root(target) + } + } + + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + target + .with_local_scope::<_, _, 1>(|target, frame| { + let array_type = array_type.unwrap(Private); + let tuple = super::sized_dim_tuple(frame, self); + let arr = jl_ptr_to_array(array_type, data, tuple.unwrap(Private), 0); + + Ok(target.data_from_ptr(NonNull::new_unchecked(arr), Private)) + }) + .unwrap_unchecked() + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} + +impl Dims for (usize, usize, usize) { + #[inline] fn rank(&self) -> usize { 3 } + #[inline] fn n_elements(&self, dimension: usize) -> usize { match dimension { 0 => self.0, @@ -209,13 +603,73 @@ impl Dims for (usize, usize, usize) { } } -impl Dims for (usize, usize, usize, usize) { - const SIZE: isize = 4; +impl DimsExt for (usize, usize, usize, usize) { + const RANK: isize = 4; + + type DimTupleConstructor = Tuple4; + + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + tup[0].write(self.0); + tup[1].write(self.1); + tup[2].write(self.2); + tup[3].write(self.3); + } + + #[inline] + unsafe fn alloc_array<'target, Tgt>( + &self, + target: Tgt, + array_type: Value, + ) -> ArrayData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + let ptr = self.alloc_large(array_type.unwrap(Private), &target); + target.data_from_ptr(NonNull::new_unchecked(ptr), Private) + } + + #[inline] + unsafe fn alloc_array_with_data<'target, 'data, Tgt: Target<'target>>( + &self, + target: Tgt, + array_type: Value, + data: *mut c_void, + ) -> ArrayData<'target, 'data, Tgt> { + target + .with_local_scope::<_, _, 1>(|target, frame| { + let array_type = array_type.unwrap(Private); + let tuple = super::sized_dim_tuple(frame, self); + let arr = jl_ptr_to_array(array_type, data, tuple.unwrap(Private), 0); + + Ok(target.data_from_ptr(NonNull::new_unchecked(arr), Private)) + }) + .unwrap_unchecked() + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} +impl Dims for (usize, usize, usize, usize) { + #[inline] fn rank(&self) -> usize { 4 } + #[inline] fn n_elements(&self, dimension: usize) -> usize { match dimension { 0 => self.0, @@ -227,13 +681,41 @@ impl Dims for (usize, usize, usize, usize) { } } -impl Dims for &[usize; N] { - const SIZE: isize = N as isize; +impl DimsExt for &[usize; N] { + const RANK: isize = N as isize; + + type DimTupleConstructor = NTuple; + + type ArrayContructor = ArrayTypeConstructor>; + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + for i in 0..N { + tup[i].write(self[i]); + } + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} + +impl Dims for &[usize; N] { + #[inline] fn rank(&self) -> usize { N } + #[inline] fn n_elements(&self, dim: usize) -> usize { if dim < N { self[dim] @@ -243,13 +725,41 @@ impl Dims for &[usize; N] { } } -impl Dims for [usize; N] { - const SIZE: isize = N as isize; +impl DimsExt for [usize; N] { + const RANK: isize = N as isize; + + type DimTupleConstructor = NTuple; + + type ArrayContructor = ArrayTypeConstructor>; + + #[inline] + fn fill_tuple(&self, tup: &mut [MaybeUninit], _: Private) { + for i in 0..N { + tup[i].write(self[i]); + } + } + + #[inline] + fn dimension_object<'target, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> DataTypeData<'target, Tgt> { + unsafe { + NTuple::::construct_type(&target) + .as_managed() + .cast_unchecked::() + .root(target) + } + } +} +impl Dims for [usize; N] { + #[inline] fn rank(&self) -> usize { N } + #[inline] fn n_elements(&self, dim: usize) -> usize { if dim < N { self[dim] @@ -260,12 +770,12 @@ impl Dims for [usize; N] { } impl Dims for &[usize] { - const SIZE: isize = -1; - + #[inline] fn rank(&self) -> usize { self.len() } + #[inline] fn n_elements(&self, dim: usize) -> usize { if dim < self.len() { self[dim] @@ -310,6 +820,7 @@ impl Dimensions { } /// Returns the dimensions as a slice. + #[inline] pub fn as_slice(&self) -> &[usize] { match self { Dimensions::Few(ref v) => &v[1..v[0] as usize + 1], @@ -319,8 +830,7 @@ impl Dimensions { } impl Dims for Dimensions { - const SIZE: isize = -1; - + #[inline] fn rank(&self) -> usize { match self { Dimensions::Few([n, _, _, _]) => *n, @@ -328,6 +838,7 @@ impl Dims for Dimensions { } } + #[inline] fn n_elements(&self, dim: usize) -> usize { if dim < self.rank() { match self { @@ -339,6 +850,7 @@ impl Dims for Dimensions { } } + #[inline] fn size(&self) -> usize { if self.rank() == 0 { return 0; @@ -376,6 +888,26 @@ impl Display for Dimensions { } } +pub(crate) mod private { + pub trait DimsPriv {} + + impl DimsPriv for () {} + + impl DimsPriv for usize {} + + impl DimsPriv for (usize,) {} + + impl DimsPriv for (usize, usize) {} + + impl DimsPriv for (usize, usize, usize) {} + + impl DimsPriv for (usize, usize, usize, usize) {} + + impl DimsPriv for [usize; N] {} + + impl DimsPriv for &[usize; N] {} +} + #[cfg(test)] mod tests { use super::{Dimensions, Dims}; diff --git a/jlrs/src/data/managed/array/mod.rs b/jlrs/src/data/managed/array/mod.rs index 5ab9bc26..0ed52a8f 100644 --- a/jlrs/src/data/managed/array/mod.rs +++ b/jlrs/src/data/managed/array/mod.rs @@ -21,7 +21,6 @@ //! a constant at compile time. use std::{ - cell::UnsafeCell, ffi::c_void, fmt::{Debug, Formatter, Result as FmtResult}, marker::PhantomData, @@ -32,11 +31,9 @@ use std::{ }; use jl_sys::{ - jl_alloc_array_1d, jl_alloc_array_2d, jl_alloc_array_3d, jl_apply_array_type, - jl_apply_tuple_type_v, jl_array_data, jl_array_del_beg, jl_array_del_end, jl_array_dims_ptr, + jl_apply_array_type, jl_array_data, jl_array_del_beg, jl_array_del_end, jl_array_dims_ptr, jl_array_eltype, jl_array_grow_beg, jl_array_grow_end, jl_array_ndims, jl_array_t, - jl_datatype_t, jl_gc_add_ptr_finalizer, jl_new_array, jl_new_struct_uninit, jl_pchar_to_array, - jl_ptr_to_array, jl_ptr_to_array_1d, jl_reshape_array, + jl_gc_add_ptr_finalizer, jl_new_struct_uninit, jl_pchar_to_array, jl_reshape_array, }; use self::{ @@ -46,6 +43,7 @@ use self::{ InlinePtrArrayAccessorMut, Mutable, PtrArrayAccessorI, PtrArrayAccessorMut, UnionArrayAccessorI, UnionArrayAccessorMut, }, + dimensions::DimsExt, tracked::{TrackedArray, TrackedArrayMut}, }; use super::{ @@ -54,7 +52,7 @@ use super::{ Ref, }; use crate::{ - catch::{catch_exceptions, catch_exceptions_with_slots}, + catch::catch_exceptions, convert::{ ccall_types::{CCallArg, CCallReturn}, into_julia::IntoJulia, @@ -88,8 +86,9 @@ use crate::{ memory::{ context::ledger::Ledger, get_tls, - target::{frame::GcFrame, private::TargetPriv, unrooted::Unrooted, ExtendedTarget, Target}, + target::{unrooted::Unrooted, Target, TargetException, TargetResult}, }, + prelude::ValueData, private::Private, }; @@ -125,74 +124,35 @@ pub struct Array<'scope, 'data>( impl<'data> Array<'_, 'data> { /// Allocate a new n-dimensional Julia array of dimensions `dims` for data of type `T`. /// - /// This method can only be used in combination with types that implement `IntoJulia`. If you - /// want to create an array for a type that doesn't implement this trait you must use - /// [`Array::new_for`]. + /// This method can only be used in combination with types that implement `ConstructType`. /// /// If the array size is too large, Julia will throw an error. This error is caught and /// returned. - pub fn new<'target, 'current, 'borrow, T, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub fn new<'target, 'current, 'borrow, T, D, Tgt>( + target: Tgt, dims: D, - ) -> ArrayResult<'target, 'static, S> + ) -> ArrayResult<'target, 'static, Tgt> where - T: IntoJulia, - D: Dims, - S: Target<'target>, + T: ConstructType, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let elty_ptr = T::julia_type(&frame).ptr(); + unsafe { + let callback = || { + let array_type = D::ArrayContructor::::construct_type(&target).as_value(); + let array = dims.alloc_array(&target, array_type); + array + }; - // Safety: The array type is rooted until the array has been constructed, all C API - // functions are called with valid data. - unsafe { - let mut callback = - |frame: &mut GcFrame, result: &mut MaybeUninit<*mut jl_array_t>| { - let array_type = - jl_apply_array_type(elty_ptr.as_ptr().cast(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_alloc_array_1d(array_type, dims.n_elements(0)), - 2 => jl_alloc_array_2d( - array_type, - dims.n_elements(0), - dims.n_elements(1), - ), - 3 => jl_alloc_array_3d( - array_type, - dims.n_elements(0), - dims.n_elements(1), - dims.n_elements(2), - ), - n if n <= 8 => { - let tuple = small_dim_tuple(frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - _ => { - let tuple = large_dim_tuple(frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - }; - - result.write(array); - Ok(()) - }; - - let res = match catch_exceptions_with_slots(&mut frame, &mut callback).unwrap() - { - Ok(array_ptr) => Ok(NonNull::new_unchecked(array_ptr)), - Err(e) => Err(e.ptr()), - }; - - Ok(output.result_from_ptr(res, Private)) - } - }) - .unwrap() + let exc = |err: Value| err.unwrap_non_null(Private); + + let v = match catch_exceptions(callback, exc) { + Ok(arr) => Ok(arr.ptr()), + Err(e) => Err(e), + }; + + target.result_from_ptr(v, Private) + } } /// Allocate a new n-dimensional Julia array of dimensions `dims` for data of type `T`. @@ -201,46 +161,17 @@ impl<'data> Array<'_, 'data> { /// /// Safety: If the array size is too large, Julia will throw an error. This error is not /// caught, which is UB from a `ccall`ed function. - pub unsafe fn new_unchecked<'target, 'current, 'borrow, T, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub unsafe fn new_unchecked<'target, 'current, 'borrow, T, D, Tgt>( + target: Tgt, dims: D, - ) -> ArrayData<'target, 'static, S> + ) -> ArrayData<'target, 'static, Tgt> where - T: IntoJulia, - D: Dims, - S: Target<'target>, + T: ConstructType, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let elty_ptr = T::julia_type(&frame).ptr(); - let array_type = jl_apply_array_type(elty_ptr.cast().as_ptr(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_alloc_array_1d(array_type, dims.n_elements(0)), - 2 => jl_alloc_array_2d(array_type, dims.n_elements(0), dims.n_elements(1)), - 3 => jl_alloc_array_3d( - array_type, - dims.n_elements(0), - dims.n_elements(1), - dims.n_elements(2), - ), - n if n <= 8 => { - let tuple = small_dim_tuple(&mut frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - _ => { - let tuple = large_dim_tuple(&mut frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - }; - - Ok(output.data_from_ptr(NonNull::new_unchecked(array), Private)) - }) - .unwrap() + let array_type = D::ArrayContructor::::construct_type(&target).as_value(); + dims.alloc_array(target, array_type) } /// Allocate a new n-dimensional Julia array of dimensions `dims` for data of type `ty`. @@ -249,66 +180,35 @@ impl<'data> Array<'_, 'data> { /// /// If the array size is too large or if the type is invalid, Julia will throw an error. This /// error is caught and returned. - pub fn new_for<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub fn new_for<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, dims: D, ty: Value, - ) -> ArrayResult<'target, 'static, S> + ) -> ArrayResult<'target, 'static, Tgt> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let elty_ptr = ty.unwrap(Private); - // Safety: The array type is rooted until the array has been constructed, all C API - // functions are called with valid data. - unsafe { - let mut callback = - |frame: &mut GcFrame, result: &mut MaybeUninit<*mut jl_array_t>| { - let array_type = jl_apply_array_type(elty_ptr.cast(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_alloc_array_1d(array_type, dims.n_elements(0)), - 2 => jl_alloc_array_2d( - array_type, - dims.n_elements(0), - dims.n_elements(1), - ), - 3 => jl_alloc_array_3d( - array_type, - dims.n_elements(0), - dims.n_elements(1), - dims.n_elements(2), - ), - n if n <= 8 => { - let tuple = small_dim_tuple(frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - _ => { - let tuple = large_dim_tuple(frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - }; - - result.write(array); - Ok(()) - }; - - let res = match catch_exceptions_with_slots(&mut frame, &mut callback).unwrap() - { - Ok(array_ptr) => Ok(NonNull::new_unchecked(array_ptr)), - Err(e) => Err(e.ptr()), - }; - - Ok(output.result_from_ptr(res, Private)) - } - }) - .unwrap() + let elty_ptr = ty.unwrap(Private); + // Safety: The array type is rooted until the array has been constructed, all C API + // functions are called with valid data. + unsafe { + let callback = || { + let array_type = Value::wrap_non_null( + NonNull::new_unchecked(jl_apply_array_type(elty_ptr, dims.rank())), + Private, + ); + dims.alloc_array(&target, array_type).ptr() + }; + + let exc = |err: Value| err.unwrap_non_null(Private); + let res = match catch_exceptions(callback, exc) { + Ok(array_ptr) => Ok(array_ptr), + Err(e) => Err(e), + }; + + target.result_from_ptr(res, Private) + } } /// Allocate a new n-dimensional Julia array of dimensions `dims` for data of type `T`. @@ -318,45 +218,23 @@ impl<'data> Array<'_, 'data> { /// /// Safety: If the array size is too large or if the type is invalid, Julia will throw an /// error. This error is not caught, which is UB from a `ccall`ed function. - pub unsafe fn new_for_unchecked<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub unsafe fn new_for_unchecked<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, dims: D, ty: Value, - ) -> ArrayData<'target, 'static, S> + ) -> ArrayData<'target, 'static, Tgt> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let array_type = jl_apply_array_type(ty.unwrap(Private), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_alloc_array_1d(array_type, dims.n_elements(0)), - 2 => jl_alloc_array_2d(array_type, dims.n_elements(0), dims.n_elements(1)), - 3 => jl_alloc_array_3d( - array_type, - dims.n_elements(0), - dims.n_elements(1), - dims.n_elements(2), - ), - n if n <= 8 => { - let tuple = small_dim_tuple(&mut frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - _ => { - let tuple = large_dim_tuple(&mut frame, &dims); - jl_new_array(array_type, tuple.unwrap(Private)) - } - }; + let elty_ptr = ty.unwrap(Private); + let array_type = Value::wrap_non_null( + NonNull::new_unchecked(jl_apply_array_type(elty_ptr, dims.rank())), + Private, + ); + let array = dims.alloc_array(&target, array_type); - Ok(output.data_from_ptr(NonNull::new_unchecked(array), Private)) - }) - .unwrap() + array.root(target) } /// Create a new n-dimensional Julia array of dimensions `dims` that borrows data from Rust. @@ -367,15 +245,15 @@ impl<'data> Array<'_, 'data> { /// /// If the array size is too large, Julia will throw an error. This error is caught and /// returned. - pub fn from_slice<'target: 'current, 'current: 'borrow, 'borrow, T, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub fn from_slice<'target: 'current, 'current: 'borrow, 'borrow, T, D, Tgt>( + target: Tgt, data: &'data mut [T], dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where - T: IntoJulia, - D: Dims, - S: Target<'target>, + T: IntoJulia + ConstructType, + D: DimsExt, + Tgt: Target<'target>, { if dims.size() != data.len() { Err(InstantiationError::ArraySizeMismatch { @@ -384,60 +262,24 @@ impl<'data> Array<'_, 'data> { })?; } - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let elty_ptr = T::julia_type(&frame).ptr().cast(); + // Safety: The array type is rooted until the array has been constructed, all C API + // functions are called with valid data. The data-lifetime ensures the data can't be + // used from Rust after the borrow ends. + unsafe { + let callback = || { + let array_type = D::ArrayContructor::::construct_type(&target).as_value(); + dims.alloc_array_with_data(&target, array_type, data.as_mut_ptr().cast()) + .ptr() + }; - // Safety: The array type is rooted until the array has been constructed, all C API - // functions are called with valid data. The data-lifetime ensures the data can't be - // used from Rust after the borrow ends. - unsafe { - let mut callback = - |frame: &mut GcFrame, result: &mut MaybeUninit<*mut jl_array_t>| { - let array_type = jl_apply_array_type(elty_ptr.as_ptr(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_ptr_to_array_1d( - array_type, - data.as_mut_ptr().cast(), - dims.n_elements(0), - 0, - ), - n if n <= 8 => { - let tuple = small_dim_tuple(frame, &dims); - jl_ptr_to_array( - array_type, - data.as_mut_ptr().cast(), - tuple.unwrap(Private), - 0, - ) - } - _ => { - let tuple = large_dim_tuple(frame, &dims); - jl_ptr_to_array( - array_type, - data.as_mut_ptr().cast(), - tuple.unwrap(Private), - 0, - ) - } - }; - - result.write(array); - Ok(()) - }; - - let res = match catch_exceptions_with_slots(&mut frame, &mut callback).unwrap() { - Ok(array_ptr) => Ok(NonNull::new_unchecked(array_ptr)), - Err(e) => Err(e.ptr()), - }; + let exc = |err: Value| err.unwrap_non_null(Private); + let res = match catch_exceptions(callback, exc) { + Ok(array_ptr) => Ok(array_ptr), + Err(e) => Err(e), + }; - Ok(output.result_from_ptr(res, Private)) - } - }) + Ok(target.result_from_ptr(res, Private)) + } } /// Create a new n-dimensional Julia array of dimensions `dims` that borrows data from Rust. @@ -448,15 +290,15 @@ impl<'data> Array<'_, 'data> { /// /// Safety: If the array size is too large, Julia will throw an error. This error is not /// caught, which is UB from a `ccall`ed function. - pub unsafe fn from_slice_unchecked<'target, 'current, 'borrow, T, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub unsafe fn from_slice_unchecked<'target, 'current, 'borrow, T, D, Tgt>( + target: Tgt, data: &'data mut [T], dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where - T: IntoJulia, - D: Dims, - S: Target<'target>, + T: IntoJulia + ConstructType, + D: DimsExt, + Tgt: Target<'target>, { if dims.size() != data.len() { Err(InstantiationError::ArraySizeMismatch { @@ -465,40 +307,8 @@ impl<'data> Array<'_, 'data> { })?; } - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let array_type = - jl_apply_array_type(T::julia_type(&frame).ptr().cast().as_ptr(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => { - jl_ptr_to_array_1d(array_type, data.as_mut_ptr().cast(), dims.n_elements(0), 0) - } - n if n <= 8 => { - let tuple = small_dim_tuple(&mut frame, &dims); - jl_ptr_to_array( - array_type, - data.as_mut_ptr().cast(), - tuple.unwrap(Private), - 0, - ) - } - _ => { - let tuple = large_dim_tuple(&mut frame, &dims); - jl_ptr_to_array( - array_type, - data.as_mut_ptr().cast(), - tuple.unwrap(Private), - 0, - ) - } - }; - - Ok(output.data_from_ptr(NonNull::new_unchecked(array), Private)) - }) + let array_type = D::ArrayContructor::::construct_type(&target).as_value(); + Ok(dims.alloc_array_with_data(target, array_type, data.as_mut_ptr().cast())) } /// Create a new n-dimensional Julia array of dimensions `dims` that takes ownership of Rust @@ -510,15 +320,15 @@ impl<'data> Array<'_, 'data> { /// /// If the array size is too large, Julia will throw an error. This error is caught and /// returned. - pub fn from_vec<'target, 'current, 'borrow, T, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub fn from_vec<'target, 'current, 'borrow, T, D, Tgt>( + target: Tgt, data: Vec, dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where - T: IntoJulia, - D: Dims, - S: Target<'target>, + T: IntoJulia + ConstructType, + D: DimsExt, + Tgt: Target<'target>, { if dims.size() != data.len() { Err(InstantiationError::ArraySizeMismatch { @@ -527,67 +337,35 @@ impl<'data> Array<'_, 'data> { })?; } - let (output, scope) = target.split(); - scope.scope(|mut frame| { - let elty_ptr = T::julia_type(&frame).ptr().cast(); - let data = Box::leak(data.into_boxed_slice()); + let data = Box::leak(data.into_boxed_slice()); - // Safety: The array type is rooted until the array has been constructed, all C API - // functions are called with valid data. The data-lifetime ensures the data can't be - // used from Rust after the borrow ends. - unsafe { - let mut callback = - |frame: &mut GcFrame, result: &mut MaybeUninit<*mut jl_array_t>| { - let array_type = jl_apply_array_type(elty_ptr.as_ptr(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_ptr_to_array_1d( - array_type, - data.as_mut_ptr().cast(), - dims.n_elements(0), - 1, - ), - n if n <= 8 => { - let tuple = small_dim_tuple(frame, &dims); - jl_ptr_to_array( - array_type, - data.as_mut_ptr().cast(), - tuple.unwrap(Private), - 1, - ) - } - _ => { - let tuple = large_dim_tuple(frame, &dims); - jl_ptr_to_array( - array_type, - data.as_mut_ptr().cast(), - tuple.unwrap(Private), - 1, - ) - } - }; - - jl_gc_add_ptr_finalizer( - get_tls(), - array.cast(), - droparray:: as *mut c_void, - ); - - result.write(array); - Ok(()) - }; - - let res = match catch_exceptions_with_slots(&mut frame, &mut callback).unwrap() { - Ok(array_ptr) => Ok(NonNull::new_unchecked(array_ptr)), - Err(e) => Err(e.ptr()), - }; + // Safety: The array type is rooted until the array has been constructed, all C API + // functions are called with valid data. The data-lifetime ensures the data can't be + // used from Rust after the borrow ends. + unsafe { + let callback = || { + let array_type = D::ArrayContructor::::construct_type(&target).as_value(); + let array = dims + .alloc_array_with_data(&target, array_type, data.as_mut_ptr().cast()) + .ptr(); + + jl_gc_add_ptr_finalizer( + get_tls(), + array.as_ptr().cast(), + droparray:: as *mut c_void, + ); + + array + }; - Ok(output.result_from_ptr(res, Private)) - } - }) + let exc = |err: Value| err.unwrap_non_null(Private); + let res = match catch_exceptions(callback, exc) { + Ok(array_ptr) => Ok(array_ptr), + Err(e) => Err(e), + }; + + Ok(target.result_from_ptr(res, Private)) + } } /// Create a new n-dimensional Julia array of dimensions `dims` that takes ownership of Rust @@ -599,15 +377,15 @@ impl<'data> Array<'_, 'data> { /// /// Safety: If the array size is too large, Julia will throw an error. This error is not /// caught, which is UB from a `ccall`ed function. - pub unsafe fn from_vec_unchecked<'target, 'current, 'borrow, T, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub unsafe fn from_vec_unchecked<'target, 'current, 'borrow, T, D, Tgt>( + target: Tgt, data: Vec, dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where - T: IntoJulia, - D: Dims, - S: Target<'target>, + T: IntoJulia + ConstructType, + D: DimsExt, + Tgt: Target<'target>, { if dims.size() != data.len() { Err(InstantiationError::ArraySizeMismatch { @@ -616,51 +394,26 @@ impl<'data> Array<'_, 'data> { })?; } - let (output, scope) = target.split(); - scope.scope(|mut frame| { - let array_type = - jl_apply_array_type(T::julia_type(&frame).ptr().cast().as_ptr(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let array = match dims.rank() { - 1 => jl_ptr_to_array_1d( - array_type, - Box::into_raw(data.into_boxed_slice()).cast(), - dims.n_elements(0), - 1, - ), - n if n <= 8 => { - let tuple = small_dim_tuple(&mut frame, &dims); - jl_ptr_to_array( - array_type, - Box::into_raw(data.into_boxed_slice()).cast(), - tuple.unwrap(Private), - 1, - ) - } - _ => { - let tuple = large_dim_tuple(&mut frame, &dims); - jl_ptr_to_array( - array_type, - Box::into_raw(data.into_boxed_slice()).cast(), - tuple.unwrap(Private), - 1, - ) - } - }; + let data = Box::leak(data.into_boxed_slice()); + let array_type = D::ArrayContructor::::construct_type(&target).as_value(); + let array = dims + .alloc_array_with_data(&target, array_type, data.as_mut_ptr().cast()) + .ptr(); - jl_gc_add_ptr_finalizer(get_tls(), array.cast(), droparray:: as *mut c_void); - Ok(output.data_from_ptr(NonNull::new_unchecked(array), Private)) - }) + jl_gc_add_ptr_finalizer( + get_tls(), + array.as_ptr().cast(), + droparray:: as *mut c_void, + ); + Ok(target.data_from_ptr(array, Private)) } /// Convert a string to a Julia array. - pub fn from_string<'target, A, T>(target: T, data: A) -> ArrayData<'target, 'static, T> + #[inline] + pub fn from_string<'target, A, Tgt>(target: Tgt, data: A) -> ArrayData<'target, 'static, Tgt> where A: AsRef, - T: Target<'target>, + Tgt: Target<'target>, { let string = data.as_ref(); let nbytes = string.bytes().len(); @@ -672,7 +425,7 @@ impl<'data> Array<'_, 'data> { } } - #[inline(always)] + #[inline] pub(crate) fn data_ptr(self) -> *mut c_void { // Safety: the pointer points to valid data. unsafe { self.unwrap_non_null(Private).as_ref().data } @@ -681,12 +434,14 @@ impl<'data> Array<'_, 'data> { impl<'scope, 'data> Array<'scope, 'data> { /// Returns the array's dimensions. - /// TODO safety + // TODO safety + #[inline] pub unsafe fn dimensions(self) -> ArrayDimensions<'scope> { ArrayDimensions::new(self) } /// Returns the type of this array's elements. + #[inline] pub fn element_type(self) -> Value<'scope, 'static> { // Safety: C API function is called valid arguments. unsafe { @@ -698,12 +453,14 @@ impl<'scope, 'data> Array<'scope, 'data> { } /// Returns the size of this array's elements. + #[inline] pub fn element_size(self) -> usize { // Safety: the pointer points to valid data. unsafe { self.unwrap_non_null(Private).as_ref().elsize as usize } } /// Returns `true` if the layout of the elements is compatible with `T`. + #[inline] pub fn contains(self) -> bool { // Safety: C API function is called valid arguments. T::valid_field(self.element_type()) @@ -711,11 +468,13 @@ impl<'scope, 'data> Array<'scope, 'data> { /// Returns `true` if the layout of the elements is compatible with `T` and these elements are /// stored inline. + #[inline] pub fn contains_inline(self) -> bool { self.contains::() && self.is_inline_array() } /// Returns `true` if the elements of the array are stored inline. + #[inline] pub fn is_inline_array(self) -> bool { // Safety: the pointer points to valid data. unsafe { self.unwrap_non_null(Private).as_ref().flags.ptrarray() == 0 } @@ -723,12 +482,14 @@ impl<'scope, 'data> Array<'scope, 'data> { /// Returns `true` if the elements of the array are stored inline and the element type is a /// union type. + #[inline] pub fn is_union_array(self) -> bool { self.is_inline_array() && self.element_type().is::() } /// Returns true if the elements of the array are stored inline and at least one of the fields /// of the inlined type is a pointer. + #[inline] pub fn has_inlined_pointers(self) -> bool { // Safety: the pointer points to valid data. unsafe { @@ -738,6 +499,7 @@ impl<'scope, 'data> Array<'scope, 'data> { } /// Returns `true` if elements of this array are zero-initialized. + #[inline] pub fn zero_init(self) -> bool { // Safety: the pointer points to valid data. unsafe { @@ -756,6 +518,7 @@ impl<'scope, 'data> Array<'scope, 'data> { } /// Returns true if the elements of the array are stored as [`Value`]s. + #[inline] pub fn is_value_array(self) -> bool { !self.is_inline_array() } @@ -776,12 +539,12 @@ impl<'scope, 'data> Array<'scope, 'data> { } /// Convert this array to a [`TypedValue`]. - pub fn as_typed_value( + pub fn as_typed_value<'target, T: ConstructType, Tgt: Target<'target>, const N: isize>( self, - frame: &mut GcFrame, + target: &Tgt, ) -> JlrsResult>> { - frame.scope(|mut frame| { - let ty = T::construct_type(frame.as_extended_target()); + unsafe { + let ty = T::construct_type(target).as_value(); let elty = self.element_type(); if ty != elty { // err @@ -791,23 +554,22 @@ impl<'scope, 'data> Array<'scope, 'data> { })?; } - unsafe { - let rank = self.dimensions().rank(); - if rank != N as _ { - Err(ArrayLayoutError::RankMismatch { - found: rank as isize, - provided: N, - })?; - } - - Ok(TypedValue::>::from_value_unchecked( - self.as_value(), - )) + let rank = self.dimensions().rank(); + if rank != N as _ { + Err(ArrayLayoutError::RankMismatch { + found: rank as isize, + provided: N, + })?; } - }) + + Ok(TypedValue::>::from_value_unchecked( + self.as_value(), + )) + } } /// Convert this array to a [`TypedValue`] without checking if the layout is compatible. + #[inline] pub unsafe fn as_typed_value_unchecked( self, ) -> TypedValue<'scope, 'data, ArrayType> { @@ -849,6 +611,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// valid. /// /// Safety: `T` must be a valid representation of the data stored in the array. + #[inline] pub unsafe fn as_typed_unchecked(self) -> TypedArray<'scope, 'data, T> where T: ValidField, @@ -859,6 +622,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// Track this array. /// /// While an array is tracked, it can't be exclusively tracked. + #[inline] pub fn track_shared<'borrow>( &'borrow self, ) -> JlrsResult> { @@ -869,6 +633,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// Exclusively track this array. /// /// While an array is exclusively tracked, it can't be tracked otherwise. + #[inline] pub unsafe fn track_exclusive<'borrow>( &'borrow mut self, ) -> JlrsResult> { @@ -902,6 +667,7 @@ impl<'scope, 'data> Array<'scope, 'data> { // TODO docs // TODO safety for all + /// Immutably access the contents of this array. The elements must have an `isbits` type. /// /// Returns `ArrayLayoutError::NotInline` if the data is not stored inline, `ArrayLayoutError::NotBits` @@ -909,6 +675,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// layout for the array elements. /// /// Safety: it's not checked if the content of this array are already borrowed by Rust code. + #[inline] pub unsafe fn bits_data<'borrow, T>( &'borrow self, ) -> JlrsResult> @@ -930,6 +697,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn bits_data_mut<'borrow, T>( &'borrow mut self, ) -> JlrsResult> @@ -948,6 +716,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Returns `ArrayLayoutError::NotInline` if the data is not stored inline or /// `AccessError::InvalidLayout` if `T` is not a valid layout for the array elements. + #[inline] pub unsafe fn inline_data<'borrow, T>( &'borrow self, ) -> JlrsResult> @@ -969,6 +738,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn inline_data_mut<'borrow, T>( &'borrow mut self, ) -> JlrsResult> @@ -987,6 +757,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Returns `ArrayLayoutError::NotPointer` if the data is stored inline or `AccessError::InvalidLayout` if `T` /// is not a valid layout for the array elements. + #[inline] pub unsafe fn managed_data<'borrow, T>( &'borrow self, ) -> JlrsResult> @@ -1009,6 +780,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn managed_data_mut<'borrow, T>( &'borrow mut self, ) -> JlrsResult> @@ -1027,6 +799,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// You can borrow data from multiple arrays at the same time. /// /// Returns `ArrayLayoutError::NotPointer` if the data is stored inline. + #[inline] pub unsafe fn value_data<'borrow>( &'borrow self, ) -> JlrsResult>> { @@ -1044,6 +817,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn value_data_mut<'borrow>( &'borrow mut self, ) -> JlrsResult>> { @@ -1058,6 +832,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// You can borrow data from multiple arrays at the same time. /// /// Returns `ArrayLayoutError::NotUnion` if the data is not stored as a bits union. + #[inline] pub unsafe fn union_data<'borrow>( &'borrow self, ) -> JlrsResult> { @@ -1075,6 +850,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn union_data_mut<'borrow>( &'borrow mut self, ) -> JlrsResult> { @@ -1087,6 +863,7 @@ impl<'scope, 'data> Array<'scope, 'data> { /// Immutably access the contents of this array. /// /// You can borrow data from multiple arrays at the same time. + #[inline] pub unsafe fn indeterminate_data<'borrow>( &'borrow self, ) -> IndeterminateArrayAccessorI<'borrow, 'scope, 'data> { @@ -1099,30 +876,35 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn indeterminate_data_mut<'borrow>( &'borrow mut self, ) -> IndeterminateArrayAccessor<'borrow, 'scope, 'data, Mutable<'borrow, u8>> { ArrayAccessor::new(self) } + #[inline] pub unsafe fn into_slice_unchecked(self) -> &'scope [T] { let len = self.dimensions().size(); let data = self.data_ptr().cast::(); std::slice::from_raw_parts(data, len) } + #[inline] pub unsafe fn as_slice_unchecked<'borrow, T>(&'borrow self) -> &'borrow [T] { let len = self.dimensions().size(); let data = self.data_ptr().cast::(); std::slice::from_raw_parts(data, len) } + #[inline] pub unsafe fn into_mut_slice_unchecked(self) -> &'scope mut [T] { let len = self.dimensions().size(); let data = self.data_ptr().cast::(); std::slice::from_raw_parts_mut(data, len) } + #[inline] pub unsafe fn as_mut_slice_unchecked<'borrow, T>(&'borrow mut self) -> &'borrow mut [T] { let len = self.dimensions().size(); let data = self.data_ptr().cast::(); @@ -1134,51 +916,36 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// This method returns an exception if the old and new array have a different number of /// elements. - pub unsafe fn reshape<'target, 'current, 'borrow, D, S>( + pub unsafe fn reshape<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> ArrayResult<'target, 'data, S> + ) -> ArrayResult<'target, 'data, Tgt> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, scope) = target.split(); - scope - .scope(|mut frame| { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { let elty_ptr = self.element_type().unwrap(Private); // Safety: The array type is rooted until the array has been constructed, all C API // functions are called with valid data. If an exception is thrown it's caught. - let mut callback = - |frame: &mut GcFrame, result: &mut MaybeUninit<*mut jl_array_t>| { - let array_type = jl_apply_array_type(elty_ptr, dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let tuple = if dims.rank() <= 8 { - small_dim_tuple(frame, &dims) - } else { - large_dim_tuple(frame, &dims) - }; - - let array = jl_reshape_array( - array_type, - self.unwrap(Private), - tuple.unwrap(Private), - ); - - result.write(array); - Ok(()) - }; - - let res = match catch_exceptions_with_slots(&mut frame, &mut callback).unwrap() { + let callback = || { + let array_type = jl_apply_array_type(elty_ptr, dims.rank()); + + let tuple = sized_dim_tuple(&mut frame, &dims); + + jl_reshape_array(array_type, self.unwrap(Private), tuple.unwrap(Private)) + }; + + let exc = |err: Value| err.unwrap_non_null(Private); + let res = match catch_exceptions(callback, exc) { Ok(array_ptr) => Ok(NonNull::new_unchecked(array_ptr)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; - Ok(output.result_from_ptr(res, Private)) + Ok(target.result_from_ptr(res, Private)) }) .unwrap() } @@ -1188,32 +955,23 @@ impl<'scope, 'data> Array<'scope, 'data> { /// /// Safety: If the dimensions are incompatible with the array size, Julia will throw an error. /// This error is not caught, which is UB from a `ccall`ed function. - pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, S>( + pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> ArrayData<'target, 'data, S> + ) -> ArrayData<'target, 'data, Tgt> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, scope) = target.split(); - scope - .scope(|mut frame| { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { let elty_ptr = self.element_type().unwrap(Private); let array_type = jl_apply_array_type(elty_ptr.cast(), dims.rank()); - let _: Value = frame - .as_mut() - .data_from_ptr(NonNull::new_unchecked(array_type), Private); - - let tuple = if dims.rank() <= 8 { - small_dim_tuple(&mut frame, &dims) - } else { - large_dim_tuple(&mut frame, &dims) - }; + let tuple = sized_dim_tuple(&mut frame, &dims); let res = jl_reshape_array(array_type, self.unwrap(Private), tuple.unwrap(Private)); - Ok(output.data_from_ptr(NonNull::new_unchecked(res), Private)) + Ok(target.data_from_ptr(NonNull::new_unchecked(res), Private)) }) .unwrap() } @@ -1312,21 +1070,19 @@ impl<'scope> Array<'scope, 'static> { &mut self, target: S, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { // Safety: the C API function is called with valid data. If an exception is thrown it's caught. - let mut callback = |result: &mut MaybeUninit<()>| { - jl_array_grow_end(self.unwrap(Private), inc); - result.write(()); - Ok(()) - }; + let callback = || jl_array_grow_end(self.unwrap(Private), inc); + + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.exception_from_ptr(res, Private) @@ -1337,6 +1093,7 @@ impl<'scope> Array<'scope, 'static> { /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn grow_end_unchecked(&mut self, inc: usize) { jl_array_grow_end(self.unwrap(Private), inc); } @@ -1345,20 +1102,22 @@ impl<'scope> Array<'scope, 'static> { /// /// The array must be 1D, not contain data borrowed or moved from Rust, otherwise an exception /// is returned. - pub unsafe fn del_end<'target, S>(&mut self, target: S, dec: usize) -> S::Exception<'static, ()> + pub unsafe fn del_end<'target, S>( + &mut self, + target: S, + dec: usize, + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { // Safety: the C API function is called with valid data. If an exception is thrown it's caught. - let mut callback = |result: &mut MaybeUninit<()>| { - jl_array_del_end(self.unwrap(Private), dec); - result.write(()); - Ok(()) - }; + let callback = || jl_array_del_end(self.unwrap(Private), dec); + + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.exception_from_ptr(res, Private) @@ -1369,6 +1128,7 @@ impl<'scope> Array<'scope, 'static> { /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn del_end_unchecked(&mut self, dec: usize) { jl_array_del_end(self.unwrap(Private), dec); } @@ -1381,20 +1141,17 @@ impl<'scope> Array<'scope, 'static> { &mut self, target: S, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { // Safety: the C API function is called with valid data. If an exception is thrown it's caught. - let mut callback = |result: &mut MaybeUninit<()>| { - jl_array_grow_beg(self.unwrap(Private), inc); - result.write(()); - Ok(()) - }; + let callback = || jl_array_grow_beg(self.unwrap(Private), inc); + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.exception_from_ptr(res, Private) @@ -1405,6 +1162,7 @@ impl<'scope> Array<'scope, 'static> { /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn grow_begin_unchecked(&mut self, inc: usize) { jl_array_grow_beg(self.unwrap(Private), inc); } @@ -1417,20 +1175,17 @@ impl<'scope> Array<'scope, 'static> { &mut self, target: S, dec: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { // Safety: the C API function is called with valid data. If an exception is thrown it's caught. - let mut callback = |result: &mut MaybeUninit<()>| { - jl_array_del_beg(self.unwrap(Private), dec); - result.write(()); - Ok(()) - }; + let callback = || jl_array_del_beg(self.unwrap(Private), dec); + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.exception_from_ptr(res, Private) @@ -1441,12 +1196,14 @@ impl<'scope> Array<'scope, 'static> { /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn del_begin_unchecked(&mut self, dec: usize) { jl_array_del_beg(self.unwrap(Private), dec); } } unsafe impl<'scope, 'data> Typecheck for Array<'scope, 'data> { + #[inline] fn typecheck(t: DataType) -> bool { // Safety: Array is a UnionAll. so check if the typenames match unsafe { t.type_name() == TypeName::of_array(&Unrooted::new()) } @@ -1462,11 +1219,12 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for Array<'scope, 'data> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData, PhantomData) } - #[inline(always)] + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } @@ -1485,21 +1243,25 @@ pub struct TypedArray<'scope, 'data, T>( impl<'scope, 'data, T> TypedArray<'scope, 'data, T> { /// Returns the array's dimensions. + #[inline] pub unsafe fn dimensions(self) -> ArrayDimensions<'scope> { self.as_array().dimensions() } /// Returns the type of this array's elements. + #[inline] pub fn element_type(self) -> Value<'scope, 'static> { self.as_array().element_type() } /// Returns the size of this array's elements. + #[inline] pub fn element_size(self) -> usize { self.as_array().element_size() } /// Convert `self` to `Array`. + #[inline] pub fn as_array(self) -> Array<'scope, 'data> { unsafe { Array::wrap_non_null(self.0, Private) } } @@ -1509,6 +1271,7 @@ impl<'scope, 'data, U: ValidField> TypedArray<'scope, 'data, U> { /// Track this array. /// /// While an array is tracked, it can't be exclusively tracked. + #[inline] pub fn track_shared<'borrow>( &'borrow self, ) -> JlrsResult> { @@ -1519,6 +1282,7 @@ impl<'scope, 'data, U: ValidField> TypedArray<'scope, 'data, U> { /// Exclusively track this array. /// /// While an array is exclusively tracked, it can't be tracked otherwise. + #[inline] pub unsafe fn track_exclusive<'borrow>( &'borrow mut self, ) -> JlrsResult> { @@ -1549,6 +1313,7 @@ impl<'scope, 'data, T: ConstructType> TypedArray<'scope, 'data, T> { } /// Convert this array to a [`TypedValue`] without checking if the layout is compatible. + #[inline] pub unsafe fn as_typed_value_unchecked( self, ) -> TypedValue<'scope, 'data, ArrayType> { @@ -1563,6 +1328,7 @@ impl<'scope, 'data, T> Clone for TypedArray<'scope, 'data, T> where T: ValidField, { + #[inline] fn clone(&self) -> Self { unsafe { TypedArray::wrap_non_null(self.unwrap_non_null(Private), Private) } } @@ -1572,7 +1338,7 @@ impl<'scope, 'data, T> Copy for TypedArray<'scope, 'data, T> where T: ValidField impl<'data, T> TypedArray<'_, 'data, T> where - T: ValidField + IntoJulia, + T: ValidField + IntoJulia + ConstructType, { /// Allocate a new n-dimensional Julia array of dimensions `dims` for data of type `T`. /// @@ -1582,33 +1348,25 @@ where /// /// If the array size is too large, Julia will throw an error. This error is caught and /// returned. - pub fn new<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + #[inline] + pub fn new<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, dims: D, - ) -> TypedArrayResult<'target, 'static, S, T> + ) -> TypedArrayResult<'target, 'static, Tgt, T> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { unsafe { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let global = frame.unrooted(); - let target = frame.extended_target(global); - let x = Array::new::(target, dims); - - let res = match x { - Ok(arr) => Ok(arr - .as_managed() - .as_typed_unchecked::() - .unwrap_non_null(Private)), - Err(e) => Err(e.as_managed().unwrap_non_null(Private)), - }; - - Ok(output.result_from_ptr(res, Private)) - }) - .unwrap() + let res = match Array::new::(&target, dims) { + Ok(arr) => Ok(arr + .as_managed() + .as_typed_unchecked::() + .unwrap_non_null(Private)), + Err(e) => Err(e.as_managed().unwrap_non_null(Private)), + }; + + target.result_from_ptr(res, Private) } } @@ -1618,27 +1376,20 @@ where /// /// Safety: If the array size is too large, Julia will throw an error. This error is not /// caught, which is UB from a `ccall`ed function. - pub unsafe fn new_unchecked<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + #[inline] + pub unsafe fn new_unchecked<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, dims: D, - ) -> TypedArrayData<'target, 'data, S, T> + ) -> TypedArrayData<'target, 'data, Tgt, T> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let inner_output = frame.unrooted(); - let target = frame.extended_target(inner_output); - - let res = Array::new_unchecked::(target, dims) - .as_managed() - .as_typed_unchecked::(); + let res = Array::new_unchecked::(&target, dims) + .as_managed() + .as_typed_unchecked::(); - Ok(output.data_from_ptr(res.unwrap_non_null(Private), Private)) - }) - .unwrap() + target.data_from_ptr(res.unwrap_non_null(Private), Private) } /// Create a new n-dimensional Julia array of dimensions `dims` that borrows data from Rust. @@ -1649,32 +1400,27 @@ where /// /// If the array size is too large, Julia will throw an error. This error is caught and /// returned. - pub fn from_slice<'target: 'current, 'current: 'borrow, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + #[inline] + pub fn from_slice<'target: 'current, 'current: 'borrow, 'borrow, D, Tgt>( + target: Tgt, data: &'data mut [T], dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where T: IntoJulia, - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { unsafe { - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let global = frame.unrooted(); - let target = frame.extended_target(global); - - let res = match Array::from_slice::(target, data, dims)? { - Ok(arr) => Ok(arr - .as_managed() - .as_typed_unchecked::() - .unwrap_non_null(Private)), - Err(e) => Err(e.as_managed().unwrap_non_null(Private)), - }; + let res = match Array::from_slice::(&target, data, dims)? { + Ok(arr) => Ok(arr + .as_managed() + .as_typed_unchecked::() + .unwrap_non_null(Private)), + Err(e) => Err(e.as_managed().unwrap_non_null(Private)), + }; - Ok(output.result_from_ptr(res, Private)) - }) + Ok(target.result_from_ptr(res, Private)) } } @@ -1686,27 +1432,22 @@ where /// /// Safety: If the array size is too large, Julia will throw an error. This error is not /// caught, which is UB from a `ccall`ed function. - pub unsafe fn from_slice_unchecked<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + #[inline] + pub unsafe fn from_slice_unchecked<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, data: &'data mut [T], dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where T: IntoJulia, - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let inner_output = frame.unrooted(); - let target = frame.extended_target(inner_output); + let res = Array::from_slice_unchecked::(&target, data, dims)? + .as_managed() + .as_typed_unchecked::(); - let res = Array::from_slice_unchecked::(target, data, dims)? - .as_managed() - .as_typed_unchecked::(); - - Ok(output.data_from_ptr(res.unwrap_non_null(Private), Private)) - }) + Ok(target.data_from_ptr(res.unwrap_non_null(Private), Private)) } /// Create a new n-dimensional Julia array of dimensions `dims` that takes ownership of Rust @@ -1718,32 +1459,27 @@ where /// /// If the array size is too large, Julia will throw an error. This error is caught and /// returned. - pub fn from_vec<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + #[inline] + pub fn from_vec<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, data: Vec, dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where T: IntoJulia, - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { unsafe { - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let global = frame.unrooted(); - let target = frame.extended_target(global); - - let res = match Array::from_vec::(target, data, dims)? { - Ok(arr) => Ok(arr - .as_managed() - .as_typed_unchecked::() - .unwrap_non_null(Private)), - Err(e) => Err(e.as_managed().unwrap_non_null(Private)), - }; + let res = match Array::from_vec::(&target, data, dims)? { + Ok(arr) => Ok(arr + .as_managed() + .as_typed_unchecked::() + .unwrap_non_null(Private)), + Err(e) => Err(e.as_managed().unwrap_non_null(Private)), + }; - Ok(output.result_from_ptr(res, Private)) - }) + Ok(target.result_from_ptr(res, Private)) } } @@ -1756,27 +1492,22 @@ where /// /// Safety: If the array size is too large, Julia will throw an error. This error is not /// caught, which is UB from a `ccall`ed function. - pub unsafe fn from_vec_unchecked<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + #[inline] + pub unsafe fn from_vec_unchecked<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, data: Vec, dims: D, - ) -> JlrsResult> + ) -> JlrsResult> where T: IntoJulia, - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let inner_output = frame.unrooted(); - let target = frame.extended_target(inner_output); - - let res = Array::from_vec_unchecked::(target, data, dims)? - .as_managed() - .as_typed_unchecked::(); + let res = Array::from_vec_unchecked::(&target, data, dims)? + .as_managed() + .as_typed_unchecked::(); - Ok(output.data_from_ptr(res.unwrap_non_null(Private), Private)) - }) + Ok(target.data_from_ptr(res.unwrap_non_null(Private), Private)) } } @@ -1790,14 +1521,14 @@ where /// /// If the array size is too large or if the type is invalid, Julia will throw an error. This /// error is caught and returned. - pub fn new_for<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub fn new_for<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, dims: D, ty: Value, - ) -> JlrsResult> + ) -> JlrsResult> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { if !T::valid_field(ty) { let value_type = ty.display_string_or(CANNOT_DISPLAY_TYPE).into(); @@ -1805,21 +1536,15 @@ where } unsafe { - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let global = frame.unrooted(); - let target = frame.extended_target(global); - - let res = match Array::new_for(target, dims, ty) { - Ok(arr) => Ok(arr - .as_managed() - .as_typed_unchecked::() - .unwrap_non_null(Private)), - Err(e) => Err(e.as_managed().unwrap_non_null(Private)), - }; + let res = match Array::new_for(&target, dims, ty) { + Ok(arr) => Ok(arr + .as_managed() + .as_typed_unchecked::() + .unwrap_non_null(Private)), + Err(e) => Err(e.as_managed().unwrap_non_null(Private)), + }; - Ok(output.result_from_ptr(res, Private)) - }) + Ok(target.result_from_ptr(res, Private)) } } @@ -1830,36 +1555,31 @@ where /// /// Safety: If the array size is too large or if the type is invalid, Julia will throw an /// error. This error is not caught, which is UB from a `ccall`ed function. - pub unsafe fn new_for_unchecked<'target, 'current, 'borrow, D, S>( - target: ExtendedTarget<'target, '_, '_, S>, + pub unsafe fn new_for_unchecked<'target, 'current, 'borrow, D, Tgt>( + target: Tgt, dims: D, ty: Value, - ) -> JlrsResult> + ) -> JlrsResult> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { if !T::valid_field(ty) { let value_type = ty.display_string_or(CANNOT_DISPLAY_TYPE).into(); Err(AccessError::InvalidLayout { value_type })?; } - let (output, frame) = target.split(); - frame.scope(|mut frame| { - let inner_output = frame.unrooted(); - let target = frame.extended_target(inner_output); - - let res = Array::new_for_unchecked(target, dims, ty) - .as_managed() - .as_typed_unchecked::(); + let res = Array::new_for_unchecked(&target, dims, ty) + .as_managed() + .as_typed_unchecked::(); - Ok(output.data_from_ptr(res.unwrap_non_null(Private), Private)) - }) + Ok(target.data_from_ptr(res.unwrap_non_null(Private), Private)) } } impl<'data> TypedArray<'_, 'data, u8> { /// Convert a string to a Julia array. + #[inline] pub fn from_string<'target, A, T>(target: T, data: A) -> TypedArrayData<'target, 'static, T, u8> where A: AsRef, @@ -1882,22 +1602,26 @@ where T: ValidField, { /// Returns `true` if the elements of the array are stored inline. + #[inline] pub fn is_inline_array(self) -> bool { self.as_array().is_inline_array() } /// Returns true if the elements of the array are stored inline and at least one of the fields /// of the inlined type is a pointer. + #[inline] pub fn has_inlined_pointers(self) -> bool { self.as_array().has_inlined_pointers() } /// Returns `true` if elements of this array are zero-initialized. + #[inline] pub fn zero_init(self) -> bool { self.as_array().zero_init() } /// Returns true if the elements of the array are stored as [`Value`]s. + #[inline] pub fn is_value_array(self) -> bool { !self.is_inline_array() } @@ -1940,6 +1664,7 @@ where /// Returns `ArrayLayoutError::NotInline` if the data is not stored inline, `ArrayLayoutError::NotBits` /// if the type is not an `isbits` type, or `AccessError::InvalidLayout` if `T` is not a valid /// layout for the array elements. + #[inline] pub unsafe fn bits_data<'borrow>( &'borrow self, ) -> JlrsResult> { @@ -1960,6 +1685,7 @@ where /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn bits_data_mut<'borrow>( &'borrow mut self, ) -> JlrsResult> { @@ -1976,6 +1702,7 @@ where /// /// Returns `ArrayLayoutError::NotInline` if the data is not stored inline or /// `AccessError::InvalidLayout` if `T` is not a valid layout for the array elements. + #[inline] pub unsafe fn inline_data<'borrow>( &'borrow self, ) -> JlrsResult> @@ -1998,6 +1725,7 @@ where /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn inline_data_mut<'borrow>( &'borrow mut self, ) -> JlrsResult> @@ -2043,6 +1771,7 @@ where } /// Convert `self` to `Array`. + #[inline] pub fn as_array_ref(&self) -> &Array<'scope, 'data> { unsafe { std::mem::transmute(self) } } @@ -2052,32 +1781,25 @@ where /// /// This method returns an exception if the old and new array have a different number of /// elements. - pub unsafe fn reshape<'target, 'current, 'borrow, D, S>( + #[inline] + pub unsafe fn reshape<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> TypedArrayResult<'target, 'data, S, T> + ) -> TypedArrayResult<'target, 'data, Tgt, T> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let global = frame.unrooted(); - let target = frame.extended_target(global); - - let res = match self.as_array().reshape(target, dims) { - Ok(arr) => Ok(arr - .as_managed() - .as_typed_unchecked::() - .unwrap_non_null(Private)), - Err(e) => Err(e.as_managed().unwrap_non_null(Private)), - }; + let res = match self.as_array().reshape(&target, dims) { + Ok(arr) => Ok(arr + .as_managed() + .as_typed_unchecked::() + .unwrap_non_null(Private)), + Err(e) => Err(e.as_managed().unwrap_non_null(Private)), + }; - Ok(output.result_from_ptr(res, Private)) - }) - .unwrap() + target.result_from_ptr(res, Private) } /// Reshape the array, a new array is returned that has dimensions `dims`. The new array and @@ -2085,35 +1807,30 @@ where /// /// Safety: If the dimensions are incompatible with the array size, Julia will throw an error. /// This error is not caught, which is UB from a `ccall`ed function. - pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, S>( + #[inline] + pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, Tgt>( self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> TypedArrayData<'target, 'data, S, T> + ) -> TypedArrayData<'target, 'data, Tgt, T> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { - let (output, frame) = target.split(); - frame - .scope(|mut frame| { - let inner_output = frame.unrooted(); - let target = frame.extended_target(inner_output); - - let res = self - .as_array() - .reshape_unchecked(target, dims) - .as_managed() - .as_typed_unchecked::() - .unwrap_non_null(Private); - Ok(output.data_from_ptr(res, Private)) - }) - .unwrap() + let res = self + .as_array() + .reshape_unchecked(&target, dims) + .as_managed() + .as_typed_unchecked::() + .unwrap_non_null(Private); + + target.data_from_ptr(res, Private) } /// Immutably access the contents of this array. /// /// You can borrow data from multiple arrays at the same time. + #[inline] pub unsafe fn indeterminate_data<'borrow>( &'borrow self, ) -> IndeterminateArrayAccessor<'borrow, 'scope, 'data, Immutable<'borrow, u8>> { @@ -2127,6 +1844,7 @@ where /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn indeterminate_data_mut<'borrow>( &'borrow mut self, ) -> IndeterminateArrayAccessor<'borrow, 'scope, 'data, Mutable<'borrow, u8>> { @@ -2156,6 +1874,7 @@ where /// /// Returns `ArrayLayoutError::NotPointer` if the data is stored inline or `AccessError::InvalidLayout` if `T` /// is not a valid layout for the array elements. + #[inline] pub unsafe fn managed_data<'borrow>( &'borrow self, ) -> JlrsResult> { @@ -2175,6 +1894,7 @@ where /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn managed_data_mut<'borrow>( &'borrow mut self, ) -> JlrsResult> { @@ -2190,6 +1910,7 @@ where /// You can borrow data from multiple arrays at the same time. /// /// Returns `ArrayLayoutError::NotPointer` if the data is stored inline. + #[inline] pub unsafe fn value_data<'borrow>( &'borrow self, ) -> JlrsResult>> { @@ -2208,6 +1929,7 @@ where /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn value_data_mut<'borrow>( &'borrow mut self, ) -> JlrsResult>> { @@ -2253,11 +1975,12 @@ where /// /// The array must be 1D and not contain data borrowed or moved from Rust, otherwise an exception /// is returned. + #[inline] pub unsafe fn grow_end<'target, S>( &mut self, target: S, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { @@ -2269,6 +1992,7 @@ where /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn grow_end_unchecked(&mut self, inc: usize) { self.as_array().grow_end_unchecked(inc) } @@ -2277,7 +2001,12 @@ where /// /// The array must be 1D, not contain data borrowed or moved from Rust, otherwise an exception /// is returned. - pub unsafe fn del_end<'target, S>(&mut self, target: S, dec: usize) -> S::Exception<'static, ()> + #[inline] + pub unsafe fn del_end<'target, S>( + &mut self, + target: S, + dec: usize, + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { @@ -2288,6 +2017,7 @@ where /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn del_end_unchecked(&mut self, dec: usize) { self.as_array().del_end_unchecked(dec) } @@ -2296,11 +2026,12 @@ where /// /// The array must be 1D, not contain data borrowed or moved from Rust, otherwise an exception /// is returned. + #[inline] pub unsafe fn grow_begin<'target, S>( &mut self, target: S, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { @@ -2312,6 +2043,7 @@ where /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn grow_begin_unchecked(&mut self, inc: usize) { self.as_array().grow_begin_unchecked(inc) } @@ -2320,11 +2052,12 @@ where /// /// The array must be 1D, not contain data borrowed or moved from Rust, otherwise an exception /// is returned. + #[inline] pub unsafe fn del_begin<'target, S>( &mut self, target: S, dec: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), S> where S: Target<'target>, { @@ -2336,12 +2069,14 @@ where /// Safety: the array must be 1D and not contain data borrowed or moved from Rust, otherwise /// Julia throws an exception. This error is not exception, which is UB from a `ccall`ed /// function. + #[inline] pub unsafe fn del_begin_unchecked(&mut self, dec: usize) { self.as_array().del_begin_unchecked(dec) } } unsafe impl<'scope, 'data, T: ValidField> Typecheck for TypedArray<'scope, 'data, T> { + #[inline] fn typecheck(t: DataType) -> bool { // Safety: borrow is only temporary unsafe { @@ -2367,76 +2102,44 @@ impl<'scope, 'data, T: ValidField> ManagedPriv<'scope, 'data> for TypedArray<'sc // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. T must be correct + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData, PhantomData, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -thread_local! { - // Used to convert dimensions to tuples. Safe because a thread local is initialized - // when `with` is first called, which happens after `Julia::init` has been called. The C API - // requires a mutable pointer to this array so an `UnsafeCell` is used to store it. - static JL_LONG_TYPE: UnsafeCell<[*mut jl_datatype_t; 8]> = unsafe { - let global = Unrooted::new(); - let t = isize::julia_type(global).ptr().as_ptr(); - UnsafeCell::new([ - t, - t, - t, - t, - t, - t, - t, - t - ]) - }; -} +#[repr(transparent)] +#[derive(Copy, Clone)] +pub(self) struct AssumeThreadsafe(T); -// Safety: dims.m_dimensions() <= 8 -unsafe fn small_dim_tuple<'scope, D>( - frame: &mut GcFrame<'scope>, - dims: &D, -) -> Value<'scope, 'static> -where - D: Dims, -{ - let n = dims.rank(); - debug_assert!(n <= 8, "Too many dimensions for small_dim_tuple"); - let elem_types = JL_LONG_TYPE.with(|longs| longs.get()); - let tuple_type = jl_apply_tuple_type_v(elem_types.cast(), n); - let tuple = jl_new_struct_uninit(tuple_type.cast()); - let dims = dims.into_dimensions(); - let tup_nn = NonNull::new_unchecked(tuple); - let _: Value = frame.data_from_ptr(tup_nn, Private); - - let usize_ptr: *mut usize = tuple.cast(); - std::ptr::copy_nonoverlapping(dims.as_slice().as_ptr(), usize_ptr, n); - - Value::wrap_non_null(tup_nn, Private) -} +unsafe impl Send for AssumeThreadsafe {} +unsafe impl Sync for AssumeThreadsafe {} -fn large_dim_tuple<'scope, D>(frame: &mut GcFrame<'scope>, dims: &D) -> Value<'scope, 'static> +#[inline] +pub(self) fn sized_dim_tuple<'target, D, Tgt>( + target: Tgt, + dims: &D, +) -> ValueData<'target, 'static, Tgt> where - D: Dims, + D: DimsExt, + Tgt: Target<'target>, { - // Safety: all C API functions are called with valid arguments. unsafe { - let n = dims.rank(); - let mut elem_types = vec![isize::julia_type(&frame); n]; - let tuple_type = jl_apply_tuple_type_v(elem_types.as_mut_ptr().cast(), n); - let tuple = jl_new_struct_uninit(tuple_type.cast()); - let tup_nn = NonNull::new_unchecked(tuple); - let _: Value = frame.data_from_ptr(tup_nn, Private); + let rank = dims.rank(); + let dims_type = dims.dimension_object(&target).as_managed(); + let tuple = jl_new_struct_uninit(dims_type.unwrap(Private)); - let usize_ptr: *mut usize = tuple.cast(); - let dims = dims.into_dimensions(); - std::ptr::copy_nonoverlapping(dims.as_slice().as_ptr(), usize_ptr, n); + { + let slice = std::slice::from_raw_parts_mut(tuple as *mut MaybeUninit, rank); + dims.fill_tuple(slice, Private); + } - Value::wrap_non_null(tup_nn, Private) + Value::wrap_non_null(NonNull::new_unchecked(tuple), Private).root(target) } } @@ -2483,6 +2186,7 @@ impl ArrayUnbound { /// Track this array. /// /// While an array is tracked, it can't be exclusively tracked. + #[inline] pub fn track_shared_unbound(self) -> JlrsResult> { Ledger::try_borrow_shared(self.as_value())?; unsafe { Ok(TrackedArray::new_from_owned(self)) } @@ -2491,6 +2195,7 @@ impl ArrayUnbound { /// Exclusively track this array. /// /// While an array is exclusively tracked, it can't be tracked otherwise. + #[inline] pub unsafe fn track_exclusive_unbound( self, ) -> JlrsResult> { @@ -2504,43 +2209,57 @@ impl ArrayUnbound { pub type ArrayRet = Ref<'static, 'static, Array<'static, 'static>>; unsafe impl ConstructType for Array<'_, '_> { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> super::value::ValueData<'target, 'static, T> + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> super::value::ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, _) = target.split(); UnionAll::array_type(&target).as_value().root(target) } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { Some(UnionAll::array_type(&target).as_value()) } + + type Static = Array<'static, 'static>; } unsafe impl ValidLayout for ArrayRef<'_, '_> { + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::() - } else if let Ok(ua) = v.cast::() { + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + UnionAll::array_type(target).as_value() + } + const IS_REF: bool = true; } unsafe impl ValidField for Option> { + #[inline] fn valid_field(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::() - } else if let Ok(ua) = v.cast::() { + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::() } else { false @@ -2582,6 +2301,7 @@ impl TypedArrayUnbound { /// Track this array. /// /// While an array is tracked, it can't be exclusively tracked. + #[inline] pub fn track_shared_unbound(self) -> JlrsResult> { Ledger::try_borrow_shared(self.as_value())?; unsafe { Ok(TrackedArray::new_from_owned(self)) } @@ -2590,6 +2310,7 @@ impl TypedArrayUnbound { /// Exclusively track this array. /// /// While an array is exclusively tracked, it can't be tracked otherwise. + #[inline] pub unsafe fn track_exclusive_unbound( self, ) -> JlrsResult> { @@ -2603,24 +2324,35 @@ impl TypedArrayUnbound { pub type TypedArrayRet = Ref<'static, 'static, TypedArray<'static, 'static, T>>; unsafe impl ValidLayout for TypedArrayRef<'_, '_, T> { + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::>() - } else if let Ok(ua) = v.cast::() { + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::>() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + UnionAll::array_type(target).as_value() + } + const IS_REF: bool = true; } unsafe impl ValidField for Option> { + #[inline] fn valid_field(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::>() - } else if let Ok(ua) = v.cast::() { + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::>() } else { false @@ -2628,15 +2360,14 @@ unsafe impl ValidField for Option> { } } -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Array` or `ArrayRef`, depending on the target type `T`. pub type ArrayData<'target, 'data, T> = >::Data<'data, Array<'target, 'data>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type ArrayResult<'target, 'data, T> = - >::Result<'data, Array<'target, 'data>>; +pub type ArrayResult<'target, 'data, T> = TargetResult<'target, 'data, Array<'target, 'data>, T>; /// `TypedArray` or `TypedArrayRef`, depending on the target type `T`. pub type TypedArrayData<'target, 'data, T, U> = @@ -2645,7 +2376,7 @@ pub type TypedArrayData<'target, 'data, T, U> = /// `JuliaResult>` or `JuliaResultRef>`, depending on the target /// type `T`. pub type TypedArrayResult<'target, 'data, T, U> = - >::Result<'data, TypedArray<'target, 'data, U>>; + TargetResult<'target, 'data, TypedArray<'target, 'data, U>, T>; unsafe impl<'scope, 'data, T: ValidField + ConstructType> CCallArg for TypedArray<'scope, 'data, T> @@ -2659,6 +2390,12 @@ unsafe impl CCallReturn for TypedArrayRet { type CCallReturnType = Value<'static, 'static>; type FunctionReturnType = TypedValue<'static, 'static, ArrayTypeConstructor>>>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } /// An array with a definite rank. @@ -2671,17 +2408,18 @@ pub struct RankedArray<'scope, 'data, const N: isize>( impl<'scope, 'data, const N: isize> RankedArray<'scope, 'data, N> { /// Convert `self` to `Array`. + #[inline] pub fn as_array(self) -> Array<'scope, 'data> { unsafe { Array::wrap_non_null(self.0, Private) } } /// Convert this array to a [`TypedValue`]. - pub fn as_typed_value( + pub fn as_typed_value<'target, T: ConstructType, Tgt: Target<'target>>( self, - frame: &mut GcFrame, + target: &Tgt, ) -> JlrsResult>> { - frame.scope(|mut frame| { - let ty = T::construct_type(frame.as_extended_target()); + target.local_scope::<_, _, 1>(|frame| { + let ty = T::construct_type(frame); let arr = self.as_array(); let elty = arr.element_type(); if ty != elty { @@ -2701,6 +2439,7 @@ impl<'scope, 'data, const N: isize> RankedArray<'scope, 'data, N> { } /// Convert this array to a [`TypedValue`] without checking if the layout is compatible. + #[inline] pub unsafe fn as_typed_value_unchecked( self, ) -> TypedValue<'scope, 'data, ArrayType> { @@ -2709,6 +2448,7 @@ impl<'scope, 'data, const N: isize> RankedArray<'scope, 'data, N> { } impl Clone for RankedArray<'_, '_, N> { + #[inline] fn clone(&self) -> Self { RankedArray(self.0, PhantomData, PhantomData) } @@ -2723,17 +2463,19 @@ impl<'scope, 'data, const N: isize> ManagedPriv<'scope, 'data> for RankedArray<' // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData, PhantomData) } - #[inline(always)] + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } unsafe impl Typecheck for RankedArray<'_, '_, N> { + #[inline] fn typecheck(t: DataType) -> bool { // Safety: Array is a UnionAll. so check if the typenames match unsafe { @@ -2773,24 +2515,35 @@ pub type RankedArrayRef<'scope, 'data, const N: isize> = pub type RankedArrayRet = Ref<'static, 'static, RankedArray<'static, 'static, N>>; unsafe impl ValidLayout for RankedArrayRef<'_, '_, N> { + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { - dt.is::() - } else if let Ok(ua) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; + dt.is::>() + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::>() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + UnionAll::array_type(target).as_value() + } + const IS_REF: bool = true; } unsafe impl ValidField for Option> { + #[inline] fn valid_field(v: Value) -> bool { - if let Ok(dt) = v.cast::() { - dt.is::() - } else if let Ok(ua) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; + dt.is::>() + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::>() } else { false @@ -2804,8 +2557,14 @@ unsafe impl<'scope, 'data, const N: isize> CCallArg for RankedArray<'scope, 'dat } unsafe impl<'scope, 'data, const N: isize> CCallReturn for RankedArray<'scope, 'data, N> { - type CCallReturnType = Value<'scope, 'data>; + type CCallReturnType = Value<'static, 'static>; type FunctionReturnType = ArrayTypeConstructor>, ConstantIsize>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } /// An array with a set element type and a definite rank. @@ -2818,22 +2577,24 @@ pub struct TypedRankedArray<'scope, 'data, U, const N: isize>( ); impl<'scope, 'data, U: ConstructType, const N: isize> TypedRankedArray<'scope, 'data, U, N> { + #[inline] pub fn as_typed(self) -> TypedArray<'scope, 'data, U> { TypedArray(self.0, PhantomData, PhantomData, PhantomData) } /// Convert `self` to `Array`. + #[inline] pub fn as_array(self) -> Array<'scope, 'data> { unsafe { Array::wrap_non_null(self.0, Private) } } /// Convert this array to a [`TypedValue`]. - pub fn as_typed_value( + pub fn as_typed_value<'target, Tgt: Target<'target>>( self, - frame: &mut GcFrame, + target: &Tgt, ) -> JlrsResult>> { - frame.scope(|mut frame| { - let ty = U::construct_type(frame.as_extended_target()); + target.local_scope::<_, _, 1>(|frame| { + let ty = U::construct_type(frame); let arr = self.as_array(); let elty = arr.element_type(); if ty != elty { @@ -2853,6 +2614,7 @@ impl<'scope, 'data, U: ConstructType, const N: isize> TypedRankedArray<'scope, ' } /// Convert this array to a [`TypedValue`] without checking if the layout is compatible. + #[inline] pub unsafe fn as_typed_value_unchecked(self) -> TypedValue<'scope, 'data, ArrayType> { let arr = self.as_array(); TypedValue::>::from_value_unchecked(arr.as_value()) @@ -2860,6 +2622,7 @@ impl<'scope, 'data, U: ConstructType, const N: isize> TypedRankedArray<'scope, ' } impl Clone for TypedRankedArray<'_, '_, U, N> { + #[inline] fn clone(&self) -> Self { TypedRankedArray(self.0, PhantomData, PhantomData, PhantomData) } @@ -2870,20 +2633,23 @@ impl Copy for TypedRankedArray<'_, '_, U, N> {} unsafe impl ConstructType for TypedRankedArray<'_, '_, U, N> { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> super::value::ValueData<'target, 'static, T> + type Static = ArrayTypeConstructor>; + + // TODO + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> super::value::ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, frame) = target.split(); - frame - .scope(|mut frame| { + target + .with_local_scope::<_, _, 4>(|target, mut frame| { let ua = UnionAll::array_type(&target); unsafe { let inner = ua.body(); let ty_var = ua.var(); - let elem_ty = U::construct_type(frame.as_extended_target()); + let elem_ty = U::construct_type(&mut frame); let rank = Value::new(&mut frame, N); let with_rank = inner.apply_type_unchecked(&mut frame, [rank]); @@ -2898,6 +2664,7 @@ unsafe impl ConstructType .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -2907,6 +2674,7 @@ unsafe impl ConstructType } unsafe impl Typecheck for TypedRankedArray<'_, '_, U, N> { + #[inline] fn typecheck(t: DataType) -> bool { // Safety: Array is a UnionAll. so check if the typenames match unsafe { @@ -2946,10 +2714,12 @@ impl<'scope, 'data, U: ValidField, const N: isize> ManagedPriv<'scope, 'data> // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. T must be correct + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData, PhantomData, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } @@ -2972,22 +2742,31 @@ pub type TypedRankedArrayRet = pub type TypedRankedArrayUnbound = TypedRankedArray<'static, 'static, U, N>; unsafe impl ValidLayout for TypedRankedArrayRef<'_, '_, U, N> { + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { - dt.is::() - } else if let Ok(ua) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; + dt.is::>() + } else if v.is::() { + let ua = unsafe { v.cast_unchecked::() }; ua.base_type().is::>() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + UnionAll::array_type(target).as_value() + } + const IS_REF: bool = true; } unsafe impl ValidField for Option> { + #[inline] fn valid_field(v: Value) -> bool { if let Ok(dt) = v.cast::() { dt.is::() @@ -3009,8 +2788,14 @@ unsafe impl<'scope, 'data, U: ValidField + ConstructType, const N: isize> CCallA unsafe impl<'scope, 'data, U: ValidField + ConstructType, const N: isize> CCallReturn for TypedRankedArrayRef<'scope, 'data, U, N> { - type CCallReturnType = TypedRankedArray<'scope, 'data, U, N>; + type CCallReturnType = Value<'static, 'static>; type FunctionReturnType = TypedRankedArray<'scope, 'data, U, N>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } // TODO: conversions diff --git a/jlrs/src/data/managed/array/tracked.rs b/jlrs/src/data/managed/array/tracked.rs index 364ac118..d89d5144 100644 --- a/jlrs/src/data/managed/array/tracked.rs +++ b/jlrs/src/data/managed/array/tracked.rs @@ -15,7 +15,7 @@ use super::{ }, copied::CopiedArray, }, - dimensions::{ArrayDimensions, Dims}, + dimensions::{ArrayDimensions, DimsExt}, Array, ArrayData, ArrayResult, TypedArray, TypedArrayData, TypedArrayResult, }; use crate::{ @@ -27,7 +27,7 @@ use crate::{ error::JlrsResult, memory::{ context::ledger::Ledger, - target::{ExtendedTarget, Target}, + target::{Target, TargetException}, }, }; @@ -180,14 +180,14 @@ impl<'tracked, 'scope, 'data> TrackedArray<'tracked, 'scope, 'data, Array<'scope /// /// Returns a new array with the provided dimensions, the content of the array is shared with /// the original array. The old and new dimensions must have an equal number of elements. - pub fn reshape<'target, 'current, 'borrow, D, S>( + pub fn reshape<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> ArrayResult<'target, 'data, S> + ) -> ArrayResult<'target, 'data, Tgt> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { unsafe { self.data.reshape(target, dims) } } @@ -198,14 +198,14 @@ impl<'tracked, 'scope, 'data> TrackedArray<'tracked, 'scope, 'data, Array<'scope /// the original array. The old and new dimensions must have an equal number of elements. /// /// Safety: if an exception is thrown it isn't caught. - pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, S>( + pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> ArrayData<'target, 'data, S> + ) -> ArrayData<'target, 'data, Tgt> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { self.data.reshape_unchecked(target, dims) } @@ -263,14 +263,14 @@ where /// /// Returns a new array with the provided dimensions, the content of the array is shared with /// the original array. The old and new dimensions must have an equal number of elements. - pub fn reshape<'target, 'current, 'borrow, D, S>( + pub fn reshape<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> TypedArrayResult<'target, 'data, S, T> + ) -> TypedArrayResult<'target, 'data, Tgt, T> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { unsafe { self.data.reshape(target, dims) } } @@ -281,14 +281,14 @@ where /// the original array. The old and new dimensions must have an equal number of elements. /// /// Safety: if an exception is thrown it isn't caught. - pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, S>( + pub unsafe fn reshape_unchecked<'target, 'current, 'borrow, D, Tgt>( &self, - target: ExtendedTarget<'target, '_, '_, S>, + target: Tgt, dims: D, - ) -> TypedArrayData<'target, 'data, S, T> + ) -> TypedArrayData<'target, 'data, Tgt, T> where - D: Dims, - S: Target<'target>, + D: DimsExt, + Tgt: Target<'target>, { self.data.reshape_unchecked(target, dims) } @@ -431,13 +431,13 @@ impl<'tracked, 'scope> TrackedArrayMut<'tracked, 'scope, 'static, Array<'scope, /// type. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn grow_end<'target, S>( + pub unsafe fn grow_end<'target, Tgt>( &mut self, - target: S, + target: Tgt, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.grow_end(target, inc) } @@ -455,9 +455,13 @@ impl<'tracked, 'scope> TrackedArrayMut<'tracked, 'scope, 'static, Array<'scope, /// the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn del_end<'target, S>(&mut self, target: S, dec: usize) -> S::Exception<'static, ()> + pub unsafe fn del_end<'target, Tgt>( + &mut self, + target: Tgt, + dec: usize, + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.del_end(target, dec) } @@ -475,13 +479,13 @@ impl<'tracked, 'scope> TrackedArrayMut<'tracked, 'scope, 'static, Array<'scope, /// one-dimensional. If the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn grow_begin<'target, S>( + pub unsafe fn grow_begin<'target, Tgt>( &mut self, - target: S, + target: Tgt, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.grow_begin(target, inc) } @@ -499,13 +503,13 @@ impl<'tracked, 'scope> TrackedArrayMut<'tracked, 'scope, 'static, Array<'scope, /// the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn del_begin<'target, S>( + pub unsafe fn del_begin<'target, Tgt>( &mut self, - target: S, + target: Tgt, dec: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.del_begin(target, dec) } @@ -604,13 +608,13 @@ where /// one-dimensional. If the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn grow_end<'target, S>( + pub unsafe fn grow_end<'target, Tgt>( &mut self, - target: S, + target: Tgt, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.grow_end(target, inc) } @@ -628,9 +632,13 @@ where /// the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn del_end<'target, S>(&mut self, target: S, dec: usize) -> S::Exception<'static, ()> + pub unsafe fn del_end<'target, Tgt>( + &mut self, + target: Tgt, + dec: usize, + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.del_end(target, dec) } @@ -648,13 +656,13 @@ where /// one-dimensional. If the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn grow_begin<'target, S>( + pub unsafe fn grow_begin<'target, Tgt>( &mut self, - target: S, + target: Tgt, inc: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.grow_begin(target, inc) } @@ -672,13 +680,13 @@ where /// the array isn't one-dimensional an exception is thrown. /// /// Safety: Mutating things that should absolutely not be mutated is not prevented. - pub unsafe fn del_begin<'target, S>( + pub unsafe fn del_begin<'target, Tgt>( &mut self, - target: S, + target: Tgt, dec: usize, - ) -> S::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), Tgt> where - S: Target<'target>, + Tgt: Target<'target>, { self.tracked.data.del_begin(target, dec) } diff --git a/jlrs/src/data/managed/ccall_ref.rs b/jlrs/src/data/managed/ccall_ref.rs index 362251ca..4f608883 100644 --- a/jlrs/src/data/managed/ccall_ref.rs +++ b/jlrs/src/data/managed/ccall_ref.rs @@ -36,11 +36,9 @@ use crate::{ typecheck::Typecheck, }, }, - error::{JlrsError, JlrsResult, TypeError}, - memory::target::{ - frame::{BorrowedFrame, GcFrame}, - unrooted::Unrooted, - }, + error::{JlrsError, JlrsResult, TypeError, CANNOT_DISPLAY_TYPE}, + memory::target::unrooted::Unrooted, + prelude::Target, }; #[repr(C)] @@ -85,7 +83,7 @@ where } Err(TypeError::IncompatibleBaseType { - base_type: base_type.display_string_or(""), + base_type: base_type.display_string_or(CANNOT_DISPLAY_TYPE), })? } } @@ -95,12 +93,12 @@ where /// `T` must be an immutable, concrete type. Unlike [`CCallRef::as_ref`] this method /// constructs the type associated with `T` to check if the layout is correct. #[inline] - pub fn as_ref_check_constructed<'current>( - &self, - frame: BorrowedFrame<'_, 'current, GcFrame<'current>>, - ) -> JlrsResult<&'scope T> { - frame.scope(|mut frame| unsafe { - let ty = T::construct_type(frame.as_extended_target()); + pub fn as_ref_check_constructed<'target, Tgt>(&self, target: &Tgt) -> JlrsResult<&'scope T> + where + Tgt: Target<'target>, + { + target.with_local_scope::<_, _, 1>(|_, mut frame| unsafe { + let ty = T::construct_type(&mut frame); if ty.is::() { let base_dt = ty.cast_unchecked::(); @@ -183,12 +181,12 @@ where /// `T` must be an immutable, concrete type. Unlike [`CCallRef::as_ref_to`] this method /// constructs the type associated with `T` to check if the layout is correct. #[inline] - pub fn as_ref_to_check_constructed<'current, U: ValidLayout>( + pub fn as_ref_to_check_constructed<'target, U: ValidLayout, Tgt: Target<'target>>( &self, - frame: BorrowedFrame<'_, 'current, GcFrame<'current>>, + target: Tgt, ) -> JlrsResult<&U> { - frame.scope(|mut frame| unsafe { - let ty = T::construct_type(frame.as_extended_target()); + target.with_local_scope::<_, _, 1>(|_, mut frame| unsafe { + let ty = T::construct_type(&mut frame); if ty.is::() { let base_dt = ty.cast_unchecked::(); @@ -211,7 +209,6 @@ where /// Access the referenced data as a `Value`. /// /// Only the base type of `T` is used to check if the data is passed as a `Value`. - #[inline] pub fn as_value(&self) -> JlrsResult> { unsafe { let unrooted = Unrooted::new(); @@ -249,13 +246,12 @@ where /// /// Unlike [`CCallRef::as_value`] this method constructs the type associated with `T` to check /// if the layout is correct. - #[inline] - pub fn as_value_check_constructed<'current>( + pub fn as_value_check_constructed<'target, Tgt: Target<'target>>( &self, - frame: BorrowedFrame<'_, 'current, GcFrame<'current>>, + target: &Tgt, ) -> JlrsResult> { - frame.scope(|mut frame| unsafe { - let ty = T::construct_type(frame.as_extended_target()); + target.with_local_scope::<_, _, 1>(|_, mut frame| unsafe { + let ty = T::construct_type(&mut frame); if ty.is::() { let base_dt = ty.cast_unchecked::(); diff --git a/jlrs/src/data/managed/datatype.rs b/jlrs/src/data/managed/datatype.rs index c7016f12..60bbe024 100644 --- a/jlrs/src/data/managed/datatype.rs +++ b/jlrs/src/data/managed/datatype.rs @@ -35,6 +35,7 @@ use jlrs_macros::julia_version; use super::{simple_vector::SimpleVectorData, type_name::TypeName, value::ValueData, Ref}; use crate::{ + catch::catch_exceptions, convert::to_symbol::ToSymbol, data::{ managed::{ @@ -47,9 +48,9 @@ use crate::{ }, types::typecheck::Typecheck, }, - error::{AccessError, JlrsResult, CANNOT_DISPLAY_TYPE}, + error::{AccessError, InstantiationError, JlrsResult, CANNOT_DISPLAY_TYPE}, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -79,6 +80,7 @@ impl<'scope> DataType<'scope> { */ /// Returns the `TypeName` of this type. + #[inline] pub fn type_name(self) -> TypeName<'scope> { // Safety: the pointer points to valid data, and the typename of a type never changes unsafe { @@ -89,6 +91,7 @@ impl<'scope> DataType<'scope> { } /// Returns the super-type of this type. + #[inline] pub fn super_type(self) -> DataType<'scope> { // Safety: the pointer points to valid data, and the super-type of a type never changes unsafe { @@ -99,6 +102,7 @@ impl<'scope> DataType<'scope> { } /// Returns the type parameters of this type. + #[inline] pub fn parameters(self) -> SimpleVector<'scope> { // Safety: the pointer points to valid data and this data is const unsafe { @@ -109,12 +113,14 @@ impl<'scope> DataType<'scope> { } /// Returns the number of type parameters. + #[inline] pub fn n_parameters(self) -> usize { // Safety: the pointer points to valid data, the parameters field is never null self.parameters().len() } /// Returns the type parameter at position `idx`, or `None` if the index is out of bounds. + #[inline] pub fn parameter<'target, T>( self, target: T, @@ -137,6 +143,7 @@ impl<'scope> DataType<'scope> { } /// Returns the field types of this type. + #[inline] pub fn field_types<'target, T>(self, target: T) -> SimpleVectorData<'target, T> where T: Target<'target>, @@ -151,6 +158,7 @@ impl<'scope> DataType<'scope> { /// Returns the field type of the field at position `idx`, or `None` if the index is out of /// bounds. + #[inline] pub fn field_type<'target, T>( self, target: T, @@ -176,6 +184,7 @@ impl<'scope> DataType<'scope> { /// Returns the field type of the field at position `idx` without performing a bounds check. /// /// Safety: `idx` must be in-bounds. + #[inline] pub unsafe fn field_type_unchecked<'target, T>( self, target: T, @@ -196,6 +205,7 @@ impl<'scope> DataType<'scope> { } /// Returns the field type of the field at position `idx`. + #[inline] pub fn field_type_concrete<'target, T>( self, target: T, @@ -220,6 +230,7 @@ impl<'scope> DataType<'scope> { } /// Returns the field names of this type. + #[inline] pub fn field_names(self) -> SimpleVector<'scope> { // Safety: the pointer points to valid data, so it must have a TypeName. self.type_name().names() @@ -267,6 +278,7 @@ impl<'scope> DataType<'scope> { } /// Returns the name of the field at position `idx`. + #[inline] pub fn field_name_str(self, idx: usize) -> Option<&'scope str> { if let Some(sym) = self.field_name(idx) { return sym.as_str().ok(); @@ -276,6 +288,7 @@ impl<'scope> DataType<'scope> { } /// Returns the instance if this type is a singleton. + #[inline] pub fn instance(self) -> Option> { // Safety: the pointer points to valid data unsafe { @@ -292,6 +305,7 @@ impl<'scope> DataType<'scope> { } /// Returns a pointer to the layout of this `DataType`. + #[inline] pub fn layout(self) -> Option> { // Safety: the pointer points to valid data unsafe { @@ -302,6 +316,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.8")] /// Returns the size of a value of this type in bytes. + #[inline] pub fn size(self) -> Option { if self.is_abstract() { return None; @@ -312,11 +327,13 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.9")] /// Returns the size of a value of this type in bytes. + #[inline] pub fn size(self) -> Option { Some(self.layout()?.size()) } /// Returns the hash of this type. + #[inline] pub fn hash(self) -> u32 { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().hash } @@ -324,6 +341,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// Returns true if this is an abstract type. + #[inline] pub fn is_abstract(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().abstract_ != 0 } @@ -331,12 +349,14 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if this is an abstract type. + #[inline] pub fn is_abstract(self) -> bool { self.type_name().is_abstract() } #[julia_version(until = "1.6")] /// Returns true if this is a mutable type. + #[inline] pub fn mutable(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().mutabl != 0 } @@ -344,12 +364,14 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if this is a mutable type. + #[inline] pub fn mutable(self) -> bool { self.type_name().is_mutable() } #[julia_version(until = "1.6")] /// Returns true if one or more of the type parameters has not been set. + #[inline] pub fn has_free_type_vars(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().hasfreetypevars != 0 } @@ -357,6 +379,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if one or more of the type parameters has not been set. + #[inline] pub fn has_free_type_vars(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().hasfreetypevars() != 0 } @@ -364,6 +387,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// Returns true if this type can have instances + #[inline] pub fn is_concrete_type(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isconcretetype != 0 } @@ -371,6 +395,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if this type can have instances + #[inline] pub fn is_concrete_type(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isconcretetype() != 0 } @@ -378,6 +403,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// Returns true if this type is a dispatch, or leaf, tuple type. + #[inline] pub fn is_dispatch_tuple(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isdispatchtuple != 0 } @@ -385,6 +411,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if this type is a dispatch, or leaf, tuple type. + #[inline] pub fn is_dispatch_tuple(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isdispatchtuple() != 0 } @@ -392,6 +419,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// Returns true if this type is a bits-type. + #[inline] pub fn is_bits(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isbitstype != 0 } @@ -399,6 +427,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if this type is a bits-type. + #[inline] pub fn is_bits(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isbitstype() != 0 } @@ -406,6 +435,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// Returns true if values of this type are zero-initialized. + #[inline] pub fn zero_init(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().zeroinit != 0 } @@ -413,6 +443,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if values of this type are zero-initialized. + #[inline] pub fn zero_init(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().zeroinit() != 0 } @@ -420,6 +451,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// Returns true if a value of this type stores its data inline. + #[inline] pub fn is_inline_alloc(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isinlinealloc != 0 } @@ -427,6 +459,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// Returns true if a value of this type stores its data inline. + #[inline] pub fn is_inline_alloc(self) -> bool { // Safety: the pointer points to valid data, so it must have a TypeName. unsafe { @@ -437,6 +470,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// If false, no value will have this type. + #[inline] pub fn has_concrete_subtype(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().has_concrete_subtype != 0 } @@ -444,6 +478,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7")] /// If false, no value will have this type. + #[inline] pub fn has_concrete_subtype(self) -> bool { // Safety: the pointer points to valid data unsafe { @@ -456,6 +491,7 @@ impl<'scope> DataType<'scope> { #[julia_version(until = "1.6")] /// If true, the type is stored in hash-based set cache (instead of linear cache). + #[inline] pub fn cached_by_hash(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().cached_by_hash != 0 } @@ -463,6 +499,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.7", until = "1.9")] /// If true, the type is stored in hash-based set cache (instead of linear cache). + #[inline] pub fn cached_by_hash(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().cached_by_hash() != 0 } @@ -470,6 +507,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.10")] /// Computational bit for has_concrete_supertype. See description in jltypes.c. + #[inline] pub fn maybe_subtype_of_cache(self) -> bool { // Safety: the pointer points to valid data unsafe { @@ -482,6 +520,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.9")] /// Whether this is declared with 'primitive type' keyword (sized, no fields, and immutable) + #[inline] pub fn is_primitive_type(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isprimitivetype() != 0 } @@ -489,6 +528,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.10")] /// Whether any mutable memory is reachable through this type (in the type or via fields) + #[inline] pub fn is_mutation_free(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().ismutationfree() != 0 } @@ -496,6 +536,7 @@ impl<'scope> DataType<'scope> { #[julia_version(since = "1.10")] /// Whether this type or any object reachable through its fields has non-content-based identity + #[inline] pub fn is_identity_free(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().isidentityfree() != 0 } @@ -504,11 +545,13 @@ impl<'scope> DataType<'scope> { impl<'scope> DataType<'scope> { /// Performs the given typecheck on this type. + #[inline] pub fn is(self) -> bool { T::typecheck(self) } /// Returns the alignment of a value of this type in bytes. + #[inline] pub fn align(self) -> Option { // Safety: the pointer points to valid data, if the layout is null the code // panics. @@ -516,16 +559,19 @@ impl<'scope> DataType<'scope> { } /// Returns the size of a value of this type in bits. + #[inline] pub fn n_bits(self) -> Option { Some(self.size()? * 8) } /// Returns the number of fields of a value of this type. + #[inline] pub fn n_fields(self) -> Option { Some(self.layout()?.n_fields()) } /// Returns the name of this type. + #[inline] pub fn name(self) -> &'scope str { // Safety: the pointer points to valid data, so it must have a name. If it's not // a valid UTF-8 encoded string the code panics. @@ -557,6 +603,7 @@ impl<'scope> DataType<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn field_size_unchecked(self, idx: usize) -> u32 { jl_field_size(self.unwrap(Private), idx as _) } @@ -583,6 +630,7 @@ impl<'scope> DataType<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn field_offset_unchecked(self, idx: usize) -> u32 { jl_field_offset(self.unwrap(Private), idx as _) } @@ -609,6 +657,7 @@ impl<'scope> DataType<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn is_pointer_field_unchecked(self, idx: usize) -> bool { jl_field_isptr(self.unwrap(Private), idx as _) } @@ -637,6 +686,7 @@ impl<'scope> DataType<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn is_atomic_field_unchecked(self, idx: usize) -> bool { /* const uint32_t *atomicfields = st->name->atomicfields; @@ -679,6 +729,7 @@ impl<'scope> DataType<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn is_const_field_unchecked(self, idx: usize) -> bool { /* jl_typename_t *tn = st->name; @@ -719,12 +770,6 @@ impl<'scope> DataType<'scope> { T: Target<'target>, V: AsRef<[Value<'value, 'data>]>, { - use std::mem::MaybeUninit; - - use jl_sys::jl_value_t; - - use crate::{catch::catch_exceptions, error::InstantiationError}; - // Safety: the pointer points to valid data, if an exception is thrown it's caught unsafe { if self.is::() { @@ -732,20 +777,19 @@ impl<'scope> DataType<'scope> { } let values = values.as_ref(); - let mut callback = |result: &mut MaybeUninit<*mut jl_value_t>| { - let v = jl_new_structv( + let callback = || { + jl_new_structv( self.unwrap(Private), values.as_ptr() as *mut _, values.len() as _, - ); - - result.write(v); - Ok(()) + ) }; - let res = match catch_exceptions(&mut callback).unwrap() { + let exc = |err: Value| err.unwrap_non_null(Private); + + let res = match catch_exceptions(callback, exc) { Ok(ptr) => Ok(NonNull::new_unchecked(ptr)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; Ok(target.result_from_ptr(res, Private)) @@ -762,6 +806,7 @@ impl<'scope> DataType<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn instantiate_unchecked<'target, 'value, 'data, V, T>( self, target: T, @@ -794,6 +839,7 @@ impl<'scope> DataType<'scope> { impl<'base> DataType<'base> { /// The type of the bottom type, `Union{}`. + #[inline] pub fn typeofbottom_type(_: &T) -> Self where T: Target<'base>, @@ -803,6 +849,7 @@ impl<'base> DataType<'base> { } /// The type `DataType`. + #[inline] pub fn datatype_type(_: &T) -> Self where T: Target<'base>, @@ -812,6 +859,7 @@ impl<'base> DataType<'base> { } /// The type `Union`. + #[inline] pub fn uniontype_type(_: &T) -> Self where T: Target<'base>, @@ -821,6 +869,7 @@ impl<'base> DataType<'base> { } /// The type `UnionAll`. + #[inline] pub fn unionall_type(_: &T) -> Self where T: Target<'base>, @@ -830,6 +879,7 @@ impl<'base> DataType<'base> { } /// The type `TypeVar`. + #[inline] pub fn tvar_type(_: &T) -> Self where T: Target<'base>, @@ -839,6 +889,7 @@ impl<'base> DataType<'base> { } /// The type `Any`. + #[inline] pub fn any_type(_: &T) -> Self where T: Target<'base>, @@ -848,6 +899,7 @@ impl<'base> DataType<'base> { } /// The type `TypeName`. + #[inline] pub fn typename_type(_: &T) -> Self where T: Target<'base>, @@ -857,6 +909,7 @@ impl<'base> DataType<'base> { } /// The type `Symbol`. + #[inline] pub fn symbol_type(_: &T) -> Self where T: Target<'base>, @@ -866,6 +919,7 @@ impl<'base> DataType<'base> { } /// The type `SSAValue`. + #[inline] pub fn ssavalue_type(_: &T) -> Self where T: Target<'base>, @@ -876,6 +930,7 @@ impl<'base> DataType<'base> { #[julia_version(until = "1.9")] /// The type `Slot`. + #[inline] pub fn abstractslot_type(_: &T) -> Self where T: Target<'base>, @@ -885,6 +940,7 @@ impl<'base> DataType<'base> { } /// The type `SlotNumber`. + #[inline] pub fn slotnumber_type(_: &T) -> Self where T: Target<'base>, @@ -895,6 +951,7 @@ impl<'base> DataType<'base> { #[julia_version(until = "1.9")] /// The type `TypedSlot`. + #[inline] pub fn typedslot_type(_: &T) -> Self where T: Target<'base>, @@ -904,6 +961,7 @@ impl<'base> DataType<'base> { } /// The type `Core.Argument` + #[inline] pub fn argument_type(_: &T) -> Self where T: Target<'base>, @@ -913,6 +971,7 @@ impl<'base> DataType<'base> { } /// The type `Core.Const` + #[inline] pub fn const_type(_: &T) -> Self where T: Target<'base>, @@ -922,6 +981,7 @@ impl<'base> DataType<'base> { } /// The type `Core.PartialStruct` + #[inline] pub fn partial_struct_type(_: &T) -> Self where T: Target<'base>, @@ -932,6 +992,7 @@ impl<'base> DataType<'base> { #[julia_version(since = "1.7")] /// The type `Core.PartialOpaque` + #[inline] pub fn partial_opaque_type(_: &T) -> Self where T: Target<'base>, @@ -942,6 +1003,7 @@ impl<'base> DataType<'base> { #[julia_version(since = "1.7")] /// The type `Core.InterConditional` + #[inline] pub fn interconditional_type(_: &T) -> Self where T: Target<'base>, @@ -951,6 +1013,7 @@ impl<'base> DataType<'base> { } /// The type `MethodMatch` + #[inline] pub fn method_match_type(_: &T) -> Self where T: Target<'base>, @@ -960,6 +1023,7 @@ impl<'base> DataType<'base> { } /// The type `SimpleVector`. + #[inline] pub fn simplevector_type(_: &T) -> Self where T: Target<'base>, @@ -969,6 +1033,7 @@ impl<'base> DataType<'base> { } /// The type `Tuple`. + #[inline] pub fn anytuple_type(_: &T) -> Self where T: Target<'base>, @@ -978,6 +1043,7 @@ impl<'base> DataType<'base> { } /// The type of an empty tuple. + #[inline] pub fn emptytuple_type(_: &T) -> Self where T: Target<'base>, @@ -987,6 +1053,7 @@ impl<'base> DataType<'base> { } /// The type `Tuple`. + #[inline] pub fn tuple_type(_: &T) -> Self where T: Target<'base>, @@ -997,6 +1064,7 @@ impl<'base> DataType<'base> { #[julia_version(since = "1.7")] /// The type `Vararg`. + #[inline] pub fn vararg_type(_: &T) -> Self where T: Target<'base>, @@ -1006,6 +1074,7 @@ impl<'base> DataType<'base> { } /// The type `Function`. + #[inline] pub fn function_type(_: &T) -> Self where T: Target<'base>, @@ -1015,6 +1084,7 @@ impl<'base> DataType<'base> { } /// The type `Builtin`. + #[inline] pub fn builtin_type(_: &T) -> Self where T: Target<'base>, @@ -1024,6 +1094,7 @@ impl<'base> DataType<'base> { } /// The type `MethodInstance`. + #[inline] pub fn method_instance_type(_: &T) -> Self where T: Target<'base>, @@ -1033,6 +1104,7 @@ impl<'base> DataType<'base> { } /// The type `CodeInstance`. + #[inline] pub fn code_instance_type(_: &T) -> Self where T: Target<'base>, @@ -1042,6 +1114,7 @@ impl<'base> DataType<'base> { } /// The type `CodeInfo`. + #[inline] pub fn code_info_type(_: &T) -> Self where T: Target<'base>, @@ -1051,6 +1124,7 @@ impl<'base> DataType<'base> { } /// The type `Method`. + #[inline] pub fn method_type(_: &T) -> Self where T: Target<'base>, @@ -1060,6 +1134,7 @@ impl<'base> DataType<'base> { } /// The type `Module`. + #[inline] pub fn module_type(_: &T) -> Self where T: Target<'base>, @@ -1069,6 +1144,7 @@ impl<'base> DataType<'base> { } /// The type `WeakRef`. + #[inline] pub fn weakref_type(_: &T) -> Self where T: Target<'base>, @@ -1078,6 +1154,7 @@ impl<'base> DataType<'base> { } /// The type `AbstractString`. + #[inline] pub fn abstractstring_type(_: &T) -> Self where T: Target<'base>, @@ -1087,6 +1164,7 @@ impl<'base> DataType<'base> { } /// The type `String`. + #[inline] pub fn string_type(_: &T) -> Self where T: Target<'base>, @@ -1096,6 +1174,7 @@ impl<'base> DataType<'base> { } /// The type `ErrorException`. + #[inline] pub fn errorexception_type(_: &T) -> Self where T: Target<'base>, @@ -1105,6 +1184,7 @@ impl<'base> DataType<'base> { } /// The type `ArgumentError`. + #[inline] pub fn argumenterror_type(_: &T) -> Self where T: Target<'base>, @@ -1114,6 +1194,7 @@ impl<'base> DataType<'base> { } /// The type `LoadError`. + #[inline] pub fn loaderror_type(_: &T) -> Self where T: Target<'base>, @@ -1123,6 +1204,7 @@ impl<'base> DataType<'base> { } /// The type `InitError`. + #[inline] pub fn initerror_type(_: &T) -> Self where T: Target<'base>, @@ -1132,6 +1214,7 @@ impl<'base> DataType<'base> { } /// The type `TypeError`. + #[inline] pub fn typeerror_type(_: &T) -> Self where T: Target<'base>, @@ -1141,6 +1224,7 @@ impl<'base> DataType<'base> { } /// The type `MethodError`. + #[inline] pub fn methoderror_type(_: &T) -> Self where T: Target<'base>, @@ -1150,6 +1234,7 @@ impl<'base> DataType<'base> { } /// The type `UndefVarError`. + #[inline] pub fn undefvarerror_type(_: &T) -> Self where T: Target<'base>, @@ -1160,6 +1245,7 @@ impl<'base> DataType<'base> { #[julia_version(since = "1.7")] /// The type `Core.AtomicError`. + #[inline] pub fn atomicerror_type(_: &T) -> Self where T: Target<'base>, @@ -1169,6 +1255,7 @@ impl<'base> DataType<'base> { } /// The type `LineInfoNode`. + #[inline] pub fn lineinfonode_type(_: &T) -> Self where T: Target<'base>, @@ -1178,6 +1265,7 @@ impl<'base> DataType<'base> { } /// The type `BoundsError`. + #[inline] pub fn boundserror_type(_: &T) -> Self where T: Target<'base>, @@ -1187,6 +1275,7 @@ impl<'base> DataType<'base> { } /// The type `Bool`. + #[inline] pub fn bool_type(_: &T) -> Self where T: Target<'base>, @@ -1196,6 +1285,7 @@ impl<'base> DataType<'base> { } /// The type `Char`. + #[inline] pub fn char_type(_: &T) -> Self where T: Target<'base>, @@ -1205,6 +1295,7 @@ impl<'base> DataType<'base> { } /// The type `Int8`. + #[inline] pub fn int8_type(_: &T) -> Self where T: Target<'base>, @@ -1214,6 +1305,7 @@ impl<'base> DataType<'base> { } /// The type `UInt8`. + #[inline] pub fn uint8_type(_: &T) -> Self where T: Target<'base>, @@ -1223,6 +1315,7 @@ impl<'base> DataType<'base> { } /// The type `Int16`. + #[inline] pub fn int16_type(_: &T) -> Self where T: Target<'base>, @@ -1232,6 +1325,7 @@ impl<'base> DataType<'base> { } /// The type `UInt16`. + #[inline] pub fn uint16_type(_: &T) -> Self where T: Target<'base>, @@ -1241,6 +1335,7 @@ impl<'base> DataType<'base> { } /// The type `Int32`. + #[inline] pub fn int32_type(_: &T) -> Self where T: Target<'base>, @@ -1250,6 +1345,7 @@ impl<'base> DataType<'base> { } /// The type `UInt32`. + #[inline] pub fn uint32_type(_: &T) -> Self where T: Target<'base>, @@ -1259,6 +1355,7 @@ impl<'base> DataType<'base> { } /// The type `Int64`. + #[inline] pub fn int64_type(_: &T) -> Self where T: Target<'base>, @@ -1268,6 +1365,7 @@ impl<'base> DataType<'base> { } /// The type `UInt64`. + #[inline] pub fn uint64_type(_: &T) -> Self where T: Target<'base>, @@ -1277,6 +1375,7 @@ impl<'base> DataType<'base> { } /// The type `Float16`. + #[inline] pub fn float16_type(_: &T) -> Self where T: Target<'base>, @@ -1286,6 +1385,7 @@ impl<'base> DataType<'base> { } /// The type `Float32`. + #[inline] pub fn float32_type(_: &T) -> Self where T: Target<'base>, @@ -1295,6 +1395,7 @@ impl<'base> DataType<'base> { } /// The type `Float64`. + #[inline] pub fn float64_type(_: &T) -> Self where T: Target<'base>, @@ -1304,6 +1405,7 @@ impl<'base> DataType<'base> { } /// The type `AbstractFloat`. + #[inline] pub fn floatingpoint_type(_: &T) -> Self where T: Target<'base>, @@ -1313,6 +1415,7 @@ impl<'base> DataType<'base> { } /// The type `Number`. + #[inline] pub fn number_type(_: &T) -> Self where T: Target<'base>, @@ -1322,6 +1425,7 @@ impl<'base> DataType<'base> { } /// The type `Nothing`. + #[inline] pub fn nothing_type(_: &T) -> Self where T: Target<'base>, @@ -1331,6 +1435,7 @@ impl<'base> DataType<'base> { } /// The type `Signed`. + #[inline] pub fn signed_type(_: &T) -> Self where T: Target<'base>, @@ -1340,6 +1445,7 @@ impl<'base> DataType<'base> { } /// The type `Ptr{Nothing}`. + #[inline] pub fn voidpointer_type(_: &T) -> Self where T: Target<'base>, @@ -1349,6 +1455,7 @@ impl<'base> DataType<'base> { } /// The type `Task`. + #[inline] pub fn task_type(_: &T) -> Self where T: Target<'base>, @@ -1358,6 +1465,7 @@ impl<'base> DataType<'base> { } /// The type `Expr`. + #[inline] pub fn expr_type(_: &T) -> Self where T: Target<'base>, @@ -1368,6 +1476,7 @@ impl<'base> DataType<'base> { #[julia_version(since = "1.10")] /// The type `Expr`. + #[inline] pub fn binding_type(_: &T) -> Self where T: Target<'base>, @@ -1377,6 +1486,7 @@ impl<'base> DataType<'base> { } /// The type `GlobalRef`. + #[inline] pub fn globalref_type(_: &T) -> Self where T: Target<'base>, @@ -1386,6 +1496,7 @@ impl<'base> DataType<'base> { } /// The type `LineNumberNode`. + #[inline] pub fn linenumbernode_type(_: &T) -> Self where T: Target<'base>, @@ -1395,6 +1506,7 @@ impl<'base> DataType<'base> { } /// The type `GotoNode`. + #[inline] pub fn gotonode_type(_: &T) -> Self where T: Target<'base>, @@ -1404,6 +1516,7 @@ impl<'base> DataType<'base> { } /// The type `GotoIfNot`. + #[inline] pub fn gotoifnot_type(_: &T) -> Self where T: Target<'base>, @@ -1413,6 +1526,7 @@ impl<'base> DataType<'base> { } /// The type `ReturnNode`. + #[inline] pub fn returnnode_type(_: &T) -> Self where T: Target<'base>, @@ -1422,6 +1536,7 @@ impl<'base> DataType<'base> { } /// The type `PhiNode`. + #[inline] pub fn phinode_type(_: &T) -> Self where T: Target<'base>, @@ -1431,6 +1546,7 @@ impl<'base> DataType<'base> { } /// The type `PiNode`. + #[inline] pub fn pinode_type(_: &T) -> Self where T: Target<'base>, @@ -1440,6 +1556,7 @@ impl<'base> DataType<'base> { } /// The type `PhiCNode`. + #[inline] pub fn phicnode_type(_: &T) -> Self where T: Target<'base>, @@ -1449,6 +1566,7 @@ impl<'base> DataType<'base> { } /// The type `UpsilonNode`. + #[inline] pub fn upsilonnode_type(_: &T) -> Self where T: Target<'base>, @@ -1458,6 +1576,7 @@ impl<'base> DataType<'base> { } /// The type `QuoteNode`. + #[inline] pub fn quotenode_type(_: &T) -> Self where T: Target<'base>, @@ -1467,6 +1586,7 @@ impl<'base> DataType<'base> { } /// The type `NewVarNode`. + #[inline] pub fn newvarnode_type(_: &T) -> Self where T: Target<'base>, @@ -1476,6 +1596,7 @@ impl<'base> DataType<'base> { } /// The type `Intrinsic`. + #[inline] pub fn intrinsic_type(_: &T) -> Self where T: Target<'base>, @@ -1485,6 +1606,7 @@ impl<'base> DataType<'base> { } /// The type `MethodTable`. + #[inline] pub fn methtable_type(_: &T) -> Self where T: Target<'base>, @@ -1494,6 +1616,7 @@ impl<'base> DataType<'base> { } /// The type `TypeMapLevel`. + #[inline] pub fn typemap_level_type(_: &T) -> Self where T: Target<'base>, @@ -1503,6 +1626,7 @@ impl<'base> DataType<'base> { } /// The type `TypeMapEntry`. + #[inline] pub fn typemap_entry_type(_: &T) -> Self where T: Target<'base>, @@ -1513,12 +1637,14 @@ impl<'base> DataType<'base> { } impl<'scope> PartialEq for DataType<'scope> { + #[inline] fn eq(&self, other: &Self) -> bool { self.as_value() == other.as_value() } } impl<'scope, 'data> PartialEq> for DataType<'scope> { + #[inline] fn eq(&self, other: &Value<'scope, 'data>) -> bool { self.as_value() == *other } @@ -1535,16 +1661,18 @@ impl<'scope> ManagedPriv<'scope, '_> for DataType<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, ::std::marker::PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(DataType<'_>, jl_datatype_type); +impl_construct_type_managed!(DataType, 1, jl_datatype_type); /// A reference to a [`DataType`] that has not been explicitly rooted. pub type DataTypeRef<'scope> = Ref<'scope, 'static, DataType<'scope>>; @@ -1553,16 +1681,15 @@ pub type DataTypeRef<'scope> = Ref<'scope, 'static, DataType<'scope>>; /// `ccall`able functions that return a [`DataType`]. pub type DataTypeRet = Ref<'static, 'static, DataType<'static>>; -impl_valid_layout!(DataTypeRef, DataType); +impl_valid_layout!(DataTypeRef, DataType, jl_datatype_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `DataType` or `DataTypeRef`, depending on the target type `T`. pub type DataTypeData<'target, T> = >::Data<'static, DataType<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type DataTypeResult<'target, T> = - >::Result<'static, DataType<'target>>; +pub type DataTypeResult<'target, T> = TargetResult<'target, 'static, DataType<'target>, T>; /// `DataType` layout information. #[derive(Copy, Clone)] @@ -1571,36 +1698,43 @@ pub struct DatatypeLayout<'scope>(NonNull, PhantomData<&'s impl DatatypeLayout<'_> { #[julia_version(since = "1.9")] /// Returns the size of the `DataType`. + #[inline] pub fn size(self) -> u32 { unsafe { self.0.as_ref().size } } /// Returns the number of fields of the `DataType`. + #[inline] pub fn n_fields(self) -> u32 { unsafe { self.0.as_ref().nfields } } /// Returns the number of pointers in the `DataType`. + #[inline] pub fn n_pointers(self) -> u32 { unsafe { self.0.as_ref().npointers } } /// Returns the offset to the first pointer, or -1 if the `DataType` contains no pointers. + #[inline] pub fn first_ptr(self) -> i32 { unsafe { self.0.as_ref().first_ptr } } /// Returns the alignment of the `DataType`. + #[inline] pub fn alignment(self) -> u16 { unsafe { self.0.as_ref().alignment } } /// Returns whether the `DataType` contains unitialized data. + #[inline] pub fn has_padding(self) -> u16 { unsafe { self.0.as_ref().haspadding() } } /// Returns the field descriptor type of this `DataType`. + #[inline] pub fn fielddesc_type(self) -> u16 { unsafe { self.0.as_ref().fielddesc_type() } } diff --git a/jlrs/src/data/managed/function.rs b/jlrs/src/data/managed/function.rs index 950db7ac..3d889bee 100644 --- a/jlrs/src/data/managed/function.rs +++ b/jlrs/src/data/managed/function.rs @@ -12,15 +12,17 @@ use jl_sys::jl_value_t; use super::{value::ValueResult, Ref}; use crate::{ + args::Values, call::{Call, ProvideKeywords, WithKeywords}, convert::ccall_types::{CCallArg, CCallReturn}, data::{ layout::valid_layout::{ValidField, ValidLayout}, managed::{datatype::DataType, private::ManagedPriv, value::Value, Managed}, - types::typecheck::Typecheck, + types::{construct_type::ConstructType, typecheck::Typecheck}, }, error::JlrsResult, - memory::target::{unrooted::Unrooted, Target}, + memory::target::{unrooted::Unrooted, Target, TargetResult}, + prelude::ValueData, private::Private, }; @@ -35,6 +37,7 @@ pub struct Function<'scope, 'data> { impl<'scope, 'data> Function<'scope, 'data> { /// Returns the `DataType` of this function. In Julia, every function has its own `DataType`. + #[inline] pub fn datatype(self) -> DataType<'scope> { self.as_value().datatype() } @@ -43,6 +46,7 @@ impl<'scope, 'data> Function<'scope, 'data> { // Safety: The trait is implemented correctly by using the implementation // of ValidLayout for FunctionRef unsafe impl Typecheck for Function<'_, '_> { + #[inline] fn typecheck(ty: DataType) -> bool { ::valid_layout(ty.as_value()) } @@ -57,6 +61,7 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for Function<'scope, 'data> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self { inner, @@ -65,12 +70,14 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for Function<'scope, 'data> { } } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.inner } } impl<'data> Call<'data> for Function<'_, 'data> { + #[inline] unsafe fn call0<'target, T>(self, target: T) -> ValueResult<'target, 'data, T> where T: Target<'target>, @@ -78,6 +85,20 @@ impl<'data> Call<'data> for Function<'_, 'data> { self.as_value().call0(target) } + #[inline] + unsafe fn call_unchecked<'target, 'value, V, T, const N: usize>( + self, + target: T, + args: V, + ) -> ValueData<'target, 'data, T> + where + V: Values<'value, 'data, N>, + T: Target<'target>, + { + self.as_value().call_unchecked(target, args) + } + + #[inline] unsafe fn call1<'target, T>( self, target: T, @@ -89,6 +110,7 @@ impl<'data> Call<'data> for Function<'_, 'data> { self.as_value().call1(target, arg0) } + #[inline] unsafe fn call2<'target, T>( self, target: T, @@ -101,6 +123,7 @@ impl<'data> Call<'data> for Function<'_, 'data> { self.as_value().call2(target, arg0, arg1) } + #[inline] unsafe fn call3<'target, T>( self, target: T, @@ -114,13 +137,14 @@ impl<'data> Call<'data> for Function<'_, 'data> { self.as_value().call3(target, arg0, arg1, arg2) } - unsafe fn call<'target, 'value, V, T>( + #[inline] + unsafe fn call<'target, 'value, V, T, const N: usize>( self, target: T, args: V, ) -> ValueResult<'target, 'data, T> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { self.as_value().call(target, args) @@ -128,6 +152,7 @@ impl<'data> Call<'data> for Function<'_, 'data> { } impl<'value, 'data> ProvideKeywords<'value, 'data> for Function<'value, 'data> { + #[inline] fn provide_keywords( self, kws: Value<'value, 'data>, @@ -145,16 +170,23 @@ pub type FunctionRet = Ref<'static, 'static, Function<'static, 'static>>; // Safety: FunctionRef is valid for ty if ty is a subtype of Function unsafe impl ValidLayout for FunctionRef<'_, '_> { + #[inline] fn valid_layout(ty: Value) -> bool { let global = unsafe { Unrooted::new() }; let function_type = DataType::function_type(&global); ty.subtype(function_type.as_value()) } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + DataType::function_type(&target).as_value() + } + const IS_REF: bool = true; } unsafe impl ValidField for Option> { + #[inline] fn valid_field(ty: Value) -> bool { let global = unsafe { Unrooted::new() }; let function_type = DataType::function_type(&global); @@ -162,7 +194,7 @@ unsafe impl ValidField for Option> { } } -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Function` or `FunctionRef`, depending on the target type `T`. pub type FunctionData<'target, 'data, T> = @@ -170,7 +202,7 @@ pub type FunctionData<'target, 'data, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. pub type FunctionResult<'target, 'data, T> = - >::Result<'data, Function<'target, 'data>>; + TargetResult<'target, 'data, Function<'target, 'data>, T>; unsafe impl<'scope, 'data> CCallArg for Function<'scope, 'data> { type CCallArgType = Value<'scope, 'data>; @@ -180,4 +212,34 @@ unsafe impl<'scope, 'data> CCallArg for Function<'scope, 'data> { unsafe impl CCallReturn for FunctionRet { type CCallReturnType = Value<'static, 'static>; type FunctionReturnType = Value<'static, 'static>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } +} + +unsafe impl ConstructType for Function<'_, '_> { + type Static = Function<'static, 'static>; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> super::value::ValueData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + DataType::function_type(&target).as_value().root(target) + } + + #[inline] + fn base_type<'target, T>(target: &T) -> Option> + where + T: Target<'target>, + { + Some(DataType::function_type(target).as_value()) + } } diff --git a/jlrs/src/data/managed/internal/binding.rs b/jlrs/src/data/managed/internal/binding.rs index dd688a26..c37e38e2 100644 --- a/jlrs/src/data/managed/internal/binding.rs +++ b/jlrs/src/data/managed/internal/binding.rs @@ -12,7 +12,7 @@ use jl_sys::{jl_binding_t, jl_binding_type}; use crate::{ data::managed::{private::ManagedPriv, value::ValueData, Ref}, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -110,16 +110,18 @@ impl<'scope> ManagedPriv<'scope, '_> for Binding<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, ::std::marker::PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Binding<'_>, jl_binding_type); +impl_construct_type_managed!(Binding, 1, jl_binding_type); /// A reference to a [`Binding`] that has not been explicitly rooted. pub type BindingRef<'scope> = Ref<'scope, 'static, Binding<'scope>>; @@ -128,16 +130,16 @@ pub type BindingRef<'scope> = Ref<'scope, 'static, Binding<'scope>>; /// `ccall`able functions that return a [`Binding`]. pub type BindingRet = Ref<'static, 'static, Binding<'static>>; -impl_valid_layout!(BindingRef, Binding); +impl_valid_layout!(BindingRef, Binding, jl_binding_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Binding` or `BindingRef`, depending on the target type `T`. pub type BindingData<'target, T> = >::Data<'static, Binding<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type BindingResult<'target, T> = >::Result<'static, Binding<'target>>; +pub type BindingResult<'target, T> = TargetResult<'target, 'static, Binding<'target>, T>; impl_ccall_arg_managed!(Binding, 1); impl_into_typed!(Binding); diff --git a/jlrs/src/data/managed/internal/code_instance.rs b/jlrs/src/data/managed/internal/code_instance.rs index 56cd4cdf..bdbc3d29 100644 --- a/jlrs/src/data/managed/internal/code_instance.rs +++ b/jlrs/src/data/managed/internal/code_instance.rs @@ -19,7 +19,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -292,16 +292,18 @@ impl<'scope> ManagedPriv<'scope, '_> for CodeInstance<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, ::std::marker::PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(CodeInstance<'_>, jl_code_instance_type); +impl_construct_type_managed!(CodeInstance, 1, jl_code_instance_type); /// A reference to a [`CodeInstance`] that has not been explicitly rooted. pub type CodeInstanceRef<'scope> = Ref<'scope, 'static, CodeInstance<'scope>>; @@ -310,10 +312,10 @@ pub type CodeInstanceRef<'scope> = Ref<'scope, 'static, CodeInstance<'scope>>; /// `ccall`able functions that return a [`CodeInstance`]. pub type CodeInstanceRet = Ref<'static, 'static, CodeInstance<'static>>; -impl_valid_layout!(CodeInstanceRef, CodeInstance); +impl_valid_layout!(CodeInstanceRef, CodeInstance, jl_code_instance_type); use super::method_instance::MethodInstance; -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `CodeInstance` or `CodeInstanceRef`, depending on the target type `T`. pub type CodeInstanceData<'target, T> = @@ -321,8 +323,7 @@ pub type CodeInstanceData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type CodeInstanceResult<'target, T> = - >::Result<'static, CodeInstance<'target>>; +pub type CodeInstanceResult<'target, T> = TargetResult<'target, 'static, CodeInstance<'target>, T>; impl_ccall_arg_managed!(CodeInstance, 1); impl_into_typed!(CodeInstance); diff --git a/jlrs/src/data/managed/internal/expr.rs b/jlrs/src/data/managed/internal/expr.rs index 2cbe8ad1..9be85a68 100644 --- a/jlrs/src/data/managed/internal/expr.rs +++ b/jlrs/src/data/managed/internal/expr.rs @@ -12,7 +12,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -63,16 +63,18 @@ impl<'scope> ManagedPriv<'scope, '_> for Expr<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Expr<'_>, jl_expr_type); +impl_construct_type_managed!(Expr, 1, jl_expr_type); /// A reference to an [`Expr`] that has not been explicitly rooted. pub type ExprRef<'scope> = Ref<'scope, 'static, Expr<'scope>>; @@ -81,15 +83,15 @@ pub type ExprRef<'scope> = Ref<'scope, 'static, Expr<'scope>>; /// `ccall`able functions that return a [`Expr`]. pub type ExprRet = Ref<'static, 'static, Expr<'static>>; -impl_valid_layout!(ExprRef, Expr); +impl_valid_layout!(ExprRef, Expr, jl_expr_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Expr` or `ExprRef`, depending on the target type `T`. pub type ExprData<'target, T> = >::Data<'static, Expr<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type ExprResult<'target, T> = >::Result<'static, Expr<'target>>; +pub type ExprResult<'target, T> = TargetResult<'target, 'static, Expr<'target>, T>; impl_ccall_arg_managed!(Expr, 1); impl_into_typed!(Expr); diff --git a/jlrs/src/data/managed/internal/method.rs b/jlrs/src/data/managed/internal/method.rs index c523a1ba..34c89e4a 100644 --- a/jlrs/src/data/managed/internal/method.rs +++ b/jlrs/src/data/managed/internal/method.rs @@ -28,7 +28,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -459,16 +459,18 @@ impl<'scope> ManagedPriv<'scope, '_> for Method<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, ::std::marker::PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Method<'_>, jl_method_type); +impl_construct_type_managed!(Method, 1, jl_method_type); /// A reference to a [`Method`] that has not been explicitly rooted. pub type MethodRef<'scope> = Ref<'scope, 'static, Method<'scope>>; @@ -477,16 +479,16 @@ pub type MethodRef<'scope> = Ref<'scope, 'static, Method<'scope>>; /// `ccall`able functions that return a [`Method`]. pub type MethodRet = Ref<'static, 'static, Method<'static>>; -impl_valid_layout!(MethodRef, Method); +impl_valid_layout!(MethodRef, Method, jl_method_type); use super::method_instance::MethodInstanceData; -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Method` or `MethodRef`, depending on the target type `T`. pub type MethodData<'target, T> = >::Data<'static, Method<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type MethodResult<'target, T> = >::Result<'static, Method<'target>>; +pub type MethodResult<'target, T> = TargetResult<'target, 'static, Method<'target>, T>; impl_ccall_arg_managed!(Method, 1); impl_into_typed!(Method); diff --git a/jlrs/src/data/managed/internal/method_instance.rs b/jlrs/src/data/managed/internal/method_instance.rs index 2e980f92..7a896ffe 100644 --- a/jlrs/src/data/managed/internal/method_instance.rs +++ b/jlrs/src/data/managed/internal/method_instance.rs @@ -20,7 +20,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -212,16 +212,18 @@ impl<'scope> ManagedPriv<'scope, '_> for MethodInstance<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(MethodInstance<'_>, jl_method_instance_type); +impl_construct_type_managed!(MethodInstance, 1, jl_method_instance_type); /// A reference to a [`MethodInstance`] that has not been explicitly rooted. pub type MethodInstanceRef<'scope> = Ref<'scope, 'static, MethodInstance<'scope>>; @@ -230,10 +232,10 @@ pub type MethodInstanceRef<'scope> = Ref<'scope, 'static, MethodInstance<'scope> /// `ccall`able functions that return a [`MethodInstance`]. pub type MethodInstanceRet = Ref<'static, 'static, MethodInstance<'static>>; -impl_valid_layout!(MethodInstanceRef, MethodInstance); +impl_valid_layout!(MethodInstanceRef, MethodInstance, jl_method_instance_type); use super::code_instance::CodeInstanceData; -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `MethodInstance` or `MethodInstanceRef`, depending on the target type `T`. pub type MethodInstanceData<'target, T> = @@ -242,7 +244,7 @@ pub type MethodInstanceData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target /// type `T`. pub type MethodInstanceResult<'target, T> = - >::Result<'static, MethodInstance<'target>>; + TargetResult<'target, 'static, MethodInstance<'target>, T>; impl_ccall_arg_managed!(MethodInstance, 1); impl_into_typed!(MethodInstance); diff --git a/jlrs/src/data/managed/internal/method_match.rs b/jlrs/src/data/managed/internal/method_match.rs index 16044756..94173104 100644 --- a/jlrs/src/data/managed/internal/method_match.rs +++ b/jlrs/src/data/managed/internal/method_match.rs @@ -11,6 +11,7 @@ use jl_sys::{jl_method_match_t, jl_method_match_type}; use crate::{ data::managed::{private::ManagedPriv, simple_vector::SimpleVector, value::Value, Ref}, impl_julia_typecheck, + memory::target::TargetResult, private::Private, }; @@ -77,16 +78,18 @@ impl<'scope> ManagedPriv<'scope, '_> for MethodMatch<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(MethodMatch<'_>, jl_method_match_type); +impl_construct_type_managed!(MethodMatch, 1, jl_method_match_type); /// A reference to a [`MethodMatch`] that has not been explicitly rooted. pub type MethodMatchRef<'scope> = Ref<'scope, 'static, MethodMatch<'scope>>; @@ -95,10 +98,10 @@ pub type MethodMatchRef<'scope> = Ref<'scope, 'static, MethodMatch<'scope>>; /// `ccall`able functions that return a [`MethodMatch`]. pub type MethodMatchRet = Ref<'static, 'static, MethodMatch<'static>>; -impl_valid_layout!(MethodMatchRef, MethodMatch); +impl_valid_layout!(MethodMatchRef, MethodMatch, jl_method_match_type); use super::method::Method; -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `MethodMetch` or `MethodMetchRef`, depending on the target type `T`. pub type MethodMatchData<'target, T> = @@ -106,8 +109,7 @@ pub type MethodMatchData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type MethodMatchResult<'target, T> = - >::Result<'static, MethodMatch<'target>>; +pub type MethodMatchResult<'target, T> = TargetResult<'target, 'static, MethodMatch<'target>, T>; impl_ccall_arg_managed!(MethodMatch, 1); impl_into_typed!(MethodMatch); diff --git a/jlrs/src/data/managed/internal/method_table.rs b/jlrs/src/data/managed/internal/method_table.rs index 4808ff61..45d37897 100644 --- a/jlrs/src/data/managed/internal/method_table.rs +++ b/jlrs/src/data/managed/internal/method_table.rs @@ -22,7 +22,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -233,16 +233,18 @@ impl<'scope> ManagedPriv<'scope, '_> for MethodTable<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(MethodTable<'_>, jl_methtable_type); +impl_construct_type_managed!(MethodTable, 1, jl_methtable_type); /// A reference to a [`MethodTable`] that has not been explicitly rooted. pub type MethodTableRef<'scope> = Ref<'scope, 'static, MethodTable<'scope>>; @@ -251,9 +253,9 @@ pub type MethodTableRef<'scope> = Ref<'scope, 'static, MethodTable<'scope>>; /// `ccall`able functions that return a [`MethodTable`]. pub type MethodTableRet = Ref<'static, 'static, MethodTable<'static>>; -impl_valid_layout!(MethodTableRef, MethodTable); +impl_valid_layout!(MethodTableRef, MethodTable, jl_methtable_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `MethodTable` or `MethodTableRef`, depending on the target type `T`. pub type MethodTableData<'target, T> = @@ -261,8 +263,7 @@ pub type MethodTableData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type MethodTableResult<'target, T> = - >::Result<'static, MethodTable<'target>>; +pub type MethodTableResult<'target, T> = TargetResult<'target, 'static, MethodTable<'target>, T>; impl_ccall_arg_managed!(MethodTable, 1); impl_into_typed!(MethodTable); diff --git a/jlrs/src/data/managed/internal/opaque_closure.rs b/jlrs/src/data/managed/internal/opaque_closure.rs index 558141f5..c460b74f 100644 --- a/jlrs/src/data/managed/internal/opaque_closure.rs +++ b/jlrs/src/data/managed/internal/opaque_closure.rs @@ -6,9 +6,10 @@ use std::{ ptr::{null_mut, NonNull}, }; -use jl_sys::jl_opaque_closure_t; +use jl_sys::{jl_opaque_closure_t, jl_opaque_closure_type}; use crate::{ + args::Values, call::Call, data::{ managed::{ @@ -20,7 +21,8 @@ use crate::{ }, types::typecheck::Typecheck, }, - memory::target::{unrooted::Unrooted, Target}, + memory::target::{unrooted::Unrooted, Target, TargetResult}, + prelude::ValueData, private::Private, }; @@ -104,10 +106,12 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for OpaqueClosure<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } @@ -121,6 +125,19 @@ impl<'data> Call<'data> for OpaqueClosure<'_> { self.as_value().call0(target) } + #[inline] + unsafe fn call_unchecked<'target, 'value, V, T, const N: usize>( + self, + target: T, + args: V, + ) -> ValueData<'target, 'data, T> + where + V: Values<'value, 'data, N>, + T: Target<'target>, + { + self.as_value().call_unchecked(target, args) + } + unsafe fn call1<'target, T>( self, target: T, @@ -157,13 +174,13 @@ impl<'data> Call<'data> for OpaqueClosure<'_> { self.as_value().call3(target, arg0, arg1, arg2) } - unsafe fn call<'target, 'value, V, T>( + unsafe fn call<'target, 'value, V, T, const N: usize>( self, target: T, args: V, ) -> ValueResult<'target, 'data, T> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { self.as_value().call(target, args) @@ -177,9 +194,9 @@ pub type OpaqueClosureRef<'scope> = Ref<'scope, 'static, OpaqueClosure<'scope>>; /// `ccall`able functions that return a [`OpaqueClosure`]. pub type OpaqueClosureRet = Ref<'static, 'static, OpaqueClosure<'static>>; -impl_valid_layout!(OpaqueClosureRef, OpaqueClosure); +impl_valid_layout!(OpaqueClosureRef, OpaqueClosure, jl_opaque_closure_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `OpaqueClosure` or `OpaqueClosureRef`, depending on the target type `T`. pub type OpaqueClosureData<'target, T> = @@ -188,16 +205,22 @@ pub type OpaqueClosureData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target /// type `T`. pub type OpaqueClosureResult<'target, T> = - >::Result<'static, OpaqueClosure<'target>>; + TargetResult<'target, 'static, OpaqueClosure<'target>, T>; unsafe impl<'scope> crate::convert::ccall_types::CCallArg for OpaqueClosure<'scope> { - type CCallArgType = Option>; - type FunctionArgType = Option>; + type CCallArgType = Value<'scope, 'static>; + type FunctionArgType = Value<'scope, 'static>; } unsafe impl crate::convert::ccall_types::CCallReturn for crate::data::managed::Ref<'static, 'static, OpaqueClosure<'static>> { - type CCallReturnType = Option>; - type FunctionReturnType = Option>; + type CCallReturnType = Value<'static, 'static>; + type FunctionReturnType = Value<'static, 'static>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } diff --git a/jlrs/src/data/managed/internal/typemap_entry.rs b/jlrs/src/data/managed/internal/typemap_entry.rs index 6274b904..cc1f1a2b 100644 --- a/jlrs/src/data/managed/internal/typemap_entry.rs +++ b/jlrs/src/data/managed/internal/typemap_entry.rs @@ -19,7 +19,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -158,16 +158,18 @@ impl<'scope> ManagedPriv<'scope, '_> for TypeMapEntry<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(TypeMapEntry<'_>, jl_typemap_entry_type); +impl_construct_type_managed!(TypeMapEntry, 1, jl_typemap_entry_type); /// A reference to a [`TypeMapEntry`] that has not been explicitly rooted. pub type TypeMapEntryRef<'scope> = Ref<'scope, 'static, TypeMapEntry<'scope>>; @@ -176,9 +178,9 @@ pub type TypeMapEntryRef<'scope> = Ref<'scope, 'static, TypeMapEntry<'scope>>; /// `ccall`able functions that return a [`TypeMapEntry`]. pub type TypeMapEntryRet = Ref<'static, 'static, TypeMapEntry<'static>>; -impl_valid_layout!(TypeMapEntryRef, TypeMapEntry); +impl_valid_layout!(TypeMapEntryRef, TypeMapEntry, jl_typemap_entry_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `TypeMapEntry` or `TypeMapEntryRef`, depending on the target type `T`. pub type TypeMapEntryData<'target, T> = @@ -186,8 +188,7 @@ pub type TypeMapEntryData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type TypeMapEntryResult<'target, T> = - >::Result<'static, TypeMapEntry<'target>>; +pub type TypeMapEntryResult<'target, T> = TargetResult<'target, 'static, TypeMapEntry<'target>, T>; impl_ccall_arg_managed!(TypeMapEntry, 1); impl_into_typed!(TypeMapEntry); diff --git a/jlrs/src/data/managed/internal/typemap_level.rs b/jlrs/src/data/managed/internal/typemap_level.rs index f162b421..1b7df7a1 100644 --- a/jlrs/src/data/managed/internal/typemap_level.rs +++ b/jlrs/src/data/managed/internal/typemap_level.rs @@ -19,7 +19,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -244,16 +244,18 @@ impl<'scope> ManagedPriv<'scope, '_> for TypeMapLevel<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(TypeMapLevel<'_>, jl_typemap_level_type); +impl_construct_type_managed!(TypeMapLevel, 1, jl_typemap_level_type); /// A reference to a [`TypeMapLevel`] that has not been explicitly rooted. pub type TypeMapLevelRef<'scope> = Ref<'scope, 'static, TypeMapLevel<'scope>>; @@ -262,9 +264,9 @@ pub type TypeMapLevelRef<'scope> = Ref<'scope, 'static, TypeMapLevel<'scope>>; /// `ccall`able functions that return a [`TypeMapLevel`]. pub type TypeMapLevelRet = Ref<'static, 'static, TypeMapLevel<'static>>; -impl_valid_layout!(TypeMapLevelRef, TypeMapLevel); +impl_valid_layout!(TypeMapLevelRef, TypeMapLevel, jl_typemap_level_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `TypeMaLevely` or `TypeMaLevelyRef`, depending on the target type `T`. pub type TypeMapLevelData<'target, T> = @@ -272,8 +274,7 @@ pub type TypeMapLevelData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type TypeMapLevelResult<'target, T> = - >::Result<'static, TypeMapLevel<'target>>; +pub type TypeMapLevelResult<'target, T> = TargetResult<'target, 'static, TypeMapLevel<'target>, T>; impl_ccall_arg_managed!(TypeMapLevel, 1); impl_into_typed!(TypeMapLevel); diff --git a/jlrs/src/data/managed/internal/vararg.rs b/jlrs/src/data/managed/internal/vararg.rs index be5b14fd..6e944a10 100644 --- a/jlrs/src/data/managed/internal/vararg.rs +++ b/jlrs/src/data/managed/internal/vararg.rs @@ -11,7 +11,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -56,10 +56,12 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for Vararg<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } @@ -67,12 +69,12 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for Vararg<'scope> { /// A reference to a [`Vararg`] that has not been explicitly rooted. pub type VarargRef<'scope> = Ref<'scope, 'static, Vararg<'scope>>; -impl_valid_layout!(VarargRef, Vararg); +impl_valid_layout!(VarargRef, Vararg, jl_vararg_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Vararg` or `VarargRef`, depending on the target type `T`. pub type VarargData<'target, T> = >::Data<'static, Vararg<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type`T`. -pub type VarargResult<'target, T> = >::Result<'static, Vararg<'target>>; +pub type VarargResult<'target, T> = TargetResult<'target, 'static, Vararg<'target>, T>; diff --git a/jlrs/src/data/managed/internal/weak_ref.rs b/jlrs/src/data/managed/internal/weak_ref.rs index fba48512..bf893570 100644 --- a/jlrs/src/data/managed/internal/weak_ref.rs +++ b/jlrs/src/data/managed/internal/weak_ref.rs @@ -11,7 +11,7 @@ use crate::{ Ref, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -51,16 +51,18 @@ impl<'scope> ManagedPriv<'scope, '_> for WeakRef<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(WeakRef<'_>, jl_weakref_type); +impl_construct_type_managed!(WeakRef, 1, jl_weakref_type); /// A reference to a [`WeakRef`] that has not been explicitly rooted. pub type WeakRefRef<'scope> = Ref<'scope, 'static, WeakRef<'scope>>; @@ -69,15 +71,15 @@ pub type WeakRefRef<'scope> = Ref<'scope, 'static, WeakRef<'scope>>; /// `ccall`able functions that return a [`WeakRef`]. pub type WeakRefRet = Ref<'static, 'static, WeakRef<'static>>; -impl_valid_layout!(WeakRefRef, WeakRef); +impl_valid_layout!(WeakRefRef, WeakRef, jl_weakref_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `WeakRef` or `WeakRefRef`, depending on the target type `T`. pub type WeakRefData<'target, T> = >::Data<'static, WeakRef<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type`T`. -pub type WeakRefResult<'target, T> = >::Result<'static, WeakRef<'target>>; +pub type WeakRefResult<'target, T> = TargetResult<'target, 'static, WeakRef<'target>, T>; impl_ccall_arg_managed!(WeakRef, 1); impl_into_typed!(WeakRef); diff --git a/jlrs/src/data/managed/mod.rs b/jlrs/src/data/managed/mod.rs index bc08f757..d7c216c2 100644 --- a/jlrs/src/data/managed/mod.rs +++ b/jlrs/src/data/managed/mod.rs @@ -30,15 +30,55 @@ end */ macro_rules! impl_construct_type_managed { - ($ty:ty, $jl_ty:expr) => { - unsafe impl crate::data::types::construct_type::ConstructType for $ty { - fn construct_type<'target, 'current, 'borrow, T>( - target: $crate::memory::target::ExtendedTarget<'target, '_, '_, T>, - ) -> $crate::data::managed::value::ValueData<'target, 'static, T> + ($ty:ident, 1, $jl_ty:expr) => { + unsafe impl crate::data::types::construct_type::ConstructType for $ty<'_> { + type Static = $ty<'static>; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, 'current, 'borrow, Tgt>( + target: Tgt, + ) -> $crate::data::managed::value::ValueData<'target, 'static, Tgt> + where + Tgt: $crate::memory::target::Target<'target>, + { + unsafe { + target.data_from_ptr( + NonNull::new_unchecked($jl_ty.cast::<::jl_sys::jl_value_t>()), + $crate::private::Private, + ) + } + } + + #[inline] + fn base_type<'target, Tgt>(_target: &Tgt) -> Option<$crate::data::managed::value::Value<'target, 'static>> + where + Tgt: crate::memory::target::Target<'target>, + { + unsafe { + let ptr = NonNull::new_unchecked($jl_ty.cast::<::jl_sys::jl_value_t>()); + Some(<$crate::data::managed::value::Value as $crate::data::managed::private::ManagedPriv>::wrap_non_null( + ptr, + $crate::private::Private, + )) + } + } + } + }; + ($ty:ident, 2, $jl_ty:expr) => { + unsafe impl crate::data::types::construct_type::ConstructType for $ty<'_, '_> { + type Static = $ty<'static, 'static>; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, 'current, 'borrow, Tgt>( + target: Tgt, + ) -> $crate::data::managed::value::ValueData<'target, 'static, Tgt> where - T: $crate::memory::target::Target<'target>, + Tgt: $crate::memory::target::Target<'target>, { - let (target, _) = target.split(); unsafe { target.data_from_ptr( NonNull::new_unchecked($jl_ty.cast::<::jl_sys::jl_value_t>()), @@ -47,6 +87,7 @@ macro_rules! impl_construct_type_managed { } } + #[inline] fn base_type<'target, Tgt>(_target: &Tgt) -> Option<$crate::data::managed::value::Value<'target, 'static>> where Tgt: crate::memory::target::Target<'target>, @@ -75,6 +116,12 @@ macro_rules! impl_ccall_arg_managed { { type CCallReturnType = $crate::data::managed::value::Value<'static, 'static>; type FunctionReturnType = $ty<'static>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } }; @@ -89,6 +136,12 @@ macro_rules! impl_ccall_arg_managed { { type CCallReturnType = $crate::data::managed::value::Value<'static, 'static>; type FunctionReturnType = $ty<'static, 'static>; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } }; } @@ -98,6 +151,7 @@ macro_rules! impl_into_typed { impl<'scope, 'data> $crate::data::managed::value::typed::AsTyped<'scope, 'data> for $ty<'scope> { + #[inline] fn as_typed( self, ) -> $crate::error::JlrsResult< @@ -117,22 +171,39 @@ macro_rules! impl_into_typed { } macro_rules! impl_valid_layout { - ($ref_type:ident, $type:ident) => { + ($ref_type:ident, $type:ident, $type_obj:ident) => { unsafe impl $crate::data::layout::valid_layout::ValidLayout for $ref_type<'_> { fn valid_layout(ty: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = ty.cast::<$crate::data::managed::datatype::DataType>() { + if ty.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { ty.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; dt.is::<$type>() } else { false } } + fn type_object<'target, Tgt>( + _: &Tgt + ) -> $crate::data::managed::value::Value<'target, 'static> + where + Tgt: $crate::memory::target::Target<'target> + { + unsafe { + <$crate::data::managed::value::Value as $crate::data::managed::private::ManagedPriv>::wrap_non_null( + std::ptr::NonNull::new_unchecked($type_obj.cast()), + $crate::private::Private + ) + } + } + const IS_REF: bool = true; } unsafe impl $crate::data::layout::valid_layout::ValidField for Option<$ref_type<'_>> { + #[inline] fn valid_field(ty: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = ty.cast::<$crate::data::managed::datatype::DataType>() { + if ty.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { ty.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; dt.is::<$type>() } else { false @@ -141,20 +212,38 @@ macro_rules! impl_valid_layout { } unsafe impl $crate::data::layout::valid_layout::ValidLayout for $type<'_> { + #[inline] fn valid_layout(ty: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = ty.cast::<$crate::data::managed::datatype::DataType>() { + if ty.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { ty.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; dt.is::<$type>() } else { false } } + fn type_object<'target, Tgt>( + _: &Tgt + ) -> $crate::data::managed::value::Value<'target, 'static> + where + Tgt: $crate::memory::target::Target<'target> + { + unsafe { + <$crate::data::managed::value::Value as $crate::data::managed::private::ManagedPriv>::wrap_non_null( + std::ptr::NonNull::new_unchecked($type_obj.cast()), + $crate::private::Private + ) + } + } + const IS_REF: bool = true; } unsafe impl $crate::data::layout::valid_layout::ValidField for Option<$type<'_>> { + #[inline] fn valid_field(ty: $crate::data::managed::value::Value) -> bool { - if let Ok(dt) = ty.cast::<$crate::data::managed::datatype::DataType>() { + if ty.is::<$crate::data::managed::datatype::DataType>() { + let dt = unsafe { ty.cast_unchecked::<$crate::data::managed::datatype::DataType>() }; dt.is::<$type>() } else { false @@ -203,6 +292,7 @@ use std::{ ptr::NonNull, }; +use self::module::JlrsCore; use crate::{ call::Call, data::{ @@ -238,17 +328,20 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> { type TypeConstructor<'target, 'da>: Managed<'target, 'da>; /// Convert the data to a `Ref`. + #[inline] fn as_ref(self) -> Ref<'scope, 'data, Self> { Ref::wrap(self.unwrap_non_null(Private)) } /// Convert the data to a `Value`. + #[inline] fn as_value(self) -> Value<'scope, 'data> { // Safety: Managed types can always be converted to a Value unsafe { Value::wrap_non_null(self.unwrap_non_null(Private).cast(), Private) } } /// Use the target to reroot this data. + #[inline] fn root<'target, T>(self, target: T) -> T::Data<'data, Self::TypeConstructor<'target, 'data>> where T: Target<'target>, @@ -257,6 +350,7 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> { } /// Returns a new `Unrooted`. + #[inline] fn unrooted_target(self) -> Unrooted<'scope> { unsafe { Unrooted::new() } } @@ -269,11 +363,7 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> { let global = self.unrooted_target(); let s = unsafe { - Module::main(&global) - .submodule(&global, "JlrsCore")? - .as_managed() - .function(&global, "valuestring")? - .as_managed() + JlrsCore::value_string(&global) .call1(&global, self.as_value()) .map_err(|e| e.as_value().error_string_or(CANNOT_DISPLAY_VALUE)) .map_err(|e| JlrsError::exception(format!("JlrsCore.valuestring failed: {}", e)))? @@ -298,12 +388,7 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> { let global = self.unrooted_target(); let s = unsafe { - // TODO: caching? - Module::main(&global) - .submodule(&global, "JlrsCore")? - .as_managed() - .function(&global, "errorstring")? - .as_managed() + JlrsCore::error_string(&global) .call1(&global, self.as_value()) .map_err(|e| e.as_value().error_string_or(CANNOT_DISPLAY_VALUE)) .map_err(|e| JlrsError::exception(format!("JlrsCore.errorstring failed: {}", e)))? @@ -353,6 +438,7 @@ pub trait Managed<'scope, 'data>: private::ManagedPriv<'scope, 'data> { /// `'static`. This method should only be used to return Julia data from a `ccall`ed function, /// and in combination with the `ForeignType` trait to store references to Julia data in types /// that that implement that trait. + #[inline] fn leak(self) -> Ref<'static, 'data, Self::TypeConstructor<'static, 'data>> { self.as_ref().leak() } @@ -390,6 +476,7 @@ impl<'scope, 'data, T> Clone for Ref<'scope, 'data, T> where T: Managed<'scope, 'data>, { + #[inline] fn clone(&self) -> Self { Ref(self.0, PhantomData, PhantomData) } @@ -407,6 +494,7 @@ impl<'scope, 'data, W: Managed<'scope, 'data>> Ref<'scope, 'data, W> { /// Use `target` to root this data. /// /// Safety: The data pointed to by `self` must not have been freed by the GC yet. + #[inline] pub unsafe fn root<'target, T>( self, target: T, @@ -417,6 +505,7 @@ impl<'scope, 'data, W: Managed<'scope, 'data>> Ref<'scope, 'data, W> { target.data_from_ptr(self.ptr().cast(), Private) } + #[inline] pub(crate) fn wrap(ptr: NonNull) -> Self { Ref(ptr, PhantomData, PhantomData) } @@ -426,6 +515,7 @@ impl<'scope, 'data, W: Managed<'scope, 'data>> Ref<'scope, 'data, W> { /// Safety: a reference is only guaranteed to be valid as long as it's reachable from some /// GC root. If the reference is unreachable, the GC can free it. The GC can run whenever a /// safepoint is reached, this is typically the case when new Julia data is allocated. + #[inline] pub unsafe fn as_managed(self) -> W { W::wrap_non_null(self.ptr(), Private) } @@ -435,6 +525,7 @@ impl<'scope, 'data, W: Managed<'scope, 'data>> Ref<'scope, 'data, W> { /// Safety: a reference is only guaranteed to be valid as long as it's reachable from some /// GC root. If the reference is unreachable, the GC can free it. The GC can run whenever a /// safepoint is reached, this is typically the case when new Julia data is allocated. + #[inline] pub unsafe fn as_value(self) -> Value<'scope, 'data> { Value::wrap_non_null(self.data_ptr().cast(), Private) } @@ -443,6 +534,7 @@ impl<'scope, 'data, W: Managed<'scope, 'data>> Ref<'scope, 'data, W> { /// /// Safety: this method should only be used when no data borrowed from Rust is referenced by /// this Julia data. + #[inline] pub unsafe fn assume_owned(self) -> Ref<'scope, 'static, W::TypeConstructor<'scope, 'static>> { Ref::wrap(self.ptr().cast()) } @@ -452,20 +544,44 @@ impl<'scope, 'data, W: Managed<'scope, 'data>> Ref<'scope, 'data, W> { /// /// Safety: this method should only be called to return Julia data from a `ccall`ed function /// or when storing Julia data in a foreign type. + #[inline] pub fn leak(self) -> Ref<'static, 'data, W::TypeConstructor<'static, 'data>> { Ref::wrap(self.ptr().cast()) } /// Returns a pointer to the data, + #[inline] pub fn data_ptr(self) -> NonNull { self.ptr().cast() } + #[inline] pub(crate) fn ptr(self) -> NonNull { self.0 } } +#[inline] +pub fn leak<'scope, 'data, M: Managed<'scope, 'data>>( + data: M, +) -> Ref<'static, 'data, M::TypeConstructor<'static, 'data>> { + data.as_ref().leak() +} + +#[inline] +pub unsafe fn assume_rooted<'scope, M: Managed<'scope, 'static>>( + data: Ref<'scope, 'static, M>, +) -> M { + data.as_managed() +} + +#[inline] +pub unsafe fn erase_scope_lifetime<'scope, 'data, M: Managed<'scope, 'data>>( + data: M, +) -> M::TypeConstructor<'static, 'data> { + data.leak().as_managed() +} + pub(crate) mod private { use std::{fmt::Debug, ptr::NonNull}; @@ -483,15 +599,15 @@ pub(crate) mod private { // rooted, it must never be used after becoming unreachable. unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self; - #[inline(always)] // Safety: `Self` must be the correct type for `value`. + #[inline] unsafe fn from_value_unchecked(value: Value<'scope, 'data>, _: Private) -> Self { Self::wrap_non_null(value.unwrap_non_null(Private).cast(), Private) } fn unwrap_non_null(self, _: Private) -> NonNull; - #[inline(always)] + #[inline] fn unwrap(self, _: Private) -> *mut Self::Wraps { self.unwrap_non_null(Private).as_ptr() } diff --git a/jlrs/src/data/managed/module.rs b/jlrs/src/data/managed/module.rs index df440fbe..e7c46142 100644 --- a/jlrs/src/data/managed/module.rs +++ b/jlrs/src/data/managed/module.rs @@ -6,8 +6,9 @@ // todo: jl_new_module -use std::{marker::PhantomData, ptr::NonNull}; +use std::{any::TypeId, marker::PhantomData, ptr::NonNull}; +use fxhash::FxHashMap; #[julia_version(since = "1.8", until = "1.9")] use jl_sys::jl_binding_type as jl_get_binding_type; #[julia_version(since = "1.10")] @@ -17,28 +18,54 @@ use jl_sys::{ jl_module_type, jl_set_const, jl_set_global, }; use jlrs_macros::julia_version; -use once_cell::sync::OnceCell; use super::{ + erase_scope_lifetime, function::FunctionData, - value::{ValueData, ValueResult}, - Ref, + union_all::UnionAll, + value::{ValueData, ValueResult, ValueUnbound}, + Managed, Ref, }; use crate::{ call::Call, + catch::catch_exceptions, convert::to_symbol::ToSymbol, data::{ layout::nothing::Nothing, - managed::{ - function::Function, private::ManagedPriv, symbol::Symbol, value::Value, Managed as _, - }, + managed::{function::Function, private::ManagedPriv, symbol::Symbol, value::Value}, + types::{construct_type::ConstructType, typecheck::Typecheck}, }, error::{AccessError, JlrsResult, TypeError}, - impl_julia_typecheck, - memory::target::Target, + gc_safe::{GcSafeOnceLock, GcSafeRwLock}, + impl_julia_typecheck, inline_static_ref, + memory::target::{Target, TargetException, TargetResult}, + prelude::DataType, private::Private, }; +struct GlobalCache { + // FxHashMap is significantly faster than HashMap with default hasher + // Boxed slice is faster to hash than a Vec + data: GcSafeRwLock, (TypeId, ValueUnbound)>>, +} + +impl GlobalCache { + fn new() -> Self { + GlobalCache { + data: GcSafeRwLock::default(), + } + } +} + +unsafe impl Send for GlobalCache {} +unsafe impl Sync for GlobalCache {} + +static CACHE: GcSafeOnceLock = GcSafeOnceLock::new(); + +pub(crate) unsafe fn init_global_cache() { + CACHE.set(GlobalCache::new()).ok(); +} + /// Functionality in Julia can be accessed through its module system. You can get a handle to the /// three standard modules, `Main`, `Base`, and `Core` and access their submodules through them. /// If you include your own Julia code with [`Julia::include`] or [`AsyncJulia::include`], its @@ -55,6 +82,7 @@ pub struct Module<'scope>(NonNull, PhantomData<&'scope ()>); impl<'scope> Module<'scope> { /// Returns the name of this module. + #[inline] pub fn name(self) -> Symbol<'scope> { // Safety: the pointer points to valid data, the name is never null unsafe { @@ -64,6 +92,7 @@ impl<'scope> Module<'scope> { } /// Returns the parent of this module. + #[inline] pub fn parent(self) -> Module<'scope> { // Safety: the pointer points to valid data, the parent is never null unsafe { @@ -73,6 +102,7 @@ impl<'scope> Module<'scope> { } /// Extend the lifetime of this module. This is safe as long as the module is never redefined. + #[inline] pub unsafe fn extend<'target, T>(self, _: &T) -> Module<'target> where T: Target<'target>, @@ -80,30 +110,115 @@ impl<'scope> Module<'scope> { Module::wrap_non_null(self.unwrap_non_null(Private), Private) } + /// Access the global at `path`. The result is cached for faster lookup in the future. + /// + /// Safety: + /// + /// This method assumes the global remains globally rooted. Only use this method to access + /// module constants and globals which are never replaced with another value. + #[inline(never)] + pub unsafe fn typed_global_cached<'target, T, S, Tgt>(target: &Tgt, path: S) -> JlrsResult + where + T: ConstructType + Managed<'target, 'static> + Typecheck, + S: AsRef, + Tgt: Target<'target>, + { + let tid = T::type_id(); + let data = &CACHE.get_unchecked().data; + let path = path.as_ref(); + + { + if let Some(cached) = data.read().get(path.as_bytes()) { + if cached.0 == tid { + return Ok(cached.1.cast_unchecked()); + } else { + let ty = T::construct_type(target).as_value(); + Err(TypeError::NotA { + value: cached.1.display_string_or(""), + field_type: ty.display_string_or(""), + })? + } + } + } + + let mut parts = path.split('.'); + let n_parts = parts.clone().count(); + let module_name = parts.next().unwrap(); + + let mut module = match module_name { + "Main" => Module::main(&target), + "Base" => Module::base(&target), + "Core" => Module::core(&target), + "JlrsCore" => JlrsCore::module(&target), + module => { + if let Some(module) = Module::package_root_module(&target, module) { + module + } else { + Err(AccessError::ModuleNotFound { + module: module_name.into(), + })? + } + } + }; + + let item = match n_parts { + 1 => module.as_value().cast::()?, + 2 => module + .global(&target, parts.next().unwrap())? + .as_value() + .cast::()?, + n => { + for _ in 1..n - 1 { + module = module + .submodule(&target, parts.next().unwrap())? + .as_managed(); + } + + module + .global(&target, parts.next().unwrap())? + .as_value() + .cast::()? + } + }; + + { + data.write().insert( + path.as_bytes().into(), + (tid, erase_scope_lifetime(item.as_value())), + ); + } + + Ok(item) + } + /// Returns a handle to Julia's `Main`-module. If you include your own Julia code with /// [`Julia::include`] or [`AsyncJulia::include`] its contents are made available relative to /// `Main`. /// /// [`Julia::include`]: crate::runtime::sync_rt::Julia::include /// [`AsyncJulia::include`]: crate::runtime::async_rt::AsyncJulia::include + #[inline] pub fn main>(_: &T) -> Self { // Safety: the Main module is globally rooted unsafe { Module::wrap_non_null(NonNull::new_unchecked(jl_main_module), Private) } } /// Returns a handle to Julia's `Core`-module. + #[inline] pub fn core>(_: &T) -> Self { // Safety: the Core module is globally rooted unsafe { Module::wrap_non_null(NonNull::new_unchecked(jl_core_module), Private) } } /// Returns a handle to Julia's `Base`-module. + #[inline] pub fn base>(_: &T) -> Self { // Safety: the Base module is globally rooted unsafe { Module::wrap_non_null(NonNull::new_unchecked(jl_base_module), Private) } } /// Returns `true` if `self` has imported `sym`. + #[inline] pub fn is_imported(self, sym: N) -> bool { // Safety: the pointer points to valid data, the C API function is called with // valid arguments. @@ -115,6 +230,7 @@ impl<'scope> Module<'scope> { #[julia_version(since = "1.8")] /// Returns the type of the binding in this module with the name `var`, + #[inline] pub fn binding_type<'target, N, T>( self, target: T, @@ -176,30 +292,31 @@ impl<'scope> Module<'scope> { target: &T, name: N, ) -> Option> { - static FUNC: OnceCell Value> = OnceCell::new(); - - let func = FUNC.get_or_init(|| unsafe { - let ptr = Module::main(&target) - .submodule(&target, "JlrsCore") - .unwrap() - .as_managed() - .global(&target, "root_module_c") - .unwrap() - .as_value() - .data_ptr() - .cast:: Value>() - .as_ptr(); - - *ptr - }); + static FUNC: GcSafeOnceLock Value> = GcSafeOnceLock::new(); + unsafe { + let func = FUNC.get_or_init(|| { + let ptr = Module::main(&target) + .submodule(&target, "JlrsCore") + .unwrap() + .as_managed() + .global(&target, "root_module_c") + .unwrap() + .as_value() + .data_ptr() + .cast() + .as_ptr(); + + *ptr + }); + + let name = name.to_symbol(&target); + let module = func(name); + if module.is::() { + return None; + } - let name = name.to_symbol(&target); - let module = unsafe { func(name) }; - if module.is::() { - return None; + Some(module.cast_unchecked()) } - - unsafe { Some(module.cast_unchecked()) } } /// Set a global value in this module. Note that if this global already exists, this can @@ -213,32 +330,23 @@ impl<'scope> Module<'scope> { target: T, name: N, value: Value<'_, 'static>, - ) -> T::Exception<'static, ()> + ) -> TargetException<'target, 'static, (), T> where N: ToSymbol, T: Target<'target>, { - use std::mem::MaybeUninit; - - use crate::catch::catch_exceptions; let symbol = name.to_symbol_priv(Private); - let mut callback = |result: &mut MaybeUninit<()>| { + let callback = || { jl_set_global( self.unwrap(Private), symbol.unwrap(Private), value.unwrap(Private), - ); - - result.write(()); - Ok(()) - }; - - let res = match catch_exceptions(&mut callback).unwrap() { - Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + ) }; + let exc = |err: Value| err.unwrap_non_null(Private); + let res = catch_exceptions(callback, exc); target.exception_from_ptr(res, Private) } @@ -247,6 +355,7 @@ impl<'scope> Module<'scope> { /// /// Safety: Mutating Julia data is generally unsafe because it can't be guaranteed mutating /// this value is allowed. + #[inline] pub unsafe fn set_global_unchecked(self, name: N, value: Value<'_, 'static>) where N: ToSymbol, @@ -268,7 +377,7 @@ impl<'scope> Module<'scope> { target: T, name: N, value: Value<'_, 'static>, - ) -> T::Exception<'static, Value<'scope, 'static>> + ) -> TargetException<'target, 'static, Value<'scope, 'static>, T> where N: ToSymbol, T: Target<'target>, @@ -277,28 +386,24 @@ impl<'scope> Module<'scope> { // valid arguments and its result is checked. if an exception is thrown it's caught // and returned unsafe { - use std::mem::MaybeUninit; - - use crate::catch::catch_exceptions; let symbol = name.to_symbol_priv(Private); - let mut callback = |result: &mut MaybeUninit<()>| { + let callback = || { jl_set_const( self.unwrap(Private), symbol.unwrap(Private), value.unwrap(Private), ); - - result.write(()); - Ok(()) }; - let res = match catch_exceptions(&mut callback).unwrap() { + let exc = |err: Value| err.unwrap_non_null(Private); + + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(Value::wrap_non_null( value.unwrap_non_null(Private), Private, )), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.exception_from_ptr(res, Private) @@ -309,6 +414,7 @@ impl<'scope> Module<'scope> { /// otherwise an unrooted reference to the constant is returned. /// /// Safety: This method must not throw an error if called from a `ccall`ed function. + #[inline] pub unsafe fn set_const_unchecked( self, name: N, @@ -402,10 +508,8 @@ impl<'scope> Module<'scope> { T: Target<'target>, N: ToSymbol, { - Module::base(&target) - .function(&target, "require") + Module::typed_global_cached::(&target, "Base.require") .unwrap() - .as_managed() .call2( target, self.as_value(), @@ -424,16 +528,18 @@ impl<'scope> ManagedPriv<'scope, '_> for Module<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Module<'_>, jl_module_type); +impl_construct_type_managed!(Module, 1, jl_module_type); /// A reference to a [`Module`] that has not been explicitly rooted. pub type ModuleRef<'scope> = Ref<'scope, 'static, Module<'scope>>; @@ -442,15 +548,167 @@ pub type ModuleRef<'scope> = Ref<'scope, 'static, Module<'scope>>; /// `ccall`able functions that return a [`Module`]. pub type ModuleRet = Ref<'static, 'static, Module<'static>>; -impl_valid_layout!(ModuleRef, Module); +impl_valid_layout!(ModuleRef, Module, jl_module_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Module` or `ModuleRef`, depending on the target type `T`. pub type ModuleData<'target, T> = >::Data<'static, Module<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type ModuleResult<'target, T> = >::Result<'static, Module<'target>>; +pub type ModuleResult<'target, T> = TargetResult<'target, 'static, Module<'target>, T>; impl_ccall_arg_managed!(Module, 1); impl_into_typed!(Module); + +pub struct JlrsCore; + +impl JlrsCore { + #[inline] + pub fn module<'target, Tgt>(target: &Tgt) -> Module<'target> + where + Tgt: Target<'target>, + { + inline_static_ref!(MODULE, Module, "JlrsCore", target) + } + + #[inline] + pub fn borrow_error<'target, Tgt>(target: &Tgt) -> DataType<'target> + where + Tgt: Target<'target>, + { + inline_static_ref!(BORROW_ERROR, DataType, "JlrsCore.BorrowError", target) + } + + #[inline] + pub fn jlrs_error<'target, Tgt>(target: &Tgt) -> DataType<'target> + where + Tgt: Target<'target>, + { + inline_static_ref!(JLRS_ERROR, DataType, "JlrsCore.JlrsError", target) + } + + #[inline] + pub fn rust_result<'target, Tgt>(target: &Tgt) -> UnionAll<'target> + where + Tgt: Target<'target>, + { + inline_static_ref!(RUST_RESULT, UnionAll, "JlrsCore.RustResult", target) + } + + #[inline] + pub fn set_pool_size<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!(SET_POOL_SIZE, Function, "JlrsCore.set_pool_size", target) + } + + #[inline] + pub fn value_string<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!(VALUE_STRING, Function, "JlrsCore.valuestring", target) + } + + #[inline] + pub fn error_string<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!(ERROR_STRING, Function, "JlrsCore.errorstring", target) + } + + #[inline] + pub fn call_catch_wrapper<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!( + CALL_CATCH_WRAPPER, + Function, + "JlrsCore.call_catch_wrapper", + target + ) + } + + #[inline] + pub fn call_catch_wrapper_c<'target, Tgt>(target: &Tgt) -> Value<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!( + CALL_CATCH_WRAPPER, + Value, + "JlrsCore.call_catch_wrapper_c", + target + ) + } + + #[cfg(feature = "async")] + #[inline] + pub(crate) fn async_call<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!(ASYNC_CALL, Function, "JlrsCore.Threads.asynccall", target) + } + + #[cfg(feature = "async")] + #[cfg(not(any(feature = "julia-1-6", feature = "julia-1-7", feature = "julia-1-8")))] + #[inline] + pub(crate) fn interactive_call<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!( + INTERACTIVE_CALL, + Function, + "JlrsCore.Threads.interactivecall", + target + ) + } + + #[cfg(feature = "async")] + #[inline] + pub(crate) fn schedule_async<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!( + SCHEDULE_ASYNC, + Function, + "JlrsCore.Threads.scheduleasync", + target + ) + } + + #[cfg(feature = "async")] + #[inline] + pub(crate) fn schedule_async_local<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!( + SCHEDULE_ASYNC_LOCAL, + Function, + "JlrsCore.Threads.scheduleasynclocal", + target + ) + } + + #[cfg(feature = "async")] + #[inline] + pub(crate) fn post_blocking<'target, Tgt>(target: &Tgt) -> Function<'target, 'static> + where + Tgt: Target<'target>, + { + inline_static_ref!( + POST_BLOCKING, + Function, + "JlrsCore.Threads.postblocking", + target + ) + } +} diff --git a/jlrs/src/data/managed/parachute.rs b/jlrs/src/data/managed/parachute.rs index e61fb0f9..7296cd3a 100644 --- a/jlrs/src/data/managed/parachute.rs +++ b/jlrs/src/data/managed/parachute.rs @@ -24,10 +24,8 @@ use crate::{ managed::{datatype::DataType, module::Module, symbol::Symbol, value::Value}, types::foreign_type::{create_foreign_type_internal, ForeignType}, }, - memory::{ - stack_frame::StackFrame, - target::{unrooted::Unrooted, RootingTarget}, - }, + memory::{stack_frame::StackFrame, target::unrooted::Unrooted}, + prelude::Target, private::Private, }; @@ -78,15 +76,13 @@ pub trait AttachParachute: 'static + Sized + Send + Sync { /// /// By attaching a parachute, you move ownership of the data from Rust to Julia. This ensures /// the data is freed by Julia's GC after it has become unreachable. - fn attach_parachute<'scope, T: RootingTarget<'scope>>( - self, - target: T, - ) -> WithParachute<'scope, Self> { - let output = target.into_output(); + // FIXME + fn attach_parachute<'scope, T: Target<'scope>>(self, target: T) -> WithParachute<'scope, Self> { let parachute = Parachute { _data: Some(self) }; - let data = Value::new(output, parachute); + let data = Value::new(&target, parachute); unsafe { - let mut ptr: NonNull> = data.unwrap_non_null(Private).cast(); + data.root(target); + let mut ptr: NonNull> = data.ptr().cast(); WithParachute { data: ptr.as_mut() } } } diff --git a/jlrs/src/data/managed/rust_result.rs b/jlrs/src/data/managed/rust_result.rs index 2a931173..a0e1698c 100644 --- a/jlrs/src/data/managed/rust_result.rs +++ b/jlrs/src/data/managed/rust_result.rs @@ -1,18 +1,20 @@ //! Managed type for `JlrsCore.RustResult`. //! -//! Functions written in Rust that are called from Julia can't arbitrarily throw an exception. +//! Previous versions of jlrs could not throw exceptions from an exported function. This +//! restriction has been lifted and `RustResult` has been deprecated. A function that may throw +//! should return `JlrsResult` or `Result`. +//! //! `RustResult{T}` is a type provided by the JlrsCore package that contains either data or an //! exception. It can be converted to `T`, if it contains an exception that exception is thrown. //! -//! This is useful when writing functions that are exported to Julia with the [`julia_module`] -//! macro. By returning a [`RustResult`], this conversion is automatically invoked by the -//! generated Julia function. -//! //! [`julia_module`]: jlrs_macros::julia_module +#![allow(deprecated)] + use std::{marker::PhantomData, ptr::NonNull}; use super::{ + module::JlrsCore, union_all::UnionAll, value::{typed::TypedValue, ValueData}, Ref, @@ -31,131 +33,121 @@ use crate::{ value::{Value, ValueRef}, Managed, }, - types::{abstract_types::AnyType, construct_type::ConstructType}, + types::construct_type::ConstructType, }, error::JlrsError, - inline_static_global, - memory::target::{target_type::TargetType, ExtendedTarget, Target}, + inline_static_ref, + memory::target::{Target, TargetResult, TargetType}, private::Private, }; + /// A `RustResult` can contain either typed data or an exception. +#[deprecated( + since = "0.19.0", + note = "exceptions should be thrown from exported functions by returning JlrsResult or Result" +)] #[derive(PartialEq)] #[repr(transparent)] pub struct RustResult<'scope, 'data, U: ConstructType>(NonNull>); impl<'target, 'data, U: ConstructType> RustResult<'target, 'data, U> { /// Constructs a `RustResult` that contains data. - pub fn ok>( - target: ExtendedTarget<'target, '_, '_, T>, + pub fn ok>( + target: Tgt, data: TypedValue<'_, 'data, U>, - ) -> RustResultData<'target, 'data, U, T> { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let unrooted = frame.unrooted(); + ) -> RustResultData<'target, 'data, U, Tgt> { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let unrooted = target.unrooted(); unsafe { - let instance = Self::construct_type(frame.as_extended_target()) + let res = Self::construct_type(&mut frame) .cast_unchecked::() - .instantiate_unchecked(&frame, [data.as_value(), Value::false_v(&unrooted)]) + .instantiate_unchecked( + unrooted, + [data.as_value(), Value::false_v(&unrooted)], + ) .as_value() .cast_unchecked::>() .root(target); - Ok(instance) + Ok(res) } }) .unwrap() } /// Constructs a `RustResult` that contains an exception. - pub fn error>( - target: ExtendedTarget<'target, '_, '_, T>, + pub fn error>( + target: Tgt, error: Value<'_, 'data>, - ) -> RustResultData<'target, 'data, U, T> { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let unrooted = frame.unrooted(); + ) -> RustResultData<'target, 'data, U, Tgt> { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let unrooted = target.unrooted(); unsafe { - let instance = Self::construct_type(frame.as_extended_target()) + let res = Self::construct_type(&mut frame) + .as_value() .cast_unchecked::() - .instantiate_unchecked(&frame, [error, Value::true_v(&unrooted)]) + .instantiate_unchecked( + unrooted, + [error.as_value(), Value::true_v(&unrooted)], + ) .as_value() .cast_unchecked::>() .root(target); - Ok(instance) + Ok(res) } }) .unwrap() } /// Constructs a `RustResult` that contains a `JlrsCore.BorrowException`. - pub fn borrow_error>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> RustResultData<'target, 'data, U, T> { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let unrooted = frame.unrooted(); - unsafe { - let error = Module::main(&unrooted) - .submodule(unrooted, "JlrsCore") - .unwrap() - .as_managed() - .global(unrooted, "BorrowError") - .unwrap() - .as_value() - .cast_unchecked::() - .instance() - .unwrap(); - - let instance = Self::construct_type(frame.as_extended_target()) - .cast_unchecked::() - .instantiate_unchecked(&frame, [error, Value::true_v(&unrooted)]) - .as_value() - .cast_unchecked::>() - .root(target); - - Ok(instance) - } + pub fn borrow_error>( + target: Tgt, + ) -> RustResultData<'target, 'data, U, Tgt> { + let unrooted = target.unrooted(); + target + .with_local_scope::<_, _, 1>(|target, mut frame| unsafe { + let error = JlrsCore::borrow_error(&unrooted).instance().unwrap(); + let instance = Self::construct_type(&mut frame) + .as_value() + .cast_unchecked::() + .instantiate_unchecked(unrooted, [error, Value::true_v(&unrooted)]) + .as_value() + .cast_unchecked::>() + .root(target); + + Ok(instance) }) .unwrap() } /// Constructs a `RustResult` that contains `error`, which is converted to a `JlrsCore.JlrsError`. - pub fn jlrs_error>( - target: ExtendedTarget<'target, '_, '_, T>, + pub fn jlrs_error>( + target: Tgt, error: JlrsError, - ) -> RustResultData<'target, 'data, U, T> { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let unrooted = frame.unrooted(); - unsafe { - let msg = JuliaString::new(&mut frame, format!("{}", error)); - let error = Module::main(&unrooted) - .submodule(unrooted, "JlrsCore") - .unwrap() - .as_managed() - .global(unrooted, "JlrsError") - .unwrap() - .as_value() - .cast_unchecked::() - .instantiate_unchecked(&mut frame, [msg.as_value()]); - - let ty = Self::construct_type(frame.as_extended_target()) - .cast_unchecked::(); - Ok(ty - .instantiate_unchecked(&frame, [error, Value::true_v(&unrooted)]) - .as_value() - .cast_unchecked::>() - .root(target)) - } + ) -> RustResultData<'target, 'data, U, Tgt> { + let unrooted = target.unrooted(); + target + .with_local_scope::<_, _, 3>(|target, mut frame| unsafe { + let msg = JuliaString::new(&mut frame, format!("{}", error)); + let error = Module::main(&unrooted) + .submodule(unrooted, "JlrsCore") + .unwrap() + .as_managed() + .global(unrooted, "JlrsError") + .unwrap() + .as_value() + .cast_unchecked::() + .instantiate_unchecked(&mut frame, [msg.as_value()]); + + let ty = Self::construct_type(&mut frame).cast_unchecked::(); + Ok(ty + .instantiate_unchecked(&frame, [error, Value::true_v(&unrooted)]) + .as_value() + .cast_unchecked::>() + .root(target)) }) .unwrap() } @@ -181,7 +173,7 @@ impl<'target, 'data, U: ConstructType> RustResult<'target, 'data, U> { .instance() .unwrap(); - let instance = Self::construct_type(frame.as_extended_target()) + let instance = Self::construct_type(&mut frame) .cast_unchecked::() .instantiate_unchecked(&frame, [error, Value::true_v(&unrooted)]) .as_value() @@ -220,26 +212,29 @@ impl<'scope, 'data, U: ConstructType> ManagedPriv<'scope, 'data> for RustResult< // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } unsafe impl<'scope, 'data, U: ConstructType> ConstructType for RustResult<'scope, 'data, U> { - fn construct_type<'target, 'current, 'borrow, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = RustResult<'static, 'static, U::Static>; + + fn construct_type_uncached<'target, 'current, 'borrow, Tgt>( + target: Tgt, + ) -> ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, frame) = target.split(); - frame - .scope(|mut frame| { - let param_ty = U::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let param_ty = U::construct_type(&mut frame); unsafe { let ty = Self::base_type(&frame) .unwrap_unchecked() @@ -258,7 +253,7 @@ unsafe impl<'scope, 'data, U: ConstructType> ConstructType for RustResult<'scope where Tgt: Target<'target>, { - let base_type = inline_static_global!(BASE_TYPE, "JlrsCore.RustResult", target); + let base_type = inline_static_ref!(BASE_TYPE, Value, "JlrsCore.RustResult", target); Some(base_type) } } @@ -298,13 +293,19 @@ pub type RustResultData<'target, 'data, U, T> = /// `JuliaResult>` or `JuliaResultRef>`, depending on the target type `T`. pub type RustResultResult<'target, 'data, U, T> = - >::Result<'data, RustResult<'target, 'data, U>>; + TargetResult<'target, 'data, RustResult<'target, 'data, U>, T>; unsafe impl CCallReturn for Ref<'static, 'static, RustResult<'static, 'static, U>> { - type CCallReturnType = AnyType; + type CCallReturnType = Value<'static, 'static>; type FunctionReturnType = U; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } /// The layout of a [`RustResult`]. diff --git a/jlrs/src/data/managed/simple_vector.rs b/jlrs/src/data/managed/simple_vector.rs index 70498043..50ca34ee 100644 --- a/jlrs/src/data/managed/simple_vector.rs +++ b/jlrs/src/data/managed/simple_vector.rs @@ -22,7 +22,7 @@ use crate::{ types::typecheck::Typecheck, }, error::{AccessError, JlrsResult}, - memory::target::{unrooted::Unrooted, Target}, + memory::target::{unrooted::Unrooted, Target, TargetResult}, private::Private, }; @@ -36,16 +36,27 @@ pub struct SimpleVectorContent<'scope, 'borrow, T = ValueRef<'scope, 'static>>( impl<'scope, 'borrow, T: ManagedRef<'scope, 'static>> SimpleVectorContent<'scope, 'borrow, T> { /// Returns the length of this `SimpleVector`. + #[inline] pub fn len(&self) -> usize { // Safety: the pointer points to valid data unsafe { self.0.as_ref().length } } /// Returns the content of this `SimpleVector` as a slice. + #[inline] pub fn as_slice(&self) -> &'borrow [Option] { // Safety: the C API function is called with valid data unsafe { std::slice::from_raw_parts(jl_svec_data(self.0.as_ptr()).cast(), self.len()) } } + + /// Returns the content of this `SimpleVector` as a slice. + /// + /// Safety: the `SimpleVector` must not contain any undefined references. + #[inline] + pub unsafe fn as_slice_non_null_managed(&self) -> &'borrow [T::Managed] { + // Safety: the C API function is called with valid data + std::slice::from_raw_parts(jl_svec_data(self.0.as_ptr()).cast(), self.len()) + } } /// Access and mutate the content of a `SimpleVector`. @@ -60,12 +71,14 @@ where impl<'scope, 'borrow, T: ManagedRef<'scope, 'static>> SimpleVectorContentMut<'scope, 'borrow, T> { /// Returns the length of this `SimpleVector`. + #[inline] pub fn len(&self) -> usize { // Safety: the pointer points to valid data unsafe { self.0.as_ref().length } } /// Returns the contents of this `SimpleVector` as a slice. + #[inline] pub fn as_slice(&self) -> &'borrow [Option] { // Safety: the C API function is called with valid data unsafe { std::slice::from_raw_parts(jl_svec_data(self.0.as_ptr()).cast(), self.len()) } @@ -108,6 +121,7 @@ pub struct SimpleVector<'scope>(NonNull, PhantomData<&'scope ()>); impl<'scope> SimpleVector<'scope> { /// Create a new `SimpleVector` that can hold `n` values. + #[inline] pub fn with_capacity(target: T, n: usize) -> SimpleVectorData<'scope, T> where T: Target<'scope>, @@ -123,6 +137,7 @@ impl<'scope> SimpleVector<'scope> { /// /// Safety: The contents must be set before calling Julia again, the contents must never be /// accessed before all elements are set. + #[inline] pub unsafe fn with_capacity_uninit(target: T, n: usize) -> SimpleVectorData<'scope, T> where T: Target<'scope>, @@ -133,11 +148,13 @@ impl<'scope> SimpleVector<'scope> { /// Access the contents of this `SimpleVector` as `ValueRef`. // TODO: ledger + #[inline] pub fn data<'borrow>(&'borrow self) -> SimpleVectorContent<'scope, 'borrow> { SimpleVectorContent(self.unwrap_non_null(Private), PhantomData, PhantomData) } /// Mutably ccess the contents of this `SimpleVector` as `ValueRef`. + #[inline] pub unsafe fn data_mut<'borrow>(&'borrow mut self) -> SimpleVectorContentMut<'scope, 'borrow> { SimpleVectorContentMut(self.unwrap_non_null(Private), PhantomData, PhantomData) } @@ -192,6 +209,7 @@ impl<'scope> SimpleVector<'scope> { /// Access the contents of this `SimpleVector` as `U`. /// /// Safety: this method doesn't check if `U` is correct for all elements. + #[inline] pub unsafe fn typed_data_unchecked<'borrow, U>( &'borrow self, ) -> SimpleVectorContent<'scope, 'borrow, U> @@ -204,6 +222,7 @@ impl<'scope> SimpleVector<'scope> { /// Mutably access the contents of this `SimpleVector` as `U`. /// /// Safety: this method doesn't check if `U` is correct for all elements. + #[inline] pub unsafe fn typed_data_mut_unchecked<'borrow, U>( &'borrow mut self, ) -> SimpleVectorContentMut<'scope, 'borrow, U> @@ -242,14 +261,21 @@ impl<'scope> SimpleVector<'scope> { } /// Returns the length of this `SimpleVector`. + #[inline] pub fn len(&self) -> usize { // Safety: the pointer points to valid data unsafe { self.0.as_ref().length } } + + #[inline] + pub unsafe fn value_slice_unchecked<'a>(&'a self) -> &'a [Value<'scope, 'static>] { + unsafe { std::slice::from_raw_parts(jl_svec_data(self.0.as_ptr()).cast(), self.len()) } + } } impl<'base> SimpleVector<'base> { /// The empty `SimpleVector`. + #[inline] pub fn emptysvec>(_: &T) -> Self { // Safety: global constant unsafe { Self::wrap_non_null(NonNull::new_unchecked(jl_emptysvec), Private) } @@ -258,6 +284,7 @@ impl<'base> SimpleVector<'base> { // Safety: if the type is jl_simplevector_type the data is an SimpleVector unsafe impl<'scope> Typecheck for SimpleVector<'scope> { + #[inline] fn typecheck(t: DataType) -> bool { // Safety: can only be called from a thread known to Julia t == DataType::simplevector_type(unsafe { &Unrooted::new() }) @@ -280,16 +307,18 @@ impl<'scope> ManagedPriv<'scope, '_> for SimpleVector<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(SimpleVector<'_>, jl_simplevector_type); +impl_construct_type_managed!(SimpleVector, 1, jl_simplevector_type); /// A reference to a [`SimpleVector`] that has not been explicitly rooted. pub type SimpleVectorRef<'scope> = Ref<'scope, 'static, SimpleVector<'scope>>; @@ -299,20 +328,29 @@ pub type SimpleVectorRef<'scope> = Ref<'scope, 'static, SimpleVector<'scope>>; pub type SimpleVectorRet = Ref<'static, 'static, SimpleVector<'static>>; unsafe impl<'scope> ValidLayout for SimpleVectorRef<'scope> { + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + DataType::simplevector_type(target).as_value() + } + const IS_REF: bool = true; } unsafe impl<'scope> ValidField for Option> { + #[inline] fn valid_field(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; dt.is::() } else { false @@ -320,7 +358,7 @@ unsafe impl<'scope> ValidField for Option> { } } -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `SimpleVector` or `SimpleVectorRef`, depending on the target type `T`. pub type SimpleVectorData<'target, T> = @@ -328,8 +366,7 @@ pub type SimpleVectorData<'target, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. -pub type SimpleVectorResult<'target, T> = - >::Result<'static, SimpleVector<'target>>; +pub type SimpleVectorResult<'target, T> = TargetResult<'target, 'static, SimpleVector<'target>, T>; impl_ccall_arg_managed!(SimpleVector, 1); impl_into_typed!(SimpleVector); diff --git a/jlrs/src/data/managed/string.rs b/jlrs/src/data/managed/string.rs index 0a4f99fd..34ca3547 100644 --- a/jlrs/src/data/managed/string.rs +++ b/jlrs/src/data/managed/string.rs @@ -17,7 +17,7 @@ use crate::{ data::managed::{private::ManagedPriv, value::Value}, error::{JlrsError, JlrsResult}, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -28,6 +28,7 @@ pub struct JuliaString<'scope>(*const u8, PhantomData<&'scope ()>); impl<'scope> JuliaString<'scope> { /// Create a new Julia string. + #[inline] pub fn new<'target, V, T>(target: T, string: V) -> StringData<'target, T> where V: AsRef, @@ -43,6 +44,7 @@ impl<'scope> JuliaString<'scope> { } /// Create a new Julia string. + #[inline] pub fn new_bytes<'target, V, T>(target: T, bytes: V) -> StringData<'target, T> where V: AsRef<[u8]>, @@ -58,6 +60,7 @@ impl<'scope> JuliaString<'scope> { } /// Returns the length of the string. + #[inline] pub fn len(self) -> usize { // Safety: the pointer points to valid data, the length of the array is stored at the // beginning @@ -65,6 +68,7 @@ impl<'scope> JuliaString<'scope> { } /// Returns the string as a `CStr`. + #[inline] pub fn as_c_str(self) -> &'scope CStr { // Safety: The string is terminated with a null character. unsafe { @@ -74,6 +78,7 @@ impl<'scope> JuliaString<'scope> { } /// Returns the string as a slice of bytes, including all null characters.. + #[inline] pub fn as_bytes(self) -> &'scope [u8] { unsafe { let len = self.len(); @@ -84,6 +89,7 @@ impl<'scope> JuliaString<'scope> { /// Returns the string as a string slice, or an error if it the string contains /// invalid characters + #[inline] pub fn as_str(self) -> JlrsResult<&'scope str> { Ok(str::from_utf8(self.as_c_str().to_bytes()).map_err(JlrsError::other)?) } @@ -91,17 +97,19 @@ impl<'scope> JuliaString<'scope> { /// Returns the string as a string slice without checking if the string is properly encoded. /// /// Safety: the string must be properly encoded. + #[inline] pub unsafe fn as_str_unchecked(self) -> &'scope str { str::from_utf8_unchecked(self.as_c_str().to_bytes()) } } -impl_construct_type_managed!(JuliaString<'_>, jl_string_type); +impl_construct_type_managed!(JuliaString, 1, jl_string_type); impl_julia_typecheck!(JuliaString<'scope>, jl_string_type, 'scope); unsafe impl Unbox for String { type Output = Result>; + #[inline] unsafe fn unbox(value: Value) -> Self::Output { let s = value.cast_unchecked::(); match s.as_str() { @@ -124,10 +132,12 @@ impl<'scope> ManagedPriv<'scope, '_> for JuliaString<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { JuliaString(inner.as_ptr(), PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { unsafe { NonNull::new_unchecked(self.0 as *mut _) } } @@ -140,16 +150,15 @@ pub type StringRef<'scope> = Ref<'scope, 'static, JuliaString<'scope>>; /// `ccall`able functions that return a [`JuliaString`]. pub type StringRet = Ref<'static, 'static, JuliaString<'static>>; -impl_valid_layout!(StringRef, JuliaString); +impl_valid_layout!(StringRef, JuliaString, jl_string_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `JuliaString` or `StringRef`, depending on the target type `T`. pub type StringData<'target, T> = >::Data<'static, JuliaString<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type StringResult<'target, T> = - >::Result<'static, JuliaString<'target>>; +pub type StringResult<'target, T> = TargetResult<'target, 'static, JuliaString<'target>, T>; impl_ccall_arg_managed!(JuliaString, 1); impl_into_typed!(JuliaString); diff --git a/jlrs/src/data/managed/symbol.rs b/jlrs/src/data/managed/symbol.rs index 53d20685..0882ee2a 100644 --- a/jlrs/src/data/managed/symbol.rs +++ b/jlrs/src/data/managed/symbol.rs @@ -4,10 +4,10 @@ use std::{ ffi::CStr, hash::{Hash, Hasher}, marker::PhantomData, - mem::MaybeUninit, ptr::NonNull, }; +use fxhash::FxHashMap; use jl_sys::{ jl_gensym, jl_sym_t, jl_symbol_n, jl_symbol_name_ as jl_symbol_name, jl_symbol_type, jl_tagged_gensym, @@ -18,11 +18,34 @@ use crate::{ catch::catch_exceptions, data::managed::private::ManagedPriv, error::{JlrsError, JlrsResult}, + gc_safe::{GcSafeOnceLock, GcSafeRwLock}, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetException, TargetResult}, + prelude::Value, private::Private, }; +struct SymbolCache { + data: GcSafeRwLock, Symbol<'static>>>, +} + +impl SymbolCache { + fn new() -> Self { + SymbolCache { + data: GcSafeRwLock::default(), + } + } +} + +unsafe impl Send for SymbolCache {} +unsafe impl Sync for SymbolCache {} + +static CACHE: GcSafeOnceLock = GcSafeOnceLock::new(); + +pub(crate) unsafe fn init_symbol_cache() { + CACHE.set(SymbolCache::new()).ok(); +} + /// `Symbol`s are used Julia to represent identifiers, `:x` represents the `Symbol` `x`. Things /// that can be accessed using a `Symbol` include submodules, functions, and globals. However, /// the methods that provide this functionality in jlrs can use strings instead. They're also used @@ -36,57 +59,96 @@ pub struct Symbol<'scope>(NonNull, PhantomData<&'scope ()>); impl<'scope> Symbol<'scope> { /// Convert the given string to a `Symbol`. + #[inline] pub fn new(_: &T, symbol: S) -> Self where S: AsRef, T: Target<'scope>, { let bytes = symbol.as_ref().as_bytes(); + let data = unsafe { &CACHE.get_unchecked().data }; + + { + if let Some(sym) = data.read().get(bytes) { + return *sym; + } + } + // Safety: Can only be called from a thread known to Julia, symbols are globally rooted unsafe { let sym = jl_symbol_n(bytes.as_ptr().cast(), bytes.len()); - Symbol::wrap_non_null(NonNull::new_unchecked(sym), Private) + let sym = Symbol::wrap_non_null(NonNull::new_unchecked(sym), Private); + data.write().insert(bytes.to_vec(), sym); + sym } } /// Convert the given byte slice to a `Symbol`. - pub fn new_bytes(target: T, symbol: N) -> T::Exception<'static, Self> + pub fn new_bytes(target: T, symbol: N) -> TargetException<'scope, 'static, Self, T> where N: AsRef<[u8]>, T: Target<'scope>, { + let bytes = symbol.as_ref(); + let data = unsafe { &CACHE.get_unchecked().data }; + + { + if let Some(sym) = data.read().get(bytes) { + unsafe { + return target.exception_from_ptr(Ok(*sym), Private); + } + } + } + unsafe { - let symbol = symbol.as_ref(); + let callback = || jl_symbol_n(bytes.as_ptr().cast(), bytes.len()); - let mut callback = |result: &mut MaybeUninit<*mut jl_sym_t>| { - let sym = jl_symbol_n(symbol.as_ptr().cast(), symbol.len()); - result.write(sym); - Ok(()) - }; + let exc = |err: Value| err.unwrap_non_null(Private); + // let exc = |err: Value| Ok(Ref::::wrap(err.unwrap_non_null(Private))); - let res = match catch_exceptions(&mut callback).unwrap() { - Ok(sym) => Ok(Symbol::wrap_non_null(NonNull::new_unchecked(sym), Private)), - Err(e) => Err(e.ptr()), - }; + match catch_exceptions(callback, exc) { + Ok(sym) => { + let sym = Symbol::wrap_non_null(NonNull::new_unchecked(sym), Private); + data.write().insert(bytes.to_vec(), sym); - target.exception_from_ptr(res, Private) + Ok(sym) + } + Err(e) => target.exception_from_ptr(Err(e), Private), + } } } /// Convert the given byte slice to a `Symbol`. /// /// Safety: if `symbol` contains `0`, an error is thrown which is not caught. + #[inline] pub unsafe fn new_bytes_unchecked(_: &T, symbol: S) -> Self where S: AsRef<[u8]>, T: Target<'scope>, { - let sym_b = symbol.as_ref(); - let sym = jl_symbol_n(sym_b.as_ptr().cast(), sym_b.len()); - Symbol::wrap_non_null(NonNull::new_unchecked(sym), Private) + let bytes = symbol.as_ref(); + let data = unsafe { &CACHE.get_unchecked().data }; + + { + if let Some(sym) = data.read().get(bytes) { + return *sym; + } + } + + // Safety: Can only be called from a thread known to Julia, symbols are globally rooted + unsafe { + let sym = jl_symbol_n(bytes.as_ptr().cast(), bytes.len()); + let sym = Symbol::wrap_non_null(NonNull::new_unchecked(sym), Private); + + data.write().insert(bytes.to_vec(), sym); + + sym + } } /// Generate a new unique `Symbol`. + #[inline] pub fn generate(_: &T) -> Self where T: Target<'scope>, @@ -98,6 +160,7 @@ impl<'scope> Symbol<'scope> { } /// Generate a new unique tagged `Symbol`. + #[inline] pub fn generate_tagged(_: &T, tag: S) -> Self where S: AsRef, @@ -114,6 +177,7 @@ impl<'scope> Symbol<'scope> { /// lifetime can be safely extended. /// /// [`Value`]: crate::data::managed::value::Value + #[inline] pub fn extend<'target, T>(self, _: &T) -> Symbol<'target> where T: Target<'target>, @@ -123,17 +187,20 @@ impl<'scope> Symbol<'scope> { } /// The hash of this `Symbol`. + #[inline] pub fn hash(self) -> usize { // Safety: symbols are globally rooted unsafe { self.unwrap_non_null(Private).as_ref().hash } } /// Convert `self` to a `String`. + #[inline] pub fn as_string(self) -> JlrsResult { self.as_str().map(Into::into) } /// View `self` as a string slice. Returns an error if the symbol is not valid UTF8. + #[inline] pub fn as_str(self) -> JlrsResult<&'scope str> { // Safety: symbols are globally rooted unsafe { @@ -144,6 +211,7 @@ impl<'scope> Symbol<'scope> { } /// View `self` as a `Cstr`. + #[inline] pub fn as_cstr(self) -> &'scope CStr { // Safety: symbols are globally rooted unsafe { @@ -153,6 +221,7 @@ impl<'scope> Symbol<'scope> { } /// View `self` as an slice of bytes without the trailing null. + #[inline] pub fn as_bytes(self) -> &'scope [u8] { // Safety: symbols are globally rooted unsafe { @@ -164,6 +233,7 @@ impl<'scope> Symbol<'scope> { } impl Hash for Symbol<'_> { + #[inline] fn hash(&self, state: &mut H) { state.write_usize((*self).hash()) } @@ -179,16 +249,18 @@ impl<'scope> ManagedPriv<'scope, '_> for Symbol<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Symbol<'_>, jl_symbol_type); +impl_construct_type_managed!(Symbol, 1, jl_symbol_type); /// A reference to a [`Symbol`] that has not been explicitly rooted. pub type SymbolRef<'scope> = Ref<'scope, 'static, Symbol<'scope>>; @@ -197,15 +269,15 @@ pub type SymbolRef<'scope> = Ref<'scope, 'static, Symbol<'scope>>; /// `ccall`able functions that return a [`Symbol`]. pub type SymbolRet = Ref<'static, 'static, Symbol<'static>>; -impl_valid_layout!(SymbolRef, Symbol); +impl_valid_layout!(SymbolRef, Symbol, jl_symbol_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Task` or `TaskRef`, depending on the target type `T`. pub type SymbolData<'target, T> = >::Data<'static, Symbol<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type SymbolResult<'target, T> = >::Result<'static, Symbol<'target>>; +pub type SymbolResult<'target, T> = TargetResult<'target, 'static, Symbol<'target>, T>; pub type SymbolUnbound = Symbol<'static>; diff --git a/jlrs/src/data/managed/task.rs b/jlrs/src/data/managed/task.rs index 0e49f9e1..ef824de5 100644 --- a/jlrs/src/data/managed/task.rs +++ b/jlrs/src/data/managed/task.rs @@ -14,7 +14,10 @@ use jl_sys::{jl_task_t, jl_task_type}; use jlrs_macros::julia_version; use super::Ref; -use crate::{data::managed::private::ManagedPriv, impl_julia_typecheck, private::Private}; +use crate::{ + data::managed::private::ManagedPriv, impl_julia_typecheck, memory::target::TargetResult, + private::Private, +}; #[cfg(feature = "extra-fields")] use crate::{ data::managed::value::{ValueData, ValueRef}, @@ -49,6 +52,7 @@ impl<'scope> Task<'scope> { /// Invasive linked list for scheduler #[cfg(feature = "extra-fields")] + #[inline] pub fn next<'target, T>(self, target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, @@ -63,6 +67,7 @@ impl<'scope> Task<'scope> { /// Invasive linked list for scheduler #[cfg(feature = "extra-fields")] + #[inline] pub fn queue<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -77,6 +82,7 @@ impl<'scope> Task<'scope> { /// The `tls` field, called `Task.storage` in Julia. #[cfg(feature = "extra-fields")] + #[inline] pub fn storage<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -91,6 +97,7 @@ impl<'scope> Task<'scope> { /// The `donenotify` field. #[cfg(feature = "extra-fields")] + #[inline] pub fn done_notify<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -105,6 +112,7 @@ impl<'scope> Task<'scope> { /// The `result` field. #[cfg(feature = "extra-fields")] + #[inline] pub fn result<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -119,6 +127,7 @@ impl<'scope> Task<'scope> { /// The `logstate` field. #[cfg(feature = "extra-fields")] + #[inline] pub fn log_state<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -133,6 +142,7 @@ impl<'scope> Task<'scope> { /// The `start` field. #[cfg(feature = "extra-fields")] + #[inline] pub fn start<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -148,6 +158,7 @@ impl<'scope> Task<'scope> { #[cfg(feature = "extra-fields")] #[julia_version(until = "1.6")] /// The `_state` field. + #[inline] pub fn state(self) -> u8 { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref()._state } @@ -156,6 +167,7 @@ impl<'scope> Task<'scope> { #[cfg(feature = "extra-fields")] #[julia_version(since = "1.7")] /// The `_state` field. + #[inline] pub fn state(self) -> u8 { // Safety: the pointer points to valid data unsafe { @@ -168,6 +180,7 @@ impl<'scope> Task<'scope> { /// Record whether this Task can be migrated to a new thread #[cfg(feature = "extra-fields")] + #[inline] pub fn sticky(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().sticky != 0 } @@ -176,6 +189,7 @@ impl<'scope> Task<'scope> { #[cfg(feature = "extra-fields")] #[julia_version(until = "1.6")] /// set if `result` is an exception to throw or that we exited with + #[inline] pub fn is_exception(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref()._isexception != 0 } @@ -184,6 +198,7 @@ impl<'scope> Task<'scope> { #[cfg(feature = "extra-fields")] #[julia_version(since = "1.7")] /// set if `result` is an exception to throw or that we exited with + #[inline] pub fn is_exception(self) -> bool { // Safety: the pointer points to valid data unsafe { @@ -206,16 +221,18 @@ impl<'scope> ManagedPriv<'scope, '_> for Task<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Task<'_>, jl_task_type); +impl_construct_type_managed!(Task, 1, jl_task_type); /// A reference to a [`Task`] that has not been explicitly rooted. pub type TaskRef<'scope> = Ref<'scope, 'static, Task<'scope>>; @@ -224,15 +241,15 @@ pub type TaskRef<'scope> = Ref<'scope, 'static, Task<'scope>>; /// `ccall`able functions that return a [`Task`]. pub type TaskRet = Ref<'static, 'static, Task<'static>>; -impl_valid_layout!(TaskRef, Task); +impl_valid_layout!(TaskRef, Task, jl_task_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Task` or `TaskRef`, depending on the target type `T`. pub type TaskData<'target, T> = >::Data<'static, Task<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type TaskResult<'target, T> = >::Result<'static, Task<'target>>; +pub type TaskResult<'target, T> = TargetResult<'target, 'static, Task<'target>, T>; impl_ccall_arg_managed!(Task, 1); impl_into_typed!(Task); diff --git a/jlrs/src/data/managed/type_name.rs b/jlrs/src/data/managed/type_name.rs index 0c036a43..79cd87e9 100644 --- a/jlrs/src/data/managed/type_name.rs +++ b/jlrs/src/data/managed/type_name.rs @@ -24,13 +24,13 @@ use crate::{ module::Module, private::ManagedPriv, simple_vector::SimpleVector, symbol::Symbol, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; cfg_if! { if #[cfg(feature = "extra-fields")] { - use crate::data::managed::{value::Value, simple_vector::{SimpleVectorRef, SimpleVectorData}}; + use crate::data::managed::{simple_vector::{SimpleVectorRef, SimpleVectorData}}; } } @@ -38,7 +38,7 @@ cfg_if! { cfg_if! { if #[cfg(feature = "extra-fields")] { use std::sync::atomic::Ordering; - use crate::data::managed::value::{ValueData, ValueRef}; + use crate::data::managed::value::{ValueData, Value, ValueRef}; } } @@ -70,6 +70,7 @@ impl<'scope> TypeName<'scope> { */ /// The `name` field. + #[inline] pub fn name(self) -> Symbol<'scope> { // Safety: the pointer points to valid data unsafe { @@ -80,6 +81,7 @@ impl<'scope> TypeName<'scope> { } /// The `module` field. + #[inline] pub fn module(self) -> Module<'scope> { // Safety: the pointer points to valid data unsafe { @@ -90,6 +92,7 @@ impl<'scope> TypeName<'scope> { } /// Field names. + #[inline] pub fn names(self) -> SimpleVector<'scope> { // Safety: the pointer points to valid data unsafe { @@ -101,6 +104,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.7")] /// The `atomicfields` field. + #[inline] pub fn atomicfields(self) -> *const u32 { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().atomicfields } @@ -108,14 +112,16 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.8")] /// The `atomicfields` field. + #[inline] pub fn constfields(self) -> *const u32 { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().constfields } } - #[cfg(feature = "extra-fields")] /// Either the only instantiation of the type (if no parameters) or a `UnionAll` accepting /// parameters to make an instantiation. + #[cfg(feature = "extra-fields")] + #[inline] pub fn wrapper(self) -> Value<'scope, 'static> { // Safety: the pointer points to valid data unsafe { @@ -148,6 +154,7 @@ impl<'scope> TypeName<'scope> { #[cfg(feature = "extra-fields")] #[julia_version(until = "1.6")] /// Sorted array. + #[inline] pub fn cache<'target, T>(self, target: T) -> SimpleVectorData<'target, T> where T: Target<'target>, @@ -163,6 +170,7 @@ impl<'scope> TypeName<'scope> { #[cfg(feature = "extra-fields")] #[julia_version(since = "1.7")] /// Sorted array. + #[inline] pub fn cache<'target, T>(self, target: T) -> SimpleVectorData<'target, T> where T: Target<'target>, @@ -182,6 +190,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(until = "1.6")] #[cfg(feature = "extra-fields")] /// Unsorted array. + #[inline] pub fn linear_cache<'target, T>(self, target: T) -> SimpleVectorData<'target, T> where T: Target<'target>, @@ -197,6 +206,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.7")] #[cfg(feature = "extra-fields")] /// Unsorted array. + #[inline] pub fn linear_cache<'target, T>(self, target: T) -> SimpleVectorData<'target, T> where T: Target<'target>, @@ -215,6 +225,7 @@ impl<'scope> TypeName<'scope> { /// The `mt` field. #[cfg(feature = "extra-fields")] + #[inline] pub fn mt<'target, T>(self, target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, @@ -229,6 +240,7 @@ impl<'scope> TypeName<'scope> { /// Incomplete instantiations of this type. #[cfg(feature = "extra-fields")] + #[inline] pub fn partial<'target, T>(self, target: T) -> Option> where T: Target<'target>, @@ -242,6 +254,7 @@ impl<'scope> TypeName<'scope> { } /// The `hash` field. + #[inline] pub fn hash(self) -> isize { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().hash } @@ -249,6 +262,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.7")] /// The `n_uninitialized` field. + #[inline] pub fn n_uninitialized(self) -> i32 { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().n_uninitialized } @@ -256,6 +270,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.7")] /// The `abstract` field. + #[inline] pub fn is_abstract(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().abstract_() != 0 } @@ -263,6 +278,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.7")] /// The `mutabl` field. + #[inline] pub fn is_mutable(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().mutabl() != 0 } @@ -270,6 +286,7 @@ impl<'scope> TypeName<'scope> { #[julia_version(since = "1.7")] /// The `mayinlinealloc` field. + #[inline] pub fn mayinlinealloc(self) -> bool { // Safety: the pointer points to valid data unsafe { self.unwrap_non_null(Private).as_ref().mayinlinealloc() != 0 } @@ -278,6 +295,7 @@ impl<'scope> TypeName<'scope> { impl<'base> TypeName<'base> { /// The typename of the `UnionAll` `Type`. + #[inline] pub fn of_type(_: &T) -> Self where T: Target<'base>, @@ -287,6 +305,7 @@ impl<'base> TypeName<'base> { } /// The typename of the `DataType` `Tuple`. + #[inline] pub fn of_tuple(_: &T) -> Self where T: Target<'base>, @@ -296,6 +315,7 @@ impl<'base> TypeName<'base> { } /// The typename of the `UnionAll` `VecElement`. + #[inline] pub fn of_vecelement(_: &T) -> Self where T: Target<'base>, @@ -306,6 +326,7 @@ impl<'base> TypeName<'base> { #[julia_version(until = "1.6")] /// The typename of the `UnionAll` `Vararg`. + #[inline] pub fn of_vararg(_: &T) -> Self where T: Target<'base>, @@ -315,6 +336,7 @@ impl<'base> TypeName<'base> { } /// The typename of the `UnionAll` `Array`. + #[inline] pub fn of_array(_: &T) -> Self where T: Target<'base>, @@ -325,6 +347,7 @@ impl<'base> TypeName<'base> { #[julia_version(since = "1.7")] /// The typename of the `UnionAll` `Ptr`. + #[inline] pub fn of_opaque_closure(_: &T) -> Self where T: Target<'base>, @@ -334,6 +357,7 @@ impl<'base> TypeName<'base> { } /// The typename of the `UnionAll` `Ptr`. + #[inline] pub fn of_pointer(_: &T) -> Self where T: Target<'base>, @@ -343,6 +367,7 @@ impl<'base> TypeName<'base> { } /// The typename of the `UnionAll` `LLVMPtr`. + #[inline] pub fn of_llvmpointer(_: &T) -> Self where T: Target<'base>, @@ -352,6 +377,7 @@ impl<'base> TypeName<'base> { } /// The typename of the `UnionAll` `NamedTuple`. + #[inline] pub fn of_namedtuple(_: &T) -> Self where T: Target<'base>, @@ -371,16 +397,18 @@ impl<'scope> ManagedPriv<'scope, '_> for TypeName<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(TypeName<'_>, jl_typename_type); +impl_construct_type_managed!(TypeName, 1, jl_typename_type); /// A reference to a [`TypeName`] that has not been explicitly rooted. pub type TypeNameRef<'scope> = Ref<'scope, 'static, TypeName<'scope>>; @@ -389,16 +417,15 @@ pub type TypeNameRef<'scope> = Ref<'scope, 'static, TypeName<'scope>>; /// `ccall`able functions that return a [`TypeName`]. pub type TypeNameRet = Ref<'static, 'static, TypeName<'static>>; -impl_valid_layout!(TypeNameRef, TypeName); +impl_valid_layout!(TypeNameRef, TypeName, jl_typename_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `TypeName` or `TypeNameRef`, depending on the target type `T`. pub type TypeNameData<'target, T> = >::Data<'static, TypeName<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type TypeNameResult<'target, T> = - >::Result<'static, TypeName<'target>>; +pub type TypeNameResult<'target, T> = TargetResult<'target, 'static, TypeName<'target>, T>; impl_ccall_arg_managed!(TypeName, 1); impl_into_typed!(TypeName); diff --git a/jlrs/src/data/managed/type_var.rs b/jlrs/src/data/managed/type_var.rs index cd1c8ef7..475727fa 100644 --- a/jlrs/src/data/managed/type_var.rs +++ b/jlrs/src/data/managed/type_var.rs @@ -6,6 +6,7 @@ use jl_sys::{jl_new_typevar, jl_tvar_t, jl_tvar_type}; use super::{value::ValueData, Ref}; use crate::{ + catch::catch_exceptions, convert::to_symbol::ToSymbol, data::managed::{ datatype::DataType, @@ -15,7 +16,7 @@ use crate::{ Managed, }, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -39,27 +40,20 @@ impl<'scope> TypeVar<'scope> { T: Target<'target>, N: ToSymbol, { - use std::mem::MaybeUninit; - - use crate::catch::catch_exceptions; - // Safety: if an exception is thrown it's caught and returned unsafe { let name = name.to_symbol_priv(Private); let lb = lower_bound.unwrap_or_else(|| Value::bottom_type(&target)); let ub = upper_bound.unwrap_or_else(|| DataType::any_type(&target).as_value()); - let mut callback = |result: &mut MaybeUninit<*mut jl_tvar_t>| { - let res = - jl_new_typevar(name.unwrap(Private), lb.unwrap(Private), ub.unwrap(Private)); - result.write(res); + let callback = + || jl_new_typevar(name.unwrap(Private), lb.unwrap(Private), ub.unwrap(Private)); - Ok(()) - }; + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(tvar) => Ok(NonNull::new_unchecked(tvar)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.result_from_ptr(res, Private) @@ -72,6 +66,7 @@ impl<'scope> TypeVar<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn new_unchecked<'target, N, T>( target: T, name: N, @@ -98,6 +93,7 @@ impl<'scope> TypeVar<'scope> { */ /// The name of this `TypeVar`. + #[inline] pub fn name(self) -> Symbol<'scope> { // Safety: pointer points to valid data unsafe { @@ -108,6 +104,7 @@ impl<'scope> TypeVar<'scope> { } /// The lower bound of this `TypeVar`. + #[inline] pub fn lower_bound<'target, T>(self, target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, @@ -121,6 +118,7 @@ impl<'scope> TypeVar<'scope> { } /// The upper bound of this `TypeVar`. + #[inline] pub fn upper_bound<'target, T>(self, target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, @@ -144,16 +142,18 @@ impl<'scope> ManagedPriv<'scope, '_> for TypeVar<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(TypeVar<'_>, jl_tvar_type); +impl_construct_type_managed!(TypeVar, 1, jl_tvar_type); /// A reference to a [`TypeVar`] that has not been explicitly rooted. pub type TypeVarRef<'scope> = Ref<'scope, 'static, TypeVar<'scope>>; @@ -162,15 +162,15 @@ pub type TypeVarRef<'scope> = Ref<'scope, 'static, TypeVar<'scope>>; /// `ccall`able functions that return a [`TypeVar`]. pub type TypeVarRet = Ref<'static, 'static, TypeVar<'static>>; -impl_valid_layout!(TypeVarRef, TypeVar); +impl_valid_layout!(TypeVarRef, TypeVar, jl_tvar_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `TypeVar` or `TypeVarRef`, depending on the target type `T`. pub type TypeVarData<'target, T> = >::Data<'static, TypeVar<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type TypeVarResult<'target, T> = >::Result<'static, TypeVar<'target>>; +pub type TypeVarResult<'target, T> = TargetResult<'target, 'static, TypeVar<'target>, T>; impl_ccall_arg_managed!(TypeVar, 1); impl_into_typed!(TypeVar); diff --git a/jlrs/src/data/managed/union.rs b/jlrs/src/data/managed/union.rs index c704fcb0..25eac5b3 100644 --- a/jlrs/src/data/managed/union.rs +++ b/jlrs/src/data/managed/union.rs @@ -9,9 +9,10 @@ use super::{ Ref, }; use crate::{ + catch::catch_exceptions, data::managed::{private::ManagedPriv, value::Value, Managed}, impl_julia_typecheck, - memory::target::Target, + memory::target::{Target, TargetResult}, private::Private, }; @@ -35,25 +36,16 @@ impl<'scope> Union<'scope> { V: AsRef<[Value<'scope, 'static>]>, T: Target<'target>, { - use std::mem::MaybeUninit; - - use jl_sys::jl_value_t; - - use crate::catch::catch_exceptions; - // Safety: if an exception is thrown it's caught, the result is immediately rooted unsafe { let types = types.as_ref(); - let mut callback = |result: &mut MaybeUninit<*mut jl_value_t>| { - let res = jl_type_union(types.as_ptr() as *mut _, types.len()); - result.write(res); - Ok(()) - }; + let callback = || jl_type_union(types.as_ptr() as *mut _, types.len()); + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(ptr) => Ok(NonNull::new_unchecked(ptr)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.result_from_ptr(res, Private) @@ -71,6 +63,7 @@ impl<'scope> Union<'scope> { /// /// [`Union`]: crate::data::managed::union::Union /// [`DataType`]: crate::data::managed::datatype::DataType + #[inline] pub unsafe fn new_unchecked<'target, V, T>( target: T, types: V, @@ -85,6 +78,7 @@ impl<'scope> Union<'scope> { } /// Returns true if the bits-union optimization applies to this union type. + #[inline] pub fn is_bits_union(self) -> bool { let v: Value = self.as_value(); // Safety: The C API function is called with valid arguments @@ -94,6 +88,7 @@ impl<'scope> Union<'scope> { /// Returns true if the bits-union optimization applies to this union type and calculates /// the size and aligment if it does. If this method returns false, the calculated size and /// alignment are invalid. + #[inline] pub fn isbits_size_align(self, size: &mut usize, align: &mut usize) -> bool { let v: Value = self.as_value(); // Safety: The C API function is called with valid arguments @@ -102,6 +97,7 @@ impl<'scope> Union<'scope> { /// Returns the size of a field that is of this `Union` type excluding the flag that is used /// in bits-unions. + #[inline] pub fn size(self) -> usize { let mut sz = 0; if !self.isbits_size_align(&mut sz, &mut 0) { @@ -112,6 +108,7 @@ impl<'scope> Union<'scope> { } /// Returns a vector of all type variants this union can have. + #[inline] pub fn variants(self) -> Vec> { let mut comps = vec![]; collect(self.as_value(), &mut comps); @@ -126,6 +123,7 @@ impl<'scope> Union<'scope> { /// Unions are stored as binary trees, the arguments are stored as its leaves. This method /// returns one of its branches. + #[inline] pub fn a(self) -> Value<'scope, 'static> { // Safety: the pointer points to valid data unsafe { @@ -137,6 +135,7 @@ impl<'scope> Union<'scope> { /// Unions are stored as binary trees, the arguments are stored as its leaves. This method /// returns one of its branches. + #[inline] pub fn b(self) -> Value<'scope, 'static> { // Safety: the pointer points to valid data unsafe { @@ -157,10 +156,12 @@ impl<'scope> ManagedPriv<'scope, '_> for Union<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } @@ -171,63 +172,57 @@ pub(crate) fn nth_union_component<'scope, 'data>( pi: &mut i32, ) -> Option> { // Safety: both a and b are never null - match v.cast::() { - Ok(un) => { - let a = nth_union_component(un.a(), pi); - if a.is_some() { - a - } else { - *pi -= 1; - return nth_union_component(un.b(), pi); - } + if v.is::() { + let un = unsafe { v.cast_unchecked::() }; + let a = nth_union_component(un.a(), pi); + if a.is_some() { + a + } else { + *pi -= 1; + return nth_union_component(un.b(), pi); } - Err(_) => { - if *pi == 0 { - Some(v) - } else { - None - } + } else { + if *pi == 0 { + Some(v) + } else { + None } } } fn collect<'scope>(value: Value<'scope, 'static>, comps: &mut Vec>) { // Safety: both a and b are never null - match value.cast::() { - Ok(u) => { - collect(u.a(), comps); - collect(u.b(), comps); - } - Err(_) => { - comps.push(value); - } + if value.is::() { + let u = unsafe { value.cast_unchecked::() }; + collect(u.a(), comps); + collect(u.b(), comps); + } else { + comps.push(value); } } pub(crate) fn find_union_component(haystack: Value, needle: Value, nth: &mut u32) -> bool { // Safety: both a and b are never null - match haystack.cast::() { - Ok(hs) => { - if find_union_component(hs.a(), needle, nth) { - true - } else if find_union_component(hs.b(), needle, nth) { - true - } else { - false - } + if haystack.is::() { + let hs = unsafe { haystack.cast_unchecked::() }; + if find_union_component(hs.a(), needle, nth) { + true + } else if find_union_component(hs.b(), needle, nth) { + true + } else { + false } - Err(_) => { - if needle.unwrap_non_null(Private) == haystack.unwrap_non_null(Private) { - return true; - } else { - *nth += 1; - false - } + } else { + if needle.unwrap_non_null(Private) == haystack.unwrap_non_null(Private) { + return true; + } else { + *nth += 1; + false } } } -impl_construct_type_managed!(Union<'_>, jl_uniontype_type); +impl_construct_type_managed!(Union, 1, jl_uniontype_type); /// A reference to a [`Union`] that has not been explicitly rooted. pub type UnionRef<'scope> = Ref<'scope, 'static, Union<'scope>>; @@ -236,15 +231,15 @@ pub type UnionRef<'scope> = Ref<'scope, 'static, Union<'scope>>; /// `ccall`able functions that return a [`Union`]. pub type UnionRet = Ref<'static, 'static, Union<'static>>; -impl_valid_layout!(UnionRef, Union); +impl_valid_layout!(UnionRef, Union, jl_uniontype_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Union` or `UnionRef`, depending on the target type `T`. pub type UnionData<'target, T> = >::Data<'static, Union<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type UnionResult<'target, T> = >::Result<'static, Union<'target>>; +pub type UnionResult<'target, T> = TargetResult<'target, 'static, Union<'target>, T>; impl_ccall_arg_managed!(Union, 1); impl_into_typed!(Union); diff --git a/jlrs/src/data/managed/union_all.rs b/jlrs/src/data/managed/union_all.rs index d64cdb06..5945186f 100644 --- a/jlrs/src/data/managed/union_all.rs +++ b/jlrs/src/data/managed/union_all.rs @@ -14,13 +14,15 @@ use jl_sys::{ use jlrs_macros::julia_version; use super::{ + erase_scope_lifetime, value::{ValueData, ValueResult}, Managed, Ref, }; use crate::{ + catch::catch_exceptions, data::managed::{datatype::DataType, private::ManagedPriv, type_var::TypeVar, value::Value}, impl_julia_typecheck, - memory::target::{ExtendedTarget, Target}, + memory::target::{Target, TargetResult}, private::Private, }; @@ -40,21 +42,14 @@ impl<'scope> UnionAll<'scope> { where T: Target<'target>, { - use std::mem::MaybeUninit; - - use crate::catch::catch_exceptions; - // Safety: if an exception is thrown it's caught, the result is immediately rooted unsafe { - let mut callback = |result: &mut MaybeUninit<*mut jl_value_t>| { - let res = jl_type_unionall(tvar.unwrap(Private), body.unwrap(Private)); - result.write(res); - Ok(()) - }; + let callback = || jl_type_unionall(tvar.unwrap(Private), body.unwrap(Private)); + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(ptr) => Ok(NonNull::new_unchecked(ptr)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.result_from_ptr(res, Private) @@ -65,6 +60,7 @@ impl<'scope> UnionAll<'scope> { /// /// Safety: an exception must not be thrown if this method is called from a `ccall`ed /// function. + #[inline] pub unsafe fn new_unchecked<'target, T>( target: T, tvar: TypeVar, @@ -78,16 +74,19 @@ impl<'scope> UnionAll<'scope> { } /// The type at the bottom of this `UnionAll`. + #[inline] pub fn base_type(self) -> DataType<'scope> { let mut b = self; - // Safety: pointer points to valid data - while let Ok(body_ua) = b.body().cast::() { - b = body_ua; - } + unsafe { + // Safety: pointer points to valid data + while b.body().is::() { + b = b.body().cast_unchecked(); + } - // Safety: type at the base must be a DataType - b.body().cast::().unwrap() + // Safety: type at the base must be a DataType + b.body().cast_unchecked::() + } } /* @@ -98,6 +97,7 @@ impl<'scope> UnionAll<'scope> { */ /// The body of this `UnionAll`. This is either another `UnionAll` or a `DataType`. + #[inline] pub fn body(self) -> Value<'scope, 'static> { // Safety: pointer points to valid data unsafe { @@ -108,6 +108,7 @@ impl<'scope> UnionAll<'scope> { } /// The type variable associated with this "layer" of the `UnionAll`. + #[inline] pub fn var(self) -> TypeVar<'scope> { // Safety: pointer points to valid data unsafe { @@ -126,57 +127,23 @@ impl<'scope> UnionAll<'scope> { V: AsRef<[Value<'params, 'static>]>, T: Target<'target>, { - use std::mem::MaybeUninit; - - use crate::catch::catch_exceptions; - let types = types.as_ref(); let n = types.len(); let types_ptr = types.as_ptr() as *mut *mut jl_value_t; unsafe { - let mut callback = |result: &mut MaybeUninit<*mut jl_value_t>| { - let v = jl_apply_type(self.as_value().unwrap(Private), types_ptr, n); + let callback = || jl_apply_type(self.as_value().unwrap(Private), types_ptr, n); + let exc = |err: Value| err.unwrap_non_null(Private); - result.write(v); - Ok(()) - }; - - let res = match catch_exceptions(&mut callback).unwrap() { + let res = match catch_exceptions(callback, exc) { Ok(ptr) => Ok(NonNull::new_unchecked(ptr)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.result_from_ptr(res, Private) } } - pub fn rewrap<'target, T: Target<'target>>( - target: ExtendedTarget<'target, '_, '_, T>, - ty: DataType, - ) -> ValueData<'target, 'static, T> { - // - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let params = ty.parameters(); - let params = params.data().as_slice(); - let mut body = ty.as_value(); - - for param in params.iter().copied() { - unsafe { - let param = param.unwrap().as_value(); - if let Ok(tvar) = param.cast::() { - body = UnionAll::new_unchecked(&mut frame, tvar, body).as_value(); - } - } - } - - Ok(body.root(target)) - }) - .unwrap() - } - + #[inline] pub unsafe fn apply_types_unchecked<'target, 'params, V, T>( self, target: T, @@ -193,10 +160,39 @@ impl<'scope> UnionAll<'scope> { debug_assert!(!applied.is_null()); target.data_from_ptr(NonNull::new_unchecked(applied), Private) } + + // TODO: unsafe, document, test + pub fn rewrap<'target, Tgt: Target<'target>>( + target: Tgt, + ty: DataType, + ) -> ValueData<'target, 'static, Tgt> { + // + target + .with_local_scope::<_, _, 1>(|target, mut frame| unsafe { + let params = ty.parameters(); + let params = params.data().as_slice(); + let mut local_output = frame.local_output(); + let mut body = erase_scope_lifetime(ty.as_value()); + + for param in params.iter().rev().copied() { + let param = param.unwrap_unchecked().as_value(); + if param.is::() { + let tvar = param.cast_unchecked::(); + let b = UnionAll::new_unchecked(&mut local_output, tvar, body).as_value(); + body = erase_scope_lifetime(b); + } + } + + Ok(body.root(target)) + }) + .unwrap() + } } +// TODO: use in abstract_types impl<'base> UnionAll<'base> { /// The `UnionAll` `Type`. + #[inline] pub fn type_type(_: &T) -> Self where T: Target<'base>, @@ -206,6 +202,7 @@ impl<'base> UnionAll<'base> { } /// `Type{T} where T<:Tuple` + #[inline] pub fn anytuple_type_type(_: &T) -> Self where T: Target<'base>, @@ -216,6 +213,7 @@ impl<'base> UnionAll<'base> { #[julia_version(until = "1.6")] /// The `UnionAll` `Vararg`. + #[inline] pub fn vararg_type(_: &T) -> Self where T: Target<'base>, @@ -225,6 +223,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `AbstractArray`. + #[inline] pub fn abstractarray_type(_: &T) -> Self where T: Target<'base>, @@ -235,6 +234,7 @@ impl<'base> UnionAll<'base> { #[julia_version(since = "1.7")] /// The `UnionAll` `OpaqueClosure`. + #[inline] pub fn opaque_closure_type(_: &T) -> Self where T: Target<'base>, @@ -244,6 +244,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `DenseArray`. + #[inline] pub fn densearray_type(_: &T) -> Self where T: Target<'base>, @@ -253,6 +254,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `Array`. + #[inline] pub fn array_type(_: &T) -> Self where T: Target<'base>, @@ -262,6 +264,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `Ptr`. + #[inline] pub fn pointer_type(_: &T) -> Self where T: Target<'base>, @@ -271,6 +274,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `LLVMPtr`. + #[inline] pub fn llvmpointer_type(_: &T) -> Self where T: Target<'base>, @@ -280,6 +284,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `Ref`. + #[inline] pub fn ref_type(_: &T) -> Self where T: Target<'base>, @@ -289,6 +294,7 @@ impl<'base> UnionAll<'base> { } /// The `UnionAll` `NamedTuple`. + #[inline] pub fn namedtuple_type(_: &T) -> Self where T: Target<'base>, @@ -308,16 +314,18 @@ impl<'scope> ManagedPriv<'scope, '_> for UnionAll<'scope> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(UnionAll<'_>, jl_unionall_type); +impl_construct_type_managed!(UnionAll, 1, jl_unionall_type); /// A reference to a [`UnionAll`] that has not been explicitly rooted. pub type UnionAllRef<'scope> = Ref<'scope, 'static, UnionAll<'scope>>; @@ -326,16 +334,15 @@ pub type UnionAllRef<'scope> = Ref<'scope, 'static, UnionAll<'scope>>; /// `ccall`able functions that return a [`UnionAll`]. pub type UnionAllRet = Ref<'static, 'static, UnionAll<'static>>; -impl_valid_layout!(UnionAllRef, UnionAll); +impl_valid_layout!(UnionAllRef, UnionAll, jl_unionall_type); -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `UnionAll` or `UnionAllRef`, depending on the target type `T`. pub type UnionAllData<'target, T> = >::Data<'static, UnionAll<'target>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type UnionAllResult<'target, T> = - >::Result<'static, UnionAll<'target>>; +pub type UnionAllResult<'target, T> = TargetResult<'target, 'static, UnionAll<'target>, T>; impl_ccall_arg_managed!(UnionAll, 1); impl_into_typed!(UnionAll); diff --git a/jlrs/src/data/managed/value/field_accessor.rs b/jlrs/src/data/managed/value/field_accessor.rs index 7a98e6af..186e9d73 100644 --- a/jlrs/src/data/managed/value/field_accessor.rs +++ b/jlrs/src/data/managed/value/field_accessor.rs @@ -73,6 +73,7 @@ pub struct FieldAccessor<'scope, 'data> { } impl<'scope, 'data> FieldAccessor<'scope, 'data> { + #[inline] pub(crate) fn new(value: Value<'scope, 'data>) -> Self { FieldAccessor { value: Some(value.as_ref()), @@ -149,6 +150,7 @@ impl<'scope, 'data> FieldAccessor<'scope, 'data> { } /// Returns `true` if `self.access::()` will succeed, `false` if it will fail. + #[inline] pub fn can_access_as(&self) -> bool { if self.current_field_type.is_none() { return false; @@ -308,6 +310,7 @@ impl<'scope, 'data> FieldAccessor<'scope, 'data> { /// Try to clone this accessor and its state. /// /// If the current value this accessor is accessing is locked an error is returned. + #[inline] pub fn try_clone(&self) -> JlrsResult { #[cfg(not(feature = "julia-1-6"))] if self.state == ViewState::Locked { @@ -325,23 +328,27 @@ impl<'scope, 'data> FieldAccessor<'scope, 'data> { } #[julia_version(since = "1.7")] + #[inline] /// Returns `true` if the current value the accessor is accessing is locked. pub fn is_locked(&self) -> bool { self.state == ViewState::Locked } #[julia_version(until = "1.6")] + #[inline] /// Returns `true` if the current value the accessor is accessing is locked. pub fn is_locked(&self) -> bool { false } /// Returns the type of the field the accessor is currently pointing at. + #[inline] pub fn current_field_type(&self) -> Option> { self.current_field_type } /// Returns the value the accessor is currently inspecting. + #[inline] pub fn value(&self) -> Option> { self.value } @@ -814,6 +821,7 @@ mod private { } impl FieldIndexPriv for D { + #[inline] fn field_index(&self, ty: DataType, _: Private) -> JlrsResult { debug_assert!(!ty.is::()); diff --git a/jlrs/src/data/managed/value/mod.rs b/jlrs/src/data/managed/value/mod.rs index 98537113..2e008f92 100644 --- a/jlrs/src/data/managed/value/mod.rs +++ b/jlrs/src/data/managed/value/mod.rs @@ -23,12 +23,15 @@ //! [`named_tuple`]: crate::named_tuple! /* -TODO: -jl_atomic_cmpswap_bits -jl_atomic_bool_cmpswap_bits -jl_atomic_new_bits -jl_atomic_store_bits -jl_atomic_swap_bits + TODO + + Atomic operations: + + jl_atomic_cmpswap_bits + jl_atomic_bool_cmpswap_bits + jl_atomic_new_bits + jl_atomic_store_bits + jl_atomic_swap_bits */ pub mod field_accessor; @@ -71,7 +74,7 @@ macro_rules! count { /// let i = Value::new(&mut frame, 2u64); /// let j = Value::new(&mut frame, 1u32); /// -/// let _nt = named_tuple!(frame.as_extended_target(), "i" => i, "j" => j); +/// let _nt = named_tuple!(&mut frame, "i" => i, "j" => j); /// /// Ok(()) /// }).unwrap(); @@ -81,31 +84,41 @@ macro_rules! count { #[macro_export] macro_rules! named_tuple { ($frame:expr, $name:expr => $value:expr) => { - $crate::data::managed::value::Value::new_named_tuple($frame, &mut [$name], &mut [$value]).expect("Invalid use of named_tuple!") + { + let name = $crate::convert::to_symbol::ToSymbol::to_symbol(&$name, &$frame); + $crate::data::managed::value::Value::new_named_tuple($frame, &[(name, $value)]) + } }; ($frame:expr, $name:expr => $value:expr, $($rest:tt)+) => { { - let n = $crate::count!($($rest)+); - let mut names = ::smallvec::SmallVec::<[_; $crate::data::managed::value::MAX_SIZE]>::with_capacity(n); - let mut values = ::smallvec::SmallVec::<[_; $crate::data::managed::value::MAX_SIZE]>::with_capacity(n); + const n: usize = $crate::count!($($rest)+); + let mut pairs: [::std::mem::MaybeUninit::<($crate::data::managed::symbol::Symbol, $crate::data::managed::value::Value)>; n] = [::std::mem::MaybeUninit::uninit(); n]; + let name = $crate::convert::to_symbol::ToSymbol::to_symbol(&$name, &$frame); - names.push($name); - values.push($value); - $crate::named_tuple!($frame, &mut names, &mut values, $($rest)+) + pairs[0].write((name, $value)); + $crate::named_tuple!($frame, 1, &mut pairs, $($rest)+) } }; - ($frame:expr, $names:expr, $values:expr, $name:expr => $value:expr, $($rest:tt)+) => { + ($frame:expr, $i:expr, $pairs:expr, $name:expr => $value:expr, $($rest:tt)+) => { { - $names.push($name); - $values.push($value); - named_tuple!($frame, $names, $values, $($rest)+) + let name = $crate::convert::to_symbol::ToSymbol::to_symbol(&$name, &$frame); + $pairs[$i].write((name, $value)); + named_tuple!($frame, $i + 1, $pairs, $($rest)+) } }; - ($frame:expr, $names:expr, $values:expr, $name:expr => $value:expr) => { + ($frame:expr, $i:expr, $pairs:expr, $name:expr => $value:expr) => { { - $names.push($name); - $values.push($value); - $crate::data::managed::value::Value::new_named_tuple($frame, $names, $values).expect("Invalid use of named_tuple!") + let name = $crate::convert::to_symbol::ToSymbol::to_symbol(&$name, &$frame); + $pairs[$i].write((name, $value)); + + let pairs: &[($crate::data::managed::symbol::Symbol, $crate::data::managed::value::Value); n] = unsafe { + ::std::mem::transmute::< + &[::std::mem::MaybeUninit::<($crate::data::managed::symbol::Symbol, $crate::data::managed::value::Value)>; n], + &[($crate::data::managed::symbol::Symbol, $crate::data::managed::value::Value); n] + >($pairs) + }; + + $crate::data::managed::value::Value::new_named_tuple($frame, pairs) } }; } @@ -122,12 +135,13 @@ use std::{ #[julia_version(since = "1.7")] use jl_sys::jl_pair_type; use jl_sys::{ - jl_an_empty_string, jl_an_empty_vec_any, jl_any_type, jl_apply_type, jl_array_any_type, - jl_array_int32_type, jl_array_symbol_type, jl_array_uint8_type, jl_bottom_type, jl_call, - jl_call0, jl_call1, jl_call2, jl_call3, jl_diverror_exception, jl_egal, jl_emptytuple, - jl_eval_string, jl_exception_occurred, jl_false, jl_field_index, jl_field_isptr, - jl_gc_add_finalizer, jl_gc_add_ptr_finalizer, jl_get_nth_field, jl_get_nth_field_noalloc, - jl_interrupt_exception, jl_isa, jl_memory_exception, jl_nothing, jl_object_id, + jl_an_empty_string, jl_an_empty_vec_any, jl_any_type, jl_apply_generic, jl_apply_type, + jl_array_any_type, jl_array_int32_type, jl_array_symbol_type, jl_array_uint8_type, + jl_bottom_type, jl_call, jl_call0, jl_call1, jl_call2, jl_call3, jl_diverror_exception, + jl_egal, jl_emptytuple, jl_eval_string, jl_exception_occurred, jl_false, jl_field_index, + jl_field_isptr, jl_gc_add_finalizer, jl_gc_add_ptr_finalizer, jl_get_nth_field, + jl_get_nth_field_noalloc, jl_get_world_counter, jl_interrupt_exception, jl_isa, + jl_memory_exception, jl_new_struct_uninit, jl_nothing, jl_object_id, jl_readonlymemory_exception, jl_set_nth_field, jl_stackovf_exception, jl_stderr_obj, jl_stdout_obj, jl_subtype, jl_true, jl_typeof_str, jl_undefref_exception, jl_value_t, }; @@ -136,10 +150,16 @@ use jlrs_macros::julia_version; use self::{field_accessor::FieldAccessor, typed::TypedValue}; use super::Ref; use crate::{ + args::Values, call::{Call, ProvideKeywords, WithKeywords}, + catch::catch_exceptions, convert::{into_julia::IntoJulia, to_symbol::ToSymbol, unbox::Unbox}, data::{ - layout::valid_layout::{ValidField, ValidLayout}, + layout::{ + is_bits::IsBits, + typed_layout::HasLayout, + valid_layout::{ValidField, ValidLayout}, + }, managed::{ array::Array, datatype::DataType, @@ -157,24 +177,16 @@ use crate::{ typecheck::{NamedTuple, Typecheck}, }, }, - error::{ - AccessError, IOError, InstantiationError, JlrsError, JlrsResult, TypeError, - CANNOT_DISPLAY_TYPE, - }, + error::{AccessError, IOError, JlrsError, JlrsResult, TypeError, CANNOT_DISPLAY_TYPE}, memory::{ context::ledger::Ledger, get_tls, - target::{frame::GcFrame, unrooted::Unrooted, ExtendedTarget, Target}, + target::{unrooted::Unrooted, Target, TargetException, TargetResult}, }, + prelude::NTuple, private::Private, }; -/// In some cases it's necessary to place one or more arguments in front of the arguments a -/// function is called with. Examples include the `named_tuple` macro and `Value::call_async`. -/// If they are called with fewer than `MAX_SIZE` arguments (including the added arguments), no -/// heap allocation is required to store them. -pub const MAX_SIZE: usize = 8; - /// Arbitrary Julia data. /// /// A `Value` is essentially a non-null pointer to some data owned by the Julia garbage @@ -195,11 +207,20 @@ pub struct Value<'scope, 'data>( ); impl<'scope, 'data, T: Managed<'scope, 'data>> PartialEq for Value<'_, '_> { + #[inline] fn eq(&self, other: &T) -> bool { self.egal(other.as_value()) } } +// Safety: it's always safe to treat managed data as a `Value`. +unsafe impl Typecheck for Value<'_, '_> { + #[inline] + fn typecheck(_: DataType) -> bool { + true + } +} + /// # Create new `Value`s /// /// Several methods are available to create new values. The simplest of these is [`Value::new`], @@ -211,77 +232,172 @@ impl<'scope, 'data, T: Managed<'scope, 'data>> PartialEq for Value<'_, '_> { impl Value<'_, '_> { /// Create a new Julia value, any type that implements [`IntoJulia`] can be converted using /// this function. - pub fn new<'target, V, T>(target: T, value: V) -> ValueData<'target, 'static, T> + #[inline] + pub fn new<'target, V, Tgt>(target: Tgt, value: V) -> ValueData<'target, 'static, Tgt> where V: IntoJulia, - T: Target<'target>, + Tgt: Target<'target>, { value.into_julia(target) } - /// Create a new named tuple, you should use the `named_tuple` macro rather than this method. - pub fn new_named_tuple<'target, 'current, 'borrow, 'value, 'data, S, N, T, V>( - scope: ExtendedTarget<'target, '_, '_, S>, - field_names: N, - values: V, - ) -> JlrsResult> + /// Create a new Julia value, any type that implements [`IsBits`] can be converted using + /// this function. + pub fn new_bits<'target, T, Tgt>(target: Tgt, layout: T) -> ValueData<'target, 'static, Tgt> where - S: Target<'target>, - N: AsRef<[T]>, - T: ToSymbol, - V: AsRef<[Value<'value, 'data>]>, + T: ConstructType + ValidLayout + IsBits, + Tgt: Target<'target>, { - let field_names = field_names.as_ref(); - let values_m = values.as_ref(); + unsafe { + let ty = T::construct_type(&target) + .as_value() + .cast_unchecked::(); + let val = NonNull::new_unchecked(jl_new_struct_uninit(ty.unwrap(Private))); + val.cast::>().as_mut().write(layout); + target.data_from_ptr(val, Private) + } + } - let n_names = field_names.len(); - let n_values = values_m.len(); + /// Create a new Julia value using `T` to construct the type. The layout must implement + /// `IsBits`. + pub fn new_bits_from_layout<'target, T, Tgt>( + target: Tgt, + layout: T::Layout, + ) -> JlrsResult> + where + T: HasLayout<'target, 'static>, + T::Layout: IsBits, + Tgt: Target<'target>, + { + unsafe { + let ty = T::construct_type(&target).as_value().cast::()?; + let val = NonNull::new_unchecked(jl_new_struct_uninit(ty.unwrap(Private))); + val.cast::>().as_mut().write(layout); + Ok(target.data_from_ptr(val, Private)) + } + } + + /// Create a new Julia value using `T` to construct the type and an arbitrary layout `L`. + /// + /// If the layout is not valid for `T` `TypeError::InvalidLayout` is returned. + pub fn new_bits_with_type<'target, T, L, Tgt>( + target: Tgt, + layout: L, + ) -> JlrsResult> + where + T: ConstructType, + L: IsBits + ValidLayout, + Tgt: Target<'target>, + { + unsafe { + let ty = T::construct_type(&target).as_value(); + if !L::valid_layout(ty) { + let value_type = ty.display_string_or(CANNOT_DISPLAY_TYPE); + Err(TypeError::InvalidLayout { value_type })?; + } - if n_names != n_values { - Err(InstantiationError::NamedTupleSizeMismatch { n_names, n_values })?; + let ty = ty.cast_unchecked::(); + let val = NonNull::new_unchecked(jl_new_struct_uninit(ty.unwrap(Private))); + val.cast::>().as_mut().write(layout); + Ok(target.data_from_ptr(val, Private)) } + } - let (output, scope) = scope.split(); + /// Create a new `Value` from the provided layout and type constructor. + /// + /// This is a more powerful version of [`Value::new`]. While that method is limited to types + /// that implement `IntoJulia`, this method can create instances of any constructible type by + /// providing a layout which is compatible with that type. + /// + /// This method returns an error if `L` is not a valid layout for `V`. + /// + /// Safety: + /// + /// If the layout contains references to Julia data, those fields must either be `None` or + /// point to valid data. + pub unsafe fn try_new_with<'target, Ty, L, Tgt>( + target: Tgt, + layout: L, + ) -> JlrsResult> + where + Ty: ConstructType, + L: ValidLayout, + Tgt: Target<'target>, + { + target.with_local_scope::<_, _, 1>(|target, mut frame| { + let ty = Ty::construct_type(&mut frame); + let ty_dt = ty.cast::()?; - scope.scope(|mut frame| { - let symbol_ty = DataType::symbol_type(&frame).as_value(); - let symbol_type_vec = vec![symbol_ty; n_names]; + if !ty_dt.is_concrete_type() { + let value = ty.display_string_or(CANNOT_DISPLAY_TYPE); + Err(TypeError::NotConcrete { value })?; + } - // Safety: this method can only be called from a thread known to Julia. The - // unchecked methods are used because it can be guaranteed they won't throw - // an exception for the given arguments. - unsafe { - let field_names_vec = field_names - .iter() - .map(|name| name.to_symbol_priv(Private).as_value()) - .collect::>(); - - let names = DataType::anytuple_type(&frame) - .as_value() - .apply_type_unchecked(&mut frame, &symbol_type_vec) - .cast::()? - .instantiate_unchecked(&mut frame, &field_names_vec); - - let field_types_vec = values_m - .iter() - .copied() - .map(|val| val.datatype().as_value()) - .collect::>(); - - let field_type_tup = DataType::anytuple_type(&frame) - .as_value() - .apply_type_unchecked(&mut frame, &field_types_vec); - - let ty = UnionAll::namedtuple_type(&frame) - .as_value() - .apply_type_unchecked(&mut frame, &[names, field_type_tup]) - .cast::()?; - - Ok(ty.instantiate_unchecked(output, values_m)) + if !L::valid_layout(ty) || L::IS_REF { + let value_type = ty.display_string_or(CANNOT_DISPLAY_TYPE); + Err(TypeError::InvalidLayout { value_type })?; } + + if let Some(n_fields) = ty_dt.n_fields() { + for i in 0..n_fields as usize { + let ft = ty_dt.field_type_unchecked(&frame, i).unwrap().as_value(); + + if ty_dt.is_pointer_field_unchecked(i) { + let offset = ty_dt.field_offset_unchecked(i) as usize; + check_field_isa(ft, &layout, offset)?; + } else if let Ok(u) = ft.cast::() { + check_union_equivalent::(&frame, i, u)?; + } + } + } + + let ptr = jl_new_struct_uninit(ty_dt.unwrap(Private)); + std::ptr::write(ptr.cast::(), layout); + Ok(target.data_from_ptr(NonNull::new_unchecked(ptr), Private)) }) } + /// Create a new named tuple, you should use the `named_tuple` macro rather than this method. + pub fn new_named_tuple<'target, 'value, 'data, Tgt, const N: usize>( + target: Tgt, + pairs: &[(Symbol<'value>, Value<'value, 'data>); N], + ) -> ValueData<'target, 'data, Tgt> + where + Tgt: Target<'target>, + { + unsafe { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + // Safety: this method can only be called from a thread known to Julia. The + // unchecked methods are used because it can be guaranteed they won't throw + // an exception for the given arguments. + let field_names = pairs.map(|(sym, _)| sym.as_value()); + + let names = NTuple::::construct_type(&frame) + .as_value() + .cast::()? + .instantiate_unchecked(&mut frame, &field_names); + + let values = pairs.map(|(_, val)| val); + let field_types = values.map(|val| val.datatype().as_value()); + + let field_types = DataType::anytuple_type(&frame) + .as_value() + .apply_type_unchecked(&frame, &field_types) + .as_value(); + + let ty = UnionAll::namedtuple_type(&frame) + .as_value() + .apply_type_unchecked(&frame, &[names, field_types]) + .as_value() + .cast_unchecked::(); + + Ok(ty.instantiate_unchecked(target, values)) + }) + .unwrap_unchecked() + } + } + /// Apply the given types to `self`. /// /// If `self` is the [`DataType`] `anytuple_type`, calling this method will return a new @@ -302,22 +418,18 @@ impl Value<'_, '_> { T: Target<'target>, V: AsRef<[Value<'value, 'data>]>, { - use crate::catch::catch_exceptions; - // Safety: if an exception is thrown it's caught, the result is immediately rooted unsafe { let types = types.as_ref(); - let mut callback = |result: &mut MaybeUninit<*mut jl_value_t>| { - let res = - jl_apply_type(self.unwrap(Private), types.as_ptr() as *mut _, types.len()); - result.write(res); - Ok(()) - }; + let callback = + || jl_apply_type(self.unwrap(Private), types.as_ptr() as *mut _, types.len()); - let res = match catch_exceptions(&mut callback).unwrap() { + let exc = |err: Value| err.unwrap_non_null(Private); + + let res = match catch_exceptions(callback, exc) { Ok(ptr) => Ok(NonNull::new_unchecked(ptr)), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; target.result_from_ptr(res, Private) @@ -338,6 +450,7 @@ impl Value<'_, '_> { /// function. /// /// [`Union::new`]: crate::data::managed::union::Union::new + #[inline] pub unsafe fn apply_type_unchecked<'target, 'value, 'data, T, V>( self, target: T, @@ -360,6 +473,7 @@ impl Value<'_, '_> { impl<'scope, 'data> Value<'scope, 'data> { #[julia_version(until = "1.9")] /// Returns the `DataType` of this value. + #[inline] pub fn datatype(self) -> DataType<'scope> { // Safety: the pointer points to valid data, every value can be converted to a tagged // value. @@ -374,6 +488,7 @@ impl<'scope, 'data> Value<'scope, 'data> { } #[julia_version(since = "1.10")] + #[inline] /// Returns the `DataType` of this value. pub fn datatype(self) -> DataType<'scope> { // Safety: the pointer points to valid data, every value has a type. @@ -385,6 +500,7 @@ impl<'scope, 'data> Value<'scope, 'data> { } /// Returns the name of this value's [`DataType`] as a string slice. + #[inline] pub fn datatype_name(self) -> JlrsResult<&'scope str> { // Safety: the pointer points to valid data, the C API function // is called with a valid argument. @@ -429,11 +545,13 @@ impl Value<'_, '_> { /// /// [`JuliaStruct`]: crate::data::managed::traits::julia_struct::JuliaStruct /// [here]: ../../../layout/typecheck/trait.Typecheck.html#implementors + #[inline] pub fn is(self) -> bool { self.datatype().is::() } /// Returns true if the value is an array with elements of type `T`. + #[inline] pub fn is_array_of(self) -> bool { match self.cast::() { Ok(arr) => arr.contains::(), @@ -442,6 +560,7 @@ impl Value<'_, '_> { } /// Returns true if `self` is a subtype of `sup`. + #[inline] pub fn subtype(self, sup: Value) -> bool { // Safety: the pointers point to valid data, the C API function // is called with valid arguments. @@ -450,6 +569,7 @@ impl Value<'_, '_> { /// Returns true if `self` is the type of a `DataType`, `UnionAll`, `Union`, or `Union{}` (the /// bottom type). + #[inline] pub fn is_kind(self) -> bool { // Safety: this method can only be called from a thread known to Julia, its lifetime is // never used @@ -464,11 +584,13 @@ impl Value<'_, '_> { /// Returns true if the value is a type, ie a `DataType`, `UnionAll`, `Union`, or `Union{}` /// (the bottom type). + #[inline] pub fn is_type(self) -> bool { Value::is_kind(self.datatype().as_value()) } /// Returns true if `self` is of type `ty`. + #[inline] pub fn isa(self, ty: Value) -> bool { // Safety: the pointers point to valid data, the C API function // is called with valid arguments. @@ -497,6 +619,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// /// If the data is immutable the borrow isn't tracked by the ledger because it can't be /// mutably borrowed. + #[inline] pub fn track_shared<'borrow, T: ValidLayout>( &'borrow self, ) -> JlrsResult> { @@ -539,6 +662,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// mutable access to the contents of the data, which is inherently unsafe. /// /// [`write_barrier`]: crate::memory::gc::write_barrier + #[inline] pub unsafe fn track_exclusive<'borrow, T: ValidLayout>( &'borrow mut self, ) -> JlrsResult> { @@ -559,16 +683,19 @@ impl<'scope, 'data> Value<'scope, 'data> { } /// Returns `true` if `self` is currently tracked. + #[inline] pub fn is_tracked(self) -> JlrsResult { Ledger::is_borrowed(self) } /// Returns `true` if `self` is currently tracked. + #[inline] pub fn is_tracked_shared(self) -> JlrsResult { Ledger::is_borrowed_shared(self) } /// Returns `true` if `self` is currently mutably tracked. + #[inline] pub fn is_tracked_exclusive(self) -> JlrsResult { Ledger::is_borrowed_exclusive(self) } @@ -587,6 +714,7 @@ impl ValueUnbound { /// /// The returned instance of `Tracked` must only be used in the `ccall`ed function and the /// `AsyncCallback`. + #[inline] pub unsafe fn track_shared_unbound( self, ) -> JlrsResult> { @@ -614,6 +742,7 @@ impl ValueUnbound { /// /// The returned instance of `TrackedMut` must only be used in the `ccall`ed function and the /// `AsyncCallback`. + #[inline] pub unsafe fn track_exclusive_unbound( self, ) -> JlrsResult> { @@ -646,6 +775,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// data this function can be used to relax its second lifetime to `'static`. /// /// Safety: The value must not contain any data borrowed from Rust. + #[inline] pub unsafe fn assume_owned(self) -> Value<'scope, 'static> { Value::wrap_non_null(self.unwrap_non_null(Private), Private) } @@ -665,6 +795,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// unboxed value can't be used as a [`Value`] again without reallocating it. impl<'scope, 'data> Value<'scope, 'data> { /// Cast the value to a managed type `T`. Returns an error if the conversion is invalid. + #[inline] pub fn cast + Typecheck>(self) -> JlrsResult { if self.is::() { // Safety: self.is::() returning true guarantees this is safe @@ -679,12 +810,14 @@ impl<'scope, 'data> Value<'scope, 'data> { /// Cast the value to a managed type `T` without checking if this conversion is valid. /// /// Safety: You must guarantee `self.is::()` would have returned `true`. + #[inline] pub unsafe fn cast_unchecked>(self) -> T { T::from_value_unchecked(self, Private) } /// Unbox the contents of the value as the output type associated with `T`. Returns an error /// if the layout of `T::Output` is incompatible with the layout of the type in Julia. + #[inline] pub fn unbox(self) -> JlrsResult { if !self.is::() { Err(AccessError::InvalidLayout { @@ -700,17 +833,18 @@ impl<'scope, 'data> Value<'scope, 'data> { /// if the layout of `T::Output` is compatible with the layout of the type in Julia. /// /// Safety: You must guarantee `self.is::()` would have returned `true`. + #[inline] pub unsafe fn unbox_unchecked(self) -> T::Output { T::unbox(self) } /// Convert this value to a typed value if this value is an instance of the constructed type. - pub fn as_typed( + pub fn as_typed<'target, T: ConstructType, Tgt: Target<'target>>( self, - frame: &mut GcFrame<'_>, + target: &Tgt, ) -> JlrsResult> { - frame.scope(|mut frame| { - let ty = T::construct_type(frame.as_extended_target()); + target.with_local_scope::<_, _, 1>(|_, mut frame| { + let ty = T::construct_type(&mut frame); if self.isa(ty) { unsafe { Ok(TypedValue::::from_value_unchecked(self)) } } else { @@ -725,6 +859,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// Convert this value to a typed value without checking if the conversion is valid. /// /// Safety: the converted value must be an instance of the constructed type. + #[inline] pub unsafe fn as_typed_unchecked(self) -> TypedValue<'scope, 'data, T> { TypedValue::::from_value_unchecked(self) } @@ -732,6 +867,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// Returns a pointer to the data, this is useful when the output type of `Unbox` is different /// than the implementation type and you have to write a custom unboxing function. It's your /// responsibility this pointer is used correctly. + #[inline] pub fn data_ptr(self) -> NonNull { self.unwrap_non_null(Private).cast() } @@ -754,6 +890,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// the second as a `u32`. impl<'scope, 'data> Value<'scope, 'data> { /// Returns the field names of this value as a slice of `Symbol`s. + #[inline] pub fn field_names(self) -> &'scope [Symbol<'scope>] { // Symbol and SymbolRef have the same layout, and this data is non-null. Symbols are // globally rooted. @@ -761,11 +898,13 @@ impl<'scope, 'data> Value<'scope, 'data> { } /// Returns the number of fields the underlying Julia value has. + #[inline] pub fn n_fields(self) -> usize { self.datatype().n_fields().unwrap() as _ } /// Returns an accessor to access the contents of this value without allocating temporary Julia data. + #[inline] pub fn field_accessor(self) -> FieldAccessor<'scope, 'data> { FieldAccessor::new(self) } @@ -933,12 +1072,10 @@ impl<'scope, 'data> Value<'scope, 'data> { target: T, idx: usize, value: Value<'_, 'data>, - ) -> JlrsResult> + ) -> JlrsResult> where T: Target<'target>, { - use crate::catch::catch_exceptions; - let n_fields = self.n_fields(); if n_fields <= idx { Err(AccessError::OutOfBoundsField { @@ -965,15 +1102,12 @@ impl<'scope, 'data> Value<'scope, 'data> { })? } - let mut callback = |result: &mut MaybeUninit<()>| { - jl_set_nth_field(self.unwrap(Private), idx, value.unwrap(Private)); - result.write(()); - Ok(()) - }; + let callback = || jl_set_nth_field(self.unwrap(Private), idx, value.unwrap(Private)); + let exc = |err: Value| err.unwrap_non_null(Private); - let res = match catch_exceptions(&mut callback)? { + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; Ok(target.exception_from_ptr(res, Private)) @@ -984,6 +1118,7 @@ impl<'scope, 'data> Value<'scope, 'data> { /// Safety: this method doesn't check if the type of the value is a subtype of the field's /// type. Mutating things that should absolutely not be mutated, like the fields of a /// `DataType`, is also not prevented. + #[inline] pub unsafe fn set_nth_field_unchecked(self, idx: usize, value: Value<'_, 'data>) { jl_set_nth_field(self.unwrap(Private), idx, value.unwrap(Private)) } @@ -999,13 +1134,11 @@ impl<'scope, 'data> Value<'scope, 'data> { target: T, field_name: N, value: Value<'_, 'data>, - ) -> JlrsResult> + ) -> JlrsResult> where N: ToSymbol, T: Target<'target>, { - use crate::catch::catch_exceptions; - let symbol = field_name.to_symbol_priv(Private); let idx = jl_field_index(self.datatype().unwrap(Private), symbol.unwrap(Private), 0); @@ -1033,15 +1166,14 @@ impl<'scope, 'data> Value<'scope, 'data> { })? } - let mut callback = |result: &mut MaybeUninit<()>| { - jl_set_nth_field(self.unwrap(Private), idx as usize, value.unwrap(Private)); - result.write(()); - Ok(()) - }; + let callback = + || jl_set_nth_field(self.unwrap(Private), idx as usize, value.unwrap(Private)); - let res = match catch_exceptions(&mut callback)? { + let exc = |err: Value| err.unwrap_non_null(Private); + + let res = match catch_exceptions(callback, exc) { Ok(_) => Ok(()), - Err(e) => Err(e.ptr()), + Err(e) => Err(e), }; Ok(target.exception_from_ptr(res, Private)) @@ -1089,6 +1221,7 @@ impl Value<'_, '_> { /// /// Safety: The command can't be checked for correctness, nothing prevents you from causing a /// segmentation fault with a command like `unsafe_load(Ptr{Float64}(C_NULL))`. + #[inline] pub unsafe fn eval_string<'target, C, T>(target: T, cmd: C) -> ValueResult<'target, 'static, T> where C: AsRef, @@ -1112,6 +1245,7 @@ impl Value<'_, '_> { /// /// Safety: The command can't be checked for correctness, nothing prevents you from causing a /// segmentation fault with a command like `unsafe_load(Ptr{Float64}(C_NULL))`. + #[inline] pub unsafe fn eval_cstring<'target, C, T>(target: T, cmd: C) -> ValueResult<'target, 'static, T> where C: AsRef, @@ -1134,23 +1268,22 @@ impl Value<'_, '_> { /// /// Safety: The content of the file can't be checked for correctness, nothing prevents you /// from causing a segmentation fault with code like `unsafe_load(Ptr{Float64}(C_NULL))`. - pub unsafe fn include<'target, 'current, 'borrow, P, T>( - target: ExtendedTarget<'target, '_, '_, T>, + pub unsafe fn include<'target, 'current, 'borrow, P, Tgt>( + target: Tgt, path: P, - ) -> JlrsResult> + ) -> JlrsResult> where P: AsRef, - T: Target<'target>, + Tgt: Target<'target>, { if path.as_ref().exists() { - let (output, scope) = target.split(); - return scope.scope(|mut frame| { + return target.with_local_scope::<_, _, 1>(|target, mut frame| { let path_jl_str = JuliaString::new(&mut frame, path.as_ref().to_string_lossy()); let include_func = Module::main(&frame) .function(&frame, "include")? .as_managed(); - Ok(include_func.call1(output, path_jl_str.as_value())) + Ok(include_func.call1(target, path_jl_str.as_value())) }); } @@ -1163,6 +1296,7 @@ impl Value<'_, '_> { /// # Equality impl Value<'_, '_> { /// Returns the object id of this value. + #[inline] pub fn object_id(self) -> usize { // Safety: the pointer points to valid data, the C API // functions is called with a valid argument. @@ -1170,6 +1304,7 @@ impl Value<'_, '_> { } /// Returns true if `self` and `other` are equal. + #[inline] pub fn egal(self, other: Value) -> bool { // Safety: the pointer points to valid data, the C API // functions is called with a valid argument. @@ -1183,6 +1318,7 @@ impl Value<'_, '_> { /// called when this value is about to be freed by the garbage collector. /// /// Safety: the finalizer must be compatible with the data. + #[inline] pub unsafe fn add_finalizer(self, f: Value<'_, 'static>) { jl_gc_add_finalizer(self.unwrap(Private), f.unwrap(Private)) } @@ -1191,6 +1327,7 @@ impl Value<'_, '_> { /// takes one argument, the value as a void pointer. /// /// Safety: the finalizer must be compatible with the data. + #[inline] pub unsafe fn add_ptr_finalizer(self, f: unsafe extern "C" fn(*mut c_void) -> ()) { jl_gc_add_ptr_finalizer(get_tls(), self.unwrap(Private), f as *mut c_void) } @@ -1199,6 +1336,7 @@ impl Value<'_, '_> { /// # Constant values. impl<'scope> Value<'scope, 'static> { /// `Union{}`. + #[inline] pub fn bottom_type(_: &T) -> Self where T: Target<'scope>, @@ -1208,6 +1346,7 @@ impl<'scope> Value<'scope, 'static> { } /// `StackOverflowError`. + #[inline] pub fn stackovf_exception(_: &T) -> Self where T: Target<'scope>, @@ -1217,6 +1356,7 @@ impl<'scope> Value<'scope, 'static> { } /// `OutOfMemoryError`. + #[inline] pub fn memory_exception(_: &T) -> Self where T: Target<'scope>, @@ -1226,6 +1366,7 @@ impl<'scope> Value<'scope, 'static> { } /// `ReadOnlyMemoryError`. + #[inline] pub fn readonlymemory_exception(_: &T) -> Self where T: Target<'scope>, @@ -1237,6 +1378,7 @@ impl<'scope> Value<'scope, 'static> { } /// `DivideError`. + #[inline] pub fn diverror_exception(_: &T) -> Self where T: Target<'scope>, @@ -1246,6 +1388,7 @@ impl<'scope> Value<'scope, 'static> { } /// `UndefRefError`. + #[inline] pub fn undefref_exception(_: &T) -> Self where T: Target<'scope>, @@ -1255,6 +1398,7 @@ impl<'scope> Value<'scope, 'static> { } /// `InterruptException`. + #[inline] pub fn interrupt_exception(_: &T) -> Self where T: Target<'scope>, @@ -1264,6 +1408,7 @@ impl<'scope> Value<'scope, 'static> { } /// An empty `Array{Any, 1}. + #[inline] pub fn an_empty_vec_any(_: &T) -> Self where T: Target<'scope>, @@ -1273,6 +1418,7 @@ impl<'scope> Value<'scope, 'static> { } /// An empty immutable String, "". + #[inline] pub fn an_empty_string(_: &T) -> Self where T: Target<'scope>, @@ -1282,6 +1428,7 @@ impl<'scope> Value<'scope, 'static> { } /// `Array{UInt8, 1}` + #[inline] pub fn array_uint8_type(_: &T) -> Self where T: Target<'scope>, @@ -1291,6 +1438,7 @@ impl<'scope> Value<'scope, 'static> { } /// `Array{Any, 1}` + #[inline] pub fn array_any_type(_: &T) -> Self where T: Target<'scope>, @@ -1300,6 +1448,7 @@ impl<'scope> Value<'scope, 'static> { } /// `Array{Symbol, 1}` + #[inline] pub fn array_symbol_type(_: &T) -> Self where T: Target<'scope>, @@ -1309,6 +1458,7 @@ impl<'scope> Value<'scope, 'static> { } /// `Array{Int32, 1}` + #[inline] pub fn array_int32_type(_: &T) -> Self where T: Target<'scope>, @@ -1318,6 +1468,7 @@ impl<'scope> Value<'scope, 'static> { } /// The empty tuple, `()`. + #[inline] pub fn emptytuple(_: &T) -> Self where T: Target<'scope>, @@ -1327,6 +1478,7 @@ impl<'scope> Value<'scope, 'static> { } /// The instance of `true`. + #[inline] pub fn true_v(_: &T) -> Self where T: Target<'scope>, @@ -1336,6 +1488,7 @@ impl<'scope> Value<'scope, 'static> { } /// The instance of `false`. + #[inline] pub fn false_v(_: &T) -> Self where T: Target<'scope>, @@ -1345,6 +1498,7 @@ impl<'scope> Value<'scope, 'static> { } /// The instance of `Nothing`, `nothing`. + #[inline] pub fn nothing(_: &T) -> Self where T: Target<'scope>, @@ -1354,6 +1508,7 @@ impl<'scope> Value<'scope, 'static> { } /// The handle to `stdout` as a Julia value. + #[inline] pub fn stdout(_: &T) -> Self where T: Target<'scope>, @@ -1363,6 +1518,7 @@ impl<'scope> Value<'scope, 'static> { } /// The handle to `stderr` as a Julia value. + #[inline] pub fn stderr(_: &T) -> Self where T: Target<'scope>, @@ -1373,6 +1529,7 @@ impl<'scope> Value<'scope, 'static> { #[julia_version(since = "1.7")] /// The `Pair` type + #[inline] pub fn pair_type(_: &T) -> Self where T: Target<'scope>, @@ -1400,6 +1557,39 @@ impl<'data> Call<'data> for Value<'_, 'data> { target.result_from_ptr(res, Private) } + #[inline] + unsafe fn call_unchecked<'target, 'value, V, T, const N: usize>( + self, + target: T, + args: V, + ) -> ValueData<'target, 'data, T> + where + V: Values<'value, 'data, N>, + T: Target<'target>, + { + #[cfg(feature = "julia-1-6")] + let mut task = NonNull::new_unchecked(jl_sys::jl_get_ptls_states()); + #[cfg(not(feature = "julia-1-6"))] + let mut task = NonNull::new_unchecked(jl_sys::jl_get_current_task()); + + let last_age = { + let task = task.as_mut(); + let last_age = task.world_age; + task.world_age = jl_get_world_counter(); + last_age + }; + + let args = args.as_slice(Private); + let v = jl_apply_generic(self.0.as_ptr(), args.as_ptr() as *mut _, args.len() as _); + + { + let task = task.as_mut(); + task.world_age = last_age; + } + + target.data_from_ptr(NonNull::new_unchecked(v), Private) + } + #[inline] unsafe fn call1<'target, T>( self, @@ -1476,16 +1666,16 @@ impl<'data> Call<'data> for Value<'_, 'data> { } #[inline] - unsafe fn call<'target, 'value, V, T>( + unsafe fn call<'target, 'value, V, T, const N: usize>( self, target: T, args: V, ) -> ValueResult<'target, 'data, T> where - V: AsRef<[Value<'value, 'data>]>, + V: Values<'value, 'data, N>, T: Target<'target>, { - let args = args.as_ref(); + let args = args.as_slice(Private); let n = args.len(); let res = jl_call( self.unwrap(Private), @@ -1505,6 +1695,7 @@ impl<'data> Call<'data> for Value<'_, 'data> { } impl<'value, 'data> ProvideKeywords<'value, 'data> for Value<'value, 'data> { + #[inline] fn provide_keywords( self, kws: Value<'value, 'data>, @@ -1526,17 +1717,17 @@ impl<'scope, 'data> ManagedPriv<'scope, 'data> for Value<'scope, 'data> { // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } } -impl_construct_type_managed!(Option>, jl_any_type); - /// A reference to a [`Value`] that has not been explicitly rooted. pub type ValueRef<'scope, 'data> = Ref<'scope, 'data, Value<'scope, 'data>>; @@ -1551,27 +1742,63 @@ pub type ValueRet = Ref<'static, 'static, Value<'static, 'static>>; pub type ValueUnbound = Value<'static, 'static>; unsafe impl ValidLayout for ValueRef<'_, '_> { + #[inline] fn valid_layout(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; !dt.is_inline_alloc() - } else if v.cast::().is_ok() { + } else if v.is::() { true - } else if let Ok(u) = v.cast::() { + } else if v.is::() { + let u = unsafe { v.cast_unchecked::() }; !u.is_bits_union() } else { false } } + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + DataType::any_type(target).as_value() + } + const IS_REF: bool = true; } + +unsafe impl ValidLayout for Value<'static, 'static> { + #[inline] + fn valid_layout(v: Value) -> bool { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; + !dt.is_inline_alloc() + } else if v.is::() { + true + } else if v.is::() { + let u = unsafe { v.cast_unchecked::() }; + !u.is_bits_union() + } else { + false + } + } + + #[inline] + fn type_object<'target, Tgt: Target<'target>>(target: &Tgt) -> Value<'target, 'static> { + DataType::any_type(target).as_value() + } + + const IS_REF: bool = true; +} + unsafe impl ValidField for Option> { + #[inline] fn valid_field(v: Value) -> bool { - if let Ok(dt) = v.cast::() { + if v.is::() { + let dt = unsafe { v.cast_unchecked::() }; !dt.is_inline_alloc() - } else if v.cast::().is_ok() { + } else if v.is::() { true - } else if let Ok(u) = v.cast::() { + } else if v.is::() { + let u = unsafe { v.cast_unchecked::() }; !u.is_bits_union() } else { false @@ -1579,16 +1806,82 @@ unsafe impl ValidField for Option> { } } -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; /// `Value` or `ValueRef`, depending on the target type `T`. pub type ValueData<'target, 'data, T> = >::Data<'data, Value<'target, 'data>>; /// `JuliaResult` or `JuliaResultRef`, depending on the target type `T`. -pub type ValueResult<'target, 'data, T> = - >::Result<'data, Value<'target, 'data>>; +pub type ValueResult<'target, 'data, T> = TargetResult<'target, 'data, Value<'target, 'data>, T>; impl_ccall_arg_managed!(Value, 2); -impl_construct_type_managed!(Value<'_, '_>, jl_any_type); +impl_construct_type_managed!(Value, 2, jl_any_type); + +unsafe fn check_union_equivalent<'target, L: ValidLayout, Tgt: Target<'target>>( + target: &Tgt, + idx: usize, + u: Union, +) -> JlrsResult<()> { + // TODO: Union{}? + + // Field is a bits union. Check if the union in the layout and the constructed type contain + // the same types. + let type_obj = L::type_object(target); + if let Ok(type_obj) = type_obj.cast::() { + let ft_in_layout = type_obj + .field_type_unchecked(target, idx) + .unwrap() + .as_value(); + if ft_in_layout != u { + Err(TypeError::IncompatibleType { + element_type: u.display_string_or(CANNOT_DISPLAY_TYPE), + value_type: ft_in_layout.display_string_or(CANNOT_DISPLAY_TYPE), + })? + } + } else if let Ok(type_obj) = type_obj.cast::() { + let base_type_obj = type_obj.base_type(); + let ft_in_layout = base_type_obj + .field_type_unchecked(target, idx) + .unwrap() + .as_value(); + if ft_in_layout != u { + Err(TypeError::IncompatibleType { + element_type: u.display_string_or(CANNOT_DISPLAY_TYPE), + value_type: ft_in_layout.display_string_or(CANNOT_DISPLAY_TYPE), + })? + } + } else { + Err(TypeError::NotA { + value: type_obj.display_string_or(CANNOT_DISPLAY_TYPE), + field_type: "DataType or UnionAll".into(), + })? + } + + Ok(()) +} + +unsafe fn check_field_isa( + ft: Value, + l_ptr: *const L, + offset: usize, +) -> JlrsResult<()> { + // Field is a pointer field, check if the provided value in that position is a valid instance + // of the field type. + if let Some(field) = l_ptr + .cast::>() + .add(offset) + .cast::() + .as_ref() + { + if !field.isa(ft) { + Err(TypeError::NotA { + value: field.display_string_or(""), + field_type: ft.display_string_or(""), + })? + } + } + + Ok(()) +} diff --git a/jlrs/src/data/managed/value/tracked.rs b/jlrs/src/data/managed/value/tracked.rs index e893a7c4..a193431f 100644 --- a/jlrs/src/data/managed/value/tracked.rs +++ b/jlrs/src/data/managed/value/tracked.rs @@ -29,6 +29,7 @@ pub struct Tracked<'tracked, 'scope, 'data, T> { } impl<'tracked, 'scope, 'data, T: ValidLayout> Tracked<'tracked, 'scope, 'data, T> { + #[inline] pub(crate) unsafe fn new(value: &'tracked Value<'scope, 'data>) -> Self { Tracked { tracked: value.data_ptr().cast::().as_ref(), @@ -39,6 +40,7 @@ impl<'tracked, 'scope, 'data, T: ValidLayout> Tracked<'tracked, 'scope, 'data, T } impl<'scope, 'data, T: ValidLayout> Tracked<'scope, 'scope, 'data, T> { + #[inline] pub(crate) unsafe fn new_owned(value: Value<'scope, 'data>) -> Self { Tracked { tracked: value.data_ptr().cast::().as_ref(), @@ -51,6 +53,7 @@ impl<'scope, 'data, T: ValidLayout> Tracked<'scope, 'scope, 'data, T> { impl<'tracked, 'scope, 'data, T: ValidLayout> Deref for Tracked<'tracked, 'scope, 'data, T> { type Target = T; + #[inline] fn deref(&self) -> &Self::Target { self.tracked } @@ -87,6 +90,7 @@ pub struct TrackedMut<'tracked, 'scope, 'data, T: ValidLayout> { } impl<'tracked, 'scope, 'data, T: ValidLayout> TrackedMut<'tracked, 'scope, 'data, T> { + #[inline] pub(crate) unsafe fn new(value: &'tracked mut Value<'scope, 'data>) -> Self { TrackedMut { t: value.data_ptr().cast::().as_mut(), @@ -97,6 +101,7 @@ impl<'tracked, 'scope, 'data, T: ValidLayout> TrackedMut<'tracked, 'scope, 'data } impl<'scope, 'data, T: ValidLayout> TrackedMut<'scope, 'scope, 'data, T> { + #[inline] pub(crate) unsafe fn new_owned(value: Value<'scope, 'data>) -> Self { TrackedMut { t: value.data_ptr().cast::().as_mut(), @@ -109,12 +114,14 @@ impl<'scope, 'data, T: ValidLayout> TrackedMut<'scope, 'scope, 'data, T> { impl<'tracked, 'scope, 'data, T: ValidLayout> Deref for TrackedMut<'tracked, 'scope, 'data, T> { type Target = T; + #[inline] fn deref(&self) -> &Self::Target { self.t } } impl<'tracked, 'scope, 'data, T: ValidLayout> DerefMut for TrackedMut<'tracked, 'scope, 'data, T> { + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { self.t } @@ -129,7 +136,7 @@ impl Drop for TrackedMut<'_, '_, '_, T> { fn drop(&mut self) { unsafe { let v = Value::wrap_non_null( - NonNull::new_unchecked(self.t as *const _ as *mut jl_value_t), + NonNull::new_unchecked(self.t as *mut _ as *mut jl_value_t), Private, ); Ledger::unborrow_exclusive(v).unwrap(); diff --git a/jlrs/src/data/managed/value/typed.rs b/jlrs/src/data/managed/value/typed.rs index 4ae6321c..663cd4df 100644 --- a/jlrs/src/data/managed/value/typed.rs +++ b/jlrs/src/data/managed/value/typed.rs @@ -40,7 +40,7 @@ use crate::{ types::{abstract_types::AnyType, construct_type::ConstructType, typecheck::Typecheck}, }, error::{JlrsResult, TypeError}, - memory::target::{frame::GcFrame, ExtendedTarget, Target}, + memory::target::{Target, TargetResult}, private::Private, }; @@ -61,6 +61,7 @@ pub struct TypedValue<'scope, 'data, T>( impl TypedValue<'_, '_, U> { /// Create a new typed value, any type that implements [`IntoJulia`] can be converted using /// this function. + #[inline] pub fn new<'target, T>(target: T, data: U) -> TypedValueData<'target, 'static, U, T> where T: Target<'target>, @@ -74,34 +75,57 @@ impl TypedValue<'_, '_, U> { } } +impl TypedValue<'_, '_, U> { + /// Create a new typed value, any type that implements [`ValidLayout`] can be converted using + /// this function as long as it's valid for `U`. + #[inline] + pub fn try_new_with<'target, L, Tgt>( + target: Tgt, + data: L, + ) -> JlrsResult> + where + L: ValidLayout, + Tgt: Target<'target>, + { + unsafe { + let v = Value::try_new_with::(&target, data)?.as_value(); + Ok(TypedValue::::from_value_unchecked(v).root(target)) + } + } +} + impl<'scope, 'data, U: ConstructType> TypedValue<'scope, 'data, U> { /// Create a new typed value from an existing value. - pub fn from_value( - frame: &mut GcFrame, + pub fn from_value<'target, Tgt>( + target: &Tgt, value: Value<'scope, 'data>, - ) -> JlrsResult> { - frame.scope(|mut frame| { - let ty = U::construct_type(frame.as_extended_target()); - if value.isa(ty) { - unsafe { + ) -> JlrsResult> + where + Tgt: Target<'target>, + { + unsafe { + target.local_scope::<_, _, 1>(|mut frame| { + let ty = U::construct_type(&mut frame).as_value(); + if value.isa(ty) { Ok(TypedValue::::wrap_non_null( value.unwrap_non_null(Private), Private, )) + } else { + Err(TypeError::NotA { + value: value.display_string_or(""), + field_type: ty.display_string_or(""), + })? } - } else { - Err(TypeError::NotA { - value: value.display_string_or(""), - field_type: ty.display_string_or(""), - })? - } - }) + }) + } } /// Create a new typed value from an existing value without checking the value is an instance /// of `U`. /// /// Safety: `value` must be an instance of the constructed type `U`. + #[inline] pub unsafe fn from_value_unchecked( value: Value<'scope, 'data>, ) -> TypedValue<'scope, 'data, U> { @@ -113,6 +137,7 @@ impl<'scope, 'data, U: ValidLayout + ConstructType> TypedValue<'scope, 'data, U> /// Track `self` immutably. /// /// See [`Value::track_shared`] for more information. + #[inline] pub unsafe fn track_shared<'tracked>( &'tracked self, ) -> JlrsResult> { @@ -122,6 +147,7 @@ impl<'scope, 'data, U: ValidLayout + ConstructType> TypedValue<'scope, 'data, U> /// Track `self` mutably. /// /// See [`Value::track_exclusive`] for more information. + #[inline] pub unsafe fn track_exclusive<'tracked>( &'tracked mut self, ) -> JlrsResult> { @@ -133,6 +159,7 @@ impl<'scope, 'data, U: ConstructType> TypedValue<'scope, 'data, U> { /// Track `self` immutably. /// /// See [`Value::track_shared`] for more information. + #[inline] pub unsafe fn track_shared_as<'tracked, V: ValidLayout>( &'tracked self, ) -> JlrsResult> { @@ -142,6 +169,7 @@ impl<'scope, 'data, U: ConstructType> TypedValue<'scope, 'data, U> { /// Track `self` mutably. /// /// See [`Value::track_exclusive`] for more information. + #[inline] pub unsafe fn track_exclusive_as<'tracked, V: ValidLayout>( &'tracked mut self, ) -> JlrsResult> { @@ -153,6 +181,7 @@ impl TypedValueUnbound { /// Track `self` immutably. /// /// See [`Value::track_shared_unbound`] for more information. + #[inline] pub unsafe fn track_shared_unbound(self) -> JlrsResult> { self.as_value().track_shared_unbound() } @@ -160,6 +189,7 @@ impl TypedValueUnbound { /// Track `self` mutably. /// /// See [`Value::track_exclusive_unbound`] for more information. + #[inline] pub unsafe fn track_exclusive_unbound( self, ) -> JlrsResult> { @@ -171,6 +201,7 @@ impl TypedValueUnbound { /// Track `self` immutably. /// /// See [`Value::track_shared_unbound`] for more information. + #[inline] pub unsafe fn track_shared_unbound_as( self, ) -> JlrsResult> { @@ -180,6 +211,7 @@ impl TypedValueUnbound { /// Track `self` mutably. /// /// See [`Value::track_exclusive_unbound`] for more information. + #[inline] pub unsafe fn track_exclusive_unbound_as( self, ) -> JlrsResult> { @@ -190,11 +222,13 @@ impl TypedValueUnbound { impl<'scope, 'data, U: ConstructType> Deref for TypedValue<'scope, 'data, U> { type Target = Value<'scope, 'data>; + #[inline] fn deref(&self) -> &Self::Target { unsafe { std::mem::transmute(self) } } } impl<'scope, 'data, U: ConstructType> DerefMut for TypedValue<'scope, 'data, U> { + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { unsafe { std::mem::transmute(self) } } @@ -213,6 +247,7 @@ impl Clone for TypedValue<'_, '_, T> where T: ConstructType, { + #[inline] fn clone(&self) -> Self { unsafe { Self::wrap_non_null(self.unwrap_non_null(Private), Private) } } @@ -224,16 +259,26 @@ unsafe impl ValidLayout for TypedValue<'_, '_, T> where T: ConstructType, { + #[inline] fn valid_layout(v: Value) -> bool { ValueRef::valid_layout(v) } + #[inline] + fn type_object<'target, Tgt>(target: &Tgt) -> Value<'target, 'static> + where + Tgt: Target<'target>, + { + T::base_type(target).expect("Type has no base type") + } + const IS_REF: bool = true; } unsafe impl ValidField for Option> where T: ConstructType, { + #[inline] fn valid_field(v: Value) -> bool { Option::::valid_field(v) } @@ -249,10 +294,12 @@ where // Safety: `inner` must not have been freed yet, the result must never be // used after the GC might have freed it. + #[inline] unsafe fn wrap_non_null(inner: NonNull, _: Private) -> Self { Self(inner, PhantomData, PhantomData, PhantomData) } + #[inline] fn unwrap_non_null(self, _: Private) -> NonNull { self.0 } @@ -262,37 +309,41 @@ unsafe impl<'scope, 'data, T> Typecheck for TypedValue<'scope, 'data, T> where T: ValidLayout + ConstructType, { + #[inline] fn typecheck(t: DataType) -> bool { T::valid_layout(t.as_value()) } } -unsafe impl ConstructType for TypedValue<'_, 'static, U> +unsafe impl ConstructType for TypedValue<'_, '_, U> where U: ConstructType, { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = U::Static; + + #[inline] + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - U::construct_type(target) + U::construct_type_uncached(target) } - fn base_type<'target, Tgt>(_target: &Tgt) -> Option> + #[inline] + fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - None + U::base_type(target) } } -use crate::memory::target::target_type::TargetType; +use crate::memory::target::TargetType; pub type TypedValueRef<'scope, 'data, T> = Ref<'scope, 'data, TypedValue<'scope, 'data, T>>; impl<'scope, 'data> TypedValueRef<'scope, 'data, AnyType> { + #[inline] pub fn from_value_ref(value_ref: ValueRef<'scope, 'data>) -> Self { TypedValueRef::wrap(value_ref.ptr()) } @@ -309,7 +360,7 @@ pub type TypedValueData<'target, 'data, U, T> = /// `JuliaResult` or `JuliaResultRef`, depending on the target type /// `T`. pub type TypedValueResult<'target, 'data, U, T> = - >::Result<'data, TypedValue<'target, 'data, U>>; + TargetResult<'target, 'data, TypedValue<'target, 'data, U>, T>; pub type TypedValueUnbound = TypedValue<'static, 'static, T>; @@ -321,4 +372,10 @@ unsafe impl<'scope, 'data, T: ConstructType> CCallArg for TypedValue<'scope, 'da unsafe impl CCallReturn for TypedValueRef<'static, 'static, T> { type CCallReturnType = Value<'static, 'static>; type FunctionReturnType = T; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } diff --git a/jlrs/src/data/static_data.rs b/jlrs/src/data/static_data.rs index 5d8ca1a5..c2ea8c45 100644 --- a/jlrs/src/data/static_data.rs +++ b/jlrs/src/data/static_data.rs @@ -2,66 +2,30 @@ //! //! Accessing global Julia data through the module system can be expensive. If the global is a //! constant or never replaced with another value, this data is globally rooted so it's safe to -//! hold on to a reference to this data. -//! -//! This module provides [`StaticSymbol`] and [`StaticGlobal`], and macros to create and access -//! them. - -use std::marker::PhantomData; +//! hold on to a reference to this data. This module provides [`StaticGlobal`] and [`StaticRef`], +//! and macros to create and access them. -use once_cell::sync::OnceCell; +use std::{ + marker::PhantomData, + ptr::{null_mut, NonNull}, + sync::atomic::AtomicPtr, +}; -use super::{managed::symbol::SymbolUnbound, types::typecheck::Typecheck}; +use super::types::typecheck::Typecheck; use crate::{ - data::managed::{module::Module, symbol::Symbol, value::ValueUnbound, Managed}, + data::managed::{module::Module, value::ValueUnbound, Managed}, + gc_safe::GcSafeOnceLock, memory::target::Target, + private::Private, }; struct StaticDataInner(ValueUnbound, PhantomData); unsafe impl Send for StaticDataInner {} unsafe impl Sync for StaticDataInner {} -/// Static reference to a [`Symbol`]. -/// -/// Symbols are immutable and guaranteed to be globally rooted. -pub struct StaticSymbol { - sym: OnceCell>, - sym_str: &'static str, -} - -impl StaticSymbol { - /// Define a new static symbol `sym`. - /// - /// The symbol is created when it's accessed for the first time. - pub const fn new(sym: &'static str) -> Self { - StaticSymbol { - sym: OnceCell::new(), - sym_str: sym, - } - } - - /// Get the symbol, create it if it doesn't exist yet. - pub fn get_or_init<'target, Tgt>(&self, target: &Tgt) -> SymbolUnbound - where - Tgt: Target<'target>, - { - unsafe { - self.sym - .get_or_init(|| { - StaticDataInner( - Symbol::new(target, self.sym_str).leak().as_value(), - PhantomData, - ) - }) - .0 - .cast_unchecked() - } - } -} - -/// Static reference to arbitrary managed data. +/// Static reference to arbitrary managed data. Guaranteed to be initialized at most once. pub struct StaticGlobal { - global: OnceCell>, + global: GcSafeOnceLock>, path: &'static str, } @@ -73,9 +37,10 @@ where /// /// The global is looked up only once when this data is accessedd for the first time. The /// `path` argument must be the full path to the data, e.g. `"Main.Submodule.Foo"`. + #[inline] pub const fn new(path: &'static str) -> StaticGlobal { StaticGlobal { - global: OnceCell::new(), + global: GcSafeOnceLock::new(), path, } } @@ -88,42 +53,58 @@ where Tgt: Target<'target>, { unsafe { - self.global - .get_or_init(|| { - let split_path = self.path.split('.').collect::>(); - let n_parts = split_path.len(); + if let Some(global) = self.global.get() { + return global.0.cast_unchecked::(); + } else { + self.init(target) + } + } + } - let mut module = match split_path[0] { - "Main" => Module::main(target), - "Base" => Module::base(target), - "Core" => Module::core(target), - pkg => Module::package_root_module(target, pkg).unwrap(), - }; + #[inline(never)] + #[cold] + unsafe fn init<'target, Tgt>(&self, target: &Tgt) -> T + where + Tgt: Target<'target>, + { + // If multiple threads try to initialize the global, only one calls the init code and + // the others are parked. We call jlrs_gc_safe_enter to allow the GC to run while a + // thread is parked, and immediately transition back once we regain control. + let global = self.global.get_or_init(|| { + let split_path = self.path.split('.').collect::>(); + let n_parts = split_path.len(); - if n_parts == 1 { - let global = module.leak().as_value().cast::().unwrap(); - return StaticDataInner(global.as_value(), PhantomData); - } + let mut module = match split_path[0] { + "Main" => Module::main(target), + "Base" => Module::base(target), + "Core" => Module::core(target), + pkg => Module::package_root_module(target, pkg).unwrap(), + }; - for i in 1..n_parts - 1 { - module = module - .submodule(target, split_path[i]) - .unwrap() - .as_managed(); - } + if n_parts == 1 { + let global = module.leak().as_value().cast::().unwrap(); + return StaticDataInner(global.as_value(), PhantomData); + } - let global = module - .global(target, split_path[n_parts - 1]) - .unwrap() - .leak() - .as_value() - .cast::() - .unwrap(); - return StaticDataInner(global.as_value(), PhantomData); - }) - .0 - .cast_unchecked() - } + for i in 1..n_parts - 1 { + module = module + .submodule(target, split_path[i]) + .unwrap() + .as_managed(); + } + + let global = module + .global(target, split_path[n_parts - 1]) + .unwrap() + .leak() + .as_value() + .cast::() + .unwrap(); + + return StaticDataInner(global.as_value(), PhantomData); + }); + + global.0.cast_unchecked() } } @@ -134,96 +115,99 @@ impl StaticGlobal { /// `path` argument must be the full path to the data, e.g. `"Main.Submodule.Foo"`. pub const fn new_value(path: &'static str) -> StaticGlobal { StaticGlobal { - global: OnceCell::new(), + global: GcSafeOnceLock::new(), + path, + } + } +} + +/// Static reference to arbitrary managed data. Can be initialized multiple times. +/// +/// In general, a `StaticRef` is faster than a `StaticGlobal`. +pub struct StaticRef> { + global: AtomicPtr, + path: &'static str, +} + +impl StaticRef +where + T: Managed<'static, 'static> + Typecheck, +{ + /// Define a new static ref available at `path`. + /// + /// The global is looked up if the ref is uninitialized. The `path` argument must be the full + /// path to the data, e.g. `"Main.Submodule.Foo"`. + #[inline] + pub const fn new(path: &'static str) -> StaticRef { + StaticRef { + global: AtomicPtr::new(null_mut()), path, } } /// Get the global data, look it up if it doesn't exist yet. /// - /// The global must exist. Otherwise this method will panic. - pub fn get_or_init<'target, Tgt>(&self, target: &Tgt) -> ValueUnbound + /// The global must exist and be an instance of `T`. Otherwise this method will panic. + #[inline] + pub fn get_or_init<'target, Tgt>(&self, target: &Tgt) -> T + where + Tgt: Target<'target>, + { + let ptr = self.global.load(atomic::Ordering::Relaxed); + if ptr.is_null() { + // It's fine to initialize this multiple times. We're going to store the same data each time. + self.init(target) + } else { + unsafe { T::wrap_non_null(NonNull::new_unchecked(ptr), Private) } + } + } + + #[cold] + #[inline(never)] + fn init<'target, Tgt>(&self, target: &Tgt) -> T where Tgt: Target<'target>, { unsafe { - self.global - .get_or_init(|| { - let split_path = self.path.split('.').collect::>(); - let n_parts = split_path.len(); + let split_path = self.path.split('.').collect::>(); + let n_parts = split_path.len(); + + let mut module = match split_path[0] { + "Main" => Module::main(target), + "Base" => Module::base(target), + "Core" => Module::core(target), + pkg => Module::package_root_module(target, pkg).unwrap(), + }; - let mut module = match split_path[0] { - "Main" => Module::main(target), - "Base" => Module::base(target), - "Core" => Module::core(target), - pkg => Module::package_root_module(target, pkg).unwrap(), - }; + if n_parts == 1 { + let global = module.leak().as_value().cast::().unwrap(); + let ptr = global.unwrap(Private); + self.global.store(ptr, atomic::Ordering::Relaxed); + return T::wrap_non_null(NonNull::new_unchecked(ptr), Private); + } - if n_parts == 1 { - let global = module.leak().as_value(); - return StaticDataInner(global, PhantomData); - } + for i in 1..n_parts - 1 { + module = module + .submodule(target, split_path[i]) + .unwrap() + .as_managed(); + } - for i in 1..n_parts - 1 { - module = module - .submodule(target, split_path[i]) - .unwrap() - .as_managed(); - } + let global = module + .global(target, split_path[n_parts - 1]) + .unwrap() + .leak() + .as_value() + .cast::() + .unwrap(); - let global = module - .global(target, split_path[n_parts - 1]) - .unwrap() - .leak() - .as_value(); - return StaticDataInner(global, PhantomData); - }) - .0 - .cast_unchecked() + let ptr = global.unwrap(Private); + self.global.store(ptr, atomic::Ordering::Relaxed); + T::wrap_non_null(NonNull::new_unchecked(ptr), Private) } } } -/// Define a static symbol -#[macro_export] -macro_rules! define_static_symbol { - ($name:ident, $sym:ident) => { - static $name: $crate::data::static_data::StaticSymbol = - $crate::data::static_data::StaticSymbol::new(stringify!($sym)); - }; - (pub $name:ident, $sym:ident) => { - pub static $name: $crate::data::static_data::StaticSymbol = - $crate::data::static_data::StaticSymbol::new(stringify!($sym)); - }; - (pub(crate) $name:ident, $sym:ident) => { - pub(crate) static $name: $crate::data::static_data::StaticSymbol = - $crate::data::static_data::StaticSymbol::new(stringify!($sym)); - }; -} - -/// Use a previously defined static symbol -#[macro_export] -macro_rules! static_symbol { - ($name:ident, $target:expr) => {{ - let sym: $crate::data::managed::symbol::Symbol = $name.get_or_init(&$target); - sym - }}; -} - -/// Define an inline static symbol. -/// -/// `inline_static_symbol!(NAME, sym,target)` is equivalent to -/// `{ define_static_symbol!(NAME, sym); static_symbol!(NAME, target) } ` -#[macro_export] -macro_rules! inline_static_symbol { - ($name:ident, $sym:ident, $target:expr) => {{ - static $name: $crate::data::static_data::StaticSymbol = - $crate::data::static_data::StaticSymbol::new(stringify!($sym)); - let sym: $crate::data::managed::symbol::Symbol = $name.get_or_init(&$target); - sym - }}; -} - /// Define a static global #[macro_export] macro_rules! define_static_global { @@ -256,6 +240,23 @@ macro_rules! define_static_global { }; } +/// Define a static ref +#[macro_export] +macro_rules! define_static_ref { + ($name:ident, $type:ty, $path:expr) => { + static $name: $crate::data::static_data::StaticRef<$type> = + $crate::data::static_data::StaticRef::new($path); + }; + (pub $name:ident, $type:ty, $path:expr) => { + pub static $name: $crate::data::static_data::StaticRef<$type> = + $crate::data::static_data::StaticRef::new($path); + }; + (pub(crate) $name:ident, $type:ty, $path:expr) => { + pub(crate) static $name: $crate::data::static_data::StaticRef<$type> = + $crate::data::static_data::StaticRef::new($path); + }; +} + /// Use a previously defined static global #[macro_export] macro_rules! static_global { @@ -263,14 +264,23 @@ macro_rules! static_global { $name.get_or_init(&$target) }}; } +/// Use a previously defined static ref +#[macro_export] +macro_rules! static_ref { + ($name:ident, $target:expr) => {{ + $name.get_or_init(&$target) + }}; +} -pub(crate) use define_static_global; -pub(crate) use static_global; +pub use define_static_global; +pub use define_static_ref; +pub use static_global; +pub use static_ref; /// Define an inline static global. /// -/// `inline_static_global!(NAME, T, target)` is equivalent to -/// `{ define_static_global!(NAME, T); static_global!(NAME, target) } ` +/// `inline_static_global!(NAME, T, path, target)` is equivalent to +/// `{ define_static_global!(NAME, T, path); static_global!(NAME, target) }` #[macro_export] macro_rules! inline_static_global { ($name:ident, $type:ty, $path:expr, $target:expr) => {{ @@ -282,3 +292,15 @@ macro_rules! inline_static_global { $crate::data::static_data::static_global!($name, $target) }}; } + +/// Define an inline static ref. +/// +/// `inline_static_ref!(NAME, T, path, target)` is equivalent to +/// `{ define_static_ref!(NAME, T, path); static_ref!(NAME, target) }` +#[macro_export] +macro_rules! inline_static_ref { + ($name:ident, $type:ty, $path:expr, $target:expr) => {{ + $crate::data::static_data::define_static_ref!($name, $type, $path); + $crate::data::static_data::static_ref!($name, $target) + }}; +} diff --git a/jlrs/src/data/types/abstract_types.rs b/jlrs/src/data/types/abstract_types.rs index dc03b388..0c285d49 100644 --- a/jlrs/src/data/types/abstract_types.rs +++ b/jlrs/src/data/types/abstract_types.rs @@ -2,56 +2,79 @@ //! //! These types can be used with the `ConstructType` trait. -use std::{marker::PhantomData, ptr::NonNull}; +use std::marker::PhantomData; -use jl_sys::{jl_any_type, jl_value_t}; use jlrs_macros::julia_version; use super::construct_type::ConstructType; use crate::{ data::managed::{ datatype::DataType, - module::Module, - private::ManagedPriv, type_var::TypeVar, union_all::UnionAll, value::{Value, ValueData}, Managed, }, - memory::target::{ExtendedTarget, Target}, - private::Private, + inline_static_ref, + memory::target::Target, }; /// Marker trait that must only be implemented by type constructors that build an abstract type. pub unsafe trait AbstractType: ConstructType {} macro_rules! impl_construct_julia_type_abstract { - ($ty:ty, $mod:ident) => { + ($ty:ty, $path:expr) => { unsafe impl ConstructType for $ty { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = $ty; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, _) = target.split(); - Module::$mod(&target) - .global(target, stringify!($ty)) - .unwrap() + Self::base_type(&target).unwrap().root(target) } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::$mod(target) - .global(target, stringify!($ty)) - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, $path, target); + Some(value) + } + } + }; +} + +macro_rules! impl_construct_julia_type_abstract_using { + ($ty:ty, $path:expr) => { + unsafe impl ConstructType for $ty { + type Static = $ty; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, Tgt>( + target: Tgt, + ) -> ValueData<'target, 'static, Tgt> + where + Tgt: Target<'target>, + { + Self::base_type(&target).unwrap().root(target) + } + + #[inline] + fn base_type<'target, Tgt>(target: &Tgt) -> Option> + where + Tgt: Target<'target>, + { + let value = $path(target).as_value(); + Some(value) } } }; @@ -61,109 +84,87 @@ macro_rules! impl_construct_julia_type_abstract { /// Construct a new `Core.AbstractChar` type object. pub struct AbstractChar; unsafe impl AbstractType for AbstractChar {} -impl_construct_julia_type_abstract!(AbstractChar, core); +impl_construct_julia_type_abstract!(AbstractChar, "Core.AbstractChar"); /// Construct a new `Core.AbstractFloat` type object. pub struct AbstractFloat; unsafe impl AbstractType for AbstractFloat {} -impl_construct_julia_type_abstract!(AbstractFloat, core); +impl_construct_julia_type_abstract_using!(AbstractFloat, DataType::floatingpoint_type); /// Construct a new `Core.AbstractString` type object. pub struct AbstractString; unsafe impl AbstractType for AbstractString {} -impl_construct_julia_type_abstract!(AbstractString, core); +impl_construct_julia_type_abstract!(AbstractString, "Core.AbstractString"); /// Construct a new `Core.Exception` type object. pub struct Exception; unsafe impl AbstractType for Exception {} -impl_construct_julia_type_abstract!(Exception, core); +impl_construct_julia_type_abstract!(Exception, "Core.Exception"); /// Construct a new `Core.Function` type object. pub struct Function; unsafe impl AbstractType for Function {} -impl_construct_julia_type_abstract!(Function, core); +impl_construct_julia_type_abstract_using!(Function, DataType::function_type); /// Construct a new `Core.IO` type object. pub struct IO; unsafe impl AbstractType for IO {} -impl_construct_julia_type_abstract!(IO, core); +impl_construct_julia_type_abstract!(IO, "Core.IO"); /// Construct a new `Core.Integer` type object. pub struct Integer; unsafe impl AbstractType for Integer {} -impl_construct_julia_type_abstract!(Integer, core); +impl_construct_julia_type_abstract!(Integer, "Core.Integer"); /// Construct a new `Core.Real` type object. pub struct Real; unsafe impl AbstractType for Real {} -impl_construct_julia_type_abstract!(Real, core); +impl_construct_julia_type_abstract!(Real, "Core.Real"); /// Construct a new `Core.Number` type object. pub struct Number; unsafe impl AbstractType for Number {} -impl_construct_julia_type_abstract!(Number, core); +impl_construct_julia_type_abstract_using!(Number, DataType::number_type); /// Construct a new `Core.Signed` type object. pub struct Signed; unsafe impl AbstractType for Signed {} -impl_construct_julia_type_abstract!(Signed, core); +impl_construct_julia_type_abstract_using!(Signed, DataType::signed_type); /// Construct a new `Core.Unsigned` type object. pub struct Unsigned; unsafe impl AbstractType for Unsigned {} -impl_construct_julia_type_abstract!(Unsigned, core); +impl_construct_julia_type_abstract!(Unsigned, "Core.Unsigned"); /// Construct a new `Base.AbstractDisplay` type object. pub struct AbstractDisplay; unsafe impl AbstractType for AbstractDisplay {} -impl_construct_julia_type_abstract!(AbstractDisplay, base); +impl_construct_julia_type_abstract!(AbstractDisplay, "Base.AbstractDisplay"); /// Construct a new `Base.AbstractIrrational` type object. pub struct AbstractIrrational; unsafe impl AbstractType for AbstractIrrational {} -impl_construct_julia_type_abstract!(AbstractIrrational, base); +impl_construct_julia_type_abstract!(AbstractIrrational, "Base.AbstractIrrational"); /// Construct a new `Base.AbstractMatch` type object. pub struct AbstractMatch; unsafe impl AbstractType for AbstractMatch {} -impl_construct_julia_type_abstract!(AbstractMatch, base); +impl_construct_julia_type_abstract!(AbstractMatch, "Base.AbstractMatch"); /// Construct a new `Base.AbstractPattern` type object. pub struct AbstractPattern; unsafe impl AbstractType for AbstractPattern {} -impl_construct_julia_type_abstract!(AbstractPattern, base); +impl_construct_julia_type_abstract!(AbstractPattern, "Base.AbstractPattern"); /// Construct a new `Base.IndexStyle` type object. pub struct IndexStyle; unsafe impl AbstractType for IndexStyle {} -impl_construct_julia_type_abstract!(IndexStyle, base); +impl_construct_julia_type_abstract!(IndexStyle, "Base.IndexStyle"); +/// Construct a new `Core.Signed` type object. pub struct AnyType; unsafe impl AbstractType for AnyType {} -unsafe impl ConstructType for AnyType { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> - where - T: Target<'target>, - { - let (target, _) = target.split(); - unsafe { - let ptr = NonNull::new_unchecked(jl_any_type.cast::()); - target.data_from_ptr(ptr, Private) - } - } - - fn base_type<'target, Tgt>(_target: &Tgt) -> Option> - where - Tgt: Target<'target>, - { - unsafe { - let ptr = NonNull::new_unchecked(jl_any_type.cast::()); - Some(Value::wrap_non_null(ptr, Private)) - } - } -} +impl_construct_julia_type_abstract_using!(AnyType, DataType::any_type); /// Construct a new `AbstractArray` type object from the provided type parameters. pub struct AbstractArray { @@ -174,25 +175,23 @@ pub struct AbstractArray { unsafe impl AbstractType for AbstractArray {} unsafe impl ConstructType for AbstractArray { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractArray; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); - let rank_param = N::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); + let rank_param = N::construct_type(&mut frame); let params = [ty_param, rank_param]; unsafe { let applied = UnionAll::abstractarray_type(&frame) .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -200,6 +199,7 @@ unsafe impl ConstructType for AbstractArray< .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -217,25 +217,23 @@ pub struct DenseArray { unsafe impl AbstractType for DenseArray {} unsafe impl ConstructType for DenseArray { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = DenseArray; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); - let rank_param = N::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); + let rank_param = N::construct_type(&mut frame); let params = [ty_param, rank_param]; unsafe { let applied = UnionAll::densearray_type(&frame) .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -243,6 +241,7 @@ unsafe impl ConstructType for DenseArray(target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -259,24 +258,22 @@ pub struct RefTypeConstructor { unsafe impl AbstractType for RefTypeConstructor {} unsafe impl ConstructType for RefTypeConstructor { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = RefTypeConstructor; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { let applied = UnionAll::ref_type(&frame) .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -284,6 +281,7 @@ unsafe impl ConstructType for RefTypeConstructor { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -300,24 +298,22 @@ pub struct TypeTypeConstructor { unsafe impl AbstractType for TypeTypeConstructor {} unsafe impl ConstructType for TypeTypeConstructor { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = TypeTypeConstructor; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { let applied = UnionAll::type_type(&frame) .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -325,6 +321,7 @@ unsafe impl ConstructType for TypeTypeConstructor { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -341,26 +338,23 @@ pub struct AbstractChannel { unsafe impl AbstractType for AbstractChannel {} unsafe impl ConstructType for AbstractChannel { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractChannel; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractChannel") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); + Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -368,18 +362,13 @@ unsafe impl ConstructType for AbstractChannel { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractChannel") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractChannel", target); + Some(value) } } @@ -392,27 +381,24 @@ pub struct AbstractDict { unsafe impl AbstractType for AbstractDict {} unsafe impl ConstructType for AbstractDict { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractDict; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let key_param = K::construct_type(frame.as_extended_target()); - let value_param = V::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let key_param = K::construct_type(&mut frame); + let value_param = V::construct_type(&mut frame); let params = [key_param, value_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractDict") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); + Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -420,18 +406,13 @@ unsafe impl ConstructType for AbstractDict(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractDict") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractDict", target); + Some(value) } } @@ -443,26 +424,22 @@ pub struct AbstractMatrix { unsafe impl AbstractType for AbstractMatrix {} unsafe impl ConstructType for AbstractMatrix { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractMatrix; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractMatrix") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -470,18 +447,13 @@ unsafe impl ConstructType for AbstractMatrix { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractMatrix") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractMatrix", target); + Some(value) } } @@ -493,26 +465,22 @@ pub struct AbstractRange { unsafe impl AbstractType for AbstractRange {} unsafe impl ConstructType for AbstractRange { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractRange; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractRange") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -520,18 +488,13 @@ unsafe impl ConstructType for AbstractRange { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractRange") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractRange", target); + Some(value) } } @@ -543,26 +506,22 @@ pub struct AbstractSet { unsafe impl AbstractType for AbstractSet {} unsafe impl ConstructType for AbstractSet { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractSet; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractSet") - .unwrap() - .as_value() + let applied = Self::base_type(&frame) + .unwrap_unchecked() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -570,18 +529,13 @@ unsafe impl ConstructType for AbstractSet { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractSet") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractSet", target); + Some(value) } } @@ -597,27 +551,23 @@ unsafe impl AbstractType for AbstractSlices< #[julia_version(since = "1.9")] unsafe impl ConstructType for AbstractSlices { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractSlices; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); - let n_param = N::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); + let n_param = N::construct_type(&mut frame); let params = [ty_param, n_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractSlices") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -625,18 +575,13 @@ unsafe impl ConstructType for AbstractSlices .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractSlices") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractSlices", target); + Some(value) } } @@ -646,26 +591,22 @@ pub struct AbstractUnitRange { } unsafe impl ConstructType for AbstractUnitRange { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractUnitRange; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractUnitRange") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -673,18 +614,13 @@ unsafe impl ConstructType for AbstractUnitRange { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractUnitRange") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractUnitRange", target); + Some(value) } } @@ -698,26 +634,22 @@ pub struct AbstractVector { unsafe impl AbstractType for AbstractVector {} unsafe impl ConstructType for AbstractVector { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = AbstractVector; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "AbstractVector") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -725,18 +657,13 @@ unsafe impl ConstructType for AbstractVector { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "AbstractVector") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.AbstractVector", target); + Some(value) } } @@ -748,26 +675,22 @@ pub struct DenseMatrix { unsafe impl AbstractType for DenseMatrix {} unsafe impl ConstructType for DenseMatrix { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = DenseMatrix; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "DenseMatrix") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -775,18 +698,13 @@ unsafe impl ConstructType for DenseMatrix { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "DenseMatrix") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.DenseMatrix", target); + Some(value) } } @@ -798,26 +716,22 @@ pub struct DenseVector { unsafe impl AbstractType for DenseVector {} unsafe impl ConstructType for DenseVector { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = DenseVector; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "DenseVector") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -825,18 +739,13 @@ unsafe impl ConstructType for DenseVector { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "DenseVector") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.DenseVector", target); + Some(value) } } @@ -848,38 +757,34 @@ pub struct Enum { unsafe impl AbstractType for Enum {} unsafe impl ConstructType for Enum { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = Enum; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); // Validate bound if let Ok(tvar) = ty_param.cast::() { unsafe { let ub = tvar.upper_bound(&frame).as_value(); - assert!(ub.subtype(Integer::construct_type(frame.as_extended_target()))); + assert!(ub.subtype(Integer::construct_type(&mut frame))); } } else { - assert!(ty_param.subtype(Integer::construct_type(frame.as_extended_target()))); + assert!(ty_param.subtype(Integer::construct_type(&mut frame))); } let params = [ty_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "Enum") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -887,18 +792,13 @@ unsafe impl ConstructType for Enum { .unwrap() } + #[inline] fn base_type<'target, Tgt>(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "Enum") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.Enum", target); + Some(value) } } @@ -911,27 +811,23 @@ pub struct OrdinalRange { unsafe impl AbstractType for OrdinalRange {} unsafe impl ConstructType for OrdinalRange { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = OrdinalRange; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); - let n_param = S::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); + let n_param = S::construct_type(&mut frame); let params = [ty_param, n_param]; unsafe { - let applied = Module::base(&frame) - .global(&frame, "OrdinalRange") + let applied = Self::base_type(&frame) .unwrap() - .as_value() .apply_type_unchecked(&mut frame, params); Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) } @@ -939,18 +835,13 @@ unsafe impl ConstructType for OrdinalRange(target: &Tgt) -> Option> where Tgt: Target<'target>, { - unsafe { - Some( - Module::base(target) - .global(target, "OrdinalRange") - .unwrap() - .as_value(), - ) - } + let value = inline_static_ref!(STATIC, Value, "Base.OrdinalRange", target); + Some(value) } } diff --git a/jlrs/src/data/types/construct_type.rs b/jlrs/src/data/types/construct_type.rs index 8be22d26..02295555 100644 --- a/jlrs/src/data/types/construct_type.rs +++ b/jlrs/src/data/types/construct_type.rs @@ -1,42 +1,80 @@ //! Construct Julia type objects from Rust types. -use std::{ffi::c_void, marker::PhantomData, ptr::NonNull}; +use std::{any::TypeId, ffi::c_void, marker::PhantomData, ptr::NonNull}; +use fnv::FnvHashMap; use jl_sys::{ - jl_array_type, jl_bool_type, jl_bottom_type, jl_char_type, jl_float32_type, jl_float64_type, - jl_int16_type, jl_int32_type, jl_int64_type, jl_int8_type, jl_pointer_type, jl_uint16_type, - jl_uint32_type, jl_uint64_type, jl_uint8_type, jl_uniontype_type, jl_value_t, + jl_array_typename, jl_bool_type, jl_bottom_type, jl_char_type, jl_float32_type, + jl_float64_type, jl_int16_type, jl_int32_type, jl_int64_type, jl_int8_type, jl_pointer_type, + jl_uint16_type, jl_uint32_type, jl_uint64_type, jl_uint8_type, jl_uniontype_type, jl_value_t, jl_voidpointer_type, }; use super::abstract_types::AnyType; use crate::{ - data::{ - layout::valid_layout::ValidField, - managed::{ - datatype::DataType, - type_var::TypeVar, - union::Union, - union_all::UnionAll, - value::{Value, ValueData}, - Managed, - }, + convert::to_symbol::ToSymbol, + data::managed::{ + datatype::DataType, + type_var::TypeVar, + union::Union, + union_all::UnionAll, + value::{Value, ValueData}, + Managed, }, - memory::target::{frame::GcFrame, ExtendedTarget, Target}, + gc_safe::{GcSafeOnceLock, GcSafeRwLock}, + memory::target::Target, + prelude::Tuple, private::Private, }; +static CONSTRUCTED_TYPE_CACHE: GcSafeOnceLock = GcSafeOnceLock::new(); + +pub(crate) unsafe fn init_constructed_type_cache() { + CONSTRUCTED_TYPE_CACHE.set(ConstructedTypes::new()).ok(); +} + /// Associate a Julia type object with a Rust type. /// /// Safety: /// /// `ConstructType::construct_type` must either return a valid type object, or an instance of an /// isbits type which is immediately used as a type parameter of another constructed type. -pub unsafe trait ConstructType { +pub unsafe trait ConstructType: Sized { + /// `Self`, but with all lifetimes set to `'static`. + type Static: 'static + ConstructType; + + /// Indicates whether the type might be cacheable. + /// + /// If set to `false`, `construct_type` will never try to cache or look up the + /// constructed type. It should be set to `false` if the constructed type isn't a `DataType`. + const CACHEABLE: bool = true; + + /// Returns the `TypeId` of this type. + #[inline] + fn type_id() -> TypeId { + TypeId::of::() + } + + /// Construct the type object and try to cache the result. If a cached entry is available, it + /// is returned. + #[inline] + fn construct_type<'target, T>(target: T) -> ValueData<'target, 'static, T> + where + T: Target<'target>, + { + if Self::CACHEABLE { + unsafe { + CONSTRUCTED_TYPE_CACHE + .get_unchecked() + .find_or_construct::(target) + } + } else { + Self::construct_type_uncached(target) + } + } + /// Constructs the type object associated with this type. - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + fn construct_type_uncached<'target, T>(target: T) -> ValueData<'target, 'static, T> where T: Target<'target>; @@ -48,30 +86,24 @@ pub unsafe trait ConstructType { fn base_type<'target, T>(target: &T) -> Option> where T: Target<'target>; - - /// Returns `true` if `T` is a valid field layout for instances of the constructed type. - fn is_compatible(frame: &mut GcFrame) -> bool - where - T: ValidField, - { - let ty = Self::construct_type(frame.as_extended_target()); - T::valid_field(ty) - } } macro_rules! impl_construct_julia_type_constant { ($ty:ty, $const_ty:ty) => { unsafe impl ConstructType for $ty { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = $ty; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, T>(target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, { - let (target, _) = target.split(); Value::new(target, N) } + #[inline] fn base_type<'target, T>(_target: &T) -> Option> where T: Target<'target>, @@ -85,19 +117,22 @@ macro_rules! impl_construct_julia_type_constant { macro_rules! impl_construct_julia_type_primitive { ($ty:ty, $jl_ty:ident) => { unsafe impl ConstructType for $ty { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = $ty; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, T>(target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, { - let (target, _) = target.split(); unsafe { let ptr = NonNull::new_unchecked($jl_ty.cast::()); target.data_from_ptr(ptr, Private) } } + #[inline] fn base_type<'target, T>(_target: &T) -> Option> where T: Target<'target>, @@ -136,6 +171,31 @@ impl_construct_julia_type_constant!(ConstantI64, i64); pub struct ConstantIsize; impl_construct_julia_type_constant!(ConstantIsize, isize); +/// Constant `isize`. +pub struct ConstantSize; +unsafe impl ConstructType for ConstantSize { + type Static = ConstantSize; + + const CACHEABLE: bool = false; + + #[inline] + fn construct_type_uncached<'target, T>(target: T) -> ValueData<'target, 'static, T> + where + T: Target<'target>, + { + Value::new(target, N as isize) + } + + #[inline] + fn base_type<'target, T>(_target: &T) -> Option> + where + T: Target<'target>, + { + None + } +} + +// TODO: UInt8 and/or Int8 objects are statically allocated in Julia and can be cached. /// Constant `u8`. pub struct ConstantU8; impl_construct_julia_type_constant!(ConstantU8, u8); @@ -164,16 +224,52 @@ impl_construct_julia_type_constant!(ConstantBool, bool); pub struct ConstantChar; impl_construct_julia_type_constant!(ConstantChar, char); +/// Constant string. Not a type constructor, but can be used to implement multi-character type +/// vars. +pub trait ConstantStr: 'static { + /// The string constant. + const STR: &'static str; +} + /// The name of a `TypeVar`. pub struct Name; /// Trait to set the name of`TypeVar`. -pub trait TypeVarName { - const NAME: char; +/// +/// Implemented by [`Name`], [`ConstantChar`], and implementations of [`ConstantStr`]. +pub trait TypeVarName: 'static { + /// The type returned by `name`. + type Sym: ToSymbol; + + // Returns the name. + fn name() -> Self::Sym; } impl TypeVarName for Name { - const NAME: char = N; + type Sym = String; + + #[inline] + fn name() -> Self::Sym { + String::from(N) + } +} + +impl TypeVarName for ConstantChar { + type Sym = String; + + #[inline] + fn name() -> Self::Sym { + String::from(N) + } +} + +impl TypeVarName for T { + type Sym = &'static str; + + #[inline] + fn name() -> Self::Sym { + Self::STR + } } /// Construct a new `TypeVar` from the provided type parameters. @@ -190,22 +286,20 @@ pub struct TypeVarConstructor< unsafe impl ConstructType for TypeVarConstructor { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = TypeVarConstructor; + + fn construct_type_uncached<'target, T>(target: T) -> ValueData<'target, 'static, T> where T: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let upper_bound = U::construct_type(frame.as_extended_target()); - let lower_bound = L::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let upper_bound = U::construct_type(&mut frame); + let lower_bound = L::construct_type(&mut frame); unsafe { Ok(TypeVar::new_unchecked( &target, - N::NAME.to_string(), + N::name(), Some(lower_bound), Some(upper_bound), ) @@ -216,6 +310,7 @@ unsafe impl ConstructType .unwrap() } + #[inline] fn base_type<'target, T>(_target: &T) -> Option> where T: Target<'target>, @@ -231,41 +326,43 @@ pub struct ArrayTypeConstructor { } unsafe impl ConstructType for ArrayTypeConstructor { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> + type Static = ArrayTypeConstructor; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let ty_param = T::construct_type(frame.as_extended_target()); - let rank_param = N::construct_type(frame.as_extended_target()); - let params = [ty_param, rank_param]; - unsafe { - let applied = UnionAll::array_type(&frame) - .as_value() + unsafe { + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let ty_param = T::construct_type(&mut frame); + let rank_param = N::construct_type(&mut frame); + let params = [ty_param, rank_param]; + let applied = Self::base_type(&frame) + .unwrap_unchecked() .apply_type_unchecked(&mut frame, params); + Ok(UnionAll::rewrap( - target.into_extended_target(&mut frame), + target, applied.cast_unchecked::(), )) - } - }) - .unwrap() + }) + .unwrap_unchecked() + } } + #[inline] fn base_type<'target, Tgt>(_target: &Tgt) -> Option> where Tgt: Target<'target>, { unsafe { - let ptr = NonNull::new_unchecked(jl_array_type.cast::()); + let wrapper = + NonNull::new_unchecked(NonNull::new_unchecked(jl_array_typename).as_ref().wrapper); + // let ptr = NonNull::new_unchecked(jl_array_type.cast::()); Some( ::wrap_non_null( - ptr, + wrapper, crate::private::Private, ), ) @@ -283,24 +380,23 @@ pub struct UnionTypeConstructor { } unsafe impl ConstructType for UnionTypeConstructor { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = UnionTypeConstructor; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, frame) = target.split(); - - frame - .scope(|mut frame| { - let l = L::construct_type(frame.as_extended_target()); - let r = R::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let l = L::construct_type(&mut frame); + let r = R::construct_type(&mut frame); unsafe { Ok(Union::new_unchecked(target, [l, r])) } }) .unwrap() } + #[inline] fn base_type<'target, Tgt>(_target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -320,19 +416,19 @@ unsafe impl ConstructType for UnionTypeConst pub struct BottomType; unsafe impl ConstructType for BottomType { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = BottomType; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, _) = target.split(); unsafe { let ptr = NonNull::new_unchecked(jl_bottom_type.cast::()); target.data_from_ptr(ptr, Private) } } + #[inline] fn base_type<'target, Tgt>(_target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -378,16 +474,15 @@ impl_construct_julia_type_primitive!(char, jl_char_type); impl_construct_julia_type_primitive!(*mut c_void, jl_voidpointer_type); unsafe impl ConstructType for *mut U { - fn construct_type<'target, T>( - target: ExtendedTarget<'target, '_, '_, T>, - ) -> ValueData<'target, 'static, T> + type Static = *mut U::Static; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { - let (target, frame) = target.split(); - frame - .scope(|mut frame| { - let ty = U::construct_type(frame.as_extended_target()); + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let ty = U::construct_type(&mut frame); unsafe { Ok(UnionAll::pointer_type(&frame) .as_value() @@ -397,6 +492,7 @@ unsafe impl ConstructType for *mut U { .unwrap() } + #[inline] fn base_type<'target, Tgt>(_target: &Tgt) -> Option> where Tgt: Target<'target>, @@ -412,3 +508,58 @@ unsafe impl ConstructType for *mut U { } } } + +struct ConstructedTypes { + data: GcSafeRwLock>>, +} + +impl ConstructedTypes { + fn new() -> Self { + ConstructedTypes { + data: GcSafeRwLock::new(FnvHashMap::default()), + } + } + + #[inline] + fn find_or_construct<'target, T: ConstructType, Tgt: Target<'target>>( + &self, + target: Tgt, + ) -> ValueData<'target, 'static, Tgt> { + let tid = T::type_id(); + + { + if let Some(res) = self.data.read().get(&tid).copied() { + return res.root(target); + } + } + + do_construct::(target, self, tid) + } +} + +#[inline(never)] +fn do_construct<'target, T: ConstructType, Tgt: Target<'target>>( + target: Tgt, + ct: &ConstructedTypes, + tid: TypeId, +) -> ValueData<'target, 'static, Tgt> { + unsafe { + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let ty = T::construct_type_uncached(&mut frame); + + if ty.is::() { + let dt = ty.cast_unchecked::(); + if !dt.has_free_type_vars() && (!dt.is::() || dt.is_concrete_type()) { + ct.data.write().insert(tid, ty.leak().as_value()); + } + } + + Ok(ty.root(target)) + }) + .unwrap_unchecked() + } +} + +unsafe impl Sync for ConstructedTypes {} +unsafe impl Send for ConstructedTypes {} diff --git a/jlrs/src/data/types/foreign_type.rs b/jlrs/src/data/types/foreign_type.rs index 5a2acd58..e71896d7 100644 --- a/jlrs/src/data/types/foreign_type.rs +++ b/jlrs/src/data/types/foreign_type.rs @@ -52,61 +52,82 @@ //! `julia_module` automatically takes care of this, otherwise you must manually call //! `OpaqueType::create_type` or `OpaqueType::reinit_type`. The first must be called if the //! type doesn't exist yet, the second if the module that defines the type has been precompiled. -use std::{any::TypeId, ffi::c_void, mem::MaybeUninit, ptr::NonNull, sync::RwLock}; +use std::{ + any::{Any, TypeId}, + ffi::c_void, + marker::PhantomData, + mem::MaybeUninit, + ptr::NonNull, +}; +use cfg_if::cfg_if; +use fnv::FnvHashMap; #[julia_version(except = ["1.7"])] use jl_sys::jl_gc_schedule_foreign_sweepfunc; #[julia_version(since = "1.9")] use jl_sys::jl_reinit_foreign_type; -use jl_sys::{jl_emptysvec, jl_gc_alloc_typed, jl_new_datatype, jl_new_foreign_type, jl_value_t}; +use jl_sys::{ + jl_any_type, jl_emptysvec, jl_gc_alloc_typed, jl_new_datatype, jl_new_foreign_type, jl_value_t, +}; use jlrs_macros::julia_version; -use super::typecheck::Typecheck; +use super::{ + construct_type::{TypeVarConstructor, TypeVarName}, + typecheck::Typecheck, +}; use crate::{ - convert::{into_julia::IntoJulia, unbox::Unbox}, + convert::{into_jlrs_result::IntoJlrsResult, into_julia::IntoJulia, unbox::Unbox}, data::{ layout::valid_layout::ValidLayout, managed::{ datatype::{DataType, DataTypeData}, + erase_scope_lifetime, module::Module, private::ManagedPriv, + simple_vector::{SimpleVector, SimpleVectorData}, symbol::Symbol, + union_all::UnionAll, value::{Value, ValueData, ValueRef}, Managed, }, types::construct_type::ConstructType, }, - memory::{ - get_tls, - target::{ExtendedTarget, Target}, - PTls, - }, + gc_safe::{GcSafeOnceLock, GcSafeRwLock}, + memory::{get_tls, target::Target, PTls}, private::Private, }; -static FOREIGN_TYPE_REGISTRY: ForeignTypes = ForeignTypes::new(); +static FOREIGN_TYPE_REGISTRY: GcSafeOnceLock = GcSafeOnceLock::new(); + +pub(crate) unsafe fn init_foreign_type_registry() { + FOREIGN_TYPE_REGISTRY.set(ForeignTypes::new()).ok(); +} + +struct Key(PhantomData); struct ForeignTypes { - data: RwLock)>>, + data: GcSafeRwLock>>, } impl ForeignTypes { - const fn new() -> Self { + #[inline] + fn new() -> Self { ForeignTypes { - data: RwLock::new(Vec::new()), + data: GcSafeRwLock::default(), } } + #[inline] fn find(&self) -> Option { let tid = TypeId::of::(); - self.data - .read() - .expect("Lock poisoned") - .iter() - .find_map(|s| match s { - &(type_id, ty) if type_id == tid => Some(ty), - _ => None, - }) + self.data.read().get(&tid).copied() + } + + // Safety: ty must be the datatype associated with T. + #[inline] + unsafe fn insert(&self, ty: DataType<'static>) { + let tid = TypeId::of::(); + self.data.write().insert(tid, ty); } } @@ -128,6 +149,7 @@ pub unsafe trait OpaqueType: Sized + Send + 'static { const TYPE_FN: Option DataType<'static>> = None; /// The super-type of this type, `Core.Any` by default. + #[inline] fn super_type<'target, Tgt>(target: Tgt) -> DataTypeData<'target, Tgt> where Tgt: Target<'target>, @@ -144,6 +166,7 @@ pub unsafe trait OpaqueType: Sized + Send + 'static { /// /// The new type is not set as a constant in `module`, you must do this manually after calling /// this function. You must not override the default implementation. + #[inline] unsafe fn create_type<'target, Tgt>( target: Tgt, name: Symbol, @@ -165,11 +188,495 @@ pub unsafe trait OpaqueType: Sized + Send + 'static { /// /// The datatype must have been originally created by calling `OpaqueType::create_type`. You /// must not override the default implementation. + #[inline] unsafe fn reinit_type(datatype: DataType) -> bool { reinit_opaque_type::(datatype) } } +pub trait Bounds { + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>; +} + +impl Bounds for TypeVarConstructor +where + N: TypeVarName, + U: ConstructType, + L: ConstructType, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 1) }; + let tvar = Self::construct_type(&mut frame); + unsafe { + svec.data_mut().set(0, Some(tvar)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +impl Bounds + for ( + TypeVarConstructor, + TypeVarConstructor, + ) +where + N0: TypeVarName, + U0: ConstructType, + L0: ConstructType, + N1: TypeVarName, + U1: ConstructType, + L1: ConstructType, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 2) }; + let tvar_1 = TypeVarConstructor::::construct_type(&mut frame); + let tvar_2 = TypeVarConstructor::::construct_type(&mut frame); + unsafe { + let mut svec_ref = svec.data_mut(); + svec_ref.set(0, Some(tvar_1)).unwrap(); + svec_ref.set(1, Some(tvar_2)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +impl Bounds + for ( + TypeVarConstructor, + TypeVarConstructor, + TypeVarConstructor, + ) +where + N0: TypeVarName, + U0: ConstructType, + L0: ConstructType, + N1: TypeVarName, + U1: ConstructType, + L1: ConstructType, + N2: TypeVarName, + U2: ConstructType, + L2: ConstructType, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 4>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 3) }; + let tvar_1 = TypeVarConstructor::::construct_type(&mut frame); + let tvar_2 = TypeVarConstructor::::construct_type(&mut frame); + let tvar_3 = TypeVarConstructor::::construct_type(&mut frame); + unsafe { + let mut svec_ref = svec.data_mut(); + svec_ref.set(0, Some(tvar_1)).unwrap(); + svec_ref.set(1, Some(tvar_2)).unwrap(); + svec_ref.set(2, Some(tvar_3)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +pub struct DefaultBounds1(PhantomData); + +impl Bounds for N +where + N: TypeVarName, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 1) }; + let tvar = TypeVarConstructor::::construct_type(&mut frame); + unsafe { + svec.data_mut().set(0, Some(tvar)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +impl Bounds for DefaultBounds1 +where + N: TypeVarName, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 1) }; + let tvar = TypeVarConstructor::::construct_type(&mut frame); + unsafe { + svec.data_mut().set(0, Some(tvar)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +pub struct DefaultBounds2(PhantomData<(N0, N1)>); + +impl Bounds for DefaultBounds2 +where + N0: TypeVarName, + N1: TypeVarName, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 2) }; + let tvar_1 = TypeVarConstructor::::construct_type(&mut frame); + let tvar_2 = TypeVarConstructor::::construct_type(&mut frame); + unsafe { + let mut svec_ref = svec.data_mut(); + svec_ref.set(0, Some(tvar_1)).unwrap(); + svec_ref.set(1, Some(tvar_2)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +pub struct DefaultBounds3( + PhantomData<(N0, N1, N2)>, +); + +impl Bounds for DefaultBounds3 +where + N0: TypeVarName, + N1: TypeVarName, + N2: TypeVarName, +{ + fn construct_bounds<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + target + .with_local_scope::<_, _, 4>(|target, mut frame| { + let mut svec = unsafe { SimpleVector::with_capacity_uninit(&mut frame, 3) }; + let tvar_1 = TypeVarConstructor::::construct_type(&mut frame); + let tvar_2 = TypeVarConstructor::::construct_type(&mut frame); + let tvar_3 = TypeVarConstructor::::construct_type(&mut frame); + unsafe { + let mut svec_ref = svec.data_mut(); + svec_ref.set(0, Some(tvar_1)).unwrap(); + svec_ref.set(1, Some(tvar_2)).unwrap(); + svec_ref.set(2, Some(tvar_3)).unwrap(); + } + Ok(svec.root(target)) + }) + .unwrap() + } +} + +pub unsafe trait ParametricBase: Sized + Send + 'static { + /// Key for this family of opaque types. + /// + /// Must be unique, and must not depend on any of the type parameters of the implementing + /// type. If this trait is implemented for `Foo`, `Foo` may be used as a key, but + /// `Foo` may not. + type Key: Any; + + fn type_parameters<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>; + + /// The super-type of this type, `Core.Any` by default. + #[inline] + fn super_type<'target, Tgt>(target: Tgt) -> DataTypeData<'target, Tgt> + where + Tgt: Target<'target>, + { + DataType::any_type(&target).root(target) + } + + /// Creates a new opaque type named `name` in `module`. + /// + /// An opaque type must be created if it doesn't exist yet in `module`. This method is called + /// automatically by init functions generated with the `julia_module` macro. + /// + /// Safety: + /// + /// The new type is not set as a constant in `module`, you must do this manually after calling + /// this function. You must not override the default implementation. + #[inline] + unsafe fn create_type<'target, Tgt>( + target: Tgt, + name: Symbol, + module: Module, + ) -> DataTypeData<'target, Tgt> + where + Tgt: Target<'target>, + { + create_parametric_opaque_type::(target, name, module) + } + + /// Reinitializes the previously created type `datatype`. + /// + /// An opaque type must be reinitialized if it has been created in a precompiled module and + /// this module is loaded. This method is called automatically by init functions generated + /// with the `julia_module` macro. + /// + /// Safety: + /// + /// The datatype must have been originally created by calling `OpaqueType::create_type`. You + /// must not override the default implementation. + #[inline] + unsafe fn reinit_type(datatype: DataType) -> bool { + reinit_parametric_opaque_type::(datatype) + } +} + +#[macro_export(local_inner_macros)] +macro_rules! count_exprs { + ($t:literal) => { + 1 + }; + ($t:ty) => { + 1 + }; + ($t:literal <: $ub:ty) => { + 1 + }; + ($t:literal <: $ub:ty >: $lb:ty) => { + 1 + }; + ($t:literal >: $lb:ty) => { + 1 + }; + () => { + 0 + }; + ($t:literal, $($x:tt),*) => { + 1 + $crate::count_exprs!($($x),*) + }; + ($t:ty, $($x:tt),*) => { + 1 + $crate::count_exprs!($($x),*) + }; + ($t:literal <: $ub:ty, $($x:tt)*) => { + 1 + $crate::count_exprs!($($x)*) + }; + ($t:literal <: $ub:ty >: $lb:ty, $($x:tt)*) => { + 1 + $crate::count_exprs!($($x)*) + }; + ($t:literal >: $lb:ty, $($x:tt)*) => { + 1 + $crate::count_exprs!($($x)*) + }; +} + +#[macro_export(local_inner_macros)] +macro_rules! expand_type_bound { + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal, $($rest:tt)*) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + expand_type_bound!($nth + 1, $frame, $svec_ref, $($rest)*) + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:ty, $($rest:tt)*) => { + { + let ty = <$t as $crate::data::types::construct_type::ConstructType>::construct_type($frame); + $svec_ref.set($nth, Some(ty)).unwrap(); + } + expand_type_bound!($nth + 1, $frame, $svec_ref, $($rest)*) + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:ty) => { + { + let ty = <$t as $crate::data::types::construct_type::ConstructType>::construct_type($frame); + $svec_ref.set($nth, Some(ty)).unwrap(); + } + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal <: $ub:ty, $($rest:tt)*) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>, $ub>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + expand_type_bound!($nth + 1, $frame, $svec_ref, $($rest)*) + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal <: $ub:ty) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>, $ub>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal >: $lb:ty, $($rest:tt)*) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>, $crate::data::types::abstract_types::AnyType, $lb>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + expand_type_bound!($nth + 1, $frame, $svec_ref, $($rest)*) + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal >: $lb:ty) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>, $crate::data::types::abstract_types::AnyType, $lb>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal <: $ub:ty >: $lb:ty, $($rest:tt)*) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>, $ub, $lb>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + expand_type_bound!($nth + 1, $frame, $svec_ref, $($rest)*) + }; + ($nth:expr, $frame:expr, $svec_ref:expr, $t:literal <: $ub:ty >: $lb:ty) => { + { + type Ctor = $crate::data::types::construct_type::TypeVarConstructor::<$crate::data::types::construct_type::ConstantChar<$t>, $ub, $lb>; + let tvar = ::construct_type($frame); + $svec_ref.set($nth, Some(tvar)).unwrap(); + } + }; +} + +#[macro_export] +macro_rules! impl_type_parameters { + () => { + #[inline] + fn type_parameters<'target, Tgt>( + target: Tgt, + ) -> $crate::data::managed::simple_vector::SimpleVectorData<'target, Tgt> + where + Tgt: $crate::memory::target::Target<'target>, + { + $crate::data::managed::simple_vector::SimpleVector::emptysvec(&target).root(target) + } + }; + ($($t:tt)+) => { + fn type_parameters<'target, Tgt>( + target: Tgt, + ) -> $crate::data::managed::simple_vector::SimpleVectorData<'target, Tgt> + where + Tgt: $crate::memory::target::Target<'target>, + { + + const N: usize = $crate::count_exprs!($($t)+); + const M: usize = N + 1; + target.with_local_scope::<_, _, M>(|target, mut frame| unsafe { + let mut svec = $crate::data::managed::simple_vector::SimpleVector::with_capacity_uninit(&mut frame, N); + + { + let mut svec_ref = svec.data_mut(); + $crate::expand_type_bound!(0, &mut frame, svec_ref, $($t)+); + } + + Ok(svec.root(target)) + }).unwrap() + } + }; +} + +#[macro_export] +macro_rules! impl_variant_parameters { + () => { + #[inline] + fn variant_parameters<'target, Tgt>( + target: Tgt, + ) -> $crate::data::managed::simple_vector::SimpleVectorData<'target, Tgt> + where + Tgt: $crate::memory::target::Target<'target>, + { + $crate::data::managed::simple_vector::SimpleVector::emptysvec(&target).root(target) + } + }; + ($($t:tt)+) => { + fn variant_parameters<'target, Tgt>( + target: Tgt, + ) -> $crate::data::managed::simple_vector::SimpleVectorData<'target, Tgt> + where + Tgt: $crate::memory::target::Target<'target>, + { + const N: usize = $crate::count_exprs!($($t)+); + const M: usize = N + 1; + + target.with_local_scope::<_, _, M>(|target, mut frame| unsafe { + let mut svec = $crate::data::managed::simple_vector::SimpleVector::with_capacity_uninit(&mut frame, N); + + { + let mut svec_ref = svec.data_mut(); + $crate::expand_type_bound!(0, &mut frame, svec_ref, $($t)+); + } + + Ok(svec.root(target)) + }).unwrap() + } + }; +} + +pub unsafe trait ParametricVariant: ParametricBase { + #[doc(hidden)] + const IS_FOREIGN: bool = false; + #[doc(hidden)] + const TYPE_FN: Option DataType<'static>> = None; + + fn variant_parameters<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>; + + unsafe fn create_variant<'target, Tgt>(target: Tgt, name: Symbol) -> DataTypeData<'target, Tgt> + where + Tgt: Target<'target>, + { + create_parametric_opaque_variant::(target, name) + } + + /// Reinitializes the previously created type `datatype`. + /// + /// An opaque type must be reinitialized if it has been created in a precompiled module and + /// this module is loaded. This method is called automatically by init functions generated + /// with the `julia_module` macro. + /// + /// Safety: + /// + /// The datatype must have been originally created by calling `OpaqueType::create_type`. You + /// must not override the default implementation. + #[inline] + unsafe fn reinit_variant(datatype: DataType) -> bool { + reinit_parametric_opaque_variant::(datatype) + } +} + /// A trait that allows Rust data with internal references to Julia data to be converted to Julia. /// /// A `ForeignType` can contain references to Julia data because it has a custom mark function. @@ -217,14 +724,16 @@ pub unsafe trait ForeignType: Sized + Send + 'static { const HAS_POINTERS: bool = true; /// The super-type of this type, `Core.Any` by default. - fn super_type<'target, T>(target: T) -> DataTypeData<'target, T> + #[inline] + fn super_type<'target, Tgt>(target: Tgt) -> DataTypeData<'target, Tgt> where - T: Target<'target>, + Tgt: Target<'target>, { DataType::any_type(&target).root(target) } /// Convert a reference to this foreign type to a `ValueRef`. + #[inline] fn as_value_ref<'scope>(&'scope self) -> ValueRef<'scope, 'static> { unsafe { ValueRef::wrap(NonNull::new_unchecked(self as *const _ as *mut jl_value_t)) } } @@ -245,6 +754,7 @@ unsafe impl OpaqueType for T { const IS_FOREIGN: bool = true; const TYPE_FN: Option DataType<'static>> = ::TYPE_FN; + #[inline] fn super_type<'target, Tgt>(target: Tgt) -> DataTypeData<'target, Tgt> where Tgt: Target<'target>, @@ -252,6 +762,7 @@ unsafe impl OpaqueType for T { ::super_type(target) } + #[inline] unsafe fn create_type<'target, Tgt>( target: Tgt, name: Symbol, @@ -263,36 +774,127 @@ unsafe impl OpaqueType for T { create_foreign_type::(target, name, module) } + #[inline] unsafe fn reinit_type(datatype: DataType) -> bool { reinit_foreign_type::(datatype) } } -unsafe fn create_foreign_type<'target, U, T>( - target: T, +unsafe impl ParametricBase for T { + type Key = Self; + + #[inline] + fn type_parameters<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + SimpleVector::emptysvec(&target).root(target) + } + + #[inline] + fn super_type<'target, Tgt>(target: Tgt) -> DataTypeData<'target, Tgt> + where + Tgt: Target<'target>, + { + ::super_type(target) + } + + #[inline] + unsafe fn create_type<'target, Tgt>( + target: Tgt, + name: Symbol, + module: Module, + ) -> DataTypeData<'target, Tgt> + where + Tgt: Target<'target>, + { + ::create_type(target, name, module) + } + + #[inline] + unsafe fn reinit_type(datatype: DataType) -> bool { + ::reinit_type(datatype) + } +} + +unsafe impl ParametricVariant for T { + const TYPE_FN: Option DataType<'static>> = T::TYPE_FN; + + #[inline] + fn variant_parameters<'target, Tgt>(target: Tgt) -> SimpleVectorData<'target, Tgt> + where + Tgt: Target<'target>, + { + SimpleVector::emptysvec(&target).root(target) + } + + #[inline] + unsafe fn create_variant<'target, Tgt>( + _target: Tgt, + _name: Symbol, + ) -> DataTypeData<'target, Tgt> + where + Tgt: Target<'target>, + { + unimplemented!("OpaqueTypes can't have variants") + } + + #[inline] + unsafe fn reinit_variant(_datatype: DataType) -> bool { + unimplemented!("OpaqueTypes can't have variants") + } +} + +#[inline] +unsafe fn create_foreign_type<'target, U, Tgt>( + target: Tgt, + name: Symbol, + module: Module, +) -> DataTypeData<'target, Tgt> +where + U: ForeignType, + Tgt: Target<'target>, +{ + create_foreign_type_nostack::(target, name, module) +} + +pub(crate) unsafe fn create_foreign_type_nostack<'target, U, Tgt>( + target: Tgt, name: Symbol, module: Module, -) -> DataTypeData<'target, T> +) -> DataTypeData<'target, Tgt> where U: ForeignType, - T: Target<'target>, + Tgt: Target<'target>, { - if let Some(ty) = FOREIGN_TYPE_REGISTRY.find::() { + if let Some(ty) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { return target.data_from_ptr(ty.unwrap_non_null(Private), Private); } let large = U::LARGE as _; let has_pointers = U::HAS_POINTERS as _; - unsafe extern "C" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { - T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) - } + cfg_if! { + if #[cfg(feature = "c-unwind")] { + unsafe extern "C-unwind" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { + T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) + } + + unsafe extern "C-unwind" fn sweep(value: *mut jl_value_t) { + do_sweep::(&mut *value.cast()) + } + } else { + unsafe extern "C" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { + T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) + } - unsafe extern "C" fn sweep(value: *mut jl_value_t) { - do_sweep::(&mut *value.cast()) + unsafe extern "C" fn sweep(value: *mut jl_value_t) { + do_sweep::(&mut *value.cast()) + } + } } - let super_type = U::super_type(&target).ptr().as_ptr(); + let super_type = jl_any_type; let ty = jl_new_foreign_type( name.unwrap(Private), @@ -306,93 +908,195 @@ where debug_assert!(!ty.is_null()); FOREIGN_TYPE_REGISTRY - .data - .write() - .expect("Foreign type lock was poisoned") - .push(( - TypeId::of::(), - DataType::wrap_non_null(NonNull::new_unchecked(ty), Private), - )); - + .get_unchecked() + .insert::(DataType::wrap_non_null(NonNull::new_unchecked(ty), Private)); target.data_from_ptr(NonNull::new_unchecked(ty), Private) } -unsafe fn create_opaque_type<'target, U, T>( - target: T, +unsafe fn create_opaque_type<'target, U, Tgt>( + target: Tgt, name: Symbol, module: Module, -) -> DataTypeData<'target, T> +) -> DataTypeData<'target, Tgt> where U: OpaqueType, - T: Target<'target>, + Tgt: Target<'target>, { - if let Some(ty) = FOREIGN_TYPE_REGISTRY.find::() { + if let Some(ty) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { return target.data_from_ptr(ty.unwrap_non_null(Private), Private); } - let super_type = U::super_type(&target).ptr().as_ptr(); + target + .with_local_scope::<_, _, 1>(|target, mut frame| { + let super_type = U::super_type(&mut frame).unwrap(Private); + + #[cfg(feature = "julia-1-6")] + let ty = jl_new_datatype( + name.unwrap(Private), + module.unwrap(Private), + super_type, + jl_emptysvec, + jl_emptysvec, + jl_emptysvec, + 0, + 1, + 0, + ); + + #[cfg(not(feature = "julia-1-6"))] + let ty = jl_new_datatype( + name.unwrap(Private), + module.unwrap(Private), + super_type, + jl_emptysvec, + jl_emptysvec, + jl_emptysvec, + jl_emptysvec, + 0, + 1, + 0, + ); + + debug_assert!(!ty.is_null()); + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .insert::(DataType::wrap_non_null(NonNull::new_unchecked(ty), Private)); + + Ok(target.data_from_ptr(NonNull::new_unchecked(ty), Private)) + }) + .unwrap() +} - #[cfg(feature = "julia-1-6")] - let ty = jl_new_datatype( - name.unwrap(Private), - module.unwrap(Private), - super_type, - jl_emptysvec, - jl_emptysvec, - jl_emptysvec, - 0, - 1, - 0, - ); +unsafe fn create_parametric_opaque_variant<'target, U, Tgt>( + target: Tgt, + name: Symbol, +) -> DataTypeData<'target, Tgt> +where + U: ParametricVariant, + Tgt: Target<'target>, +{ + if let Some(ty) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { + return target.data_from_ptr(ty.unwrap_non_null(Private), Private); + } - #[cfg(not(feature = "julia-1-6"))] - let ty = jl_new_datatype( - name.unwrap(Private), - module.unwrap(Private), - super_type, - jl_emptysvec, - jl_emptysvec, - jl_emptysvec, - jl_emptysvec, - 0, - 1, - 0, - ); + let base_ty = FOREIGN_TYPE_REGISTRY.get_unchecked().find::>(); + if base_ty.is_none() { + panic!("Type {} was not registered", name.as_str().unwrap()); + } - debug_assert!(!ty.is_null()); - FOREIGN_TYPE_REGISTRY - .data - .write() - .expect("Foreign type lock was poisoned") - .push(( - TypeId::of::(), - DataType::wrap_non_null(NonNull::new_unchecked(ty), Private), - )); + target + .with_local_scope::<_, _, 3>(|target, mut frame| { + let params = U::variant_parameters(&mut frame); + let params_slice = params.data().as_slice_non_null_managed(); - target.data_from_ptr(NonNull::new_unchecked(ty), Private) + let ty = base_ty.unwrap_unchecked(); + + let ty = UnionAll::rewrap(&mut frame, ty); + + let ty = ty + .apply_type(&mut frame, params_slice) + .into_jlrs_result()? + .cast::()?; + + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .insert::(erase_scope_lifetime(ty)); + + Ok(ty.root(target)) + }) + .unwrap() +} + +unsafe fn create_parametric_opaque_type<'target, U, Tgt>( + target: Tgt, + name: Symbol, + module: Module, +) -> DataTypeData<'target, Tgt> +where + U: ParametricBase, + Tgt: Target<'target>, +{ + if let Some(ty) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::>() { + return target.data_from_ptr(ty.unwrap_non_null(Private), Private); + } + + target + .with_local_scope::<_, _, 2>(|target, mut frame| { + let super_type = U::super_type(&mut frame); + let bounds = U::type_parameters(&mut frame); + + #[cfg(feature = "julia-1-6")] + let ty = jl_new_datatype( + name.unwrap(Private), + module.unwrap(Private), + super_type.unwrap(Private), + bounds.unwrap(Private), + jl_emptysvec, + jl_emptysvec, + 0, + 1, + 0, + ); + + #[cfg(not(feature = "julia-1-6"))] + let ty = jl_new_datatype( + name.unwrap(Private), + module.unwrap(Private), + super_type.unwrap(Private), + bounds.unwrap(Private), + jl_emptysvec, + jl_emptysvec, + jl_emptysvec, + 0, + 1, + 0, + ); + + debug_assert!(!ty.is_null()); + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .insert::>(DataType::wrap_non_null( + NonNull::new_unchecked(ty), + Private, + )); + + Ok(target.data_from_ptr::(NonNull::new_unchecked(ty), Private)) + }) + .unwrap() } -pub(crate) unsafe fn create_foreign_type_internal<'target, U, T>( - target: T, +pub(crate) unsafe fn create_foreign_type_internal<'target, U, Tgt>( + target: Tgt, name: Symbol, module: Module, -) -> DataTypeData<'target, T> +) -> DataTypeData<'target, Tgt> where U: ForeignType, - T: Target<'target>, + Tgt: Target<'target>, { let large = U::LARGE as _; let has_pointers = U::HAS_POINTERS as _; + cfg_if! { + if #[cfg(feature = "c-unwind")] { + unsafe extern "C-unwind" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { + T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) + } - unsafe extern "C" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { - T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) - } + unsafe extern "C-unwind" fn sweep(value: *mut jl_value_t) { + do_sweep::(&mut *value.cast()) + } + } else { + unsafe extern "C" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { + T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) + } - unsafe extern "C" fn sweep(value: *mut jl_value_t) { - do_sweep::(NonNull::new_unchecked(value.cast()).as_mut()) + unsafe extern "C" fn sweep(value: *mut jl_value_t) { + do_sweep::(&mut *value.cast()) + } + } } - let super_type = U::super_type(&target).ptr().as_ptr(); + let super_type = jl_any_type; let ty = jl_new_foreign_type( name.unwrap(Private), @@ -412,29 +1116,36 @@ unsafe fn reinit_foreign_type(datatype: DataType) -> bool where U: ForeignType, { - if let Some(_) = FOREIGN_TYPE_REGISTRY.find::() { + if let Some(_) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { return true; } - unsafe extern "C" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { - T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) - } + cfg_if! { + if #[cfg(feature = "c-unwind")] { + unsafe extern "C-unwind" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { + T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) + } + + unsafe extern "C-unwind" fn sweep(value: *mut jl_value_t) { + do_sweep::(&mut *value.cast()) + } + } else { + unsafe extern "C" fn mark(ptls: PTls, value: *mut jl_value_t) -> usize { + T::mark(ptls, NonNull::new_unchecked(value.cast()).as_ref()) + } - unsafe extern "C" fn sweep(value: *mut jl_value_t) { - do_sweep::(NonNull::new_unchecked(value.cast()).as_mut()) + unsafe extern "C" fn sweep(value: *mut jl_value_t) { + do_sweep::(&mut *value.cast()) + } + } } let ty = datatype.unwrap(Private); let ret = jl_reinit_foreign_type(ty, Some(mark::), Some(sweep::)); if ret != 0 { FOREIGN_TYPE_REGISTRY - .data - .write() - .expect("Foreign type lock was poisoned") - .push(( - TypeId::of::(), - DataType::wrap_non_null(NonNull::new_unchecked(ty), Private), - )); + .get_unchecked() + .insert::(DataType::wrap_non_null(NonNull::new_unchecked(ty), Private)); true } else { panic!() @@ -442,6 +1153,7 @@ where } #[julia_version(until = "1.8")] +#[inline] unsafe fn reinit_foreign_type(datatype: DataType) -> bool where U: ForeignType, @@ -453,23 +1165,46 @@ unsafe fn reinit_opaque_type(ty: DataType) -> bool where U: OpaqueType, { - if let Some(_) = FOREIGN_TYPE_REGISTRY.find::() { + if let Some(_) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { return true; } FOREIGN_TYPE_REGISTRY - .data - .write() - .expect("Foreign type lock was poisoned") - .push(( - TypeId::of::(), - DataType::wrap_non_null(ty.unwrap_non_null(Private), Private), - )); + .get_unchecked() + .insert::(erase_scope_lifetime(ty)); + true +} + +unsafe fn reinit_parametric_opaque_type(ty: DataType) -> bool +where + U: ParametricBase, +{ + if let Some(_) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::>() { + return true; + } + + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .insert::>(erase_scope_lifetime(ty)); + true +} + +unsafe fn reinit_parametric_opaque_variant(ty: DataType) -> bool +where + U: ParametricVariant, +{ + if let Some(_) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { + return true; + } + + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .insert::(erase_scope_lifetime(ty)); true } #[julia_version(since = "1.7", until = "1.7")] -#[inline(always)] +#[inline] unsafe fn do_sweep(_: &mut ForeignValue) where T: ForeignType, @@ -478,7 +1213,7 @@ where } #[julia_version(except = ["1.7"])] -#[inline(always)] +#[inline] unsafe fn do_sweep(data: &mut ForeignValue) where T: ForeignType, @@ -486,13 +1221,19 @@ where data.data.assume_init_drop(); } -unsafe impl IntoJulia for F { +unsafe impl IntoJulia for F { + #[inline] fn julia_type<'scope, T>(target: T) -> DataTypeData<'scope, T> where T: Target<'scope>, { - let ty = FOREIGN_TYPE_REGISTRY.find::().expect("Doesn't exist"); - unsafe { target.data_from_ptr(ty.unwrap_non_null(Private), Private) } + unsafe { + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .find::() + .expect("Doesn't exist") + .root(target) + } } fn into_julia<'scope, T>(self, target: T) -> ValueData<'scope, 'static, T> @@ -500,37 +1241,33 @@ unsafe impl IntoJulia for F { T: Target<'scope>, { unsafe { - let ptls = get_tls(); let sz = std::mem::size_of::(); - let maybe_ty = FOREIGN_TYPE_REGISTRY.find::(); + let maybe_ty = FOREIGN_TYPE_REGISTRY.get_unchecked().find::(); let ty = match maybe_ty { None => { if let Some(func) = Self::TYPE_FN { - let mut guard = FOREIGN_TYPE_REGISTRY - .data - .write() - .expect("Foreign type lock was poisoned"); + let mut guard = FOREIGN_TYPE_REGISTRY.get_unchecked().data.write(); // Check again let tid = TypeId::of::(); - if let Some(ty) = guard.iter().find_map(|s| match s { - &(type_id, ty) if type_id == tid => Some(ty), - _ => None, - }) { + let res = if let Some(ty) = guard.get(&tid).copied() { ty } else { let ty = func(); - guard.push((TypeId::of::(), ty)); + guard.insert(TypeId::of::(), ty); ty - } + }; + + res } else { - maybe_ty.expect("Doesn't exist") + panic!("Unknown type") } } Some(t) => t, }; + let ptls = get_tls(); let ptr: *mut Self = jl_gc_alloc_typed(ptls, sz, ty.unwrap(Private).cast()).cast(); ptr.write(self); let res = target.data_from_ptr(NonNull::new_unchecked(ptr.cast()), Private); @@ -558,27 +1295,43 @@ unsafe impl IntoJulia for F { } } -unsafe impl ValidLayout for T { +unsafe impl ValidLayout for T { + #[inline] fn valid_layout(ty: Value) -> bool { - if let Ok(dt) = ty.cast::() { - if let Some(ty) = FOREIGN_TYPE_REGISTRY.find::() { - dt.unwrap(Private) == ty.unwrap(Private) - } else { - false + if ty.is::() { + unsafe { + if let Some(found_ty) = FOREIGN_TYPE_REGISTRY.get_unchecked().find::() { + let dt = ty.cast_unchecked::(); + dt.unwrap(Private) == found_ty.unwrap(Private) + } else { + false + } } } else { false } } + + #[inline] + fn type_object<'target, Tgt: Target<'target>>(_target: &Tgt) -> Value<'target, 'static> { + unsafe { + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .find::() + .unwrap() + .as_value() + } + } } -unsafe impl Typecheck for T { +unsafe impl Typecheck for T { + #[inline] fn typecheck(ty: DataType) -> bool { T::valid_layout(ty.as_value()) } } -unsafe impl Unbox for T { +unsafe impl Unbox for T { type Output = T; } @@ -588,30 +1341,41 @@ struct ForeignValue { pub data: MaybeUninit, } -unsafe extern "C" fn drop_opaque(data: *mut c_void) { +#[inline] +unsafe extern "C" fn drop_opaque(data: *mut c_void) { let p = data as *mut MaybeUninit; NonNull::new_unchecked(p).as_mut().assume_init_drop() } -unsafe impl ConstructType for T { - fn construct_type<'target, Tgt>( - target: ExtendedTarget<'target, '_, '_, Tgt>, - ) -> ValueData<'target, 'static, Tgt> +unsafe impl ConstructType for T { + type Static = T; + + fn construct_type_uncached<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> where Tgt: Target<'target>, { - let (target, _) = target.split(); - FOREIGN_TYPE_REGISTRY - .find::() - .unwrap() - .as_value() - .root(target) + unsafe { + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .find::() + .unwrap() + .as_value() + .root(target) + } } fn base_type<'target, Tgt>(_target: &Tgt) -> Option> where Tgt: Target<'target>, { - Some(FOREIGN_TYPE_REGISTRY.find::().unwrap().as_value()) + unsafe { + Some( + FOREIGN_TYPE_REGISTRY + .get_unchecked() + .find::() + .unwrap() + .as_value(), + ) + } } } diff --git a/jlrs/src/data/types/typecheck.rs b/jlrs/src/data/types/typecheck.rs index 3f173c61..f3277e8c 100644 --- a/jlrs/src/data/types/typecheck.rs +++ b/jlrs/src/data/types/typecheck.rs @@ -11,6 +11,7 @@ //! [`Unbox`]: crate::convert::unbox::Unbox use std::ffi::c_void; +// TODO: Unify with abstract types #[julia_version(until = "1.9")] use jl_sys::jl_typedslot_type; use jl_sys::{ @@ -50,7 +51,7 @@ pub unsafe trait Typecheck { macro_rules! impl_julia_typecheck { ($type:ty, $jl_type:expr, $($lt:lifetime),+) => { unsafe impl<$($lt),+> crate::data::types::typecheck::Typecheck for $type { - #[inline(always)] + #[inline] fn typecheck(t: $crate::data::managed::datatype::DataType) -> bool { unsafe { <$crate::data::managed::datatype::DataType as $crate::data::managed::private::ManagedPriv>::unwrap(t, crate::private::Private) == $jl_type @@ -60,7 +61,7 @@ macro_rules! impl_julia_typecheck { }; ($type:ty, $jl_type:expr) => { unsafe impl crate::data::types::typecheck::Typecheck for $type { - #[inline(always)] + #[inline] fn typecheck(t: $crate::data::managed::datatype::DataType) -> bool { unsafe { <$crate::data::managed::datatype::DataType as $crate::data::managed::private::ManagedPriv>::unwrap(t, crate::private::Private) == $jl_type @@ -70,7 +71,7 @@ macro_rules! impl_julia_typecheck { }; ($type:ty) => { unsafe impl crate::data::types::typecheck::Typecheck for $type { - #[inline(always)] + #[inline] fn typecheck(t: crate::data::managed::datatype::DataType) -> bool { unsafe { let global = $crate::memory::target::unrooted::Unrooted::new(); @@ -98,6 +99,7 @@ impl_julia_typecheck!(char); impl_julia_typecheck!(*mut c_void); unsafe impl Typecheck for *mut T { + #[inline] fn typecheck(t: DataType) -> bool { unsafe { let global = Unrooted::new(); @@ -110,7 +112,7 @@ unsafe impl Typecheck for *mut T { let params = t.parameters(); let params = params.data().as_slice(); let inner_ty = T::julia_type(global); - if params[0].unwrap().as_value() != inner_ty.as_value() { + if params[0].unwrap_unchecked().as_value() != inner_ty.as_value() { return false; } @@ -124,7 +126,7 @@ unsafe impl Typecheck for *mut T { /// `DataType`, a `UnionAll`, a `Union` or a `Union{}`. pub struct Type; unsafe impl Typecheck for Type { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.as_value().is_kind() } @@ -134,7 +136,7 @@ unsafe impl Typecheck for Type { /// the `DataType` (or the `DataType` of the `Value`) is a bits type. pub struct Bits; unsafe impl Typecheck for Bits { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.is_bits() } @@ -144,7 +146,7 @@ unsafe impl Typecheck for Bits { /// the `DataType` is abstract. If it's invoked through `Value::is` it will always return false. pub struct Abstract; unsafe impl Typecheck for Abstract { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.is_abstract() } @@ -169,7 +171,7 @@ unsafe impl Typecheck for AbstractRef { /// the value is a `VecElement`. pub struct VecElement; unsafe impl Typecheck for VecElement { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.type_name() == TypeName::of_vecelement(&Unrooted::new()) } } @@ -194,7 +196,7 @@ unsafe impl Typecheck for TypeType { /// the value is a dispatch tuple. pub struct DispatchTuple; unsafe impl Typecheck for DispatchTuple { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.is_dispatch_tuple() } @@ -204,7 +206,7 @@ unsafe impl Typecheck for DispatchTuple { /// a value of this type is a named tuple. pub struct NamedTuple; unsafe impl Typecheck for NamedTuple { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.unwrap_non_null(Private).as_ref().name == jl_namedtuple_typename } } @@ -214,7 +216,7 @@ unsafe impl Typecheck for NamedTuple { /// the fields of a value of this type can be modified. pub struct Mutable; unsafe impl Typecheck for Mutable { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.mutable() } @@ -224,7 +226,7 @@ unsafe impl Typecheck for Mutable { /// the fields of a value of this type cannot be modified. pub struct Immutable; unsafe impl Typecheck for Immutable { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { !t.mutable() } @@ -248,7 +250,7 @@ unsafe impl Typecheck for PrimitiveType { /// a value of this type is a struct type. pub struct StructType; unsafe impl Typecheck for StructType { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { !t.is_abstract() && !t.is::() } @@ -258,7 +260,7 @@ unsafe impl Typecheck for StructType { /// a value of this type is a struct type. pub struct Singleton; unsafe impl Typecheck for Singleton { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.instance().is_some() } @@ -270,7 +272,7 @@ pub struct Slot; #[julia_version(until = "1.9")] unsafe impl Typecheck for Slot { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.unwrap(Private) == jl_slotnumber_type || t.unwrap(Private) == jl_typedslot_type } } @@ -278,7 +280,7 @@ unsafe impl Typecheck for Slot { #[julia_version(since = "1.10")] unsafe impl Typecheck for Slot { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.unwrap(Private) == jl_slotnumber_type } } @@ -340,7 +342,7 @@ impl_julia_typecheck!(String, jl_string_type); /// a value of this type is a pointer to data not owned by Julia. pub struct Pointer; unsafe impl Typecheck for Pointer { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.type_name() == TypeName::of_pointer(&Unrooted::new()) } } @@ -350,7 +352,7 @@ unsafe impl Typecheck for Pointer { /// a value of this type is an LLVM pointer. pub struct LLVMPointer; unsafe impl Typecheck for LLVMPointer { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { unsafe { t.type_name() == TypeName::of_llvmpointer(&Unrooted::new()) } } @@ -365,7 +367,7 @@ impl_julia_typecheck!(Intrinsic, jl_intrinsic_type); /// instances of the type can be created. pub struct Concrete; unsafe impl Typecheck for Concrete { - #[inline(always)] + #[inline] fn typecheck(t: DataType) -> bool { t.is_concrete_type() } diff --git a/jlrs/src/error.rs b/jlrs/src/error.rs index 5051684a..4dd8b824 100644 --- a/jlrs/src/error.rs +++ b/jlrs/src/error.rs @@ -66,10 +66,16 @@ pub enum TypeError { }, #[error("{value} is not a {field_type}")] NotA { value: String, field_type: String }, + #[error("{value} is not a concrete datatype")] + NotConcrete { value: String }, + #[error("layout is invalid for {value_type}")] + InvalidLayout { value_type: String }, #[error("{value_type} is immutable")] Immutable { value_type: String }, #[error("No base type is available")] NoBaseType, + #[error("Layout of {ty} is None")] + LayoutNone { ty: String }, #[error("The layout of this type is incompatible with {base_type}")] IncompatibleBaseType { base_type: String }, } @@ -101,6 +107,8 @@ pub enum AccessError { InvalidLayout { value_type: String }, #[error("no value named {name} in {module}")] GlobalNotFound { name: String, module: String }, + #[error("module named {module} not found")] + ModuleNotFound { module: String }, #[error("the current value is locked")] Locked, #[error("{tag} is not a valid tag for {union_type}")] @@ -180,21 +188,25 @@ pub enum JlrsError { impl JlrsError { /// Convert an arbitrary error to `JlrsError::Other`. + #[inline] pub fn other(reason: E) -> Self { JlrsError::Other(Box::new(reason)) } /// Convert an error message to `JlrsError::Exception`. + #[inline] pub fn exception>(msg: S) -> Self { JlrsError::Exception(Exception { msg: msg.into() }) } /// Convert an arbitrary error to `Err(JlrsError::Other)`. + #[inline] pub fn other_error(reason: E) -> Result { Err(Self::other(reason)) } /// Convert an error message to `Err(JlrsError::Exception)`. + #[inline] pub fn exception_error(msg: String) -> Result { Err(JlrsError::exception(msg)) } @@ -203,12 +215,14 @@ impl JlrsError { macro_rules! impl_from { ($type:ident) => { impl From<$type> for JlrsError { + #[inline] fn from(e: $type) -> Self { JlrsError::$type(e) } } impl From<$type> for Box { + #[inline] fn from(e: $type) -> Self { Box::new(JlrsError::from(e)) } diff --git a/jlrs/src/gc_safe/fair_mutex.rs b/jlrs/src/gc_safe/fair_mutex.rs new file mode 100644 index 00000000..6971b571 --- /dev/null +++ b/jlrs/src/gc_safe/fair_mutex.rs @@ -0,0 +1,20 @@ +//! A GC-safe `FairMutex`. +//! +//! The API matches that of [`parking_lot::FairMutex`]. + +use super::raw_fair_mutex::RawGcSafeFairMutex; + +/// A GC-safe fair mutex. See [`parking_lot::FairMutex`] for more information. +pub type GcSafeFairMutex = lock_api::Mutex; + +/// Create a new GC-safe fair mutex. See [`parking_lot::const_fair_mutex`] for more information. +pub const fn const_gc_safe_fair_mutex(val: T) -> GcSafeFairMutex { + GcSafeFairMutex::const_new(::INIT, val) +} + +/// A GC-safe `FairMutexGuard`. See [`parking_lot::FairMutexGuard`] for more information. +pub type GcSafeFairMutexGuard<'a, T> = lock_api::MutexGuard<'a, RawGcSafeFairMutex, T>; + +/// A GC-safe `MappedFairMutexGuard`. See [`parking_lot::MappedFairMutexGuard`] for more +/// information. +pub type MappedGcSafeFairMutexGuard<'a, T> = lock_api::MappedMutexGuard<'a, RawGcSafeFairMutex, T>; diff --git a/jlrs/src/gc_safe/mod.rs b/jlrs/src/gc_safe/mod.rs new file mode 100644 index 00000000..3efa66fb --- /dev/null +++ b/jlrs/src/gc_safe/mod.rs @@ -0,0 +1,26 @@ +//! GC-safe synchronization primitives. +//! +//! Naively using synchronization primitives like `OnceLock` or `Mutex` from a thread that belongs +//! to Julia is dangerous. If the GC needs to collect garbage while a thread is waiting to acquire +//! such a primitive you can end up with a deadlock. We can prevent this from happening by +//! entering a GC-safe state before blocking and leaving that state as soon as we wake up. +//! +//! This module offers the following GC-safe synchronization primitives: [`GcSafeOnceLock`], +//! [`GcSafeRwLock`], [`GcSafeMutex`], and [`GcSafeFairMutex`]. All of them guarantee the calling +//! thread is in a GC-safe state while it is blocked. + +pub mod fair_mutex; +pub mod mutex; +pub mod once_lock; +mod raw_fair_mutex; +mod raw_mutex; +mod raw_rwlock; +pub mod rwlock; + +pub use fair_mutex::GcSafeFairMutex; +pub use mutex::GcSafeMutex; +pub use once_lock::GcSafeOnceLock; +pub use raw_fair_mutex::RawGcSafeFairMutex; +pub use raw_mutex::RawGcSafeMutex; +pub use raw_rwlock::RawGcSafeRwLock; +pub use rwlock::GcSafeRwLock; diff --git a/jlrs/src/gc_safe/mutex.rs b/jlrs/src/gc_safe/mutex.rs new file mode 100644 index 00000000..ad48e5f1 --- /dev/null +++ b/jlrs/src/gc_safe/mutex.rs @@ -0,0 +1,19 @@ +//! A GC-safe `Mutex`. +//! +//! The API matches that of [`parking_lot::Mutex`]. + +use super::raw_mutex::RawGcSafeMutex; + +/// A GC-safe `Mutex`. See [`parking_lot::Mutex`] for more information. +pub type GcSafeMutex = lock_api::Mutex; + +/// Create a new GC-safe mutex. See [`parking_lot::const_mutex`] for more information. +pub const fn const_gc_safe_mutex(val: T) -> GcSafeMutex { + GcSafeMutex::const_new(::INIT, val) +} + +/// A GC-safe `MutexGuard`. See [`parking_lot::MutexGuard`] for more information. +pub type MutexGuard<'a, T> = lock_api::MutexGuard<'a, RawGcSafeMutex, T>; + +/// A GC-safe `MappedMutexGuard`. See [`parking_lot::MappedMutexGuard`] for more information. +pub type MappedMutexGuard<'a, T> = lock_api::MappedMutexGuard<'a, RawGcSafeMutex, T>; diff --git a/jlrs/src/gc_safe/once_lock.rs b/jlrs/src/gc_safe/once_lock.rs new file mode 100644 index 00000000..43eb7c3f --- /dev/null +++ b/jlrs/src/gc_safe/once_lock.rs @@ -0,0 +1,159 @@ +//! A GC-safe `OnceLock`. +//! +//! The API matches that of [`once_cell::sync::OnceCell`]. + +use std::fmt; + +use jl_sys::{jlrs_gc_safe_enter, jlrs_gc_safe_leave, jlrs_gc_unsafe_enter, jlrs_gc_unsafe_leave}; +use once_cell::sync::OnceCell; + +use crate::memory::get_tls; + +/// A GC-safe `OnceLock`. See [`once_cell::sync::OnceCell`] for more information. +#[derive(Clone)] +pub struct GcSafeOnceLock { + inner: OnceCell, +} + +impl Default for GcSafeOnceLock { + fn default() -> GcSafeOnceLock { + GcSafeOnceLock::new() + } +} + +impl fmt::Debug for GcSafeOnceLock { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + self.inner.fmt(f) + } +} + +impl From for GcSafeOnceLock { + fn from(value: T) -> Self { + Self::with_value(value) + } +} + +impl PartialEq for GcSafeOnceLock { + fn eq(&self, other: &GcSafeOnceLock) -> bool { + self.get() == other.get() + } +} + +impl Eq for GcSafeOnceLock {} + +impl GcSafeOnceLock { + #[inline] + pub const fn new() -> Self { + GcSafeOnceLock { + inner: OnceCell::new(), + } + } + + /// Creates a new initialized cell. + #[inline] + pub const fn with_value(value: T) -> GcSafeOnceLock { + GcSafeOnceLock { + inner: OnceCell::with_value(value), + } + } + + #[inline] + pub fn get(&self) -> Option<&T> { + self.inner.get() + } + + #[inline] + pub fn wait(&self) -> &T { + unsafe { + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + let res = self.inner.wait(); + jlrs_gc_safe_leave(ptls, state); + res + } + } + + #[inline] + pub fn get_mut(&mut self) -> Option<&mut T> { + self.inner.get_mut() + } + + #[inline] + pub unsafe fn get_unchecked(&self) -> &T { + self.inner.get_unchecked() + } + + #[inline] + pub fn set(&self, value: T) -> Result<(), T> { + unsafe { + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + let res = self.inner.set(value); + jlrs_gc_safe_leave(ptls, state); + res + } + } + + #[inline] + pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { + self.inner.try_insert(value) + } + + pub fn get_or_init(&self, f: F) -> &T + where + F: FnOnce() -> T, + { + if let Some(v) = self.get() { + return v; + } + + unsafe { + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + + let res = self.inner.get_or_init(|| { + let state = jlrs_gc_unsafe_enter(ptls); + let res = f(); + jlrs_gc_unsafe_leave(ptls, state); + res + }); + + jlrs_gc_safe_leave(ptls, state); + res + } + } + + pub fn get_or_try_init(&self, f: F) -> Result<&T, E> + where + F: FnOnce() -> Result, + { + if let Some(v) = self.get() { + return Ok(v); + } + + unsafe { + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + + let res = self.inner.get_or_try_init(|| { + let state = jlrs_gc_unsafe_enter(ptls); + let res = f(); + jlrs_gc_unsafe_leave(ptls, state); + res + }); + + jlrs_gc_unsafe_leave(ptls, state); + res + } + } + + #[inline] + pub fn take(&mut self) -> Option { + self.inner.take() + } + + #[inline] + pub fn into_inner(self) -> Option { + self.inner.into_inner() + } +} diff --git a/jlrs/src/gc_safe/raw_fair_mutex.rs b/jlrs/src/gc_safe/raw_fair_mutex.rs new file mode 100644 index 00000000..b404ce57 --- /dev/null +++ b/jlrs/src/gc_safe/raw_fair_mutex.rs @@ -0,0 +1,75 @@ +use std::time::{Duration, Instant}; + +use jl_sys::{jlrs_gc_safe_enter, jlrs_gc_safe_leave}; +use parking_lot::RawMutex; + +use crate::memory::get_tls; + +/// See [`parking_lot::RawFairMutex`] for more information. +pub struct RawGcSafeFairMutex { + inner: RawMutex, +} + +unsafe impl lock_api::RawMutex for RawGcSafeFairMutex { + const INIT: Self = RawGcSafeFairMutex { + inner: ::INIT, + }; + + type GuardMarker = ::GuardMarker; + + #[inline] + fn lock(&self) { + unsafe { + if self.try_lock() { + return; + } + + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + self.inner.lock(); + jlrs_gc_safe_leave(ptls, state); + } + } + + #[inline] + fn try_lock(&self) -> bool { + self.inner.try_lock() + } + + #[inline] + unsafe fn unlock(&self) { + self.inner.unlock() + } + + #[inline] + fn is_locked(&self) -> bool { + self.inner.is_locked() + } +} + +unsafe impl lock_api::RawMutexFair for RawGcSafeFairMutex { + #[inline] + unsafe fn unlock_fair(&self) { + self.inner.unlock_fair() + } + + #[inline] + unsafe fn bump(&self) { + self.inner.bump() + } +} + +unsafe impl lock_api::RawMutexTimed for RawGcSafeFairMutex { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_until(&self, timeout: Instant) -> bool { + self.inner.try_lock_until(timeout) + } + + #[inline] + fn try_lock_for(&self, timeout: Duration) -> bool { + self.inner.try_lock_for(timeout) + } +} diff --git a/jlrs/src/gc_safe/raw_mutex.rs b/jlrs/src/gc_safe/raw_mutex.rs new file mode 100644 index 00000000..49975f8e --- /dev/null +++ b/jlrs/src/gc_safe/raw_mutex.rs @@ -0,0 +1,75 @@ +use std::time::{Duration, Instant}; + +use jl_sys::{jlrs_gc_safe_enter, jlrs_gc_safe_leave}; +use parking_lot::RawMutex; + +use crate::memory::get_tls; + +/// See [`parking_lot::RawMutex`] for more information. +pub struct RawGcSafeMutex { + inner: RawMutex, +} + +unsafe impl lock_api::RawMutex for RawGcSafeMutex { + const INIT: Self = RawGcSafeMutex { + inner: RawMutex::INIT, + }; + + type GuardMarker = ::GuardMarker; + + #[inline] + fn lock(&self) { + unsafe { + if self.try_lock() { + return; + } + + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + self.inner.lock(); + jlrs_gc_safe_leave(ptls, state); + } + } + + #[inline] + fn try_lock(&self) -> bool { + self.inner.try_lock() + } + + #[inline] + unsafe fn unlock(&self) { + self.inner.unlock() + } + + #[inline] + fn is_locked(&self) -> bool { + self.inner.is_locked() + } +} + +unsafe impl lock_api::RawMutexFair for RawGcSafeMutex { + #[inline] + unsafe fn unlock_fair(&self) { + self.inner.unlock_fair() + } + + #[inline] + unsafe fn bump(&self) { + self.inner.bump() + } +} + +unsafe impl lock_api::RawMutexTimed for RawGcSafeMutex { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_until(&self, timeout: Instant) -> bool { + self.inner.try_lock_until(timeout) + } + + #[inline] + fn try_lock_for(&self, timeout: Duration) -> bool { + self.inner.try_lock_for(timeout) + } +} diff --git a/jlrs/src/gc_safe/raw_rwlock.rs b/jlrs/src/gc_safe/raw_rwlock.rs new file mode 100644 index 00000000..5dae3c78 --- /dev/null +++ b/jlrs/src/gc_safe/raw_rwlock.rs @@ -0,0 +1,236 @@ +use std::time::{Duration, Instant}; + +use jl_sys::{jlrs_gc_safe_enter, jlrs_gc_safe_leave}; +use parking_lot::RawRwLock; + +use crate::memory::get_tls; + +/// See [`parking_lot::RawRwLock`] for more information. +pub struct RawGcSafeRwLock { + inner: RawRwLock, +} + +unsafe impl lock_api::RawRwLock for RawGcSafeRwLock { + const INIT: Self = RawGcSafeRwLock { + inner: RawRwLock::INIT, + }; + + type GuardMarker = ::GuardMarker; + + #[inline] + fn lock_shared(&self) { + unsafe { + if self.try_lock_shared() { + return; + } + + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + self.inner.lock_shared(); + jlrs_gc_safe_leave(ptls, state); + } + } + + #[inline] + fn try_lock_shared(&self) -> bool { + self.inner.try_lock_shared() + } + + #[inline] + unsafe fn unlock_shared(&self) { + self.inner.unlock_shared(); + } + + #[inline] + fn lock_exclusive(&self) { + unsafe { + if self.try_lock_exclusive() { + return; + } + + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + self.inner.lock_exclusive(); + jlrs_gc_safe_leave(ptls, state); + } + } + + #[inline] + fn try_lock_exclusive(&self) -> bool { + self.inner.try_lock_exclusive() + } + + #[inline] + unsafe fn unlock_exclusive(&self) { + self.inner.unlock_exclusive(); + } +} + +unsafe impl lock_api::RawRwLockFair for RawGcSafeRwLock { + #[inline] + unsafe fn unlock_shared_fair(&self) { + self.inner.unlock_shared_fair() + } + + #[inline] + unsafe fn unlock_exclusive_fair(&self) { + self.inner.unlock_exclusive_fair() + } + + #[inline] + unsafe fn bump_shared(&self) { + self.inner.bump_shared() + } + + #[inline] + unsafe fn bump_exclusive(&self) { + self.inner.bump_exclusive() + } +} + +unsafe impl lock_api::RawRwLockDowngrade for RawGcSafeRwLock { + #[inline] + unsafe fn downgrade(&self) { + self.inner.downgrade() + } +} + +unsafe impl lock_api::RawRwLockTimed for RawGcSafeRwLock { + type Duration = Duration; + type Instant = Instant; + + #[inline] + fn try_lock_shared_for(&self, timeout: Self::Duration) -> bool { + self.inner.try_lock_shared_for(timeout) + } + + #[inline] + fn try_lock_shared_until(&self, timeout: Self::Instant) -> bool { + self.inner.try_lock_shared_until(timeout) + } + + #[inline] + fn try_lock_exclusive_for(&self, timeout: Duration) -> bool { + self.inner.try_lock_exclusive_for(timeout) + } + + #[inline] + fn try_lock_exclusive_until(&self, timeout: Instant) -> bool { + self.inner.try_lock_exclusive_until(timeout) + } +} + +unsafe impl lock_api::RawRwLockRecursive for RawGcSafeRwLock { + #[inline] + fn lock_shared_recursive(&self) { + self.inner.lock_shared_recursive() + } + + #[inline] + fn try_lock_shared_recursive(&self) -> bool { + self.inner.try_lock_shared_recursive() + } +} + +unsafe impl lock_api::RawRwLockRecursiveTimed for RawGcSafeRwLock { + #[inline] + fn try_lock_shared_recursive_for(&self, timeout: Self::Duration) -> bool { + self.inner.try_lock_shared_recursive_for(timeout) + } + + #[inline] + fn try_lock_shared_recursive_until(&self, timeout: Self::Instant) -> bool { + self.inner.try_lock_shared_recursive_until(timeout) + } +} + +unsafe impl lock_api::RawRwLockUpgrade for RawGcSafeRwLock { + #[inline] + fn lock_upgradable(&self) { + unsafe { + if self.try_lock_upgradable() { + return; + } + + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + self.inner.lock_upgradable(); + jlrs_gc_safe_leave(ptls, state); + } + } + + #[inline] + fn try_lock_upgradable(&self) -> bool { + self.inner.try_lock_upgradable() + } + + #[inline] + unsafe fn unlock_upgradable(&self) { + self.inner.unlock_upgradable() + } + + #[inline] + unsafe fn upgrade(&self) { + unsafe { + if self.try_upgrade() { + return; + } + + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + self.inner.upgrade(); + jlrs_gc_safe_leave(ptls, state); + } + } + + #[inline] + unsafe fn try_upgrade(&self) -> bool { + self.inner.try_upgrade() + } +} + +unsafe impl lock_api::RawRwLockUpgradeFair for RawGcSafeRwLock { + #[inline] + unsafe fn unlock_upgradable_fair(&self) { + self.inner.unlock_upgradable_fair() + } + + #[inline] + unsafe fn bump_upgradable(&self) { + self.inner.bump_upgradable() + } +} + +unsafe impl lock_api::RawRwLockUpgradeDowngrade for RawGcSafeRwLock { + #[inline] + unsafe fn downgrade_upgradable(&self) { + self.inner.downgrade_upgradable() + } + + #[inline] + unsafe fn downgrade_to_upgradable(&self) { + self.inner.downgrade_to_upgradable() + } +} + +unsafe impl lock_api::RawRwLockUpgradeTimed for RawGcSafeRwLock { + #[inline] + fn try_lock_upgradable_until(&self, timeout: Instant) -> bool { + self.inner.try_lock_upgradable_until(timeout) + } + + #[inline] + fn try_lock_upgradable_for(&self, timeout: Duration) -> bool { + self.inner.try_lock_upgradable_for(timeout) + } + + #[inline] + unsafe fn try_upgrade_until(&self, timeout: Instant) -> bool { + self.inner.try_upgrade_until(timeout) + } + + #[inline] + unsafe fn try_upgrade_for(&self, timeout: Duration) -> bool { + self.inner.try_upgrade_for(timeout) + } +} diff --git a/jlrs/src/gc_safe/rwlock.rs b/jlrs/src/gc_safe/rwlock.rs new file mode 100644 index 00000000..fb573db2 --- /dev/null +++ b/jlrs/src/gc_safe/rwlock.rs @@ -0,0 +1,34 @@ +//! A GC-safe `RwLock`. +//! +//! The API matches that of [`parking_lot::RwLock`]. + +use super::raw_rwlock::RawGcSafeRwLock; + +/// A GC-safe fair `RwLock`. See [`parking_lot::RwLock`] for more information. +pub type GcSafeRwLock = lock_api::RwLock; + +/// Create a new GC-safe `RwLock`. See [`parking_lot::const_rwlock`] for more information. +pub const fn const_gc_safe_rwlock(val: T) -> GcSafeRwLock { + GcSafeRwLock::const_new(::INIT, val) +} + +/// A GC-safe `RwLockReadGuard`. See [`parking_lot::RwLockReadGuard`] for more information. +pub type GcSafeRwLockReadGuard<'a, T> = lock_api::RwLockReadGuard<'a, RawGcSafeRwLock, T>; + +/// A GC-safe `RwLockWriteGuard`. See [`parking_lot::RwLockWriteGuard`] for more information. +pub type GcSafeRwLockWriteGuard<'a, T> = lock_api::RwLockWriteGuard<'a, RawGcSafeRwLock, T>; + +/// A GC-safe `MappedRwLockReadGuard`. See [`parking_lot::MappedRwLockReadGuard`] for more +/// information. +pub type MappedGcSafeRwLockReadGuard<'a, T> = + lock_api::MappedRwLockReadGuard<'a, RawGcSafeRwLock, T>; + +/// A GC-safe `MappedRwLockWriteGuard`. See [`parking_lot::MappedRwLockWriteGuard`] for more +/// information. +pub type MappedGcSafeRwLockWriteGuard<'a, T> = + lock_api::MappedRwLockWriteGuard<'a, RawGcSafeRwLock, T>; + +/// A GC-safe `RwLockUpgradableReadGuard`. See [`parking_lot::RwLockUpgradableReadGuard`] for more +/// information. +pub type GcSafeRwLockUpgradableReadGuard<'a, T> = + lock_api::RwLockUpgradableReadGuard<'a, RawGcSafeRwLock, T>; diff --git a/jlrs/src/info.rs b/jlrs/src/info.rs index 5d7f61d3..a1ad06af 100644 --- a/jlrs/src/info.rs +++ b/jlrs/src/info.rs @@ -19,38 +19,45 @@ pub struct Info; impl Info { /// Number of threads the CPU supports. + #[inline] pub fn n_cpu_threads() -> usize { unsafe { jl_cpu_threads() as usize } } #[julia_version(until = "1.8")] + #[inline] /// Number of threads Julia can use. pub fn n_threads() -> usize { unsafe { jl_n_threads as usize } } #[julia_version(since = "1.9")] + #[inline] /// Number of threads Julia can use. pub fn n_threads() -> usize { unsafe { jl_n_threads.load(::std::sync::atomic::Ordering::Relaxed) as usize } } /// The page size used by the garbage collector. + #[inline] pub fn page_size() -> usize { unsafe { jl_getpagesize() as usize } } /// The allocation granularity. + #[inline] pub fn allocation_granularity() -> usize { unsafe { jl_getallocationgranularity() as usize } } /// Returns `true` if a debug build of Julia is used. + #[inline] pub fn is_debugbuild() -> bool { unsafe { jl_is_debugbuild() != 0 } } /// Name and information of the kernel. + #[inline] pub fn uname() -> StrOrBytes<'static> { unsafe { let cstr = @@ -65,6 +72,7 @@ impl Info { } /// The CPU architecture. + #[inline] pub fn arch() -> StrOrBytes<'static> { unsafe { let cstr = @@ -79,26 +87,31 @@ impl Info { } /// The major version of Julia. + #[inline] pub fn major_version() -> isize { unsafe { jl_ver_major() as isize } } /// The minor version of Julia. + #[inline] pub fn minor_version() -> isize { unsafe { jl_ver_minor() as isize } } /// The patch version of Julia. + #[inline] pub fn patch_version() -> isize { unsafe { jl_ver_patch() as isize } } /// Returns true if a release version of Julia is used. + #[inline] pub fn is_release() -> bool { unsafe { jl_ver_is_release() != 0 } } /// Returns the git branch that was used to compile the used version of Julia. + #[inline] pub fn git_branch() -> StrOrBytes<'static> { unsafe { let cstr = CStr::from_ptr(jl_git_branch()); @@ -112,11 +125,13 @@ impl Info { } /// Returns the git commit that was used to compile the used version of Julia. + #[inline] pub fn git_commit() -> &'static str { unsafe { CStr::from_ptr(jl_git_commit()).to_str().unwrap() } } /// Returns the version string of the used version of Julia. + #[inline] pub fn version_string() -> &'static str { unsafe { CStr::from_ptr(jl_ver_string()).to_str().unwrap() } } diff --git a/jlrs/src/lib.rs b/jlrs/src/lib.rs index 94b7d749..d14554f0 100644 --- a/jlrs/src/lib.rs +++ b/jlrs/src/lib.rs @@ -1,8 +1,8 @@ //! jlrs is a crate that provides access to most of the Julia C API, it can be used to embed Julia //! in Rust applications and to use functionality it provides when writing `ccall`able //! functions in Rust. Currently this crate is only tested in combination with Julia 1.6 and 1.9, -//! but also supports Julia 1.7 and 1.8. Using the current stable version is highly recommended. -//! The minimum supported Rust version is currently 1.65. +//! but also supports Julia 1.7, 1.8 and 1.10. Using the current stable version is highly +//! recommended. The minimum supported Rust version is currently 1.65. //! //! The documentation assumes you're already familiar with the Julia and Rust programming //! languages. @@ -35,7 +35,7 @@ //! # 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 JlrsCore package must also have been installed, if this is not the +//! including Julia 1.10. The JlrsCore package must also have been installed, if this is not the //! case it will automatically be added when jlrs is initialized by default. jlrs has not been //! tested with juliaup yet on Linux and macOS. //! @@ -94,6 +94,7 @@ //! - `julia-1-7` //! - `julia-1-8` //! - `julia-1-9` +//! - `julia-1-10` //! //! Exactly one version feature must be enabled. If no version is enabled, or multiple are, jl-sys //! will fail to compile. @@ -107,6 +108,7 @@ //! julia-1-7 = ["jlrs/julia-1-7"] //! julia-1-8 = ["jlrs/julia-1-8"] //! julia-1-9 = ["jlrs/julia-1-9"] +//! julia-1-10 = ["jlrs/julia-1-10"] //! ``` //! //! In this case you must provide this feature when you build or run your crate: @@ -214,7 +216,8 @@ //! Flag that must be enabled when compiling with BinaryBuilder. //! //! You can enable all features except `debug`, `i686`, `windows`, `no-link` and `yggdrasil` by -//! enabling the `full` feature. +//! enabling the `full` feature. If you don't want to enable any runtimes either, you can use +//! `full-no-rt`. //! //! //! # Using this crate @@ -222,11 +225,11 @@ //! If you want to embed Julia in a Rust application, you must enable a runtime and a version //! feature: //! -//! `jlrs = {version = "0.18.0", features = ["sync-rt", "julia-1-8"]}` +//! `jlrs = {version = "0.19.0", features = ["sync-rt", "julia-1-8"]}` //! -//! `jlrs = {version = "0.18.0", features = ["tokio-rt", "julia-1-8"]}` +//! `jlrs = {version = "0.19.0", features = ["tokio-rt", "julia-1-8"]}` //! -//! `jlrs = {version = "0.18.0", features = ["async-std-rt", "julia-1-8"]}` +//! `jlrs = {version = "0.19.0", features = ["async-std-rt", "julia-1-8"]}` //! //! When Julia is embedded in an application, it must be initialized before it can be used. The //! following snippet initializes the sync runtime: @@ -427,7 +430,7 @@ //! // CallAsync::call_async schedules the function call on another //! // thread and returns a Future that resolves when the scheduled //! // function has returned or thrown an error. -//! unsafe { func.call_async(&mut frame, &mut [a, b]) } +//! unsafe { func.call_async(&mut frame, [a, b]) } //! .await //! .into_jlrs_result()? //! .unbox::() @@ -484,8 +487,8 @@ //! // A `Vec` can be moved from Rust to Julia if the element type //! // implements `IntoJulia`. //! let data = vec![0usize; self.n_values]; -//! let array = TypedArray::from_vec(frame.as_extended_target(), data, self.n_values)? -//! .into_jlrs_result()?; +//! let array = +//! TypedArray::from_vec(&mut frame, data, self.n_values)?.into_jlrs_result()?; //! //! Ok(AccumulatorTaskState { array, offset: 0 }) //! } @@ -590,6 +593,8 @@ //! panic = "abort" //! ``` //! +//! You must not enable any runtime features. +//! //! The easiest way to export Rust functions like `call_me` from the previous example is by //! using the [`julia_module`] macro. The content of the macro is converted to an initialization //! function that can be called from Julia to generate the module. @@ -771,14 +776,24 @@ #![forbid(rustdoc::broken_intra_doc_links)] -use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::atomic::AtomicBool; +use atomic::Ordering; #[cfg(feature = "sync-rt")] use once_cell::sync::OnceCell; use prelude::Managed; use crate::{ - data::managed::{module::Module, value::Value}, + data::{ + managed::{ + module::{init_global_cache, Module}, + symbol::init_symbol_cache, + value::Value, + }, + types::{ + construct_type::init_constructed_type_cache, foreign_type::init_foreign_type_registry, + }, + }, memory::{ context::{ledger::init_ledger, stack::Stack}, stack_frame::PinnedFrame, @@ -809,15 +824,17 @@ macro_rules! init_fn { }; } +pub mod args; #[cfg(feature = "async")] pub mod async_util; pub mod call; -pub(crate) mod catch; +pub mod catch; #[cfg(feature = "ccall")] pub mod ccall; pub mod convert; pub mod data; pub mod error; +pub mod gc_safe; pub mod info; pub mod memory; #[cfg(feature = "prelude")] @@ -947,6 +964,11 @@ pub(crate) unsafe fn init_jlrs( return; } + init_foreign_type_registry(); + init_constructed_type_cache(); + init_symbol_cache(); + init_global_cache(); + let unrooted = Unrooted::new(); install_jlrs_core.use_or_install(unrooted); diff --git a/jlrs/src/memory/context/ledger.rs b/jlrs/src/memory/context/ledger.rs index 722bba8c..d59a5508 100644 --- a/jlrs/src/memory/context/ledger.rs +++ b/jlrs/src/memory/context/ledger.rs @@ -9,15 +9,15 @@ use std::ffi::c_void; -use once_cell::sync::OnceCell; - use crate::{ - data::managed::{module::Module, value::Value}, + data::managed::{module::Module, private::ManagedPriv, value::Value}, error::{JlrsError, JlrsResult}, + gc_safe::GcSafeOnceLock, memory::target::unrooted::Unrooted, + private::Private, }; -const API_VERSION: usize = 1; +const API_VERSION: usize = 2; #[derive(PartialEq, Eq, Debug)] #[repr(u8)] @@ -26,10 +26,9 @@ pub(crate) enum LedgerResult { OkFalse = 0u8, OkTrue = 1u8, Err = 2u8, - Poison = 3u8, } -pub(crate) static LEDGER: OnceCell = OnceCell::new(); +pub(crate) static LEDGER: GcSafeOnceLock = GcSafeOnceLock::new(); pub(crate) struct Ledger { api_version: unsafe extern "C" fn() -> usize, @@ -160,94 +159,95 @@ pub(crate) unsafe extern "C" fn init_ledger() { } impl Ledger { + #[inline] pub(crate) fn api_version() -> usize { unsafe { (LEDGER.get_unchecked().api_version)() } } + #[inline] pub(crate) fn is_borrowed_shared(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().is_borrowed_shared)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("unexpected error"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) fn is_borrowed_exclusive(data: Value) -> JlrsResult { unsafe { - match (LEDGER.get_unchecked().is_borrowed_exclusive)(data.data_ptr().as_ptr()) { + match (LEDGER.get_unchecked().is_borrowed_exclusive)(data.unwrap(Private).cast()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("unexpected error"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) fn is_borrowed(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().is_borrowed)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("unexpected error"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) fn try_borrow_shared(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().try_borrow_shared)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("already exclusively borrowed"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) fn try_borrow_exclusive(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().try_borrow_exclusive)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("already exclusively borrowed"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) unsafe fn borrow_shared_unchecked(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().borrow_shared_unchecked)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("already exclusively borrowed"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) unsafe fn unborrow_shared(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().unborrow_shared)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("not borrowed"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } + #[inline] pub(crate) unsafe fn unborrow_exclusive(data: Value) -> JlrsResult { unsafe { match (LEDGER.get_unchecked().unborrow_exclusive)(data.data_ptr().as_ptr()) { LedgerResult::OkFalse => Ok(false), LedgerResult::OkTrue => Ok(true), LedgerResult::Err => Err(JlrsError::exception("not borrowed"))?, - LedgerResult::Poison => Err(JlrsError::exception("poisoned mutex"))?, } } } diff --git a/jlrs/src/memory/context/stack.rs b/jlrs/src/memory/context/stack.rs index 3a9a6f08..d0d01596 100644 --- a/jlrs/src/memory/context/stack.rs +++ b/jlrs/src/memory/context/stack.rs @@ -20,7 +20,7 @@ use crate::{ call::Call, data::{ managed::{module::Module, private::ManagedPriv, symbol::Symbol, value::Value, Managed}, - types::foreign_type::{ForeignType, OpaqueType}, + types::foreign_type::{create_foreign_type_nostack, ForeignType}, }, memory::{stack_frame::PinnedFrame, target::unrooted::Unrooted, PTls}, private::Private, @@ -41,27 +41,6 @@ unsafe impl Send for Stack {} unsafe impl Sync for Stack {} unsafe impl ForeignType for Stack { - // #[julia_version(since = "1.10")] - // fn mark(ptls: PTls, data: &Self) -> usize { - // // We can only get here while the GC is running, so there are no active mutable borrows, - // // but this function might be called from multiple threads so an immutable reference must - // // be used. - // let slots = unsafe { &*data.slots.get() }; - // - // let mut n = 0; - // unsafe { - // for slot in slots { - // if !slot.get().is_null() { - // if crate::memory::gc::mark_queue_obj(ptls, slot.get()) { - // n += 1; - // } - // } - // } - // } - // - // n - // } - fn mark(ptls: PTls, data: &Self) -> usize { // We can only get here while the GC is running, so there are no active mutable borrows, // but this function might be called from multiple threads so an immutable reference must @@ -81,6 +60,7 @@ unsafe impl ForeignType for Stack { pub(crate) struct StaticSymbol(Symbol<'static>); impl StaticSymbol { + #[inline] pub(crate) fn as_symbol(&self) -> Symbol { self.0 } @@ -128,7 +108,7 @@ impl Stack { // Safety: create_foreign_type is called with the correct arguments, the new type is // rooted until the constant has been set, and we've just checked if JlrsCore.Stack // already exists. - let dt_ref = Self::create_type(global, sym, module); + let dt_ref = create_foreign_type_nostack::(global, sym, module); let ptr = dt_ref.ptr(); frame.set_sync_root(ptr.cast().as_ptr()); @@ -142,6 +122,7 @@ impl Stack { // Push a new root to the stack. // // Safety: `root` must point to data that hasn't been freed yet. + #[inline] pub(crate) unsafe fn push_root(&self, root: NonNull) { { // We can only get here while the GC isn't running, so there are @@ -157,6 +138,7 @@ impl Stack { // // Safety: reserved slot may only be used until the frame it belongs to // is popped from the stack. + #[inline] pub(crate) unsafe fn reserve_slot(&self) -> usize { // We can only get here while the GC isn't running, so there are // no active borrows. @@ -167,6 +149,7 @@ impl Stack { } // Grow the stack capacity by at least `additional` slots + #[inline] pub(crate) fn reserve(&self, additional: usize) { unsafe { // We can only get here while the GC isn't running, so there are @@ -177,6 +160,7 @@ impl Stack { } // Set the root at `offset` + #[inline] pub(crate) unsafe fn set_root(&self, offset: usize, root: NonNull) { // We can only get here while the GC isn't running, so there are // no active borrows. @@ -188,6 +172,7 @@ impl Stack { // Pop roots from the stack, the new length is `offset`. // // Safety: must be called when a frame is popped from the stack. + #[inline] pub(crate) unsafe fn pop_roots(&self, offset: usize) { // We can only get here while the GC isn't running, so there are // no active borrows. @@ -196,6 +181,7 @@ impl Stack { } // Returns the size of the stack + #[inline] pub(crate) fn size(&self) -> usize { unsafe { // We can only get here while the GC isn't running, so there are @@ -207,6 +193,7 @@ impl Stack { // Create a new stack and move it to Julia. // Safety: root after allocating + #[inline] pub(crate) unsafe fn alloc() -> *mut Self { let global = Unrooted::new(); let stack = Value::new(global, Stack::default()); diff --git a/jlrs/src/memory/gc.rs b/jlrs/src/memory/gc.rs index 9d1aefbf..ccf74da1 100644 --- a/jlrs/src/memory/gc.rs +++ b/jlrs/src/memory/gc.rs @@ -2,13 +2,19 @@ #[julia_version(since = "1.10")] use jl_sys::jl_gc_set_max_memory; +pub use jl_sys::{jl_gc_collect, jl_gc_collection_t_JL_GC_FULL}; use jl_sys::{ - jl_gc_collect, jl_gc_collection_t, jl_gc_enable, jl_gc_is_enabled, jl_gc_mark_queue_obj, - jl_gc_mark_queue_objarray, jl_gc_safepoint, jl_gc_wb, + jl_gc_collection_t, jl_gc_enable, jl_gc_is_enabled, jl_gc_mark_queue_obj, + jl_gc_mark_queue_objarray, jl_gc_safepoint, jl_gc_wb, jlrs_gc_safe_enter, jlrs_gc_safe_leave, + jlrs_gc_unsafe_enter, jlrs_gc_unsafe_leave, }; use jlrs_macros::julia_version; -use super::{target::Target, PTls}; +use super::{ + get_tls, + target::{unrooted::Unrooted, Target}, + PTls, +}; #[cfg(feature = "sync-rt")] use crate::runtime::sync_rt::Julia; #[julia_version(since = "1.7")] @@ -33,9 +39,10 @@ pub enum GcCollection { /// /// This trait provides several methods that can be used to enable or disable the GC, force a /// collection, insert a safepoint, and to enable and disable GC logging. It's implemented for -/// [`Julia`] and all implementations of [`Target`] +/// [`Julia`] and all [`Target`]s. pub trait Gc: private::GcPriv { /// Enable or disable the GC. + #[inline] fn enable_gc(&self, on: bool) -> bool { // Safety: this function is called with a valid argument and can only be called while // Julia is active. @@ -76,6 +83,7 @@ pub trait Gc: private::GcPriv { } /// Returns `true` if the GC is enabled. + #[inline] fn gc_is_enabled(&self) -> bool { // Safety: this function can only be called while Julia is active from a thread known to // Julia. @@ -83,6 +91,7 @@ pub trait Gc: private::GcPriv { } /// Force a collection. + #[inline] fn gc_collect(&self, mode: GcCollection) { // Safety: this function can only be called while Julia is active from a thread known to // Julia. @@ -90,6 +99,7 @@ pub trait Gc: private::GcPriv { } /// Insert a safepoint, a point where the garbage collector may run. + #[inline] fn gc_safepoint(&self) { // Safety: this function can only be called while Julia is active from a thread known to // Julia. @@ -98,8 +108,67 @@ pub trait Gc: private::GcPriv { } } + /// Put the current task in a GC-safe state. + /// + /// In a GC-safe state a task must not be calling into Julia, it indicates that the GC is + /// allowed to collect without waiting for the task to reach an explicit safepoint. + /// + /// Safety: + /// + /// While in a GC-safe state, you must not call into Julia in any way that. It should only be used + /// in combination with blocking operations to allow the GC to collect while waiting for the + /// blocking operation to complete. + /// + /// You must leave the GC-safe state by calling [`Gc::gc_safe_leave`] with the state returned + /// by this function. + #[inline] + unsafe fn gc_safe_enter() -> i8 { + let ptls = get_tls(); + jlrs_gc_safe_enter(ptls) + } + + /// Leave a GC-safe region and return to the previous GC-state. + /// + /// Safety: + /// + /// Must be called with the state returned by a matching call to [`Gc::gc_safe_enter`]. + #[inline] + unsafe fn gc_safe_leave(state: i8) { + let ptls = get_tls(); + jlrs_gc_safe_leave(ptls, state) + } + + /// Put the current task in a GC-unsafe state. + /// + /// In a GC-unsafe state a task must reach an explicit safepoint before the GC can collect. + /// + /// Safety: + /// + /// This function must only be called while the task is in a GC-safe state. After calling this + /// function the task may call into Julia again. + /// + /// You must leave the GC-safe state by calling [`Gc::gc_unsafe_leave`] with the state + /// returned by this function. + #[inline] + unsafe fn gc_unsafe_enter() -> i8 { + let ptls = get_tls(); + jlrs_gc_unsafe_enter(ptls) + } + + /// Leave a GC-unsafe region and return to the previous GC-state. + /// + /// Safety: + /// + /// Must be called with the state returned by a matching call to [`Gc::gc_unsafe_enter`]. + #[inline] + unsafe fn gc_unsafe_leave(state: i8) { + let ptls = get_tls(); + jlrs_gc_unsafe_leave(ptls, state) + } + #[julia_version(since = "1.10")] /// Set GC memory trigger in bytes for greedy memory collecting + #[inline] fn gc_set_max_memory(max_mem: u64) { unsafe { jl_gc_set_max_memory(max_mem) } } @@ -114,6 +183,7 @@ pub trait Gc: private::GcPriv { /// Safety /// /// This method must only be called from `ForeignType::mark`. +#[inline] pub unsafe fn mark_queue_obj(ptls: PTls, obj: ValueRef) -> bool { jl_gc_mark_queue_obj(ptls, obj.ptr().as_ptr()) != 0 } @@ -128,6 +198,7 @@ pub unsafe fn mark_queue_obj(ptls: PTls, obj: ValueRef) -> bool { /// Safety /// /// This method must only be called from `ForeignType::mark`. +#[inline] pub unsafe fn mark_queue_objarray(ptls: PTls, parent: ValueRef, objs: &[Option]) { jl_gc_mark_queue_objarray(ptls, parent.ptr().as_ptr(), objs.as_ptr() as _, objs.len()) } @@ -143,6 +214,7 @@ pub unsafe fn mark_queue_objarray(ptls: PTls, parent: ValueRef, objs: &[Option(data: &mut T, child: Value) { jl_gc_wb(data as *mut _ as *mut _, child.unwrap(Private)) } @@ -186,7 +258,50 @@ void jl_gc_queue_multiroot(const jl_value_t *parent, const jl_value_t *ptr) JL_N } } } - */ +*/ + +/// Put the current task in a GC-safe state, call `f`, and return to the previous GC state. +/// +/// This must only be used when long-running functions that don't call into Julia are called from +/// a thread that can call into Julia. It puts the current task into a GC-safe state, this can be +/// thought of as extended safepoint: a task that is in a GC-safe state allows the GC to collect +/// garbage as if it had reached a safepoint. +/// +/// Safety: +/// +/// - This function must be called from a thread that can call into Julia. +/// - `f` must not call into Julia in any way, except inside a function called with `gc_unsafe`. +#[inline] +pub unsafe fn gc_safe T, T>(f: F) -> T { + let ptls = get_tls(); + + let state = jlrs_gc_safe_enter(ptls); + let res = f(); + jlrs_gc_safe_leave(ptls, state); + + res +} + +/// Put the current task in a GC-unsafe state, call `f`, and return to the previous GC state. +/// +/// This should only be used in a function called with [`gc_safe`]. It puts the task back into a +/// GC=unsafe state. If the task is already in an GC-unsafe state calling this function has no +/// effect. +/// +/// Safety: +/// +/// - This function must be called from a thread that can call into Julia. +#[inline] +pub unsafe fn gc_unsafe FnOnce(Unrooted<'scope>) -> T, T>(f: F) -> T { + let ptls = get_tls(); + + let unrooted = Unrooted::new(); + let state = jlrs_gc_unsafe_enter(ptls); + let res = f(unrooted); + jlrs_gc_unsafe_leave(ptls, state); + + res +} #[cfg(feature = "sync-rt")] impl Gc for Julia<'_> {} diff --git a/jlrs/src/memory/mod.rs b/jlrs/src/memory/mod.rs index 9b6b1bd2..98c2fdfd 100644 --- a/jlrs/src/memory/mod.rs +++ b/jlrs/src/memory/mod.rs @@ -1,63 +1,201 @@ //! Julia memory management. //! -//! All Julia data (objects) is owned by the garbage collector (GC). The GC is a mark-and-sweep -//! GC, during the mark phase all objects that can be reached from a root are marked as reachable, -//! during the sweep phase all unreachable objects are freed. -//! -//! Roots are pointers to objects that are present on the GC stack. The GC stack is a linked list -//! of GC frames. A C function that needs to protect one or more objects allocates an -//! appropriately-sized GC frame and pushes it to the GC stack, typically at the beginning of the -//! function call, stores the pointers to objects that are returned by the Julia C API in that -//! frame, and pops the frame from the GC stack before returning from the function. -//! -//! There are several problems with this approach from a Rust perspective. The API is pretty -//! unsafe because it depends on manually pushing and popping GC frame to and from the GC stack, -//! and manually inserting pointers into the frame. More importantly, the GC frame is a -//! dynamically-sized type that is allocated on the stack with `alloca`. This is simply not -//! supported by Rust, at least not without jumping through a number awkward and limiting hoops. -//! -//! In order to work around these issues, jlrs doesn't store the roots in the frame, but uses a -//! custom object that contains a `Vec` of roots (stack). This stack is not part of the public -//! API, you can only interact with it indirectly by creating a scope first. The sync runtime lets -//! you create one directly with [`Julia::scope`], this method takes a closure which takes a -//! single argument, a [`GcFrame`]. This `GcFrame` can access the internal stack and push new -//! roots to it. The roots that are associated with a `GcFrame` are popped from the stack after -//! the closure returns. -//! -//! Rather than returning raw pointers to objects, jlrs wraps these pointers in types that -//! implement the [`Managed`] trait. Methods that return such types typically take an argument -//! that implements the [`Target`] trait, which ensures the object is rooted. The returned managed -//! type inherits the lifetime of the target to ensure this data can't be used after the scope -//! whose `GcFrame` has rooted it ends. Mutable references to `GcFrame` implement `Target`, when -//! one is used as a target the returned data remains rooted until the scope ends. -//! -//! Often you'll need to create some Julia data that doesn't need to live as long as the current -//! scope. A nested scope, with its own `GcFrame`, can be created by calling [`GcFrame::scope`]. -//! In order to return managed data from a child scope it has to be rooted in the `GcFrame` of a -//! parent scope, but this `GcFrame` can't be accessed from the child scope. Instead, you can -//! create an [`Output`] by reserving a slot on the stack by calling [`GcFrame::output`]. When an -//! `Output` is used as a target, the reserved slot is used to root the data and the returned -//! managed type inherits the lifetime of the parent scope, allowing it to be returned from the -//! child scope. -//! -//! Several other target types exist, they can all be created through methods defined for -//! `GcFrame`. You can find more information about them in the [`target`] module. -//! -//! Not all targets root the returned data. If you never need to use the data (e.g. because you -//! call a function that returns `nothing`), or you access a global value in a module that is -//! never mutated while you're using it, the result doesn't need to be rooted. A reference to a -//! rooting target is guaranteed to be a valid non-rooting target. When a non-rooting target is -//! used, the function doesn't return an instance of a managed type, but a [`Ref`] to a managed -//! type to indicate the data has not been rooted. +//! As you might already know Julia has a garbage collector (GC). Whenever new data, like an +//! `Array` or a `String` is created, the GC is responsible for freeing that data when it has +//! become unreachable. While Julia is aware of references to data existing in Julia code, it is +//! unaware of references existing outside of Julia code. +//! +//! To make Julia aware of such foreign references we'll need to tell it they exist and that the +//! GC needs to leave that data alone. This is called rooting. While a reference is rooted, the GC +//! won't free its data. Any Julia data referenced by rooted data is also safe from being freed. +//! +//! Before data can be rooted a scope has to be created. Functions that call into Julia can +//! only be called from a scope. When the sync runtime is used, a new scope can be created by +//! calling [`Julia::scope`]. This function takes a closure which contains the code called inside +//! that scope. +//! +//! This closure takes a single argument, a [`GcFrame`], which lets you root data. Methods +//! in jlrs that return Julia data can be called with a mutable reference to a `GcFrame`. The +//! returned data is guaranteed to be rooted until you leave the scope that provided it: +//! +//! ``` +//! # use jlrs::prelude::*; +//! # fn main() { +//! # let mut julia = unsafe { RuntimeBuilder::new().start().unwrap() }; +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! julia +//! .scope(|mut frame| { +//! // This data is guaranteed to live at least until we leave this scope +//! let i = Value::new(&mut frame, 1u64); +//! Ok(()) +//! }) +//! .unwrap(); +//! # } +//! ``` +//! +//! If you tried to return `i` from the scope in the example above, the code would fail to +//! compile. A `GcFrame` has a lifetime that outlives the closure but doesn't outlive the scope. +//! This lifetime is propageted to types like `Value` to prevent the data from being used after it +//! has become unrooted. +//! +//! A `GcFrame` can also be used to create a temporary subscope: +//! +//! ``` +//! # use jlrs::prelude::*; +//! # fn main() { +//! # let mut julia = unsafe { RuntimeBuilder::new().start().unwrap() }; +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! julia +//! .scope(|mut frame| { +//! let i = Value::new(&mut frame, 1u64); +//! +//! frame +//! .scope(|mut frame| { +//! let j = Value::new(&mut frame, 2u64); +//! // j can't be returned from this scope, but i can. +//! Ok(i) +//! }) +//! .unwrap(); +//! +//! Ok(()) +//! }) +//! .unwrap(); +//! # } +//! ``` +//! +//! As you can see in that example, `i` can be returned from the subscope because `i` is +//! guaranteed to outlive it, while `j` can't because it doesn't. In many cases, though, we want +//! to create a subscope and return data created in that scope. In that case, we'll need to +//! allocate an [`Output`] in the targeted scope: +//! +//! ``` +//! # use jlrs::prelude::*; +//! # fn main() { +//! # let mut julia = unsafe { RuntimeBuilder::new().start().unwrap() }; +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! julia +//! .scope(|mut frame| { +//! let output = frame.output(); +//! +//! frame +//! .scope(|_| { +//! let j = Value::new(output, 2u64); +//! Ok(j) +//! }) +//! .unwrap(); +//! +//! Ok(()) +//! }) +//! .unwrap(); +//! # } +//! ``` +//! +//! This works because an `Output` roots data in the `GcFrame` that was used to create it, and +//! the lifetime of that frame is propageted to the result. We can also see that `Value::new` +//! can't just take a mutable reference to a `GcFrame`, but also other types. These types are +//! called targets. +//! +//! All targets implement the [`Target`] trait. Each target has a lifetime that enforces the +//! result can't outlive the scope that roots it. In addition to rooting targets like +//! `&mut GcFrame` and `Output` that we've already seen, there also exist non-rooting target. +//! Non-rooting targets exist because it isn't always necessary to root data: we might be able to +//! guarantee it's already rooted or reachable and avoid creating another root, or never use the +//! data at all. +//! +//! Rooting targets can be used as a non-rooting target by using a reference to the target. +//! Rooting and non-rooting targets return different types when they're used: `Value::new` +//! returns a [`Value`] when a rooting target is used, but a [`ValueRef`] when a non-rooting one +//! is used instead. Every type that represents managed Julia data has a rooted and an unrooted +//! variant, which are named similarly to `Value` and `ValueRef`. There are two type aliases for +//! each managed type that can be used as the return type of functions that take a target +//! generically. For `Value` they are [`ValueData`] and [`ValueResult`]. `ValueData` is a `Value` +//! if a rooting target is used and a `ValueRef` otherwise. `ValueResult` is a `Result` that +//! contains `ValueData` in both its `Ok` and `Err` variants, if an `Err` is returned the +//! operation failed and an exception was caught. +//! +//! Functions that take a `Target` and return Julia data have signatures like this: +//! +//! ``` +//! # use jlrs::prelude::*; +//! fn takes_target<'target, Tgt>(target: Tgt) -> ValueData<'target, 'static, Tgt> +//! where +//! Tgt: Target<'target>, +//! { +//! # todo!() +//! } +//! ``` +//! +//! Because that funtion takes a `Target` rather than a `GcFrame` it's not possible to create a +//! subscope. This prevents us creating and rooting temporary data. There are two ways to deal +//! with this problem: a target can be extended, or a local scope can be created. A target can +//! also be extended by calling [`Target::into_extended_target`]. This method bundles the target +//! with the current frame into an [`ExtendedTarget`] which can be split later: +//! +//! ``` +//! # use jlrs::{prelude::*, memory::target::ExtendedTarget}; +//! fn takes_extended_target<'target, Tgt>( +//! target: ExtendedTarget<'target, '_, '_, Tgt>, +//! ) -> JlrsResult> +//! where +//! Tgt: Target<'target>, +//! { +//! let (target, frame) = target.split(); +//! frame.scope(|mut frame| { +//! # todo!() +//! }) +//! } +//! ``` +//! +//! Local scopes are similar to the scopes we've seen so far. The main difference is that the +//! closure takes a [`LocalGcFrame`], which is essentially a statically-sized, stack-allocated +//! `GcFrame`. Unlike a `GcFrame`, which can grow to the appropriate size, a `LocalGcFrame` can +//! only store as many roots as its size allows. There are local variants of most targets. It's +//! your responsibility that the `LocalGcFrame` is created with the correct size, trying to create +//! a new root when the frame is full will cause a `panic`, unused slots occupy stack space and +//! slow down the GC. +//! +//! ``` +//! # use jlrs::prelude::*; +//! fn creates_local_scope<'target, Tgt>( +//! target: Tgt, +//! ) -> JlrsResult> +//! where +//! Tgt: Target<'target>, +//! { +//! target.with_local_scope::<_, _, 2>(|target, mut frame| { +//! let i = Value::new(&mut frame, 1usize); +//! let j = Value::new(&mut frame, 2usize); +//! +//! // this would panic, the frame has capacity for two roots. +//! // let k = Value::new(&mut frame, 3usize); +//! +//! let k = Value::new(target, 3usize); +//! Ok(k) +//! }) +//! } +//! ``` +//! +//! In general, it's highly advised that you only write function that take target. Each use of +//! `&mut frame` in a closure will take one slot, and all you need to do is count how often +//! `&mut frame` is used to find the required size of the `LocalGcFrame`. //! //! [`Julia::scope`]: crate::runtime::sync_rt::Julia::scope //! [`GcFrame`]: crate::memory::target::frame::GcFrame +//! [`LocalGcFrame`]: crate::memory::target::frame::LocalGcFrame //! [`Output`]: crate::memory::target::output::Output //! [`GcFrame::scope`]: crate::memory::target::frame::GcFrame::scope //! [`GcFrame::output`]: crate::memory::target::frame::GcFrame::output //! [`Target`]: crate::memory::target::Target -//! [`Ref`]: crate::data::managed::Ref +//! [`Target::into_extended_target`]: crate::memory::target::Target::into_extended_target +//! [`Value`]: crate::data::managed::value::Value +//! [`ValueRef`]: crate::data::managed::value::ValueRef +//! [`ValueData`]: crate::data::managed::value::ValueData +//! [`ValueResult`]: crate::data::managed::value::ValueResult //! [`Managed`]: crate::data::managed::Managed +//! [`ExtendedTarget`]: crate::memory::target::ExtendedTarget pub(crate) mod context; pub mod gc; @@ -70,23 +208,24 @@ use jl_sys::jl_ptls_t; use jl_sys::jl_tls_states_t; use jlrs_macros::julia_version; +#[doc(hidden)] #[julia_version(since = "1.8")] pub type PTls = jl_ptls_t; +#[doc(hidden)] #[julia_version(until = "1.7")] pub type PTls = *mut jl_tls_states_t; #[julia_version(until = "1.6")] +#[inline] pub(crate) unsafe fn get_tls() -> PTls { - use jl_sys::jl_get_ptls_states; - jl_get_ptls_states() + jl_sys::jl_get_ptls_states() } #[julia_version(since = "1.7")] +#[inline] pub(crate) unsafe fn get_tls() -> PTls { use std::ptr::NonNull; - - use jl_sys::jl_get_current_task; - let task = jl_get_current_task(); - NonNull::new(task).unwrap().as_ref().ptls + let task = jl_sys::jl_get_current_task(); + NonNull::new_unchecked(task).as_ref().ptls } diff --git a/jlrs/src/memory/stack_frame.rs b/jlrs/src/memory/stack_frame.rs index d6b2f8e4..f063e499 100644 --- a/jlrs/src/memory/stack_frame.rs +++ b/jlrs/src/memory/stack_frame.rs @@ -1,4 +1,4 @@ -//! A raw, stack-allocated GC frame. +//! Raw, inactive GC frame. use std::{ cell::Cell, @@ -19,13 +19,14 @@ use crate::{ const ROOT: Cell<*mut c_void> = Cell::new(null_mut()); -/// A raw, stack-allocated GC frame. +/// A raw, inactive GC frame. /// /// When the [sync runtime] or [`CCall`] is used a `StackFrame` must be provided so the GC can -/// find all references to Julia data that exist in Rust code. +/// find all data rooted in active [`GcFrame`]s. /// /// [sync runtime]: crate::runtime::sync_rt::Julia /// [`CCall`]: crate::ccall::CCall +/// [`GcFrame`]: crate::memory::target::frame::GcFrame #[repr(C)] pub struct StackFrame { len: *mut c_void, @@ -36,12 +37,14 @@ pub struct StackFrame { impl StackFrame<0> { /// Returns a new `StackFrame`. + #[inline] pub fn new() -> Self { Self::new_n() } } impl StackFrame { + #[inline] pub(crate) fn new_n() -> Self { StackFrame { len: ((N + 1) << 2) as *mut c_void, @@ -53,6 +56,7 @@ impl StackFrame { // Safety: Must only be called once, if a new frame is pushed it must be popped before // this one is. + #[inline] pub(crate) unsafe fn pin<'scope>(&'scope mut self) -> PinnedFrame<'scope, N> { PinnedFrame::new(self) } @@ -64,13 +68,17 @@ pub(crate) struct PinnedFrame<'scope, const N: usize> { impl<'scope, const N: usize> PinnedFrame<'scope, N> { #[julia_version(until = "1.6")] + #[inline] unsafe fn new(raw: &'scope mut StackFrame) -> Self { let ptls = jl_sys::jl_get_ptls_states(); - let mut pgcstack = NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)); - let gcstack_ref: &mut *mut c_void = pgcstack.as_mut(); + let pgcstack = NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)); + let gcstack_ref: &mut *mut c_void = pgcstack.cast().as_mut(); #[cfg(feature = "mem-debug")] - eprintln!("Push raw frame: {:p} -> {:p}", gcstack_ref, raw); + eprintln!( + "Push raw frame: {:p} -> {:p}", + *gcstack_ref as *const _, raw + ); raw.prev = *gcstack_ref; *gcstack_ref = raw as *mut _ as *mut _; @@ -78,6 +86,7 @@ impl<'scope, const N: usize> PinnedFrame<'scope, N> { } #[julia_version(since = "1.7")] + #[inline] unsafe fn new(raw: &'scope mut StackFrame) -> Self { let task = NonNull::new_unchecked(jl_get_current_task().cast::()).as_mut(); raw.prev = task.gcstack.cast(); @@ -89,16 +98,19 @@ impl<'scope, const N: usize> PinnedFrame<'scope, N> { PinnedFrame { raw: Pin::new(raw) } } + #[inline] pub(crate) unsafe fn stack_frame<'inner>( &'inner mut self, ) -> JlrsStackFrame<'scope, 'inner, N> { JlrsStackFrame::new(self) } + #[inline] pub(crate) unsafe fn set_sync_root(&self, root: *mut c_void) { self.raw.sync.set(root); } + #[inline] pub(crate) unsafe fn clear_roots(&self) { self.raw.sync.set(null_mut()); for r in self.raw.roots.as_ref() { @@ -112,8 +124,8 @@ impl<'scope, const N: usize> Drop for PinnedFrame<'scope, N> { fn drop(&mut self) { unsafe { let ptls = jl_sys::jl_get_ptls_states(); - let mut pgcstack = NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)); - let gcstack_ref: &mut *mut c_void = pgcstack.as_mut(); + let pgcstack = NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)); + let gcstack_ref: &mut *mut c_void = pgcstack.cast().as_mut(); #[cfg(feature = "mem-debug")] eprintln!("Pop raw frame: {:p} -> {:p}", gcstack_ref, self.raw.prev); @@ -141,6 +153,7 @@ pub(crate) struct JlrsStackFrame<'scope, 'inner, const N: usize> { } impl<'scope, 'inner, const N: usize> JlrsStackFrame<'scope, 'inner, N> { + #[inline] unsafe fn new(pinned: &'inner mut PinnedFrame<'scope, N>) -> Self { if !Self::is_init(&pinned) { { @@ -156,6 +169,7 @@ impl<'scope, 'inner, const N: usize> JlrsStackFrame<'scope, 'inner, N> { JlrsStackFrame { pinned } } + #[inline] pub(crate) unsafe fn sync_stack(&self) -> &'scope Stack { NonNull::new_unchecked(self.pinned.raw.sync.get()) .cast() @@ -163,12 +177,14 @@ impl<'scope, 'inner, const N: usize> JlrsStackFrame<'scope, 'inner, N> { } #[cfg(feature = "async")] + #[inline] pub(crate) unsafe fn nth_stack(&self, n: usize) -> &'scope Stack { NonNull::new_unchecked(self.pinned.raw.roots[n].get()) .cast() .as_ref() } + #[inline] fn is_init(pinned: &PinnedFrame<'_, N>) -> bool { let ptr = pinned.raw.sync.get(); if !ptr.is_null() { diff --git a/jlrs/src/memory/target/frame.rs b/jlrs/src/memory/target/frame.rs index 63da48e1..8339b44a 100644 --- a/jlrs/src/memory/target/frame.rs +++ b/jlrs/src/memory/target/frame.rs @@ -1,33 +1,37 @@ -//! A frame roots data until its scope ends. +//! Dynamically and statically-sized frames. //! -//! Every scope has its own frame which can hold an arbitrary number of roots. When the scope -//! ends these roots are removed from the set of roots, so all data rooted in a frame can safely -//! be used until its scope ends. This hold true even if the frame is dropped before its scope -//! ends. +//! Every scope has its own frame which can hold some number of roots. When the scope ends these +//! roots are removed from the set of roots, so all data rooted in a frame can safely be used +//! until its scope ends. This hold true even if the frame is dropped before its scope ends. //! -//! In addition to being usable as targets, frames can also be used to create [`Output`]s, -//! [`ReusableSlot`]s, [`Unrooted`]s, and child scopes with their own frame. - -use std::{marker::PhantomData, ptr::NonNull}; +//! For more information see the documentation in the [`memory`] and [`target`] modules. +//! +//! [`memory`]: crate::memory +//! [`target`]: crate::memory::target + +use std::{ + cell::Cell, + ffi::c_void, + marker::PhantomData, + pin::Pin, + ptr::{null_mut, NonNull}, +}; use cfg_if::cfg_if; -use super::{output::Output, reusable_slot::ReusableSlot, unrooted::Unrooted}; +use super::{ + output::{LocalOutput, Output}, + reusable_slot::{LocalReusableSlot, ReusableSlot}, + unrooted::Unrooted, + ExtendedTarget, Target, +}; use crate::{ - data::managed::Managed, - error::JlrsResult, - memory::{ - context::stack::Stack, - target::{ExtendedTarget, Target}, - }, - private::Private, + data::managed::Managed, error::JlrsResult, memory::context::stack::Stack, private::Private, }; -/// A frame associated with a scope. -/// -/// Mutable references to a `GcFrame` can be used as a target, in this case the data will be -/// rooted until the frame's scope ends. Other targets can be created through a frame. For -/// example, [`GcFrame::output`] creates a new `Output` that targets the current frame. +const NULL_CELL: Cell<*mut c_void> = Cell::new(null_mut()); + +/// A dynamically-sized frame that can hold an arbitrary number of roots. pub struct GcFrame<'scope> { stack: &'scope Stack, offset: usize, @@ -48,9 +52,6 @@ impl<'scope> GcFrame<'scope> { } /// Borrow the current frame. - /// - /// When a frame is borrowed, no more roots can be pushed until a new scope has been created. - /// This is useful when a function needs to root Julia data but doesn't return Julia data. #[inline] pub fn borrow<'borrow>(&'borrow mut self) -> BorrowedFrame<'borrow, 'scope, Self> { BorrowedFrame(self, PhantomData) @@ -121,9 +122,9 @@ impl<'scope> GcFrame<'scope> { } } - /// Returns a `Unrooted` that targets the current frame. + /// Returns an `Unrooted` that targets the current frame. #[inline] - pub fn unrooted(&self) -> Unrooted<'scope> { + pub const fn unrooted(&self) -> Unrooted<'scope> { unsafe { Unrooted::new() } } @@ -161,7 +162,6 @@ impl<'scope> GcFrame<'scope> { /// # }); /// # } /// ``` - #[inline] pub fn scope(&mut self, func: F) -> JlrsResult where @@ -174,6 +174,7 @@ impl<'scope> GcFrame<'scope> { } // Safety: ptr must be a valid pointer to T + #[inline] pub(crate) unsafe fn root<'data, T: Managed<'scope, 'data>>( &self, ptr: NonNull, @@ -182,10 +183,12 @@ impl<'scope> GcFrame<'scope> { T::wrap_non_null(ptr, Private) } + #[inline] pub(crate) fn stack(&self) -> &Stack { self.stack } + #[inline] pub(crate) fn nest<'nested>(&'nested mut self) -> (GcFrameOwner<'nested>, GcFrame<'nested>) { let owner = GcFrameOwner { stack: self.stack(), @@ -201,6 +204,7 @@ impl<'scope> GcFrame<'scope> { } // Safety: only one base frame can exist per `Stack` + #[inline] pub(crate) unsafe fn base(stack: &'scope Stack) -> (GcFrameOwner<'scope>, GcFrame<'scope>) { debug_assert_eq!(stack.size(), 0); let owner = GcFrameOwner { @@ -217,6 +221,69 @@ impl<'scope> GcFrame<'scope> { } } +/// A statically-sized frame that can hold `N` roots. +pub struct LocalGcFrame<'scope, const N: usize> { + frame: &'scope PinnedLocalFrame<'scope, N>, + offset: usize, +} + +impl<'scope, const N: usize> LocalGcFrame<'scope, N> { + /// Returns a mutable reference to this frame. + #[inline] + pub fn as_mut(&mut self) -> &mut Self { + self + } + + /// Returns the number of values rooted in this frame. + #[inline] + pub fn n_roots(&self) -> usize { + self.offset + } + + /// Returns the number of values that can be rooted in this frame. + #[inline] + pub const fn frame_size(&self) -> usize { + N + } + + /// Returns a `LocalOutput` that targets the current frame. + #[inline] + pub fn local_output(&mut self) -> LocalOutput<'scope> { + let slot = &self.frame.frame.roots[self.offset]; + self.offset += 1; + LocalOutput::new(slot) + } + + /// Returns a `LocalReusableSlot` that targets the current frame. + #[inline] + pub fn local_reusable_slot(&mut self) -> LocalReusableSlot<'scope> { + let slot = &self.frame.frame.roots[self.offset]; + self.offset += 1; + LocalReusableSlot::new(slot) + } + + /// Returns a `Unrooted` that targets the current frame. + #[inline] + pub const fn unrooted(&self) -> Unrooted<'scope> { + unsafe { Unrooted::new() } + } + + #[inline] + pub(crate) unsafe fn new(frame: &'scope PinnedLocalFrame<'scope, N>) -> Self { + LocalGcFrame { frame, offset: 0 } + } + + #[inline] + pub(crate) unsafe fn root<'data, T: Managed<'scope, 'data>>( + &mut self, + ptr: NonNull, + ) -> T { + self.frame.frame.roots[self.offset].set(ptr.as_ptr().cast()); + self.offset += 1; + T::wrap_non_null(ptr, Private) + } +} + cfg_if! { if #[cfg(feature = "async")] { use std::{future::Future, ops::{Deref, DerefMut}}; @@ -277,6 +344,7 @@ cfg_if! { } // Safety: only one base frame can exist per `Stack` + #[inline] pub(crate) unsafe fn base( stack: &'scope Stack, ) -> (GcFrameOwner<'scope>, AsyncGcFrame<'scope>) { @@ -295,6 +363,7 @@ cfg_if! { (owner, frame) } + #[inline] pub(crate) fn nest_async<'nested>( &'nested mut self, ) -> (GcFrameOwner<'nested>, AsyncGcFrame<'nested>) { @@ -311,12 +380,14 @@ cfg_if! { impl<'scope> Deref for AsyncGcFrame<'scope> { type Target = GcFrame<'scope>; + #[inline] fn deref(&self) -> &Self::Target { &self.frame } } impl<'scope> DerefMut for AsyncGcFrame<'scope> { + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { &mut self.frame } @@ -324,41 +395,6 @@ cfg_if! { } } -pub(crate) struct GcFrameOwner<'scope> { - stack: &'scope Stack, - offset: usize, - _marker: PhantomData<&'scope mut &'scope ()>, -} - -impl<'scope> GcFrameOwner<'scope> { - #[cfg(feature = "ccall")] - pub(crate) fn restore(&self) -> GcFrame<'scope> { - GcFrame { - stack: self.stack, - offset: self.stack.size(), - _marker: PhantomData, - } - } - - #[cfg(feature = "async")] - pub(crate) unsafe fn reconstruct(&self, offset: usize) -> AsyncGcFrame<'scope> { - self.stack.pop_roots(offset); - AsyncGcFrame { - frame: GcFrame { - stack: self.stack, - offset, - _marker: PhantomData, - }, - } - } -} - -impl Drop for GcFrameOwner<'_> { - fn drop(&mut self) { - unsafe { self.stack.pop_roots(self.offset) } - } -} - /// A frame that has been borrowed. A new scope must be created before it can be used as a target /// again. // TODO privacy @@ -416,3 +452,97 @@ impl<'borrow, 'current> BorrowedFrame<'borrow, 'current, AsyncGcFrame<'current>> self.0.relaxed_async_scope(func).await } } + +pub(crate) struct GcFrameOwner<'scope> { + stack: &'scope Stack, + offset: usize, + _marker: PhantomData<&'scope mut &'scope ()>, +} + +impl<'scope> GcFrameOwner<'scope> { + #[cfg(feature = "async")] + #[inline] + pub(crate) unsafe fn reconstruct(&self, offset: usize) -> AsyncGcFrame<'scope> { + self.stack.pop_roots(offset); + AsyncGcFrame { + frame: GcFrame { + stack: self.stack, + offset, + _marker: PhantomData, + }, + } + } +} + +impl Drop for GcFrameOwner<'_> { + fn drop(&mut self) { + unsafe { self.stack.pop_roots(self.offset) } + } +} + +#[repr(C)] +pub(crate) struct LocalFrame { + n_roots: *mut c_void, + prev: *mut c_void, + roots: [Cell<*mut c_void>; N], +} + +impl LocalFrame { + #[inline] + pub const fn new() -> Self { + LocalFrame { + n_roots: (N << 2) as *mut c_void, + prev: null_mut(), + roots: [NULL_CELL; N], + } + } + + #[inline] + pub(crate) unsafe fn pin<'scope>( + &'scope mut self, + pgcstack: NonNull<*mut jl_sys::jl_gcframe_t>, + ) -> PinnedLocalFrame<'scope, N> { + PinnedLocalFrame::new(self, pgcstack) + } +} + +pub(crate) struct PinnedLocalFrame<'scope, const N: usize> { + frame: Pin<&'scope mut LocalFrame>, + _marker: PhantomData<&'scope mut &'scope ()>, +} + +impl<'scope, const N: usize> PinnedLocalFrame<'scope, N> { + #[inline] + unsafe fn new( + frame: &'scope mut LocalFrame, + mut pgcstack: NonNull<*mut jl_sys::jl_gcframe_t>, + ) -> Self { + let gcstack_ref = pgcstack.as_mut(); + frame.prev = gcstack_ref.cast(); + + #[cfg(feature = "mem-debug")] + eprintln!( + "Push local frame: {:p} -> {:p}", + gcstack_ref, frame as *const _ + ); + + *gcstack_ref = frame as *mut _ as *mut _; + + PinnedLocalFrame { + frame: Pin::new(frame), + _marker: PhantomData, + } + } + + #[inline] + pub(crate) unsafe fn pop(&self, mut pgcstack: NonNull<*mut jl_sys::jl_gcframe_t>) { + let gcstack_ref = pgcstack.as_mut(); + #[cfg(feature = "mem-debug")] + eprintln!( + "Pop local frame: {:p} -> {:p}", + *gcstack_ref, self.frame.prev + ); + + *gcstack_ref = self.frame.prev.cast(); + } +} diff --git a/jlrs/src/memory/target/mod.rs b/jlrs/src/memory/target/mod.rs index e8d474d5..66421716 100644 --- a/jlrs/src/memory/target/mod.rs +++ b/jlrs/src/memory/target/mod.rs @@ -1,85 +1,198 @@ -//! Targets for methods that return Julia data. +//! Frames, outputs and other targets. //! -//! Many methods in jlrs return Julia data, these methods use targets to ensure the returned data -//! has the correct type and appropriate lifetimes. +//! As explained in the [`memory`] module, functions that return Julia data take a target. All +//! targets implement the [`Target`] trait, this trait has a lifetime which encodes how long the +//! data created with this target can be used. //! -//! Targets implement the [`Target`] trait. This trait is used in combination with methods that -//! return `Data`, an `Exception` or a `Result`. `Data` is simply some Julia data, `Exception` -//! is a result that can contain Julia data in its `Err` variant, and `Result` is a `Result` that -//! contains Julia data in both its `Ok` and `Err` variants. +//! There are two different kinds of target, rooting and non-rooting targets. A rooting target +//! guarantees the returned data is rooted while it can can be used, a non-rooting target doesn't +//! root the returned data at all. jlrs distinguishes between data that has been explicitly rooted +//! or not at the type level: rooted data is represented by types that implement the [`Managed`] +//! trait, while non-rooted data is represented as a [`Ref`]. //! -//! If an `Err` is returned it contains a caught exception. An `Exception` is used in -//! combination with methods that can throw an exception, but typically don't return Julia data -//! on success. If an `Exception` does contain Julia data on success, the data is guaranteed to be -//! globally rooted. +//! All targets define whether they are rooting or non-rooting targets by implementing +//! [`TargetType`]. This trait has a generic associated type: [`TargetType::Data`]. This type +//! is a [`Managed`] type if the target is a rooting target, and a [`Ref`] if it's non-rooting. +//! There are also the [`TargetResult`] and [`TargetException`] type aliases, which are `Result`s +//! that contain [`TargetType::Data`] in at least on of their variants. //! -//! Targets don't guarantee the returned data is rooted, this depends on what target has been -//! used. The following targets currently exist, the `'scope` lifetime indicates the lifetime of -//! the returned data: +//! `Target::Data` is returned by functions that don't catch any exceptions. An example of such a +//! function is [`Value::new`], if you call that function with a rooting target it returns a +//! [`Value`], otherwise it returns a [`ValueRef`]. //! -//! | Type | Rooting | -//! |-------------------------------|---------| -//! | `(Async)GcFrame<'scope>` | Yes | -//! | `&mut (Async)GcFrame<'scope>` | Yes | -//! | `Output<'scope>` | Yes | -//! | `&'scope mut Output<'_>` | Yes | -//! | `ReusableSlot<'scope>` | Yes | -//! | `&mut ReusableSlot<'scope>` | Yes | -//! | `Unrooted<'scope>` | No | -//! | `&>` | No | +//! `TargetResult` is used when exceptions are caught. An example is calling Julia functions +//! with the methods of the [`Call`] trait. These methods return a `Result`, the `Ok` variant +//! contains the same type as `Target::Data`, the `Err` variant is a `Value` or `ValueRef` +//! depending on the target. //! +//! `TargetException` is used when exceptions are caught but the function doesn't need to return +//! Julia data on success. This is used by [`Array::grow_end`] which calls a function from the C +//! API that can throw, but doesn't return anything if it returns successfully. Like +//! `TargetResult` it's a `Result`, but can contain arbitrary data in its `Ok` variant. //! -//! The last row means that any target `T` can be used as a non-rooting target by using a -//! reference to that target. When a non-rooting target is used, Julia data is returned as a -//! [`Ref`] rather than a [`Managed`]. This is useful in cases where it can be guaranteed the -//! data is globally rooted, or if you don't care about the result. More information about these -//! target types can be found in the submodules that define them. +//! All managed types provide type aliases for `Target::Data` and `TargetResult`, their names +//! are simply the name of the type itself and `Data` or `Result`. For example, `Value` provides +//! the aliases [`ValueData`] and [`ValueResult`]. It's generally significantly less verbose to +//! use these type aliases than expressing the return type with the associated type of the target, +//! and doing so clarifies what type of data is returned and whether you might need to handle a +//! caught exception or not. //! -//! Some targets can only be used to root a single value, methods that need to allocate temporary -//! data should use extended targets. An extended target can be split into a `BorrowedFrame` and -//! a target, the `BorrowedFrame` can be used to create a temporary scope and the target for the -//! data that is returned. +//! Rooting targets can be divided into three categories: frames, outputs, and reusable slots. +//! Frames form the backbone, they can have multiple slots that can hold one root; outputs and +//! reusable slots reserve a slot in a frame and target that slot. Every time a new scope is +//! created, it's provided with a new frame. Any data rooted in that frame remains rooted until +//! leaving the scope. +//! +//! There exist three kinds of scope: dynamic, local and async scopes. Dynamic scopes provide a +//! [`GcFrame`] which can grow to the necessary size, local scopes provide a statically-sized +//! [`LocalGcFrame`], and async scopes provide an [`AsyncGcFrame`] which is dynamically-sized like +//! a `GcFrame`. New dynamic scopes can only be created using a `GcFrame` or `AsyncGcFrame`, new +//! local scopes can be created using any target, and async scopes can only be created using an +//! `AsyncGcFrame`. +//! +//! A `GcFrame` lets you create [`Output`]s and [`ReusableSlot`]s which are very similar. Both +//! target a reserved slot in that frame, they can be reused and consumed. When they're taken by +//! value they're consumed, and both types return data that will remain rooted until you leave +//! the scope of the frame that roots them. They can also be taken by mutable reference, and here +//! they act differently. When a mutable reference to an output is used as a target, it returns +//! rooted data that inherits the lifetime of the reference. A reusable slot though returns data +//! that inherits the lifetime of the slot, to account for the fact that this data can become +//! unrooted while it is usable the data is returned as a `Ref` as if this target were an +//! unrooting target instead. +//! +//! A `LocalGcFrame` lets you create [`LocalOutput`]s and [`LocalReusableSlot`]s which behave +//! the same as their dynamic counterpart. The only difference is that these targets target a +//! local frame. +//! +//! There are effectively an infinite number of unrooting targets. Every rooting target can serve +//! as an unrooting target by providing an immutable reference. Sometimes this can lead to some +//! borrowing issues, for this purpose the `Unrooted` target exists which can be created by +//! calling [`Target::unrooted`]. +//! +//! A full overview of all targets is provided below: +//! +//! | Type | Rooting | Local | Async | +//! |-------------------------------------|-----------|-------|-------| +//! | `GcFrame<'scope>` | Yes | No | No | +//! | `&mut GcFrame<'scope>` | Yes | No | No | +//! | `LocalGcFrame<'scope>` | Yes | Yes | No | +//! | `&mut LocalGcFrame<'scope>` | Yes | Yes | No | +//! | `AsyncGcFrame<'scope>` | Yes | No | Yes | +//! | `&mut AsyncGcFrame<'scope>` | Yes | No | Yes | +//! | `Output<'scope>` | Yes | No | No | +//! | `&'scope mut Output<'_>` | Yes | No | No | +//! | `LocalOutput<'scope>` | Yes | Yes | No | +//! | `&'scope mut LocalOutput<'_>` | Yes | Yes | No | +//! | `ReusableSlot<'scope>` | Yes | No | No | +//! | `&'scope mut ReusableSlot<'_>` | Partially | No | No | +//! | `LocalReusableSlot<'scope>` | Yes | Yes | No | +//! | `&'scope mut LocalReusableSlot<'_>` | Partially | Yes | No | +//! | `Unrooted<'scope>` | No | No | No | +//! | `&Target<'scope>` | No | No | No | //! //! [`Ref`]: crate::data::managed::Ref //! [`Managed`]: crate::data::managed::Managed +//! [`memory`]: crate::memory +//! [`Call`]: crate::call::Call +//! [`Array::grow_end`]: crate::data::managed::array::Array::grow_end +//! [`Value`]: crate::data::managed::value::Value +//! [`Value::new`]: crate::data::managed::value::Value::new +//! [`ValueRef`]: crate::data::managed::value::ValueRef +//! [`ValueData`]: crate::data::managed::value::ValueData +//! [`ValueResult`]: crate::data::managed::value::ValueResult -use std::marker::PhantomData; +use std::{marker::PhantomData, ptr::NonNull}; #[cfg(feature = "async")] use self::frame::AsyncGcFrame; use self::{ - frame::{BorrowedFrame, GcFrame}, - output::Output, + frame::{BorrowedFrame, GcFrame, LocalFrame, LocalGcFrame}, + output::{LocalOutput, Output}, private::TargetPriv, - reusable_slot::ReusableSlot, + reusable_slot::{LocalReusableSlot, ReusableSlot}, unrooted::Unrooted, }; +use crate::{ + data::managed::Ref, + prelude::{JlrsResult, Managed, ValueData}, +}; pub mod frame; pub mod output; pub mod reusable_slot; -pub mod target_type; pub mod unrooted; /// Trait implemented by all targets. /// -/// Whenever a function in jlrs returns new Julia data, it will take a target which implements -/// this trait. Every target implements [`TargetType`], which defines the type that is returned. -/// These functions return either `TargetType::Data`, `TargetType::Exception` or -/// `TargetType::Result`, the first is used when exceptions aren't caught, while the second is -/// used when they are caught. -/// -/// For more information see the [module-level] docs +/// For more information see the [module-level] docs. /// /// [module-level]: self -/// [`TargetType`]: crate::memory::target::target_type::TargetType pub trait Target<'target>: TargetPriv<'target> { /// Returns a new `Unrooted`. + #[inline] fn unrooted(&self) -> Unrooted<'target> { unsafe { Unrooted::new() } } - /// Convert `self` to an `ExtendedTarget`. + /// Create a new local scope and call `func`. + /// + /// The `LocalGcFrame` provided to `func` has capacity for `M` roots. + #[inline] + fn local_scope(&self, func: F) -> JlrsResult + where + for<'inner> F: FnOnce(LocalGcFrame<'inner, M>) -> JlrsResult, + { + unsafe { + let mut local_frame = LocalFrame::new(); + + #[cfg(not(feature = "julia-1-6"))] + let pgcstack = NonNull::new_unchecked(jl_sys::jl_get_pgcstack()); + + #[cfg(feature = "julia-1-6")] + let pgcstack = { + let ptls = jl_sys::jl_get_ptls_states(); + NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)) + }; + + let pinned = local_frame.pin(pgcstack); + + let res = func(LocalGcFrame::new(&pinned)); + + pinned.pop(pgcstack); + res + } + } + + /// Create a new local scope and call `func`. + /// + /// The `LocalGcFrame` provided to `func` has capacity for `M` roots, `self` is propagated to + /// the closure. + #[inline] + fn with_local_scope(self, func: F) -> JlrsResult + where + for<'inner> F: FnOnce(Self, LocalGcFrame<'inner, M>) -> JlrsResult, + { + unsafe { + let mut local_frame = LocalFrame::new(); + #[cfg(not(feature = "julia-1-6"))] + let pgcstack = NonNull::new_unchecked(jl_sys::jl_get_pgcstack()); + + #[cfg(feature = "julia-1-6")] + let pgcstack = { + let ptls = jl_sys::jl_get_ptls_states(); + NonNull::new_unchecked(jl_sys::jlrs_pgcstack(ptls)) + }; + let pinned = local_frame.pin(pgcstack); + + let res = func(self, LocalGcFrame::new(&pinned)); + + pinned.pop(pgcstack); + res + } + } + + /// Convert `self` into an `ExtendedTarget`. + #[inline] fn into_extended_target<'borrow, 'current>( self, frame: &'borrow mut GcFrame<'current>, @@ -91,8 +204,9 @@ pub trait Target<'target>: TargetPriv<'target> { } } - /// Convert `self` to an `ExtendedAsyncTarget`. + /// Convert `self` into an `ExtendedAsyncTarget`. #[cfg(feature = "async")] + #[inline] fn into_extended_async_target<'borrow, 'current>( self, frame: &'borrow mut AsyncGcFrame<'current>, @@ -105,13 +219,7 @@ pub trait Target<'target>: TargetPriv<'target> { } } -/// A trait that indicates that this target roots the returned data. -pub trait RootingTarget<'target>: Target<'target> { - /// Convert this target into an `Output`. - fn into_output(self) -> Output<'target>; -} - -/// A `Target` that borrows a frame for temporary allocations. +/// A `Target` bundled with a [`GcFrame`]. pub struct ExtendedTarget<'target, 'current, 'borrow, T> where T: Target<'target>, @@ -125,14 +233,15 @@ impl<'target, 'current, 'borrow, T> ExtendedTarget<'target, 'current, 'borrow, T where T: Target<'target>, { - /// Split the `ExtendedTarget` into its `Target` and `BorrowedFrame` + /// Split the `ExtendedTarget` into its `Target` and a `BorrowedFrame`. + #[inline] pub fn split(self) -> (T, BorrowedFrame<'borrow, 'current, GcFrame<'current>>) { (self.target, BorrowedFrame(self.frame, PhantomData)) } } #[cfg(feature = "async")] -/// A `Target` that borrows an async frame for temporary allocations. +/// A `Target` bundled with an [`AsyncGcFrame`]. pub struct ExtendedAsyncTarget<'target, 'current, 'borrow, T> where T: Target<'target>, @@ -147,71 +256,125 @@ impl<'target, 'current, 'borrow, T> ExtendedAsyncTarget<'target, 'current, 'borr where T: Target<'target>, { - /// Split the `ExtendedAsyncTarget` into its `Target` and `BorrowedFrame` + /// Split the `ExtendedTarget` into its `Target` and a `BorrowedFrame`. + #[inline] pub fn split(self) -> (T, BorrowedFrame<'borrow, 'current, AsyncGcFrame<'current>>) { (self.target, BorrowedFrame(self.frame, PhantomData)) } } impl<'target> Target<'target> for GcFrame<'target> {} -impl<'target> RootingTarget<'target> for GcFrame<'target> { - fn into_output(self) -> Output<'target> { - self.output() - } -} + +impl<'target, const N: usize> Target<'target> for LocalGcFrame<'target, N> {} impl<'target> Target<'target> for &mut GcFrame<'target> {} -impl<'target> RootingTarget<'target> for &mut GcFrame<'target> { - fn into_output(self) -> Output<'target> { - self.output() - } -} + +impl<'target, const N: usize> Target<'target> for &mut LocalGcFrame<'target, N> {} #[cfg(feature = "async")] impl<'target> Target<'target> for AsyncGcFrame<'target> {} -#[cfg(feature = "async")] -impl<'target> RootingTarget<'target> for AsyncGcFrame<'target> { - fn into_output(self) -> Output<'target> { - self.output() - } -} #[cfg(feature = "async")] impl<'target> Target<'target> for &mut AsyncGcFrame<'target> {} -#[cfg(feature = "async")] -impl<'target> RootingTarget<'target> for &mut AsyncGcFrame<'target> { - fn into_output(self) -> Output<'target> { - self.output() - } -} impl<'target> Target<'target> for Unrooted<'target> {} impl<'target> Target<'target> for Output<'target> {} -impl<'target> RootingTarget<'target> for Output<'target> { - fn into_output(self) -> Output<'target> { - self - } -} + +impl<'target> Target<'target> for LocalOutput<'target> {} impl<'target> Target<'target> for &'target mut Output<'_> {} -impl<'target> RootingTarget<'target> for &'target mut Output<'_> { - fn into_output(self) -> Output<'target> { - self.restrict() - } -} + +impl<'target> Target<'target> for &'target mut LocalOutput<'_> {} impl<'target> Target<'target> for ReusableSlot<'target> {} -impl<'target> RootingTarget<'target> for ReusableSlot<'target> { - fn into_output(self) -> Output<'target> { - self.into_output() - } -} + +impl<'target> Target<'target> for &mut LocalReusableSlot<'target> {} impl<'target> Target<'target> for &mut ReusableSlot<'target> {} impl<'target, 'data, T> Target<'target> for &T where T: Target<'target> {} +/// Defines the return types of a target, `Data`, `Exception`, and `Result`. +pub trait TargetType<'target>: Sized { + /// Type returned by functions that don't catch Julia exceptions. + /// + /// For rooting targets, this type is `T`. + /// For non-rooting targets, this type is [`Ref<'target, 'data, T>`]. + type Data<'data, T: Managed<'target, 'data>>; +} + +pub type TargetResult<'scope, 'data, T, Tgt> = + Result<>::Data<'data, T>, ValueData<'scope, 'data, Tgt>>; + +pub type TargetException<'scope, 'data, T, Tgt> = Result>; + +impl<'target> TargetType<'target> for &mut GcFrame<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target, const N: usize> TargetType<'target> for &mut LocalGcFrame<'target, N> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for GcFrame<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target, const N: usize> TargetType<'target> for LocalGcFrame<'target, N> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +#[cfg(feature = "async")] +impl<'target> TargetType<'target> for &mut AsyncGcFrame<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +#[cfg(feature = "async")] +impl<'target> TargetType<'target> for AsyncGcFrame<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for Output<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for LocalOutput<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for &'target mut Output<'_> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for &'target mut LocalOutput<'_> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for ReusableSlot<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for LocalReusableSlot<'target> { + type Data<'data, T: Managed<'target, 'data>> = T; +} + +impl<'target> TargetType<'target> for &mut ReusableSlot<'target> { + type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; +} + +impl<'target> TargetType<'target> for &mut LocalReusableSlot<'target> { + type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; +} + +impl<'target> TargetType<'target> for Unrooted<'target> { + type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; +} + +impl<'target, U: TargetType<'target>> TargetType<'target> for &U { + type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; +} + pub(crate) mod private { use std::ptr::NonNull; @@ -220,7 +383,11 @@ pub(crate) mod private { #[cfg(feature = "async")] use super::AsyncGcFrame; use super::{ - reusable_slot::ReusableSlot, target_type::TargetType, unrooted::Unrooted, GcFrame, Output, + frame::LocalGcFrame, + output::LocalOutput, + reusable_slot::{LocalReusableSlot, ReusableSlot}, + unrooted::Unrooted, + GcFrame, Output, TargetException, TargetResult, TargetType, }; use crate::{ data::managed::{ @@ -235,8 +402,12 @@ pub(crate) mod private { impl<'target> TargetBase<'target> for &mut GcFrame<'target> {} + impl<'target, const N: usize> TargetBase<'target> for &mut LocalGcFrame<'target, N> {} + impl<'target> TargetBase<'target> for GcFrame<'target> {} + impl<'target, const N: usize> TargetBase<'target> for LocalGcFrame<'target, N> {} + #[cfg(feature = "async")] impl<'target> TargetBase<'target> for &mut AsyncGcFrame<'target> {} @@ -245,12 +416,20 @@ pub(crate) mod private { impl<'target> TargetBase<'target> for Output<'target> {} + impl<'target> TargetBase<'target> for LocalOutput<'target> {} + impl<'target> TargetBase<'target> for &'target mut Output<'_> {} + impl<'target> TargetBase<'target> for &'target mut LocalOutput<'_> {} + impl<'target> TargetBase<'target> for ReusableSlot<'target> {} + impl<'target> TargetBase<'target> for LocalReusableSlot<'target> {} + impl<'target> TargetBase<'target> for &mut ReusableSlot<'target> {} + impl<'target> TargetBase<'target> for &mut LocalReusableSlot<'target> {} + impl<'target> TargetBase<'target> for Unrooted<'target> {} impl<'target, T: TargetBase<'target>> TargetBase<'target> for &T {} @@ -268,14 +447,15 @@ pub(crate) mod private { self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T>; + ) -> TargetResult<'target, 'data, T, Self>; // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_unrooted<'data, T: Managed<'target, 'data>>( self, result: Result, ValueRef<'target, 'data>>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { let result = match result { Ok(v) => Ok(v.ptr()), Err(e) => Err(e.ptr()), @@ -285,11 +465,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_rooted<'data, T: Managed<'target, 'data>>( self, result: Result>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { let result = match result { Ok(v) => Ok(v.unwrap_non_null(Private)), Err(e) => Err(e.unwrap_non_null(Private)), @@ -303,11 +484,12 @@ pub(crate) mod private { self, result: Result>, _: Private, - ) -> Self::Exception<'data, T>; + ) -> TargetException<'target, 'data, T, Self>; } impl<'target> TargetPriv<'target> for &mut GcFrame<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -317,11 +499,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.root(t)), Err(e) => Err(self.root(e)), @@ -329,11 +512,50 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(t), + Err(e) => Err(self.root(e)), + } + } + } + + impl<'target, const N: usize> TargetPriv<'target> for &mut LocalGcFrame<'target, N> { + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( + self, + value: NonNull, + _: Private, + ) -> Self::Data<'data, T> { + self.root(value) + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( + self, + result: Result, NonNull>, + _: Private, + ) -> TargetResult<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(self.root(t)), + Err(e) => Err(self.root(e)), + } + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn exception_from_ptr<'data, T>( + self, + result: Result>, + _: Private, + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.root(e)), @@ -343,6 +565,7 @@ pub(crate) mod private { impl<'target> TargetPriv<'target> for GcFrame<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -352,11 +575,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.root(t)), Err(e) => Err(self.root(e)), @@ -364,11 +588,50 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(t), + Err(e) => Err(self.root(e)), + } + } + } + + impl<'target, const N: usize> TargetPriv<'target> for LocalGcFrame<'target, N> { + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( + mut self, + value: NonNull, + _: Private, + ) -> Self::Data<'data, T> { + self.root(value) + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( + mut self, + result: Result, NonNull>, + _: Private, + ) -> TargetResult<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(self.root(t)), + Err(e) => Err(self.root(e)), + } + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn exception_from_ptr<'data, T>( + mut self, + result: Result>, + _: Private, + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.root(e)), @@ -379,6 +642,7 @@ pub(crate) mod private { #[cfg(feature = "async")] impl<'target> TargetPriv<'target> for &mut AsyncGcFrame<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -388,11 +652,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.root(t)), Err(e) => Err(self.root(e)), @@ -400,11 +665,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.root(e)), @@ -415,6 +681,7 @@ pub(crate) mod private { #[cfg(feature = "async")] impl<'target> TargetPriv<'target> for AsyncGcFrame<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -424,11 +691,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.root(t)), Err(e) => Err(self.root(e)), @@ -436,11 +704,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.root(e)), @@ -450,6 +719,7 @@ pub(crate) mod private { impl<'target> TargetPriv<'target> for Output<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -459,11 +729,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.consume(t)), Err(e) => Err(self.consume(e)), @@ -471,11 +742,50 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(t), + Err(e) => Err(self.consume(e)), + } + } + } + + impl<'target> TargetPriv<'target> for LocalOutput<'target> { + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( + self, + value: NonNull, + _: Private, + ) -> Self::Data<'data, T> { + self.consume(value) + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( + self, + result: Result, NonNull>, + _: Private, + ) -> TargetResult<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(self.consume(t)), + Err(e) => Err(self.consume(e)), + } + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn exception_from_ptr<'data, T>( + self, + result: Result>, + _: Private, + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.consume(e)), @@ -485,6 +795,45 @@ pub(crate) mod private { impl<'target> TargetPriv<'target> for &'target mut Output<'_> { // Safety: the pointer must point to valid data. + #[inline] + unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( + self, + value: NonNull, + _: Private, + ) -> Self::Data<'data, T> { + self.temporary(value) + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( + self, + result: Result, NonNull>, + _: Private, + ) -> TargetResult<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(self.temporary(t)), + Err(e) => Err(self.temporary(e)), + } + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn exception_from_ptr<'data, T>( + self, + result: Result>, + _: Private, + ) -> TargetException<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(t), + Err(e) => Err(self.temporary(e)), + } + } + } + + impl<'target> TargetPriv<'target> for &'target mut LocalOutput<'_> { + // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -494,11 +843,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.temporary(t)), Err(e) => Err(self.temporary(e)), @@ -506,11 +856,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.temporary(e)), @@ -520,6 +871,7 @@ pub(crate) mod private { impl<'target> TargetPriv<'target> for ReusableSlot<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -529,11 +881,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.consume(t)), Err(e) => Err(self.consume(e)), @@ -541,11 +894,50 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(t), + Err(e) => Err(self.consume(e)), + } + } + } + + impl<'target> TargetPriv<'target> for LocalReusableSlot<'target> { + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( + self, + value: NonNull, + _: Private, + ) -> Self::Data<'data, T> { + self.consume(value) + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( + self, + result: Result, NonNull>, + _: Private, + ) -> TargetResult<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(self.consume(t)), + Err(e) => Err(self.consume(e)), + } + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn exception_from_ptr<'data, T>( + self, + result: Result>, + _: Private, + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.consume(e)), @@ -555,6 +947,45 @@ pub(crate) mod private { impl<'target> TargetPriv<'target> for &mut ReusableSlot<'target> { // Safety: the pointer must point to valid data. + #[inline] + unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( + self, + value: NonNull, + _: Private, + ) -> Self::Data<'data, T> { + self.temporary(value) + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( + self, + result: Result, NonNull>, + _: Private, + ) -> TargetResult<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(self.temporary(t)), + Err(e) => Err(self.temporary(e)), + } + } + + // Safety: the pointer must point to valid data. + #[inline] + unsafe fn exception_from_ptr<'data, T>( + self, + result: Result>, + _: Private, + ) -> TargetException<'target, 'data, T, Self> { + match result { + Ok(t) => Ok(t), + Err(e) => Err(self.temporary(e)), + } + } + } + + impl<'target> TargetPriv<'target> for &mut LocalReusableSlot<'target> { + // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -564,11 +995,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(self.temporary(t)), Err(e) => Err(self.temporary(e)), @@ -576,11 +1008,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(self.temporary(e)), @@ -590,6 +1023,7 @@ pub(crate) mod private { impl<'target> TargetPriv<'target> for Unrooted<'target> { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -599,11 +1033,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(Ref::wrap(t)), Err(e) => Err(Ref::wrap(e)), @@ -611,11 +1046,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(Ref::wrap(e)), @@ -625,6 +1061,7 @@ pub(crate) mod private { impl<'target, U: TargetPriv<'target>> TargetPriv<'target> for &U { // Safety: the pointer must point to valid data. + #[inline] unsafe fn data_from_ptr<'data, T: Managed<'target, 'data>>( self, value: NonNull, @@ -634,11 +1071,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn result_from_ptr<'data, T: Managed<'target, 'data>>( self, result: Result, NonNull>, _: Private, - ) -> Self::Result<'data, T> { + ) -> TargetResult<'target, 'data, T, Self> { match result { Ok(t) => Ok(Ref::wrap(t)), Err(e) => Err(Ref::wrap(e)), @@ -646,11 +1084,12 @@ pub(crate) mod private { } // Safety: the pointer must point to valid data. + #[inline] unsafe fn exception_from_ptr<'data, T>( self, result: Result>, _: Private, - ) -> Self::Exception<'data, T> { + ) -> TargetException<'target, 'data, T, Self> { match result { Ok(t) => Ok(t), Err(e) => Err(Ref::wrap(e)), diff --git a/jlrs/src/memory/target/output.rs b/jlrs/src/memory/target/output.rs index 9bd45372..1fe71d58 100644 --- a/jlrs/src/memory/target/output.rs +++ b/jlrs/src/memory/target/output.rs @@ -1,80 +1,85 @@ -//! A target that uses a reserved slot in a frame. +//! Outputs +//! +//! Outputs target a reserved slot in some frame. There are two variations, [`Output`] and +//! [`LocalOutput`], both behave the same way, they only only target different kinds of frame. +//! +//! When an output is taken by mutable reference it can be reused, the lifetime that is considered +//! the `'target` lifetime is the lifetime of the borrow rather than the lifetime of the `Output`. +//! This guarantees the data can only be used while it's guaranteed to be rooted. +//! +//! Examples: +//! +//! ``` +//! # use jlrs::prelude::*; +//! # use jlrs::util::test::JULIA; +//! # fn main() { +//! # JULIA.with(|j| { +//! # let mut julia = j.borrow_mut(); +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! +//! julia +//! .scope(|mut frame| { +//! let output = frame.output(); +//! +//! let _v = frame.scope(|_| { +//! // The output has been allocated in the parent +//! // scope's frame, so by using it as a target the +//! // result can be returned from this subscope. +//! Ok(Value::new(output, 1u64)) +//! })?; +//! +//! Ok(()) +//! }) +//! .unwrap(); +//! # }); +//! # } +//! ``` +//! +//! ``` +//! # use jlrs::prelude::*; +//! # use jlrs::util::test::JULIA; +//! # fn main() { +//! # JULIA.with(|j| { +//! # let mut julia = j.borrow_mut(); +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! +//! julia +//! .scope(|mut frame| { +//! let mut output = frame.output(); +//! +//! let _v = frame.scope(|_| { +//! // _v1 can be used until the output is used again. +//! let _v1 = Value::new(&mut output, 2u64); +//! +//! Ok(Value::new(output, 1u64)) +//! })?; +//! +//! Ok(()) +//! }) +//! .unwrap(); +//! # }); +//! # } +//! ``` -use std::ptr::NonNull; +use std::{cell::Cell, ffi::c_void, ptr::NonNull}; use crate::{data::managed::Managed, memory::context::stack::Stack, private::Private}; -/// A target that uses a reserved slot in a frame. +/// An output that targets a [`GcFrame`]. /// -/// An `Output` can be allocated with [`GcFrame::output`]. When it's used as a target, the -/// returned data remains rooted until the scope this target belongs to ends. +/// See the [module-level docs] for more information. /// -/// Example: -/// -/// ``` -/// # use jlrs::prelude::*; -/// # use jlrs::util::test::JULIA; -/// # fn main() { -/// # JULIA.with(|j| { -/// # let mut julia = j.borrow_mut(); -/// # let mut frame = StackFrame::new(); -/// # let mut julia = julia.instance(&mut frame); -/// -/// julia -/// .scope(|mut frame| { -/// let output = frame.output(); -/// -/// let _v = frame.scope(|_| { -/// // The output has been allocated in the parent -/// // scope's frame, so by using it as a target the -/// // result can be returned from this child scope. -/// Ok(Value::new(output, 1u64)) -/// })?; -/// -/// Ok(()) -/// }) -/// .unwrap(); -/// # }); -/// # } -/// ``` -/// -/// An output can also be used to temporarily root data by using a mutable reference to an -/// `Output` as a target: -/// -/// ``` -/// # use jlrs::prelude::*; -/// # use jlrs::util::test::JULIA; -/// # fn main() { -/// # JULIA.with(|j| { -/// # let mut julia = j.borrow_mut(); -/// # let mut frame = StackFrame::new(); -/// # let mut julia = julia.instance(&mut frame); -/// -/// julia -/// .scope(|mut frame| { -/// let mut output = frame.output(); -/// -/// let _v = frame.scope(|_| { -/// // _v1 can be used until the output is used again. -/// let _v1 = Value::new(&mut output, 2u64); -/// -/// Ok(Value::new(output, 1u64)) -/// })?; -/// -/// Ok(()) -/// }) -/// .unwrap(); -/// # }); -/// # } -/// ``` -/// -/// [`GcFrame::output`]: crate::memory::target::frame::GcFrame::output +/// [module-level docs]: crate::memory::target::output +/// [`GcFrame`]: crate::memory::target::frame::GcFrame pub struct Output<'target> { pub(crate) stack: &'target Stack, pub(crate) offset: usize, } impl<'scope> Output<'scope> { + #[inline] pub(crate) unsafe fn consume<'data, T: Managed<'scope, 'data>>( self, ptr: NonNull, @@ -83,6 +88,7 @@ impl<'scope> Output<'scope> { T::wrap_non_null(ptr, Private) } + #[inline] pub(crate) unsafe fn temporary<'target, 'data, T: Managed<'target, 'data>>( &'target mut self, ptr: NonNull, @@ -90,11 +96,40 @@ impl<'scope> Output<'scope> { self.stack.set_root(self.offset, ptr.cast()); T::wrap_non_null(ptr, Private) } +} - pub(crate) fn restrict<'target>(&'target mut self) -> Output<'target> { - Output { - stack: self.stack, - offset: self.offset, - } +/// An output that targets a [`LocalGcFrame`]. +/// +/// See the [module-level docs] for more information. +/// +/// [module-level docs]: crate::memory::target::output +/// [`LocalGcFrame`]: crate::memory::target::frame::LocalGcFrame +#[repr(transparent)] +pub struct LocalOutput<'target> { + slot: &'target Cell<*mut c_void>, +} + +impl<'target> LocalOutput<'target> { + #[inline] + pub(crate) fn new(slot: &'target Cell<*mut c_void>) -> Self { + LocalOutput { slot } + } + + #[inline] + pub(crate) unsafe fn consume<'data, T: Managed<'target, 'data>>( + self, + ptr: NonNull, + ) -> T { + self.slot.set(ptr.as_ptr().cast()); + T::wrap_non_null(ptr, Private) + } + + #[inline] + pub(crate) unsafe fn temporary<'t, 'data, T: Managed<'t, 'data>>( + &'t mut self, + ptr: NonNull, + ) -> T { + self.slot.set(ptr.as_ptr().cast()); + T::wrap_non_null(ptr, Private) } } diff --git a/jlrs/src/memory/target/reusable_slot.rs b/jlrs/src/memory/target/reusable_slot.rs index 4517d3c3..94a85155 100644 --- a/jlrs/src/memory/target/reusable_slot.rs +++ b/jlrs/src/memory/target/reusable_slot.rs @@ -1,88 +1,91 @@ -//! A target that uses a reserved slot in a frame. +//! Reusable slots +//! +//! Reusable slots target a reserved slot in some frame. There are two variations, +//! [`ReusableSlot`] and [`LocalReusableSlot`], both behave the same way, they only only target +//! different kinds of frame. +//! +//! When a reusable slot is taken by mutable reference it can be reused, the lifetime that is +//! considered the `'target` lifetime is the lifetime of the reusable slot. Because this means +//! that the data can become while it is in use, a `Ref` is returned as if an unrooting target +//! has been used. +//! +//! Examples: +//! +//! ``` +//! # use jlrs::prelude::*; +//! # use jlrs::util::test::JULIA; +//! # fn main() { +//! # JULIA.with(|j| { +//! # let mut julia = j.borrow_mut(); +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! +//! julia +//! .scope(|mut frame| { +//! let reusable_slot = frame.reusable_slot(); +//! +//! let _v = frame.scope(|_| { +//! // The reusable slot has been allocated in the parent +//! // scope's frame, so by using it as a target the +//! // result can be returned from this subscope. +//! Ok(Value::new(reusable_slot, 1u64)) +//! })?; +//! +//! Ok(()) +//! }) +//! .unwrap(); +//! # }); +//! # } +//! ``` +//! +//! ``` +//! # use jlrs::prelude::*; +//! # use jlrs::util::test::JULIA; +//! # fn main() { +//! # JULIA.with(|j| { +//! # let mut julia = j.borrow_mut(); +//! # let mut frame = StackFrame::new(); +//! # let mut julia = julia.instance(&mut frame); +//! +//! julia +//! .scope(|mut frame| { +//! let mut reusable_slot = frame.reusable_slot(); +//! +//! let _v = frame.scope(|_| { +//! // This data can be used until you leave the parent scope, +//! // it will be rooted until the reusable slot is used again. +//! Ok(Value::new(&mut reusable_slot, 2u64)) +//! })?; +//! +//! Ok(()) +//! }) +//! .unwrap(); +//! # }); +//! # } +//! ``` -use std::ptr::NonNull; +use std::{cell::Cell, ffi::c_void, ptr::NonNull}; -use super::output::Output; use crate::{ data::managed::{Managed, Ref}, memory::context::stack::Stack, private::Private, }; -/// A target that uses a reserved slot in a frame. +/// An reusable slot that targets a [`GcFrame`]. /// -/// An `ReusableSlot` can be allocated with [`GcFrame::reusable_slot`]. When it's used as a target, the -/// returned data remains rooted until the scope this target belongs to ends. +/// See the [module-level docs] for more information. /// -/// Example: -/// -/// ``` -/// # use jlrs::prelude::*; -/// # use jlrs::util::test::JULIA; -/// # fn main() { -/// # JULIA.with(|j| { -/// # let mut julia = j.borrow_mut(); -/// # let mut frame = StackFrame::new(); -/// # let mut julia = julia.instance(&mut frame); -/// -/// julia -/// .scope(|mut frame| { -/// let reusable_slot = frame.reusable_slot(); -/// -/// let _v = frame.scope(|_| { -/// // The reusableslot has been allocated in the parent -/// // scope's frame, so by using it as a target the -/// // result can be returned from this child scope. -/// Ok(Value::new(reusable_slot, 1u64)) -/// })?; -/// -/// Ok(()) -/// }) -/// .unwrap(); -/// # }); -/// # } -/// ``` -/// -/// A reusable slot can also be used to temporarily root data by using a mutable reference to a -/// `ReusableSlot` as a target. It's returned as a `Ref` because the lifetime is not tied to the -/// mutable borrow: -/// -/// ``` -/// # use jlrs::prelude::*; -/// # use jlrs::util::test::JULIA; -/// # fn main() { -/// # JULIA.with(|j| { -/// # let mut julia = j.borrow_mut(); -/// # let mut frame = StackFrame::new(); -/// # let mut julia = julia.instance(&mut frame); -/// -/// julia -/// .scope(|mut frame| { -/// let mut reusable_slot = frame.reusable_slot(); -/// -/// let _v = frame.scope(|_| { -/// // _v1 can be used even after the slot has been used again, it's -/// // your responsibility that you don't use this data after the slot -/// // has been reused. -/// let _v1 = Value::new(&mut reusable_slot, 2u64); -/// -/// Ok(Value::new(reusable_slot, 1u64)) -/// })?; -/// -/// Ok(()) -/// }) -/// .unwrap(); -/// # }); -/// # } -/// ``` -/// -/// [`GcFrame::reusable_slot`]: crate::memory::target::frame::GcFrame::reusable_slot +/// [module-level docs]: crate::memory::target::output +/// [`GcFrame`]: crate::memory::target::frame::GcFrame + pub struct ReusableSlot<'target> { pub(crate) stack: &'target Stack, pub(crate) offset: usize, } impl<'scope> ReusableSlot<'scope> { + #[inline] pub(crate) unsafe fn consume<'data, T: Managed<'scope, 'data>>( self, ptr: NonNull, @@ -91,6 +94,7 @@ impl<'scope> ReusableSlot<'scope> { T::wrap_non_null(ptr, Private) } + #[inline] pub(crate) unsafe fn temporary<'data, T: Managed<'scope, 'data>>( &mut self, ptr: NonNull, @@ -98,11 +102,39 @@ impl<'scope> ReusableSlot<'scope> { self.stack.set_root(self.offset, ptr.cast()); Ref::::wrap(ptr) } +} - pub(crate) fn into_output(self) -> Output<'scope> { - Output { - stack: self.stack, - offset: self.offset, - } +/// An reusable slot that targets a [`LocalGcFrame`]. +/// +/// See the [module-level docs] for more information. +/// +/// [module-level docs]: crate::memory::target::output +/// [`LocalGcFrame`]: crate::memory::target::frame::LocalGcFrame +pub struct LocalReusableSlot<'target> { + slot: &'target Cell<*mut c_void>, +} + +impl<'target> LocalReusableSlot<'target> { + #[inline] + pub(crate) fn new(slot: &'target Cell<*mut c_void>) -> Self { + LocalReusableSlot { slot } + } + + #[inline] + pub(crate) unsafe fn consume<'data, T: Managed<'target, 'data>>( + self, + ptr: NonNull, + ) -> T { + self.slot.set(ptr.as_ptr().cast()); + T::wrap_non_null(ptr, Private) + } + + #[inline] + pub(crate) unsafe fn temporary<'t, 'data, T: Managed<'target, 'data>>( + &'t mut self, + ptr: NonNull, + ) -> Ref<'target, 'data, T> { + self.slot.set(ptr.as_ptr().cast()); + Ref::::wrap(ptr) } } diff --git a/jlrs/src/memory/target/target_type.rs b/jlrs/src/memory/target/target_type.rs deleted file mode 100644 index 2920a6d9..00000000 --- a/jlrs/src/memory/target/target_type.rs +++ /dev/null @@ -1,97 +0,0 @@ -//! Trait used to declare what type of data is returned by a target. - -use super::reusable_slot::ReusableSlot; -#[cfg(feature = "async")] -use crate::memory::target::frame::AsyncGcFrame; -use crate::{ - data::managed::{Managed, Ref}, - error::{JuliaResult, JuliaResultRef}, - memory::target::{frame::GcFrame, output::Output, unrooted::Unrooted}, -}; - -/// Defines the return types of a target, `Data`, `Exception`, and `Result`. -pub trait TargetType<'target>: Sized { - /// Type returned by methods that don't catch Julia exceptions. - /// - /// For rooting targets, this type is `T`. - /// For non-rooting targets, this type is [`Ref<'target, 'data, T>`]. - type Data<'data, T: Managed<'target, 'data>>; - - /// Type returned by methods that catch Julia exceptions. - /// - /// For rooting targets, this type is [`JuliaResult<'target, 'data, T>`]. - /// For non-rooting targets, this type is [`JuliaResultRef<'target, 'data, Ref<'target, 'data, T>>`]. - type Result<'data, T: Managed<'target, 'data>>; - - /// Type returned by methods that don't return Julia data on succes, but can throw a Julia - /// exception which is caught. - /// - /// For rooting targets, this type is [`JuliaResult<'target, 'data, T>`]. - /// For non-rooting targets, this type is [`JuliaResultRef<'target, 'data, T>`]. - type Exception<'data, T>; -} - -impl<'target> TargetType<'target> for &mut GcFrame<'target> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -impl<'target> TargetType<'target> for GcFrame<'target> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -#[cfg(feature = "async")] -impl<'target> TargetType<'target> for &mut AsyncGcFrame<'target> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -#[cfg(feature = "async")] -impl<'target> TargetType<'target> for AsyncGcFrame<'target> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -impl<'target> TargetType<'target> for Output<'target> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -impl<'target> TargetType<'target> for &'target mut Output<'_> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -impl<'target> TargetType<'target> for ReusableSlot<'target> { - type Data<'data, T: Managed<'target, 'data>> = T; - type Result<'data, T: Managed<'target, 'data>> = JuliaResult<'target, 'data, T>; - type Exception<'data, T> = JuliaResult<'target, 'data, T>; -} - -impl<'target> TargetType<'target> for &mut ReusableSlot<'target> { - type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; - type Result<'data, T: Managed<'target, 'data>> = - JuliaResultRef<'target, 'data, Ref<'target, 'data, T>>; - type Exception<'data, T> = JuliaResultRef<'target, 'data, T>; -} - -impl<'target> TargetType<'target> for Unrooted<'target> { - type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; - type Result<'data, T: Managed<'target, 'data>> = - JuliaResultRef<'target, 'data, Ref<'target, 'data, T>>; - type Exception<'data, T> = JuliaResultRef<'target, 'data, T>; -} - -impl<'target, U: TargetType<'target>> TargetType<'target> for &U { - type Data<'data, T: Managed<'target, 'data>> = Ref<'target, 'data, T>; - type Result<'data, T: Managed<'target, 'data>> = - JuliaResultRef<'target, 'data, Ref<'target, 'data, T>>; - type Exception<'data, T> = JuliaResultRef<'target, 'data, T>; -} diff --git a/jlrs/src/memory/target/unrooted.rs b/jlrs/src/memory/target/unrooted.rs index d0691922..0923a31d 100644 --- a/jlrs/src/memory/target/unrooted.rs +++ b/jlrs/src/memory/target/unrooted.rs @@ -16,7 +16,8 @@ pub struct Unrooted<'target> { } impl<'target> Unrooted<'target> { - pub(crate) unsafe fn new() -> Self { + #[inline] + pub(crate) const unsafe fn new() -> Self { Unrooted { _marker: PhantomData, } diff --git a/jlrs/src/prelude.rs b/jlrs/src/prelude.rs index 3719e723..01ad2e54 100644 --- a/jlrs/src/prelude.rs +++ b/jlrs/src/prelude.rs @@ -7,7 +7,8 @@ pub use jlrs_macros::julia_module; pub use jlrs_macros::julia_version; #[cfg(feature = "jlrs-derive")] pub use jlrs_macros::{ - CCallArg, CCallReturn, ConstructType, IntoJulia, Typecheck, Unbox, ValidField, ValidLayout, + CCallArg, CCallReturn, ConstructType, HasLayout, IntoJulia, IsBits, Typecheck, Unbox, + ValidField, ValidLayout, }; #[cfg(feature = "ccall")] @@ -41,22 +42,13 @@ pub use crate::{ data::{ layout::{bool::Bool, char::Char, nothing::Nothing, tuple::*}, managed::{ - array::ArrayRef, - array::TypedArrayRef, - array::{Array, TypedArray}, - datatype::DataType, - datatype::DataTypeRef, - module::Module, - module::ModuleRef, - string::JuliaString, - string::StringRef, - symbol::Symbol, - value::Value, - value::ValueRef, - /* Ref, */ Managed, + array::Array, array::ArrayRef, array::TypedArray, array::TypedArrayRef, + datatype::DataType, datatype::DataTypeRef, module::Module, module::ModuleRef, + string::JuliaString, string::StringRef, symbol::Symbol, value::Value, value::ValueData, + value::ValueRef, value::ValueResult, /* Ref, */ Managed, ManagedRef, }, }, error::JlrsResult, - memory::target::{target_type::TargetType, Target}, + memory::target::{Target, TargetType}, named_tuple, }; diff --git a/jlrs/src/pyplot/mod.rs b/jlrs/src/pyplot/mod.rs index 67165e4d..0bca1e1b 100644 --- a/jlrs/src/pyplot/mod.rs +++ b/jlrs/src/pyplot/mod.rs @@ -8,22 +8,20 @@ #[cfg(feature = "async")] use jlrs_macros::julia_version; -use smallvec::SmallVec; -#[cfg(feature = "async")] -use crate::{call::CallAsync, memory::target::frame::AsyncGcFrame}; use crate::{ + args::Values, call::{Call, ProvideKeywords}, convert::into_jlrs_result::IntoJlrsResult, data::managed::{ - function::Function, - module::Module, - value::{Value, MAX_SIZE}, - Managed, + erase_scope_lifetime, function::Function, module::Module, value::Value, Managed, }, error::JlrsResult, memory::target::{frame::GcFrame, Target}, + private::Private, }; +#[cfg(feature = "async")] +use crate::{call::CallAsync, memory::target::frame::AsyncGcFrame}; init_fn!(init_jlrs_py_plot, JLRS_PY_PLOT_JL, "JlrsPyPlot.jl"); @@ -45,21 +43,15 @@ impl<'scope> PyPlot<'scope> { /// has been closed, even if all handles have been dropped. `plot_fn` must be a plotting /// function from the Plots.jl package, such as `plot` or `hexbin`. The resources associated /// with the window are only cleaned up if one of the `PyPlot::wait` methods is called. - pub unsafe fn new<'value, V>( + pub unsafe fn new<'value, V, const N: usize>( frame: &mut GcFrame<'scope>, - plot_fn: Function<'_, 'static>, + plot_fn: Function<'value, 'static>, args: V, ) -> JlrsResult where - V: AsRef<[Value<'value, 'static>]>, + V: Values<'value, 'static, N>, { - let args = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + args.len()); - vals.push(plot_fn.as_value()); - - for arg in args.iter().copied() { - vals.push(arg); - } + let values = args.into_extended_with_start([plot_fn.as_value()], Private); let plt = Module::main(&frame) .submodule(&frame, "JlrsPyPlot") @@ -68,7 +60,7 @@ impl<'scope> PyPlot<'scope> { .function(&frame, "jlrsplot") .unwrap() .as_managed() - .call(frame, vals) + .call(frame, values.as_ref()) .into_jlrs_result()?; Ok(PyPlot(plt)) @@ -79,22 +71,16 @@ impl<'scope> PyPlot<'scope> { /// plotting function from the Plots.jl package, such as `plot` or `hexbin`. The resources /// associated with the window are only cleaned up if one of the `PyPlot::wait` methods is /// called. - pub unsafe fn new_with_keywords<'value, V>( + pub unsafe fn new_with_keywords<'value, V, const N: usize>( frame: &mut GcFrame<'scope>, - plot_fn: Function<'_, 'static>, + plot_fn: Function<'value, 'static>, args: V, - keywords: Value<'_, 'static>, + keywords: Value<'value, 'static>, ) -> JlrsResult where - V: AsRef<[Value<'value, 'static>]>, + V: Values<'value, 'static, N>, { - let args = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(1 + args.len()); - vals.push(plot_fn.as_value()); - - for arg in args.iter().copied() { - vals.push(arg); - } + let values = args.into_extended_with_start([plot_fn.as_value()], Private); let plt = Module::main(&frame) .submodule(&frame, "JlrsPyPlot") @@ -104,7 +90,7 @@ impl<'scope> PyPlot<'scope> { .unwrap() .as_managed() .provide_keywords(keywords)? - .call(frame, vals) + .call(frame, values.as_ref()) .into_jlrs_result()?; Ok(PyPlot(plt)) @@ -114,23 +100,16 @@ impl<'scope> PyPlot<'scope> { /// `plot)fn(, args...)`. If the window has already been closed an /// error is returned. Note that if multiple plotting windows are currently open, only the /// most recently created one is redrawn automatically. - pub unsafe fn update<'value, 'frame, V>( + pub unsafe fn update<'value, 'frame, V, const N: usize>( self, frame: &mut GcFrame<'scope>, - plot_fn: Function<'_, 'static>, + plot_fn: Function<'value, 'static>, args: V, ) -> JlrsResult where - V: AsRef<[Value<'value, 'static>]>, + V: Values<'value, 'static, N>, { - let args = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(2 + args.len()); - vals.push(self.0); - vals.push(plot_fn.as_value()); - - for arg in args.iter().copied() { - vals.push(arg); - } + let values = args.into_extended_with_start([plot_fn.as_value()], Private); Module::main(&frame) .submodule(&frame, "JlrsPyPlot") @@ -139,7 +118,7 @@ impl<'scope> PyPlot<'scope> { .function(&frame, "updateplot!") .unwrap() .as_managed() - .call(frame, vals) + .call(frame, values.as_ref()) .into_jlrs_result()? .unbox::() } @@ -148,24 +127,18 @@ impl<'scope> PyPlot<'scope> { /// `plot_fn(, args...; kwargs...)`. If the window has already been /// closed an error is returned. Note that if multiple plotting windows are currently open, /// only the most recently created one is redrawn automatically. - pub unsafe fn update_with_keywords<'value, 'frame, V>( + pub unsafe fn update_with_keywords<'value, 'frame, V, const N: usize>( self, frame: &mut GcFrame<'scope>, - plot_fn: Function<'_, 'static>, + plot_fn: Function<'value, 'static>, args: V, - keywords: Value<'_, 'static>, + keywords: Value<'value, 'static>, ) -> JlrsResult where - V: AsRef<[Value<'value, 'static>]>, + V: Values<'value, 'static, N>, { - let args = args.as_ref(); - let mut vals: SmallVec<[Value; MAX_SIZE]> = SmallVec::with_capacity(2 + args.len()); - vals.push(self.0); - vals.push(plot_fn.as_value()); - - for arg in args.iter().copied() { - vals.push(arg); - } + let values = args + .into_extended_with_start([erase_scope_lifetime(self.0), plot_fn.as_value()], Private); Module::main(&frame) .submodule(&frame, "JlrsPyPlot") @@ -175,7 +148,7 @@ impl<'scope> PyPlot<'scope> { .unwrap() .as_managed() .provide_keywords(keywords)? - .call(frame, vals) + .call(frame, values.as_ref()) .into_jlrs_result()? .unbox::() } @@ -227,7 +200,7 @@ impl<'scope> PyPlot<'scope> { Module::base(&frame) .function(&frame, "wait")? .as_managed() - .call_async_main(frame, &mut [self.0]) + .call_async_main(frame, [self.0]) .await .into_jlrs_result()?; @@ -247,7 +220,7 @@ impl<'scope> PyPlot<'scope> { Module::base(&frame) .function(&frame, "wait")? .as_managed() - .call_async_interactive(frame, &mut [self.0]) + .call_async_interactive(frame, [self.0]) .await .into_jlrs_result()?; @@ -266,7 +239,7 @@ impl<'scope> PyPlot<'scope> { Module::base(&frame) .function(&frame, "wait")? .as_managed() - .call_async_local(frame, &mut [self.0]) + .call_async_local(frame, [self.0]) .await .into_jlrs_result()?; @@ -282,7 +255,7 @@ impl<'scope> PyPlot<'scope> { Module::base(&frame) .function(&frame, "wait")? .as_managed() - .call_async(frame, &mut [self.0]) + .call_async(frame, [self.0]) .await .into_jlrs_result()?; diff --git a/jlrs/src/runtime/async_rt/adopted.rs b/jlrs/src/runtime/async_rt/adopted.rs index e62a2efa..dafc9ca1 100644 --- a/jlrs/src/runtime/async_rt/adopted.rs +++ b/jlrs/src/runtime/async_rt/adopted.rs @@ -1,14 +1,15 @@ use std::{cell::RefCell, collections::VecDeque, rc::Rc, time::Duration}; -use jl_sys::{jl_adopt_thread, jl_gc_safepoint}; +use jl_sys::{jl_adopt_thread, jl_gc_safepoint, jlrs_gc_safe_enter, jlrs_gc_safe_leave}; use super::{queue::Receiver, AsyncRuntime, Message, MessageInner}; use crate::{ async_util::task::sleep, error::JlrsResult, - memory::{stack_frame::StackFrame, target::unrooted::Unrooted}, + memory::{get_tls, stack_frame::StackFrame, target::unrooted::Unrooted}, }; +#[inline] pub(crate) unsafe fn init_worker( worker_id: usize, recv_timeout: Duration, @@ -17,6 +18,7 @@ pub(crate) unsafe fn init_worker( R::spawn_thread(move || run_async::(worker_id, recv_timeout, receiver)) } +#[inline] fn run_async( worker_id: usize, recv_timeout: Duration, @@ -59,14 +61,27 @@ async unsafe fn run_inner( }; loop { - if free_stacks.borrow().len() == 0 { + let n_free = free_stacks.borrow().len(); + if n_free == 0 { sleep(&Unrooted::new(), recv_timeout); R::yield_now().await; jl_gc_safepoint(); continue; } - match R::timeout(recv_timeout, receiver.recv_worker()).await { + let msg = if n_free == N { + // No tasks are running so we block until there is work to do. Enter a GC-safe state + // to indicate garbage can be collected while we wait. + let ptls = get_tls(); + let state = jlrs_gc_safe_enter(ptls); + let msg = receiver.recv_worker().await; + jlrs_gc_safe_leave(ptls, state); + Some(msg) + } else { + R::timeout(recv_timeout, receiver.recv_worker()).await + }; + + match msg { None => jl_gc_safepoint(), Some(Ok(msg)) => match msg.inner { MessageInner::Task(task) => { diff --git a/jlrs/src/runtime/async_rt/async_std_rt.rs b/jlrs/src/runtime/async_rt/async_std_rt.rs index 693be7af..5ad94ac2 100644 --- a/jlrs/src/runtime/async_rt/async_std_rt.rs +++ b/jlrs/src/runtime/async_rt/async_std_rt.rs @@ -32,6 +32,7 @@ impl AsyncRuntime for AsyncStd { type JoinHandle = JoinHandle<()>; type RuntimeHandle = JoinHandle>; + #[inline] fn spawn_blocking(rt_fn: F) -> Self::RuntimeHandle where F: FnOnce() -> JlrsResult<()> + Send + 'static, @@ -39,6 +40,7 @@ impl AsyncRuntime for AsyncStd { async_std::task::spawn_blocking(rt_fn) } + #[inline] fn block_on(loop_fn: F, _: Option) -> JlrsResult<()> where F: Future>, @@ -46,10 +48,12 @@ impl AsyncRuntime for AsyncStd { async_std::task::block_on(loop_fn) } + #[inline] async fn yield_now() { async_std::task::yield_now().await } + #[inline] fn spawn_local(future: F) -> Self::JoinHandle where F: Future + 'static, @@ -57,6 +61,7 @@ impl AsyncRuntime for AsyncStd { async_std::task::spawn_local(future) } + #[inline] async fn timeout(duration: Duration, future: F) -> Option> where F: Future>, @@ -69,6 +74,7 @@ impl Channel for (Sender, Receiver) { type Sender = Sender; type Receiver = Receiver; + #[inline] fn channel(capacity: Option) -> (Self::Sender, Self::Receiver) { match capacity { Some(n) => bounded(n.get()), @@ -79,10 +85,12 @@ impl Channel for (Sender, Receiver) { #[async_trait] impl ChannelSender for Sender { + #[inline] async fn send(&self, msg: M) -> Result<(), SendError> { Ok((&*self).send(msg).await.map_err(|e| SendError(e.0))?) } + #[inline] fn try_send(&self, msg: M) -> Result<(), TrySendError> { Ok((&*self).try_send(msg).map_err(|e| match e { async_std::channel::TrySendError::Closed(v) => TrySendError::Closed(v), @@ -93,6 +101,7 @@ impl ChannelSender for Sender { #[async_trait] impl ChannelReceiver for Receiver { + #[inline] async fn recv(&mut self) -> JlrsResult { match (&*self).recv().await { Ok(m) => Ok(m), @@ -102,6 +111,7 @@ impl ChannelReceiver for Receiver { } impl OneshotSender for Sender { + #[inline] fn send(self, msg: M) { (&self).send_blocking(msg).ok(); } diff --git a/jlrs/src/runtime/async_rt/dispatch.rs b/jlrs/src/runtime/async_rt/dispatch.rs index e872dbfc..0cb940fa 100644 --- a/jlrs/src/runtime/async_rt/dispatch.rs +++ b/jlrs/src/runtime/async_rt/dispatch.rs @@ -21,6 +21,7 @@ impl<'a, D> Debug for Dispatch<'a, D> { } impl<'a, D: Affinity> Dispatch<'a, D> { + #[inline] pub(super) fn new(sender: &'a Sender, msg: Message) -> Self { Dispatch { msg, @@ -35,6 +36,7 @@ impl<'a, D: ToAny> Dispatch<'a, D> { /// /// The dispatched task can be handled by either the main thread or any of the worker threads. /// This method doesn't resolve until the task has been successfully dispatched. + #[inline] pub async fn dispatch_any(self) { self.sender.send(self.msg).await } @@ -43,6 +45,7 @@ impl<'a, D: ToAny> Dispatch<'a, D> { /// /// The dispatched task can be handled by either the main thread or any of the worker threads. /// If the backing queue is full, the dispatcher is returned to allow retrying. + #[inline] pub fn try_dispatch_any(self) -> Result<(), Self> { if let Some(msg) = self.sender.try_send(self.msg) { Err(Dispatch { @@ -61,6 +64,7 @@ impl<'a, D: ToMain> Dispatch<'a, D> { /// /// The dispatched task is guaranteed to be handled by the main thread. This method doesn't /// resolve until the task has been successfully dispatched. + #[inline] pub async fn dispatch_main(self) { self.sender.send_main(self.msg).await } @@ -69,6 +73,7 @@ impl<'a, D: ToMain> Dispatch<'a, D> { /// /// The dispatched task is guaranteed to be handled by the main thread. If the backing queue /// is full, the dispatcher is returned to allow retrying. + #[inline] pub fn try_dispatch_main(self) -> Result<(), Self> { if let Some(msg) = self.sender.try_send_main(self.msg) { Err(Dispatch { @@ -88,6 +93,7 @@ impl<'a, D: ToWorker> Dispatch<'a, D> { /// The dispatched task is guaranteed to be handled by a worker thread if they're used, /// otherwise it's handled by the main thread. This method doesn't resolve until the task has /// been successfully dispatched. + #[inline] pub async fn dispatch_worker(self) { self.sender.send_worker(self.msg).await } @@ -97,6 +103,7 @@ impl<'a, D: ToWorker> Dispatch<'a, D> { /// The dispatched task is guaranteed to be handled by a worker thread if they're used, /// otherwise it's handled by the main thread. If the backing queue is full, the dispatcher /// is returned to allow retrying. + #[inline] pub fn try_dispatch_worker(self) -> Result<(), Self> { if let Some(msg) = self.sender.try_send_worker(self.msg) { Err(Dispatch { diff --git a/jlrs/src/runtime/async_rt/mod.rs b/jlrs/src/runtime/async_rt/mod.rs index ebbc307f..26d513e7 100644 --- a/jlrs/src/runtime/async_rt/mod.rs +++ b/jlrs/src/runtime/async_rt/mod.rs @@ -158,6 +158,7 @@ where /// /// No tasks are dropped if the queue is shrunk. This method return a future that doesn´t /// resolve until the queue can be resized without dropping any tasks. + #[inline] pub fn resize_queue<'own>( &'own self, capacity: usize, @@ -169,6 +170,7 @@ where /// /// See [`AsyncJulia::resize_queue`] for more info, the only difference is that this is an /// async method. + #[inline] pub async fn resize_queue_async(&self, capacity: usize) -> Option<()> { if let Some(fut) = self.resize_queue(capacity) { Some(fut.await) @@ -181,6 +183,7 @@ where /// /// No tasks are dropped if the queue is shrunk. This method return a future that doesn´t /// resolve until the queue can be resized without dropping any tasks. + #[inline] pub fn resize_main_queue<'own>(&'own self, capacity: usize) -> impl 'own + Future { self.sender.resize_main_queue(capacity) } @@ -189,6 +192,7 @@ where /// /// See [`AsyncJulia::resize_main_queue`] for more info, the only difference is that this is an /// async method. + #[inline] pub async fn resize_main_queue_async(&self, capacity: usize) { self.resize_main_queue(capacity).await } @@ -197,6 +201,7 @@ where /// /// No tasks are dropped if the queue is shrunk. This method return a future that doesn´t /// resolve until the queue can be resized without dropping any tasks. + #[inline] pub fn resize_worker_queue<'own>( &'own self, capacity: usize, @@ -208,6 +213,7 @@ where /// /// See [`AsyncJulia::resize_main_queue`] for more info, the only difference is that this is an /// async method. + #[inline] pub async fn resize_worker_queue_async(&self, capacity: usize) -> Option<()> { if let Some(fut) = self.resize_worker_queue(capacity) { Some(fut.await) @@ -658,6 +664,7 @@ impl fmt::Debug for Message { unsafe impl Sync for Message {} impl MessageInner { + #[inline] pub(crate) fn wrap(self) -> Message { Message { inner: self } } diff --git a/jlrs/src/runtime/async_rt/queue.rs b/jlrs/src/runtime/async_rt/queue.rs index f7615595..951756d1 100644 --- a/jlrs/src/runtime/async_rt/queue.rs +++ b/jlrs/src/runtime/async_rt/queue.rs @@ -19,6 +19,7 @@ struct Queues { } impl Queues { + #[inline] fn new(capacity: usize, has_workers: bool) -> Arc { let (worker_queue, any_queue) = if has_workers { (Some(Queue::new(capacity)), Some(Queue::new(capacity))) @@ -57,6 +58,7 @@ impl Clone for Sender { } impl Sender { + #[inline] pub(crate) async fn send(&self, item: T) { if let Some(ref q) = self.queues.any_queue { q.push(item).await @@ -65,6 +67,7 @@ impl Sender { } } + #[inline] pub(crate) fn try_send(&self, item: T) -> Option { if let Some(ref q) = self.queues.any_queue { q.try_push(item).err()?; @@ -74,6 +77,7 @@ impl Sender { None } + #[inline] pub(crate) fn resize_queue<'own>( &'own self, capacity: usize, @@ -81,15 +85,18 @@ impl Sender { self.queues.any_queue.as_ref().map(|q| q.resize(capacity)) } + #[inline] pub(crate) async fn send_main(&self, item: T) { self.queues.main_queue.push(item).await } + #[inline] pub(crate) fn try_send_main(&self, item: T) -> Option { self.queues.main_queue.try_push(item).err()?; None } + #[inline] pub(crate) fn resize_main_queue<'own>( &'own self, capacity: usize, @@ -97,6 +104,7 @@ impl Sender { self.queues.main_queue.resize(capacity) } + #[inline] pub(crate) async fn send_worker(&self, item: T) { if let Some(ref q) = self.queues.worker_queue { q.push(item).await @@ -105,6 +113,7 @@ impl Sender { } } + #[inline] pub(crate) fn try_send_worker(&self, item: T) -> Option { if let Some(ref q) = self.queues.worker_queue { q.try_push(item).err()?; @@ -114,6 +123,7 @@ impl Sender { None } + #[inline] pub(crate) fn resize_worker_queue<'own>( &'own self, capacity: usize, diff --git a/jlrs/src/runtime/async_rt/tokio_rt.rs b/jlrs/src/runtime/async_rt/tokio_rt.rs index 4b572c4d..c77a0617 100644 --- a/jlrs/src/runtime/async_rt/tokio_rt.rs +++ b/jlrs/src/runtime/async_rt/tokio_rt.rs @@ -42,6 +42,7 @@ impl AsyncRuntime for Tokio { type JoinHandle = JoinHandle<()>; type RuntimeHandle = JoinHandle>; + #[inline] fn spawn_blocking(rt_fn: F) -> Self::RuntimeHandle where F: FnOnce() -> JlrsResult<()> + Send + 'static, @@ -49,6 +50,7 @@ impl AsyncRuntime for Tokio { tokio::task::spawn_blocking(rt_fn) } + #[inline] fn block_on(loop_fn: F, worker_id: Option) -> JlrsResult<()> where F: Future>, @@ -69,6 +71,7 @@ impl AsyncRuntime for Tokio { local_set.block_on(&runtime, loop_fn) } + #[inline] fn spawn_local(future: F) -> Self::JoinHandle where F: Future + 'static, @@ -76,10 +79,12 @@ impl AsyncRuntime for Tokio { tokio::task::spawn_local(future) } + #[inline] async fn yield_now() { tokio::task::yield_now().await } + #[inline] async fn timeout(duration: Duration, future: F) -> Option> where F: Future>, @@ -92,6 +97,7 @@ impl Channel for BoundedChannel { type Sender = tokio::sync::mpsc::Sender; type Receiver = tokio::sync::mpsc::Receiver; + #[inline] fn channel(capacity: Option) -> (Self::Sender, Self::Receiver) { tokio::sync::mpsc::channel(capacity.map(|c| c.get()).unwrap_or_default()) } @@ -101,6 +107,7 @@ impl Channel for UnboundedChannel { type Sender = tokio::sync::mpsc::UnboundedSender; type Receiver = tokio::sync::mpsc::UnboundedReceiver; + #[inline] fn channel(_: Option) -> (Self::Sender, Self::Receiver) { tokio::sync::mpsc::unbounded_channel() } @@ -108,10 +115,12 @@ impl Channel for UnboundedChannel { #[async_trait] impl ChannelSender for tokio::sync::mpsc::Sender { + #[inline] async fn send(&self, msg: M) -> Result<(), SendError> { Ok((&*self).send(msg).await.map_err(|e| SendError(e.0))?) } + #[inline] fn try_send(&self, msg: M) -> Result<(), TrySendError> { Ok((&*self).try_send(msg).map_err(|e| match e { tokio::sync::mpsc::error::TrySendError::Closed(v) => TrySendError::Closed(v), @@ -122,6 +131,7 @@ impl ChannelSender for tokio::sync::mpsc::Sender { #[async_trait] impl ChannelReceiver for tokio::sync::mpsc::Receiver { + #[inline] async fn recv(&mut self) -> JlrsResult { match self.recv().await { Some(m) => Ok(m), @@ -132,10 +142,12 @@ impl ChannelReceiver for tokio::sync::mpsc::Receiver { #[async_trait] impl ChannelSender for tokio::sync::mpsc::UnboundedSender { + #[inline] async fn send(&self, msg: M) -> Result<(), SendError> { Ok((&*self).send(msg).map_err(|e| SendError(e.0))?) } + #[inline] fn try_send(&self, msg: M) -> Result<(), TrySendError> { Ok((&*self).send(msg).map_err(|e| TrySendError::Closed(e.0))?) } @@ -143,6 +155,7 @@ impl ChannelSender for tokio::sync::mpsc::UnboundedSender< #[async_trait] impl ChannelReceiver for tokio::sync::mpsc::UnboundedReceiver { + #[inline] async fn recv(&mut self) -> JlrsResult { match self.recv().await { Some(m) => Ok(m), @@ -152,24 +165,28 @@ impl ChannelReceiver for tokio::sync::mpsc::UnboundedRecei } impl OneshotSender for tokio::sync::oneshot::Sender { + #[inline] fn send(self, msg: M) { self.send(msg).ok(); } } impl OneshotSender for tokio::sync::mpsc::Sender { + #[inline] fn send(self, msg: M) { (&self).blocking_send(msg).ok(); } } impl OneshotSender for tokio::sync::broadcast::Sender { + #[inline] fn send(self, msg: M) { (&self).send(msg).ok(); } } impl OneshotSender for tokio::sync::watch::Sender { + #[inline] fn send(self, msg: M) { (&self).send(msg).ok(); } diff --git a/jlrs/src/runtime/builder.rs b/jlrs/src/runtime/builder.rs index 467254ba..a9063834 100644 --- a/jlrs/src/runtime/builder.rs +++ b/jlrs/src/runtime/builder.rs @@ -64,6 +64,7 @@ cfg_if::cfg_if! { /// /// NB: When the `nightly` or `beta` feature is enabled, this sets the number of /// threads allocated to the `:default` pool. + #[inline] pub fn n_threads(mut self, n: usize) -> Self { self.n_threads = n; self @@ -73,6 +74,7 @@ cfg_if::cfg_if! { /// Set the number of threads allocated to the `:interactive` pool. /// /// If it's set to 0, the default value, no threads are allocated to this pool. + #[inline] pub fn n_interactive_threads(mut self, n: usize) -> Self { self.n_threadsi = n; self @@ -83,6 +85,7 @@ cfg_if::cfg_if! { /// Set the number of worker threads jlrs creates in addition to the runtime thread. /// /// If it's set to 0, the default value, no worker threads are created. + #[inline] pub fn n_worker_threads(mut self, n: usize) -> Self { self.n_workers = n; self @@ -91,6 +94,7 @@ cfg_if::cfg_if! { /// Set the capacity of the channel used to communicate with the async runtime. /// /// The default value is 16. + #[inline] pub fn channel_capacity(mut self, capacity: NonZeroUsize) -> Self { self.channel_capacity = capacity; self @@ -103,6 +107,7 @@ cfg_if::cfg_if! { /// are processed periodically. /// /// The default value is 1 millisecond. + #[inline] pub fn recv_timeout(mut self, timeout: Duration) -> Self { self.recv_timeout = timeout; self @@ -119,6 +124,7 @@ cfg_if::cfg_if! { /// /// [`PackageCompiler`]: https://julialang.github.io/PackageCompiler.jl // TODO: Check if these paths exist. + #[inline] pub fn image(mut self, julia_bindir: P, image_path: Q) -> Self where P: AsRef + Send + 'static, @@ -135,6 +141,7 @@ cfg_if::cfg_if! { /// /// In order to function correctly, jlrs requires that the JlrsCore package is installed. By /// default, this package is automatically installed if it hasn't been installed yet. + #[inline] pub fn install_jlrs(mut self, install: InstallJlrsCore) -> Self { self.builder.install_jlrs_core = install; self @@ -143,6 +150,7 @@ cfg_if::cfg_if! { /// Initialize Julia on another thread. /// /// You must set the maximum number of concurrent tasks with the `N` const generic. + #[inline] pub unsafe fn start(self) -> JlrsResult<(AsyncJulia, std::thread::JoinHandle>)> { AsyncJulia::init::(self) } @@ -150,10 +158,12 @@ cfg_if::cfg_if! { /// Initialize Julia as a blocking task. /// /// You must set the maximum number of concurrent tasks with the `N` const generic. + #[inline] pub unsafe fn start_async(self) -> JlrsResult<(AsyncJulia, R::RuntimeHandle)> { AsyncJulia::init_async::(self) } + #[inline] pub(crate) fn has_workers(&self) -> bool { #[cfg(any(feature = "julia-1-10", feature = "julia-1-9"))] { @@ -171,6 +181,7 @@ cfg_if::cfg_if! { impl RuntimeBuilder { /// Create a new `RuntimeBuilder`. + #[inline] pub fn new() -> Self { RuntimeBuilder { image: None, @@ -179,6 +190,7 @@ impl RuntimeBuilder { } #[cfg(feature = "sync-rt")] + #[inline] /// initialize Julia on the current thread. pub unsafe fn start(self) -> JlrsResult { PendingJulia::init(self) @@ -219,6 +231,7 @@ impl RuntimeBuilder { /// # } /// ``` #[cfg(feature = "async-rt")] + #[inline] pub fn async_runtime(self) -> AsyncRuntimeBuilder where R: AsyncRuntime, @@ -246,6 +259,7 @@ impl RuntimeBuilder { /// /// [`PackageCompiler`]: https://julialang.github.io/PackageCompiler.jl // TODO: Check if these paths exist. + #[inline] pub fn image(mut self, julia_bindir: P, image_path: Q) -> Self where P: AsRef + Send + 'static, @@ -262,6 +276,7 @@ impl RuntimeBuilder { /// /// In order to function correctly, jlrs requires that the JlrsCore package is installed. By /// default, this package is automatically installed if it hasn't been installed yet. + #[inline] pub fn install_jlrs(mut self, install: InstallJlrsCore) -> Self { self.install_jlrs_core = install; self diff --git a/jlrs/src/runtime/sync_rt.rs b/jlrs/src/runtime/sync_rt.rs index ab382ff6..3f8379a9 100644 --- a/jlrs/src/runtime/sync_rt.rs +++ b/jlrs/src/runtime/sync_rt.rs @@ -120,6 +120,7 @@ impl Julia<'_> { Value::false_v(&frame) }; + // FIXME: make atomic Module::main(&frame) .submodule(&frame, "JlrsCore")? .as_managed() diff --git a/jlrs/tests/abstract_fields.rs b/jlrs/tests/abstract_fields.rs index 4a12f1af..973913db 100644 --- a/jlrs/tests/abstract_fields.rs +++ b/jlrs/tests/abstract_fields.rs @@ -20,16 +20,13 @@ mod tests { .global(&frame, "WithAbstract")? .as_value() }; - frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let arg1 = Value::new(&mut frame, 3u32); - frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let instance = ty .cast::()? .instantiate(&mut frame, &mut [arg1])? .into_jlrs_result()?; - frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let field = instance.field_accessor().field("a")?.access::()?; assert_eq!(field, 3); diff --git a/jlrs/tests/access_fields.rs b/jlrs/tests/access_fields.rs index 05d75b99..09dbc7d1 100644 --- a/jlrs/tests/access_fields.rs +++ b/jlrs/tests/access_fields.rs @@ -197,7 +197,7 @@ mod tests { .scope(|mut frame| unsafe { let idx = Value::new(&mut frame, 4usize); let data = vec![1.0f64, 2., 3.]; - let array = Array::from_vec_unchecked(frame.as_extended_target(), data, 3)?; + let array = Array::from_vec_unchecked(&mut frame, data, 3)?; let func = Module::base(&frame) .function(&frame, "getindex")? .as_managed(); @@ -232,7 +232,7 @@ mod tests { .scope(|mut frame| unsafe { let idx = Value::new(&mut frame, 4usize); let data = vec![1.0f64, 2., 3.]; - let array = Array::from_vec_unchecked(frame.as_extended_target(), data, 3)?; + let array = Array::from_vec_unchecked(&mut frame, data, 3)?; let func = Module::base(&frame) .function(&frame, "getindex")? .as_managed(); @@ -258,7 +258,7 @@ mod tests { .scope(|mut frame| unsafe { let idx = Value::new(&mut frame, 4usize); let data = vec![1.0f64, 2., 3.]; - let array = Array::from_vec_unchecked(frame.as_extended_target(), data, 3)?; + let array = Array::from_vec_unchecked(&mut frame, data, 3)?; let func = Module::base(&frame) .function(&frame, "getindex")? .as_managed(); @@ -286,7 +286,7 @@ mod tests { .scope(|mut frame| unsafe { let idx = Value::new(&mut frame, 4usize); let data = vec![1.0f64, 2., 3.]; - let array = Array::from_vec_unchecked(frame.as_extended_target(), data, 3)?; + let array = Array::from_vec_unchecked(&mut frame, data, 3)?; let func = Module::base(&frame) .function(&frame, "getindex")? .as_managed(); diff --git a/jlrs/tests/access_raw_field.rs b/jlrs/tests/access_raw_field.rs index 6d8428ac..d5420991 100644 --- a/jlrs/tests/access_raw_field.rs +++ b/jlrs/tests/access_raw_field.rs @@ -223,8 +223,7 @@ mod tests { .as_value() }; let data = vec![1.0, 2.0, 3.0, 4.0]; - let arg1 = Array::from_vec(frame.as_extended_target(), data, (2, 2))? - .into_jlrs_result()?; + let arg1 = Array::from_vec(&mut frame, data, (2, 2))?.into_jlrs_result()?; let instance = ty .cast::()? .instantiate(&mut frame, &mut [arg1.as_value()])? @@ -266,8 +265,7 @@ mod tests { .as_value() }; let data = vec![1.0, 2.0, 3.0, 4.0]; - let arg1 = Array::from_vec(frame.as_extended_target(), data, (2, 2))? - .into_jlrs_result()?; + let arg1 = Array::from_vec(&mut frame, data, (2, 2))?.into_jlrs_result()?; let instance = ty .cast::()? .instantiate(&mut frame, &mut [arg1.as_value()])? @@ -505,8 +503,7 @@ mod tests { .as_value() }; let data = vec![1.0, 2.0, 3.0, 4.0]; - let arg1 = Array::from_vec(frame.as_extended_target(), data, (2, 2))? - .into_jlrs_result()?; + let arg1 = Array::from_vec(&mut frame, data, (2, 2))?.into_jlrs_result()?; let instance = ty .cast::()? .instantiate(&mut frame, &mut [arg1.as_value()])? @@ -548,8 +545,7 @@ mod tests { .as_value() }; let data = vec![1.0, 2.0, 3.0, 4.0]; - let arg1 = Array::from_vec(frame.as_extended_target(), data, (2, 2))? - .into_jlrs_result()?; + let arg1 = Array::from_vec(&mut frame, data, (2, 2))?.into_jlrs_result()?; let instance = ty .cast::()? .instantiate(&mut frame, &mut [arg1.as_value()])? diff --git a/jlrs/tests/access_unboxed_array.rs b/jlrs/tests/access_unboxed_array.rs index 1b3386c6..795dc1bc 100644 --- a/jlrs/tests/access_unboxed_array.rs +++ b/jlrs/tests/access_unboxed_array.rs @@ -19,8 +19,7 @@ mod tests { (1..=24).map(|x| x as $value_type).collect(); let array = - Array::from_vec(frame.as_extended_target(), data, (2, 3, 4))? - .into_jlrs_result()?; + Array::from_vec(&mut frame, data, (2, 3, 4))?.into_jlrs_result()?; let d = unsafe { array.copy_inline_data::<$value_type>()? }; let mut out = 1 as $value_type; @@ -53,8 +52,7 @@ mod tests { (1..=24).map(|x| x as $value_type).collect(); let array = - Array::from_vec(frame.as_extended_target(), data, (2, 3, 4))? - .into_jlrs_result()?; + Array::from_vec(&mut frame, data, (2, 3, 4))?.into_jlrs_result()?; let mut d = unsafe { array.copy_inline_data::<$value_type>()? }; let mut out = 2 as $value_type; @@ -92,12 +90,8 @@ mod tests { let data: Vec<$value_type> = (1..=24).map(|x| x as $value_type).collect(); - let array = Array::from_vec( - frame.as_extended_target(), - data.clone(), - (2, 3, 4), - )? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data.clone(), (2, 3, 4))? + .into_jlrs_result()?; let d = unsafe { array.copy_inline_data::<$value_type>()? }; for (a, b) in data.iter().zip(d.as_slice()) { @@ -120,12 +114,8 @@ mod tests { let data: Vec<$value_type> = (1..=24).map(|x| x as $value_type).collect(); - let array = Array::from_vec( - frame.as_extended_target(), - data.clone(), - (2, 3, 4), - )? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data.clone(), (2, 3, 4))? + .into_jlrs_result()?; let mut d = unsafe { array.copy_inline_data::<$value_type>()? }; for (a, b) in data.iter().zip(d.as_mut_slice()) { diff --git a/jlrs/tests/arrays.rs b/jlrs/tests/arrays.rs index 135a7374..53f6a854 100644 --- a/jlrs/tests/arrays.rs +++ b/jlrs/tests/arrays.rs @@ -16,8 +16,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result(); + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result(); assert!(arr_val.is_ok()); Ok(()) }) @@ -67,8 +66,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val; let dims = unsafe { arr.dimensions() }.into_dimensions(); assert_eq!(dims.as_slice(), &[1, 2]); @@ -85,8 +83,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val; assert!(arr.contains::()); assert!(arr.contains_inline::()); @@ -124,8 +121,7 @@ mod tests { let mut jlrs = j.borrow_mut(); let out = jlrs.instance(&mut frame).scope(|mut frame| { - let array = Array::new::(frame.as_extended_target(), (3, 1)) - .into_jlrs_result()?; + let array = Array::new::(&mut frame, (3, 1)).into_jlrs_result()?; unsafe { array.copy_inline_data::() } }); @@ -140,8 +136,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val.as_value().cast::>(); assert!(arr.is_ok()); Ok(()) @@ -157,8 +152,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val.as_value().cast::>()?; let dims = unsafe { arr.dimensions() }.into_dimensions(); assert_eq!(dims.as_slice(), &[1, 2]); @@ -175,8 +169,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val.as_value().cast::>()?; assert!(!arr.has_inlined_pointers()); assert!(arr.is_inline_array()); @@ -263,8 +256,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr_val.value_data().is_err()); Ok(()) }) @@ -279,8 +271,8 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let mut arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let mut arr_val = + Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr_val.value_data_mut().is_err()); Ok(()) }) @@ -295,8 +287,8 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let mut arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let mut arr_val = + Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr_val.value_data_mut().is_err()); Ok(()) }) diff --git a/jlrs/tests/async_std_rt.rs b/jlrs/tests/async_std_rt.rs index 1a5425e2..9b10b35c 100644 --- a/jlrs/tests/async_std_rt.rs +++ b/jlrs/tests/async_std_rt.rs @@ -1,6 +1,6 @@ #[cfg(all(feature = "async-std-rt",))] #[cfg(test)] -mod util; +mod async_util; #[cfg(all(feature = "async-std-rt",))] #[cfg(test)] @@ -10,7 +10,7 @@ mod tests { use jlrs::prelude::*; use once_cell::sync::OnceCell; - use super::util::{async_tasks::*, ASYNC_TESTS_JL}; + use super::async_util::{async_tasks::*, ASYNC_TESTS_JL}; fn init() -> Arc> { unsafe { diff --git a/jlrs/tests/async_std_rt_workers.rs b/jlrs/tests/async_std_rt_workers.rs index e4dc91a7..9efa65db 100644 --- a/jlrs/tests/async_std_rt_workers.rs +++ b/jlrs/tests/async_std_rt_workers.rs @@ -3,7 +3,7 @@ not(any(feature = "julia-1-6", feature = "julia-1-7", feature = "julia-1-8")), ))] #[cfg(test)] -mod util; +mod async_util; #[cfg(all( feature = "async-std-rt", @@ -16,7 +16,7 @@ mod tests { use jlrs::prelude::*; use once_cell::sync::OnceCell; - use super::util::{async_tasks::*, ASYNC_TESTS_JL}; + use super::async_util::{async_tasks::*, ASYNC_TESTS_JL}; fn init() -> Arc> { unsafe { diff --git a/jlrs/tests/util/AsyncTests.jl b/jlrs/tests/async_util/AsyncTests.jl similarity index 89% rename from jlrs/tests/util/AsyncTests.jl rename to jlrs/tests/async_util/AsyncTests.jl index dedd153e..762b6e80 100644 --- a/jlrs/tests/util/AsyncTests.jl +++ b/jlrs/tests/async_util/AsyncTests.jl @@ -1,5 +1,5 @@ module AsyncTests -function kwfunc(dims::Int, iters::Int; kw::Float64=3.0)::Float64 +function kwfunc(dims, iters; kw::Float64=3.0)::Float64 x::Array{Float64, 2} = ones(Float64, (dims, dims)) for i in 1:iters x .+= 1.0 diff --git a/jlrs/tests/util/async_tasks.rs b/jlrs/tests/async_util/async_tasks.rs similarity index 80% rename from jlrs/tests/util/async_tasks.rs rename to jlrs/tests/async_util/async_tasks.rs index a9d35434..109dcdaf 100644 --- a/jlrs/tests/util/async_tasks.rs +++ b/jlrs/tests/async_util/async_tasks.rs @@ -14,6 +14,10 @@ impl AsyncTask for MyTask { let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); + // println!("MyTask"); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + let v = unsafe { Module::main(&frame) .submodule(&frame, "AsyncTests")? @@ -21,12 +25,14 @@ impl AsyncTask for MyTask { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? }; + // println!("MyTask done"); + Ok(v) } } @@ -42,9 +48,12 @@ impl AsyncTask for OtherRetTypeTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("OtherRetTypeTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + let v = unsafe { Module::main(&frame) .submodule(&frame, "AsyncTests")? @@ -52,12 +61,13 @@ impl AsyncTask for OtherRetTypeTask { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? as f32 }; + // println!("OtherRetTypeTask done"); Ok(v) } } @@ -73,10 +83,13 @@ impl AsyncTask for KwTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("KwTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); let kw = Value::new(&mut frame, 5.0f64); - let nt = named_tuple!(frame.as_extended_target(), "kw" => kw); + let nt = named_tuple!(&mut frame, "kw" => kw); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let v = unsafe { Module::main(&frame) @@ -85,11 +98,12 @@ impl AsyncTask for KwTask { .function(&frame, "kwfunc")? .as_managed() .provide_keywords(nt)? - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? as f32 }; + // println!("KwTask done"); Ok(v) } @@ -103,6 +117,7 @@ impl AsyncTask for ThrowingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("ThrowingTask"); let v = unsafe { Module::main(&frame) .submodule(&frame, "AsyncTests")? @@ -115,6 +130,9 @@ impl AsyncTask for ThrowingTask { .unbox::()? as f32 }; + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // println!("ThrowingTask done"); + Ok(v) } } @@ -130,6 +148,7 @@ impl AsyncTask for NestingTaskAsyncFrame { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("NestingTaskAsyncFrame"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); @@ -142,7 +161,7 @@ impl AsyncTask for NestingTaskAsyncFrame { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() .unbox::() @@ -150,6 +169,9 @@ impl AsyncTask for NestingTaskAsyncFrame { }) .await?; + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // println!("NestingTaskAsyncFrame done"); + Ok(v) } } @@ -165,9 +187,13 @@ impl AsyncTask for NestingTaskAsyncValueFrame { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("NestingTaskAsyncValueFrame"); let output = frame.output(); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let v = (&mut frame) .async_scope(|mut frame| async move { + // println!("NestingTaskAsyncFrame"); let iters = Value::new(&mut frame, self.iters); let dims = Value::new(&mut frame, self.dims); @@ -178,7 +204,7 @@ impl AsyncTask for NestingTaskAsyncValueFrame { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() }; @@ -187,6 +213,7 @@ impl AsyncTask for NestingTaskAsyncValueFrame { }) .await? .unbox::()?; + // println!("NestingTaskAsyncValueFrame done"); Ok(v) } @@ -203,6 +230,7 @@ impl AsyncTask for NestingTaskAsyncCallFrame { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("NestingTaskAsyncCallFrame"); let output = frame.output(); let v = frame .async_scope(|mut frame| async move { @@ -216,10 +244,12 @@ impl AsyncTask for NestingTaskAsyncCallFrame { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await }; + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + let out = { match out { Ok(v) => Ok(v.root(output)), @@ -232,6 +262,7 @@ impl AsyncTask for NestingTaskAsyncCallFrame { .await? .unwrap() .unbox::()?; + // println!("NestingTaskAsyncCallFrame done"); Ok(v) } @@ -248,9 +279,12 @@ impl AsyncTask for NestingTaskAsyncGcFrame { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("NestingTaskAsyncGcFrame"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + let v = frame .async_scope(|mut frame| async move { unsafe { @@ -260,13 +294,14 @@ impl AsyncTask for NestingTaskAsyncGcFrame { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() .unbox::() } }) .await?; + // println!("NestingTaskAsyncGcFrame done"); Ok(v) } @@ -283,6 +318,7 @@ impl AsyncTask for NestingTaskAsyncDynamicValueFrame { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("NestingTaskAsyncDynamicValueFrame"); let output = frame.output(); let v = frame .async_scope(|mut frame| async move { @@ -299,7 +335,7 @@ impl AsyncTask for NestingTaskAsyncDynamicValueFrame { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await .unwrap() }; @@ -308,6 +344,7 @@ impl AsyncTask for NestingTaskAsyncDynamicValueFrame { }) .await? .unbox::()?; + // println!("NestingTaskAsyncDynamicValueFrame done"); Ok(v) } @@ -324,6 +361,7 @@ impl AsyncTask for NestingTaskAsyncDynamicCallFrame { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("NestingTaskAsyncDynamicCallFrame"); let output = frame.output(); let v = frame .async_scope(|mut frame| async move { @@ -340,7 +378,7 @@ impl AsyncTask for NestingTaskAsyncDynamicCallFrame { .function(&frame, "complexfunc")? .as_managed() .as_value() - .call_async(&mut frame, &mut [dims, iters]) + .call_async(&mut frame, [dims, iters]) .await }; frame.gc_collect(jlrs::memory::gc::GcCollection::Full); @@ -358,6 +396,7 @@ impl AsyncTask for NestingTaskAsyncDynamicCallFrame { .await? .unwrap() .unbox::()?; + // println!("NestingTaskAsyncDynamicCallFrame done"); Ok(v) } @@ -388,10 +427,11 @@ impl PersistentTask for AccumulatorTask { &mut self, mut frame: AsyncGcFrame<'frame>, ) -> JlrsResult> { + // println!("AccumulatorTask intit"); unsafe { let output = frame.output(); let init_value = self.init_value; - frame + let res = frame .async_scope(|mut frame| { async move { // A nested scope is used to only root a single value in the frame provided to @@ -401,11 +441,16 @@ impl PersistentTask for AccumulatorTask { .as_value(); let init_v = Value::new(&mut frame, init_value); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Ok(func.call1(output, init_v)) } }) .await? - .into_jlrs_result() + .into_jlrs_result(); + + // println!("AccumulatorTask intit"); + res } } @@ -415,6 +460,7 @@ impl PersistentTask for AccumulatorTask { state: &mut Self::State<'state>, input: Self::Input, ) -> JlrsResult { + // println!("AccumulatorTask run"); let value = state.field_accessor().field("v")?.access::()? + input; let new_value = Value::new(&mut frame, value); @@ -424,6 +470,9 @@ impl PersistentTask for AccumulatorTask { .into_jlrs_result()?; } + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // println!("AccumulatorTask run done"); + Ok(value) } } @@ -439,6 +488,7 @@ impl AsyncTask for LocalTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("LocalTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); @@ -448,12 +498,15 @@ impl AsyncTask for LocalTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .call_async_local(&mut frame, &mut [dims, iters]) + .call_async_local(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? as f32 }; + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // println!("LocalTask done"); + Ok(v) } } @@ -469,6 +522,7 @@ impl AsyncTask for LocalSchedulingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("LocalSchedulingTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); @@ -478,9 +532,11 @@ impl AsyncTask for LocalSchedulingTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .schedule_async_local(&mut frame, &mut [dims, iters]) + .schedule_async_local(&mut frame, [dims, iters]) .unwrap(); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Module::base(&frame) .function(&mut frame, "fetch")? .call1(&mut frame, task.as_value()) @@ -488,6 +544,8 @@ impl AsyncTask for LocalSchedulingTask { .unbox::()? as f32 }; + // println!("LocalSchedulingTask done"); + Ok(v) } } @@ -503,6 +561,7 @@ impl AsyncTask for MainTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("MainTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); @@ -512,12 +571,15 @@ impl AsyncTask for MainTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .call_async_main(&mut frame, &mut [dims, iters]) + .call_async_main(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? as f32 }; + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + // println!("MainTask done"); + Ok(v) } } @@ -533,6 +595,7 @@ impl AsyncTask for MainSchedulingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("MainSchedulingTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); @@ -542,15 +605,18 @@ impl AsyncTask for MainSchedulingTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .schedule_async_main(&mut frame, &mut [dims, iters]) + .schedule_async_main(&mut frame, [dims, iters]) .unwrap(); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Module::base(&frame) .function(&mut frame, "fetch")? .call1(&mut frame, task.as_value()) .into_jlrs_result()? .unbox::()? as f32 }; + // println!("MainSchedulingTask done"); Ok(v) } @@ -567,6 +633,7 @@ impl AsyncTask for SchedulingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("SchedulingTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); @@ -576,9 +643,11 @@ impl AsyncTask for SchedulingTask { .as_managed() .function(&frame, "complexfunc")? .as_managed() - .schedule_async(&mut frame, &mut [dims, iters]) + .schedule_async(&mut frame, [dims, iters]) .unwrap(); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Module::base(&frame) .function(&mut frame, "fetch")? .call1(&mut frame, task.as_value()) @@ -586,6 +655,7 @@ impl AsyncTask for SchedulingTask { .unbox::()? as f32 }; + // println!("SchedulingTask done"); Ok(v) } } @@ -601,12 +671,13 @@ impl AsyncTask for LocalKwSchedulingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("LocalKwSchedulingTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); let v = unsafe { let kw = Value::new(&mut frame, 5.0f64); - let nt = named_tuple!(frame.as_extended_target(), "kw" => kw); + let nt = named_tuple!(&mut frame, "kw" => kw); let task = Module::main(&frame) .submodule(&frame, "AsyncTests")? @@ -614,15 +685,18 @@ impl AsyncTask for LocalKwSchedulingTask { .function(&frame, "kwfunc")? .as_managed() .provide_keywords(nt)? - .schedule_async_local(&mut frame, &mut [dims, iters]) + .schedule_async_local(&mut frame, [dims, iters]) .unwrap(); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Module::base(&frame) .function(&mut frame, "fetch")? .call1(&mut frame, task.as_value()) .into_jlrs_result()? .unbox::()? as f32 }; + // println!("LocalKwSchedulingTask done"); Ok(v) } @@ -639,12 +713,13 @@ impl AsyncTask for KwSchedulingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("KwSchedulingTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); let v = unsafe { let kw = Value::new(&mut frame, 5.0f64); - let nt = named_tuple!(frame.as_extended_target(), "kw" => kw); + let nt = named_tuple!(&mut frame, "kw" => kw); let task = Module::main(&frame) .submodule(&frame, "AsyncTests")? @@ -652,15 +727,18 @@ impl AsyncTask for KwSchedulingTask { .function(&frame, "kwfunc")? .as_managed() .provide_keywords(nt)? - .schedule_async(&mut frame, &mut [dims, iters]) + .schedule_async(&mut frame, [dims, iters]) .unwrap(); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Module::base(&frame) .function(&mut frame, "fetch")? .call1(&mut frame, task.as_value()) .into_jlrs_result()? .unbox::()? as f32 }; + // println!("KwSchedulingTask done"); Ok(v) } @@ -677,12 +755,13 @@ impl AsyncTask for MainKwSchedulingTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("MainKwSchedulingTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); let v = unsafe { let kw = Value::new(&mut frame, 5.0f64); - let nt = named_tuple!(frame.as_extended_target(), "kw" => kw); + let nt = named_tuple!(&mut frame, "kw" => kw); let task = Module::main(&frame) .submodule(&frame, "AsyncTests")? @@ -690,15 +769,18 @@ impl AsyncTask for MainKwSchedulingTask { .function(&frame, "kwfunc")? .as_managed() .provide_keywords(nt)? - .schedule_async_main(&mut frame, &mut [dims, iters]) + .schedule_async_main(&mut frame, [dims, iters]) .unwrap(); + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); + Module::base(&frame) .function(&mut frame, "fetch")? .call1(&mut frame, task.as_value()) .into_jlrs_result()? .unbox::()? as f32 }; + // println!("MainKwSchedulingTask done"); Ok(v) } @@ -715,10 +797,13 @@ impl AsyncTask for LocalKwTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("LocalKwTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); let kw = Value::new(&mut frame, 5.0f64); - let nt = named_tuple!(frame.as_extended_target(), "kw" => kw); + let nt = named_tuple!(&mut frame, "kw" => kw); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let v = unsafe { Module::main(&frame) @@ -727,11 +812,12 @@ impl AsyncTask for LocalKwTask { .function(&frame, "kwfunc")? .as_managed() .provide_keywords(nt)? - .call_async_local(&mut frame, &mut [dims, iters]) + .call_async_local(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? as f32 }; + // println!("LocalKwTask done"); Ok(v) } @@ -748,10 +834,13 @@ impl AsyncTask for MainKwTask { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("MainKwTask"); let dims = Value::new(&mut frame, self.dims); let iters = Value::new(&mut frame, self.iters); let kw = Value::new(&mut frame, 5.0f64); - let nt = named_tuple!(frame.as_extended_target(), "kw" => kw); + let nt = named_tuple!(&mut frame, "kw" => kw); + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); let v = unsafe { Module::main(&frame) @@ -760,11 +849,12 @@ impl AsyncTask for MainKwTask { .function(&frame, "kwfunc")? .as_managed() .provide_keywords(nt)? - .call_async_main(&mut frame, &mut [dims, iters]) + .call_async_main(&mut frame, [dims, iters]) .await .unwrap() .unbox::()? as f32 }; + // println!("MainKwTask done"); Ok(v) } @@ -778,23 +868,24 @@ impl AsyncTask for BorrowArrayData { type Affinity = DispatchAny; async fn run<'base>(&mut self, mut frame: AsyncGcFrame<'base>) -> JlrsResult { + // println!("BorrowArrayData"); let mut data = vec![2.0f64]; let borrowed = &mut data; let output = frame.output(); let v = unsafe { frame - .relaxed_async_scope(|mut frame| async move { - let output_scope = output.into_extended_target(&mut frame); - Array::from_slice(output_scope, borrowed, 1) - }) + .relaxed_async_scope(|_frame| async move { Array::from_slice(output, borrowed, 1) }) .await? .into_jlrs_result()? }; let data2 = unsafe { v.inline_data::()? }; + + frame.gc_collect(jlrs::memory::gc::GcCollection::Full); // Uncommenting next line must be compile error // let _ = data[0]; let v = data2[0]; + // println!("BorrowArrayData done"); Ok(v) } } diff --git a/jlrs/tests/async_util/mod.rs b/jlrs/tests/async_util/mod.rs new file mode 100644 index 00000000..9067c228 --- /dev/null +++ b/jlrs/tests/async_util/mod.rs @@ -0,0 +1,6 @@ +#[cfg(all(feature = "async-rt",))] +#[allow(dead_code)] +pub static ASYNC_TESTS_JL: &'static str = include_str!("AsyncTests.jl"); + +#[cfg(all(feature = "async-rt",))] +pub mod async_tasks; diff --git a/jlrs/tests/borrow_array.rs b/jlrs/tests/borrow_array.rs index 80048463..294acb48 100644 --- a/jlrs/tests/borrow_array.rs +++ b/jlrs/tests/borrow_array.rs @@ -15,8 +15,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let array = Array::from_slice(frame.as_extended_target(), &mut data, 4)? - .into_jlrs_result()?; + let array = Array::from_slice(&mut frame, &mut data, 4)?.into_jlrs_result()?; assert!(array.contains::()); unsafe { array.copy_inline_data::() } }) @@ -41,8 +40,7 @@ mod tests { let output = frame.output(); let array = frame.scope(|mut frame| { let borrowed = &mut data; - let arr = Array::from_slice(frame.as_extended_target(), borrowed, 4)? - .into_jlrs_result()?; + let arr = Array::from_slice(&mut frame, borrowed, 4)?.into_jlrs_result()?; Ok(arr.root(output)) })?; diff --git a/jlrs/tests/borrow_array_data.rs b/jlrs/tests/borrow_array_data.rs index c1ed31b2..169384f6 100644 --- a/jlrs/tests/borrow_array_data.rs +++ b/jlrs/tests/borrow_array_data.rs @@ -21,8 +21,8 @@ mod tests { jlrs.scope(|mut frame| unsafe { let data: Vec<$value_type> = (1..=24).map(|x| x as $value_type).collect(); - let array = Array::from_vec(frame.as_extended_target(), data, (2, 3, 4))? - .into_jlrs_result()?; + let array = + Array::from_vec(&mut frame, data, (2, 3, 4))?.into_jlrs_result()?; let d = array.inline_data::<$value_type>()?; let mut out = 1 as $value_type; @@ -51,7 +51,7 @@ mod tests { let v = gi .call( &mut frame, - &mut [array.as_value(), *first, *second, *third], + [array.as_value(), *first, *second, *third], ) .unwrap(); assert_eq!(v.unbox::<$value_type>()?, out); @@ -81,8 +81,7 @@ mod tests { (1..=24).map(|x| x as $value_type).collect(); let mut array = - Array::from_vec(frame.as_extended_target(), data, (2, 3, 4))? - .into_jlrs_result()?; + Array::from_vec(&mut frame, data, (2, 3, 4))?.into_jlrs_result()?; let mut d = array.bits_data_mut::<$value_type>()?; for third in &[0, 1, 2, 3] { @@ -108,12 +107,7 @@ mod tests { let v = gi .call( &mut frame, - &mut [ - array.as_value(), - *first, - *second, - *third, - ], + [array.as_value(), *first, *second, *third], ) .unwrap(); assert_eq!(v.unbox::<$value_type>()?, out); @@ -140,12 +134,8 @@ mod tests { let data: Vec<$value_type> = (1..=24).map(|x| x as $value_type).collect(); - let array = Array::from_vec( - frame.as_extended_target(), - data.clone(), - (2, 3, 4), - )? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data.clone(), (2, 3, 4))? + .into_jlrs_result()?; let d = array.inline_data::<$value_type>()?; for (a, b) in data.iter().zip(d.as_slice()) { @@ -168,12 +158,8 @@ mod tests { let data: Vec<$value_type> = (1..=24).map(|x| x as $value_type).collect(); - let mut array = Array::from_vec( - frame.as_extended_target(), - data.clone(), - (2, 3, 4), - )? - .into_jlrs_result()?; + let mut array = Array::from_vec(&mut frame, data.clone(), (2, 3, 4))? + .into_jlrs_result()?; let mut d = array.bits_data_mut::<$value_type>()?; for (a, b) in data.iter().zip(d.as_mut_slice()) { @@ -268,8 +254,7 @@ mod tests { .scope(|mut frame| unsafe { let data: Vec = (1..=24).map(|x| x as u8).collect(); - let array = Array::from_vec(frame.as_extended_target(), data, (2, 3, 4))? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, (2, 3, 4))?.into_jlrs_result()?; frame.scope(|mut frame| { let d = { array.inline_data::()? }; @@ -300,7 +285,7 @@ mod tests { let v = gi .call( &mut frame, - &mut [array.as_value(), *first, *second, *third], + [array.as_value(), *first, *second, *third], ) .unwrap(); assert_eq!(v.unbox::()?, out); @@ -325,8 +310,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.inline_data::()? }; @@ -345,8 +329,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let mut arr = arr_val; let data = unsafe { arr.inline_data_mut::()? }; diff --git a/jlrs/tests/bounds_error.rs b/jlrs/tests/bounds_error.rs index b5193cd0..b74e1a46 100644 --- a/jlrs/tests/bounds_error.rs +++ b/jlrs/tests/bounds_error.rs @@ -16,8 +16,7 @@ mod tests { frame.scope(|mut frame| unsafe { let idx = Value::new(&mut frame, 4usize); let data = vec![1.0f64, 2., 3.]; - let array = Array::from_vec(frame.as_extended_target(), data, 3)? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; let func = Module::base(&frame) .function(&frame, "getindex")? .as_managed(); diff --git a/jlrs/tests/call_exception.rs b/jlrs/tests/call_exception.rs index 87f8f7d3..47946c34 100644 --- a/jlrs/tests/call_exception.rs +++ b/jlrs/tests/call_exception.rs @@ -34,7 +34,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let arg = Value::new(&mut frame, 1usize); - let kw = named_tuple!(frame.as_extended_target(), "a" => arg); + let kw = named_tuple!(&mut frame, "a" => arg); let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? @@ -81,7 +81,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let arg = Value::new(&mut frame, 1usize); - let kw = named_tuple!(frame.as_extended_target(), "a" => arg); + let kw = named_tuple!(&mut frame, "a" => arg); let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? @@ -128,7 +128,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let arg = Value::new(&mut frame, 1usize); - let kw = named_tuple!(frame.as_extended_target(), "a" => arg); + let kw = named_tuple!(&mut frame, "a" => arg); let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? @@ -175,7 +175,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let arg = Value::new(&mut frame, 1usize); - let kw = named_tuple!(frame.as_extended_target(), "a" => arg); + let kw = named_tuple!(&mut frame, "a" => arg); let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? @@ -221,7 +221,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let arg = Value::new(&mut frame, 1usize); - let kw = named_tuple!(frame.as_extended_target(), "a" => arg); + let kw = named_tuple!(&mut frame, "a" => arg); let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? diff --git a/jlrs/tests/ccall.rs b/jlrs/tests/ccall.rs index b119d12c..4bf23549 100644 --- a/jlrs/tests/ccall.rs +++ b/jlrs/tests/ccall.rs @@ -66,8 +66,7 @@ mod tests { .scope(|mut frame| unsafe { let fn_ptr = Value::new(&mut frame, doesnt_use_scope as *mut std::ffi::c_void); let mut arr_data = vec![0.0f64, 1.0f64]; - let arr = - Array::from_slice_unchecked(frame.as_extended_target(), &mut arr_data, 2)?; + let arr = Array::from_slice_unchecked(&mut frame, &mut arr_data, 2)?; let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? .as_managed() @@ -92,8 +91,7 @@ mod tests { .scope(|mut frame| unsafe { let fn_ptr = Value::new(&mut frame, uses_scope as *mut std::ffi::c_void); let mut arr_data = vec![0.0f64, 1.0f64]; - let arr = - Array::from_slice_unchecked(frame.as_extended_target(), &mut arr_data, 2)?; + let arr = Array::from_slice_unchecked(&mut frame, &mut arr_data, 2)?; let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? .as_managed() @@ -121,8 +119,7 @@ mod tests { uses_scope_with_realloced_slots as *mut std::ffi::c_void, ); let mut arr_data = vec![0.0f64, 1.0f64]; - let arr = - Array::from_slice_unchecked(frame.as_extended_target(), &mut arr_data, 2)?; + let arr = Array::from_slice_unchecked(&mut frame, &mut arr_data, 2)?; let func = Module::main(&frame) .submodule(&frame, "JlrsTests")? .as_managed() diff --git a/jlrs/tests/copied_array.rs b/jlrs/tests/copied_array.rs index ded3c226..fcf37f3f 100644 --- a/jlrs/tests/copied_array.rs +++ b/jlrs/tests/copied_array.rs @@ -15,8 +15,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr_val = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr_val = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.copy_inline_data::()? }; diff --git a/jlrs/tests/datatype.rs b/jlrs/tests/datatype.rs index 808ea738..7f7c56a1 100644 --- a/jlrs/tests/datatype.rs +++ b/jlrs/tests/datatype.rs @@ -568,7 +568,7 @@ mod tests { let mut jlrs = j.borrow_mut(); jlrs.instance(&mut frame) .scope(|mut frame| { - let ty = TypedArray::::new(frame.as_extended_target(), 1) + let ty = TypedArray::::new(&mut frame, 1) .into_jlrs_result()? .as_value() .datatype(); diff --git a/jlrs/tests/derive.rs b/jlrs/tests/derive.rs index c26cab52..ae597f7c 100644 --- a/jlrs/tests/derive.rs +++ b/jlrs/tests/derive.rs @@ -1,11 +1,14 @@ #[cfg(all(test, feature = "jlrs-derive", feature = "sync-rt"))] -mod util; +mod derive_util; #[cfg(all(test, feature = "jlrs-derive", feature = "sync-rt"))] mod tests { - use jlrs::prelude::*; + use jlrs::{ + data::types::construct_type::{ConstantBool, ConstructType}, + prelude::*, + }; - use super::util::{new_derive_impls::*, JULIA_DERIVE}; + use super::derive_util::{derive_impls::*, JULIA_DERIVE}; fn derive_bits_type_bool() { JULIA_DERIVE.with(|j| { let mut julia = j.borrow_mut(); @@ -28,28 +31,164 @@ mod tests { }) } - /* - fn derive_generic_tu() { - JULIA_DERIVE.with(|j| { - let mut julia = j.borrow_mut(); - let mut frame = StackFrame::new(); - - julia - .instance(&mut frame) - .scope(|mut frame| { - let ty = - WithGenericTU::::construct_type(frame.as_extended_target()); - assert_eq!( - ty.size() as usize, - std::mem::size_of::() + std::mem::size_of::() - ); - Ok(()) - }) - .unwrap(); - }) - } - */ - /* + fn derive_elided() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| { + let a = HasElidedParam { a: 3.0 }; + type ElidedParam = + HasElidedParamTypeConstructor>; + let v = unsafe { + Value::try_new_with::, _, _>(&mut frame, a)? + }; + + assert!(v.is::>()); + assert!(v.unbox::>().is_ok()); + + Ok(()) + }) + .unwrap(); + }) + } + + fn derive_elided_with_ptr() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| { + let main_mod = Module::main(&frame).as_ref(); + let a = HasElidedParam { a: Some(main_mod) }; + type ElidedParam = + HasElidedParamTypeConstructor>; + let v = unsafe { + Value::try_new_with::, _, _>(&mut frame, a)? + }; + + assert!(v.is::>>()); + assert!(v.unbox::>>().is_ok()); + + Ok(()) + }) + .unwrap(); + }) + } + + fn derive_double_variant() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| unsafe { + let constr = Module::main(&frame) + .global(&frame, "DoubleVariant")? + .as_managed() + .cast::()?; + + let v2 = Value::new(&mut frame, 2i16); + let jl_val = constr + .instantiate(&mut frame, &mut [v2])? + .into_jlrs_result()?; + + assert!(jl_val.datatype().is::()); + + let field = jl_val.get_nth_field(&mut frame, 0).unwrap(); + assert_eq!(field.unbox::().unwrap(), 2); + + assert!(jl_val.is::()); + assert!(jl_val.unbox::().is_ok()); + + Ok(()) + }) + .unwrap(); + }) + } + + fn rebox_double_variant() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| unsafe { + let constr = Module::main(&frame) + .global(&frame, "DoubleVariant")? + .as_managed() + .cast::()?; + + let v2 = Value::new(&mut frame, 2i16); + let jl_val = constr + .instantiate(&mut frame, &mut [v2])? + .into_jlrs_result()?; + + let unboxed = jl_val.unbox::()?; + assert!( + Value::try_new_with::(&mut frame, unboxed).is_ok() + ); + + Ok(()) + }) + .unwrap(); + }) + } + + fn cannot_rebox_as_incompatible() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| unsafe { + let constr = Module::main(&frame) + .global(&frame, "DoubleVariant")? + .as_managed() + .cast::()?; + + let v2 = Value::new(&mut frame, 2i16); + let jl_val = constr + .instantiate(&mut frame, &mut [v2])? + .into_jlrs_result()?; + + let unboxed = jl_val.unbox::()?; + assert!( + Value::try_new_with::(&mut frame, unboxed).is_err() + ); + + Ok(()) + }) + .unwrap(); + }) + } + + fn derive_generic_tu() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| { + let ty = WithGenericTU::::construct_type(&mut frame); + assert_eq!( + ty.cast::().unwrap().size().unwrap() as usize, + std::mem::size_of::() + std::mem::size_of::() + ); + Ok(()) + }) + .unwrap(); + }) + } + fn derive_bits_type_char() { JULIA_DERIVE.with(|j| { let mut julia = j.borrow_mut(); @@ -497,10 +636,8 @@ mod tests { let constr = Module::main(&frame) .global(&frame, "SingleVariant")? .as_managed(); - let v1 = Value::new(&mut frame, 1i8); let v2 = Value::new(&mut frame, 2i32); - let v3 = Value::new(&mut frame, 3i8); - let jl_val = constr.call3(&mut frame, v1, v2, v3).unwrap(); + let jl_val = constr.call1(&mut frame, v2).unwrap(); assert!(Module::base(&frame) .function(&frame, "typeof")? @@ -510,12 +647,6 @@ mod tests { .cast::()? .is::()); - let first = jl_val.get_nth_field(&mut frame, 0).unwrap(); - assert_eq!(first.unbox::().unwrap(), 1); - - let third = jl_val.get_nth_field(&mut frame, 2).unwrap(); - assert_eq!(third.unbox::().unwrap(), 3); - assert!(jl_val.is::()); assert!(jl_val.unbox::().is_ok()); @@ -525,53 +656,6 @@ mod tests { }) } - #[cfg(not(all(target_os = "windows", feature = "julia-1-6")))] - fn derive_double_variant() { - JULIA_DERIVE.with(|j| { - let mut julia = j.borrow_mut(); - let mut frame = StackFrame::new(); - - julia - .instance(&mut frame) - .scope(|mut frame| unsafe { - let constr = Module::main(&frame) - .global(&frame, "DoubleVariant")? - .as_managed() - .cast::()?; - - let v1 = Value::new(&mut frame, 1i8); - let v2 = Value::new(&mut frame, 2i16); - let v3 = Value::new(&mut frame, 3i8); - let jl_val = constr - .instantiate(&mut frame, &mut [v1, v2, v3])? - .into_jlrs_result()?; - - assert!(Module::base(&frame) - .function(&frame, "typeof")? - .as_managed() - .call1(&mut frame, jl_val) - .unwrap() - .cast::()? - .is::()); - - let first = jl_val.get_nth_field(&mut frame, 0).unwrap(); - assert_eq!(first.unbox::().unwrap(), 1); - - let second = jl_val.get_nth_field(&mut frame, 1).unwrap(); - assert_eq!(second.unbox::().unwrap(), 2); - - let third = jl_val.get_nth_field(&mut frame, 2).unwrap(); - assert_eq!(third.unbox::().unwrap(), 3); - - assert!(jl_val.is::()); - assert!(jl_val.unbox::().is_ok()); - - Ok(()) - }) - .unwrap(); - }) - } - fn derive_size_align_mismatch() { JULIA_DERIVE.with(|j| { let mut julia = j.borrow_mut(); @@ -584,10 +668,8 @@ mod tests { .global(&frame, "SizeAlignMismatch")? .as_managed(); - let v1 = Value::new(&mut frame, 1i8); let v2 = Value::new(&mut frame, 2i32); - let v3 = Value::new(&mut frame, 3i8); - let jl_val = constr.call3(&mut frame, v1, v2, v3).unwrap(); + let jl_val = constr.call1(&mut frame, v2).unwrap(); assert!(Module::base(&frame) .function(&frame, "typeof")? @@ -597,15 +679,9 @@ mod tests { .cast::()? .is::()); - let first = jl_val.get_nth_field(&mut frame, 0).unwrap(); - assert_eq!(first.unbox::().unwrap(), 1); - - let second = jl_val.get_nth_field(&mut frame, 1).unwrap(); + let second = jl_val.get_nth_field(&mut frame, 0).unwrap(); assert_eq!(second.unbox::().unwrap(), 2); - let third = jl_val.get_nth_field(&mut frame, 2).unwrap(); - assert_eq!(third.unbox::().unwrap(), 3); - assert!(jl_val.is::()); assert!(jl_val.unbox::().is_ok()); @@ -627,20 +703,12 @@ mod tests { .global(&frame, "UnionInTuple")? .as_managed(); - let v1 = Value::new(&mut frame, 1i8); let v2 = Value::new(&mut frame, Tuple1(2i32)); - let v3 = Value::new(&mut frame, 3i8); - let jl_val = constr.call3(&mut frame, v1, v2, v3).unwrap(); - - let first = jl_val.get_nth_field(&mut frame, 0).unwrap(); - assert_eq!(first.unbox::().unwrap(), 1); + let jl_val = constr.call1(&mut frame, v2).unwrap(); - let second = jl_val.get_nth_field(&mut frame, 1).unwrap(); + let second = jl_val.get_nth_field(&mut frame, 0).unwrap(); assert_eq!(second.unbox::>().unwrap(), Tuple1(2)); - let third = jl_val.get_nth_field(&mut frame, 2).unwrap(); - assert_eq!(third.unbox::().unwrap(), 3); - let _uit = jl_val.unbox::()?; Ok(()) @@ -658,8 +726,6 @@ mod tests { .instance(&mut frame) .scope(|mut frame| unsafe { let constr = Module::main(&frame) - .submodule(&frame, "WithNonBitsUnion")? - .as_managed() .global(&frame, "NonBitsUnion")? .as_managed(); @@ -686,40 +752,40 @@ mod tests { }) } - /* - #[test] - fn derive_string() { - JULIA_DERIVE.with(|j| { - let mut julia = j.borrow_mut(); - let mut frame = StackFrame::new(); + fn derive_string() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); - julia.instance(&mut frame) .scope(|mut frame| unsafe { - let constr = Module::main(&frame) - .submodule(&frame, "WithStrings")?.as_managed() - .global(&frame, "WithString")?.as_managed(); + julia + .instance(&mut frame) + .scope(|mut frame| unsafe { + let constr = Module::main(&frame) + .global(&frame, "WithString")? + .as_managed(); - let v1 = Value::new(&mut frame, "foo")?; - let jl_val = constr.call1(&mut frame, v1)?.unwrap(); + let s = JuliaString::new(&mut frame, "foo"); + let jl_val = constr.call1(&mut frame, s.as_value()).into_jlrs_result()?; - assert!(Module::base(&frame) - .function(&frame, "typeof")?.as_managed() - .call1(&mut frame, jl_val)? - .unwrap() - .cast::()? - .is::()); + assert!(Module::base(&frame) + .function(&frame, "typeof")? + .as_managed() + .call1(&mut frame, jl_val) + .into_jlrs_result()? + .cast::()? + .is::()); - let first = jl_val.get_nth_field(&mut frame, 0).unwrap(); - assert_eq!(first.unbox::().unwrap().unwrap(), "foo"); + let first = jl_val.get_nth_field(&mut frame, 0).unwrap(); + assert_eq!(first.unbox::().unwrap().unwrap(), "foo"); - assert!(jl_val.is::()); - assert!(jl_val.unbox::().is_ok()); + assert!(jl_val.is::()); + assert!(jl_val.unbox::().is_ok()); - Ok(()) - }) - .unwrap() - }) - } - */ + Ok(()) + }) + .unwrap(); + }) + } fn derive_with_generic_t_i32() { JULIA_DERIVE.with(|j| { @@ -730,8 +796,6 @@ mod tests { .instance(&mut frame) .scope(|mut frame| unsafe { let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -767,8 +831,6 @@ mod tests { .instance(&mut frame) .scope(|mut frame| unsafe { let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -776,8 +838,6 @@ mod tests { let wgt = constr.call1(&mut frame, v1).unwrap(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericUnionAll")? .as_managed(); @@ -812,8 +872,6 @@ mod tests { .instance(&mut frame) .scope(|mut frame| unsafe { let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -821,8 +879,6 @@ mod tests { let wgt = constr.call1(&mut frame, v1).unwrap(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithNestedGenericT")? .as_managed(); @@ -858,8 +914,6 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -868,8 +922,6 @@ mod tests { .unwrap(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithPropagatedLifetime")? .as_managed(); @@ -895,7 +947,6 @@ mod tests { }) } - #[cfg(not(all(target_os = "windows", feature = "julia-1-6")))] fn derive_with_propagated_lifetimes() { JULIA_DERIVE.with(|j| { let mut julia = j.borrow_mut(); @@ -904,12 +955,9 @@ mod tests { julia .instance(&mut frame) .scope(|mut frame| unsafe { - let arr = Array::new::(frame.as_extended_target(), (2, 2)) - .into_jlrs_result()?; + let arr = Array::new::(&mut frame, (2, 2)).into_jlrs_result()?; let wgt_constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -921,8 +969,6 @@ mod tests { let a = wgt_constr.call1(&mut frame, tup).unwrap(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithPropagatedLifetimes")? .as_managed(); @@ -959,8 +1005,6 @@ mod tests { .instance(&mut frame) .scope(|mut frame| unsafe { let wgt_constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -968,8 +1012,6 @@ mod tests { let wgt = wgt_constr.call1(&mut frame, v1).unwrap(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithSetGeneric")? .as_managed(); @@ -1004,8 +1046,6 @@ mod tests { .instance(&mut frame) .scope(|mut frame| unsafe { let wgt_constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithGenericT")? .as_managed(); @@ -1016,8 +1056,6 @@ mod tests { let v2 = tup_constr.call1(&mut frame, wgt).unwrap(); let constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? - .as_managed() .global(&frame, "WithSetGenericTuple")? .as_managed(); @@ -1051,11 +1089,12 @@ mod tests { julia .instance(&mut frame) .scope(|mut frame| unsafe { + let b = Value::new(&mut frame, true); let wvt_constr = Module::main(&frame) - .submodule(&frame, "WithGeneric")? + .global(&frame, "WithValueType")? .as_managed() - .global(&frame, "withvaluetype")? - .as_managed(); + .apply_type(&mut frame, [b]) + .into_jlrs_result()?; let v1 = Value::new(&mut frame, 1i64); let jl_val = wvt_constr.call1(&mut frame, v1).unwrap(); @@ -1095,45 +1134,89 @@ mod tests { }) .unwrap(); }) - }*/ + } + + fn isbits_into_julia() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| { + let wvt = WithValueType { a: 1 }; + type WVT = WithValueTypeTypeConstructor>; + let v = Value::new_bits_from_layout::(&mut frame, wvt.clone())?; + let wvt_unboxed = v.unbox::()?; + assert_eq!(wvt, wvt_unboxed); + + Ok(()) + }) + .unwrap(); + }) + } + + fn trivial_isbits_into_julia() { + JULIA_DERIVE.with(|j| { + let mut julia = j.borrow_mut(); + let mut frame = StackFrame::new(); + + julia + .instance(&mut frame) + .scope(|mut frame| { + let layout = WithGenericTU { a: 1i32, b: 2u32 }; + let v = Value::new_bits(&mut frame, layout.clone()); + let layout_unboxed = v.unbox::>()?; + assert_eq!(layout, layout_unboxed); + + Ok(()) + }) + .unwrap(); + }) + } #[test] fn derive_tests() { derive_bits_type_bool(); - //derive_generic_tu(); - // derive_bits_type_char(); - // derive_bits_type_uint8(); - // derive_bits_type_uint16(); - // derive_bits_type_uint32(); - // derive_bits_type_uint64(); - // derive_bits_type_uint(); - // derive_bits_type_int8(); - // derive_bits_type_int16(); - // derive_bits_type_int32(); - // derive_bits_type_int64(); - // derive_bits_type_int(); - // derive_bits_type_float32(); - // derive_bits_type_float64(); - // derive_bits_char_float32_float64(); - // derive_bits_int_bool(); - // derive_bits_char_bits_int_char(); - // derive_bits_uint8_tuple_int32_int64(); - // derive_bits_uint8_tuple_int32_tuple_int16_uint16(); - // derive_single_variant(); - // derive_size_align_mismatch(); - // derive_union_in_tuple(); - // derive_non_bits_union(); - // derive_with_generic_t_i32(); - // derive_with_unionall(); - // derive_with_nested_generic(); - // derive_with_propagated_lifetime(); - // derive_with_set_generic(); - // derive_with_set_generic_tuple(); - // derive_with_value_type(); - // derive_zero_sized(); - // #[cfg(not(all(target_os = "windows", feature = "julia-1-6")))] - // derive_double_variant(); - // #[cfg(not(all(target_os = "windows", feature = "julia-1-6")))] - // derive_with_propagated_lifetimes(); + derive_elided(); + derive_elided_with_ptr(); + derive_double_variant(); + rebox_double_variant(); + cannot_rebox_as_incompatible(); + derive_generic_tu(); + derive_bits_type_char(); + derive_bits_type_uint8(); + derive_bits_type_uint16(); + derive_bits_type_uint32(); + derive_bits_type_uint64(); + derive_bits_type_uint(); + derive_bits_type_int8(); + derive_bits_type_int16(); + derive_bits_type_int32(); + derive_bits_type_int64(); + derive_bits_type_int(); + derive_bits_type_float32(); + derive_bits_type_float64(); + derive_bits_char_float32_float64(); + derive_bits_int_bool(); + derive_bits_char_bits_int_char(); + derive_bits_uint8_tuple_int32_int64(); + derive_bits_uint8_tuple_int32_tuple_int16_uint16(); + derive_single_variant(); + derive_size_align_mismatch(); + derive_union_in_tuple(); + derive_non_bits_union(); + derive_with_generic_t_i32(); + derive_with_unionall(); + derive_with_nested_generic(); + derive_with_propagated_lifetime(); + derive_with_set_generic(); + derive_with_set_generic_tuple(); + derive_with_value_type(); + derive_zero_sized(); + derive_with_propagated_lifetimes(); + derive_string(); + isbits_into_julia(); + trivial_isbits_into_julia(); } } diff --git a/jlrs/tests/util/JlrsNewDeriveTests.jl b/jlrs/tests/derive_util/JlrsDeriveTests.jl similarity index 96% rename from jlrs/tests/util/JlrsNewDeriveTests.jl rename to jlrs/tests/derive_util/JlrsDeriveTests.jl index 663aee69..191eeaec 100644 --- a/jlrs/tests/util/JlrsNewDeriveTests.jl +++ b/jlrs/tests/derive_util/JlrsDeriveTests.jl @@ -1,4 +1,4 @@ -# using JlrsReflect +# using JlrsCore.Reflect struct BitsIntChar a::Int @@ -127,6 +127,10 @@ struct DoubleVariant a::Union{Int16, Int32} end +struct DoubleUVariant + a::Union{UInt16, UInt32} +end + struct SizeAlignMismatch a::Union{Tuple{Int16, Int16, Int16}, Int32} end @@ -252,6 +256,10 @@ struct Empty end struct TypedEmpty{T} end +struct HasElidedParam{T, U} + a::T +end + #reflect([ # BitsCharBitsIntChar, # BitsCharFloat32Float64, @@ -276,6 +284,7 @@ struct TypedEmpty{T} end # DoubleHasGeneric, # DoubleImmut, # DoubleVariant, +# DoubleUVariant, # Empty, # HasGeneric, # HasGenericImmut, diff --git a/jlrs/tests/util/new_derive_impls.rs b/jlrs/tests/derive_util/derive_impls.rs similarity index 86% rename from jlrs/tests/util/new_derive_impls.rs rename to jlrs/tests/derive_util/derive_impls.rs index 17fefef0..472f0a22 100644 --- a/jlrs/tests/util/new_derive_impls.rs +++ b/jlrs/tests/derive_util/derive_impls.rs @@ -1,15 +1,5 @@ use jlrs::prelude::*; -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.AnAbstractType")] -pub struct AnAbstractType {} - -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.AnAbstractUnionAll")] -pub struct AnAbstractUnionAll { - _t: ::std::marker::PhantomData, -} - #[repr(C)] #[derive( Clone, @@ -19,14 +9,15 @@ pub struct AnAbstractUnionAll { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, )] -#[jlrs(julia_type = "Main.BitsIntChar")] -pub struct BitsIntChar { - pub a: i64, - pub b: ::jlrs::data::layout::char::Char, +#[jlrs(julia_type = "Main.BitsCharBitsIntChar")] +pub struct BitsCharBitsIntChar { + pub a: ::jlrs::data::layout::char::Char, + pub b: BitsIntChar, } #[repr(C)] @@ -38,14 +29,16 @@ pub struct BitsIntChar { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, )] -#[jlrs(julia_type = "Main.BitsCharBitsIntChar")] -pub struct BitsCharBitsIntChar { +#[jlrs(julia_type = "Main.BitsCharFloat32Float64")] +pub struct BitsCharFloat32Float64 { pub a: ::jlrs::data::layout::char::Char, - pub b: BitsIntChar, + pub b: f32, + pub c: f64, } #[repr(C)] @@ -57,15 +50,15 @@ pub struct BitsCharBitsIntChar { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, )] -#[jlrs(julia_type = "Main.BitsCharFloat32Float64")] -pub struct BitsCharFloat32Float64 { - pub a: ::jlrs::data::layout::char::Char, - pub b: f32, - pub c: f64, +#[jlrs(julia_type = "Main.BitsIntBool")] +pub struct BitsIntBool { + pub a: i64, + pub b: ::jlrs::data::layout::bool::Bool, } #[repr(C)] @@ -77,14 +70,15 @@ pub struct BitsCharFloat32Float64 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, )] -#[jlrs(julia_type = "Main.BitsIntBool")] -pub struct BitsIntBool { +#[jlrs(julia_type = "Main.BitsIntChar")] +pub struct BitsIntChar { pub a: i64, - pub b: ::jlrs::data::layout::bool::Bool, + pub b: ::jlrs::data::layout::char::Char, } #[repr(C)] @@ -96,6 +90,7 @@ pub struct BitsIntBool { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -114,6 +109,7 @@ pub struct BitsTypeBool { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -132,6 +128,7 @@ pub struct BitsTypeChar { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -150,6 +147,7 @@ pub struct BitsTypeFloat32 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -168,6 +166,7 @@ pub struct BitsTypeFloat64 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -186,6 +185,7 @@ pub struct BitsTypeInt { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -204,6 +204,7 @@ pub struct BitsTypeInt16 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -222,6 +223,7 @@ pub struct BitsTypeInt32 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -240,6 +242,7 @@ pub struct BitsTypeInt64 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -258,6 +261,7 @@ pub struct BitsTypeInt8 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -276,6 +280,7 @@ pub struct BitsTypeUInt { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -294,6 +299,7 @@ pub struct BitsTypeUInt16 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -312,6 +318,7 @@ pub struct BitsTypeUInt32 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -330,6 +337,7 @@ pub struct BitsTypeUInt64 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -348,6 +356,7 @@ pub struct BitsTypeUInt8 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -367,6 +376,7 @@ pub struct BitsUInt8TupleInt32Int64 { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -384,8 +394,8 @@ pub struct DoubleHasGeneric<'scope, 'data> { pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, } -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.DoubleHasGeneric")] +#[derive(ConstructType, HasLayout)] +#[jlrs(julia_type = "Main.DoubleHasGeneric", constructor_for = "DoubleHasGeneric", scope_lifetime = true, data_lifetime = true, layout_params = [], elided_params = ["T"], all_params = ["T"])] pub struct DoubleHasGenericTypeConstructor { _t: ::std::marker::PhantomData, } @@ -403,9 +413,14 @@ pub struct DoubleImmut<'scope, 'data> { #[derive( Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, )] -#[jlrs(julia_type = "Main.Immut")] -pub struct Immut<'scope, 'data> { - pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, +#[jlrs(julia_type = "Main.DoubleUVariant")] +pub struct DoubleUVariant { + #[jlrs(bits_union_align)] + _a_align: ::jlrs::data::layout::union::Align4, + #[jlrs(bits_union)] + pub a: ::jlrs::data::layout::union::BitsUnion<4>, + #[jlrs(bits_union_flag)] + pub a_flag: u8, } #[repr(C)] @@ -422,59 +437,12 @@ pub struct DoubleVariant { pub a_flag: u8, } -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, ConstructType)] -#[jlrs(julia_type = "Main.Empty", zero_sized_type)] -pub struct Empty {} - -#[repr(C)] -#[derive( - Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, -)] -#[jlrs(julia_type = "Main.HasAbstractField")] -pub struct HasAbstractField<'scope, 'data> { - pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, -} - -#[repr(C)] -#[derive( - Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, -)] -#[jlrs(julia_type = "Main.HasAbstractUnionAllField")] -pub struct HasAbstractUnionAllField<'scope, 'data> { - pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, -} - -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.HasAtomicField")] -pub struct HasAtomicFieldTypeConstructor {} - -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.HasCustomAtomicField")] -pub struct HasCustomAtomicFieldTypeConstructor {} - #[repr(C)] #[derive( - Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, + Clone, Debug, Unbox, ValidLayout, Typecheck, IntoJulia, ValidField, IsBits, ConstructType, )] -#[jlrs(julia_type = "Main.HasGenericAbstractField")] -pub struct HasGenericAbstractField { - pub a: T, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField)] -#[jlrs(julia_type = "Main.HasGenericAbstractUnionAllField")] -pub struct HasGenericAbstractUnionAllField { - pub a: U, -} - -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.HasGenericAbstractUnionAllField")] -pub struct HasGenericAbstractUnionAllFieldTypeConstructor { - _t: ::std::marker::PhantomData, - _u: ::std::marker::PhantomData, -} +#[jlrs(julia_type = "Main.Empty", zero_sized_type)] +pub struct Empty {} #[repr(C)] #[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField)] @@ -483,14 +451,14 @@ pub struct HasGenericImmut<'scope, 'data> { pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, } -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.HasGenericImmut")] +#[derive(ConstructType, HasLayout)] +#[jlrs(julia_type = "Main.HasGenericImmut", constructor_for = "HasGenericImmut", scope_lifetime = true, data_lifetime = true, layout_params = [], elided_params = ["T"], all_params = ["T"])] pub struct HasGenericImmutTypeConstructor { _t: ::std::marker::PhantomData, } #[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ConstructType)] +#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IsBits, ConstructType)] #[jlrs(julia_type = "Main.HasGeneric")] pub struct HasGeneric { pub a: T, @@ -504,7 +472,16 @@ pub struct HasImmut<'scope, 'data> { } #[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ConstructType)] +#[derive( + Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, +)] +#[jlrs(julia_type = "Main.Immut")] +pub struct Immut<'scope, 'data> { + pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, +} + +#[repr(C)] +#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, IsBits, ConstructType)] #[jlrs(julia_type = "Main.MutF32")] pub struct MutF32 { pub a: f32, @@ -535,6 +512,7 @@ pub struct NonBitsUnion<'scope, 'data> { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -559,12 +537,12 @@ pub struct SizeAlignMismatch { } #[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField)] +#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, IsBits)] #[jlrs(julia_type = "Main.TypedEmpty")] pub struct TypedEmpty {} -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.TypedEmpty")] +#[derive(ConstructType, HasLayout)] +#[jlrs(julia_type = "Main.TypedEmpty", constructor_for = "TypedEmpty", scope_lifetime = false, data_lifetime = false, layout_params = [], elided_params = ["T"], all_params = ["T"])] pub struct TypedEmptyTypeConstructor { _t: ::std::marker::PhantomData, } @@ -616,7 +594,16 @@ pub struct WithExpr<'scope, 'data> { #[repr(C)] #[derive( - Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, + Clone, + Debug, + Unbox, + ValidLayout, + Typecheck, + ValidField, + IsBits, + ConstructType, + CCallArg, + CCallReturn, )] #[jlrs(julia_type = "Main.WithGenericT")] pub struct WithGenericT { @@ -632,24 +619,6 @@ pub struct WithGenericUnionAll<'scope, 'data> { pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, } -#[repr(C)] -#[derive( - Clone, - Debug, - Unbox, - ValidLayout, - Typecheck, - IntoJulia, - ValidField, - ConstructType, - CCallArg, - CCallReturn, -)] -#[jlrs(julia_type = "Main.WithInt32")] -pub struct WithInt32 { - pub int32: i32, -} - #[repr(C)] #[derive( Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, @@ -688,7 +657,16 @@ pub struct WithModule<'scope> { #[repr(C)] #[derive( - Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, + Clone, + Debug, + Unbox, + ValidLayout, + Typecheck, + ValidField, + IsBits, + ConstructType, + CCallArg, + CCallReturn, )] #[jlrs(julia_type = "Main.WithNestedGenericT")] pub struct WithNestedGenericT { @@ -729,6 +707,7 @@ pub struct WithPropagatedLifetimes<'scope, 'data> { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -747,6 +726,7 @@ pub struct WithSetGeneric { Typecheck, IntoJulia, ValidField, + IsBits, ConstructType, CCallArg, CCallReturn, @@ -847,14 +827,135 @@ pub struct WithUnionAll<'scope> { } #[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField)] +#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, IsBits, PartialEq)] #[jlrs(julia_type = "Main.WithValueType")] pub struct WithValueType { pub a: i64, } -#[derive(ConstructType)] -#[jlrs(julia_type = "Main.WithValueType")] +#[derive(ConstructType, HasLayout)] +#[jlrs(julia_type = "Main.WithValueType", constructor_for = "WithValueType", scope_lifetime = false, data_lifetime = false, layout_params = [], elided_params = ["N"], all_params = ["N"])] pub struct WithValueTypeTypeConstructor { _n: ::std::marker::PhantomData, } + +#[derive(ConstructType)] +#[jlrs(julia_type = "Main.AnAbstractType")] +pub struct AnAbstractType {} + +#[derive(ConstructType)] +#[jlrs(julia_type = "Main.AnAbstractUnionAll")] +pub struct AnAbstractUnionAll { + _t: ::std::marker::PhantomData, +} + +#[repr(C)] +#[derive( + Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, +)] +#[jlrs(julia_type = "Main.HasAbstractField")] +pub struct HasAbstractField<'scope, 'data> { + pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, +} + +#[repr(C)] +#[derive( + Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, ConstructType, CCallArg, CCallReturn, +)] +#[jlrs(julia_type = "Main.HasAbstractUnionAllField")] +pub struct HasAbstractUnionAllField<'scope, 'data> { + pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'scope, 'data>>, +} + +#[derive(ConstructType)] +#[jlrs(julia_type = "Main.HasAtomicField")] +pub struct HasAtomicFieldTypeConstructor {} + +#[derive(ConstructType)] +#[jlrs(julia_type = "Main.HasCustomAtomicField")] +pub struct HasCustomAtomicFieldTypeConstructor {} + +#[repr(C)] +#[derive( + Clone, + Debug, + Unbox, + ValidLayout, + Typecheck, + ValidField, + IsBits, + ConstructType, + CCallArg, + CCallReturn, +)] +#[jlrs(julia_type = "Main.HasGenericAbstractField")] +pub struct HasGenericAbstractField { + pub a: T, +} + +#[repr(C)] +#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, IsBits)] +#[jlrs(julia_type = "Main.HasGenericAbstractUnionAllField")] +pub struct HasGenericAbstractUnionAllField { + pub a: U, +} + +#[derive(ConstructType)] +#[jlrs(julia_type = "Main.HasGenericAbstractUnionAllField")] +pub struct HasGenericAbstractUnionAllFieldTypeConstructor { + _t: ::std::marker::PhantomData, + _u: ::std::marker::PhantomData, +} + +#[repr(C)] +#[derive( + Clone, + Debug, + Unbox, + ValidLayout, + Typecheck, + IntoJulia, + ValidField, + IsBits, + ConstructType, + CCallArg, + CCallReturn, +)] +#[jlrs(julia_type = "Main.WithInt32")] +pub struct WithInt32 { + pub int32: i32, +} + +#[repr(C)] +#[derive( + Clone, + Debug, + Unbox, + ValidLayout, + Typecheck, + ValidField, + IsBits, + ConstructType, + CCallArg, + CCallReturn, + PartialEq, +)] +#[jlrs(julia_type = "Main.WithGenericTU")] +pub struct WithGenericTU { + pub a: T, + pub b: U, +} + +#[repr(C)] +#[derive(Clone, Debug, Unbox, ValidLayout, Typecheck, ValidField, IsBits)] +#[jlrs(julia_type = "Main.HasElidedParam")] +pub struct HasElidedParam { + pub a: T, +} + +#[derive(ConstructType)] +#[jlrs(julia_type = "Main.HasElidedParam")] +pub struct HasElidedParamTypeConstructor { + _t: ::std::marker::PhantomData, + _u: ::std::marker::PhantomData, +} diff --git a/jlrs/tests/derive_util/mod.rs b/jlrs/tests/derive_util/mod.rs new file mode 100644 index 00000000..9e37c27e --- /dev/null +++ b/jlrs/tests/derive_util/mod.rs @@ -0,0 +1,30 @@ +#[cfg(feature = "sync-rt")] +use std::cell::RefCell; + +#[cfg(feature = "sync-rt")] +use jlrs::{ + data::managed::value::Value, + memory::stack_frame::StackFrame, + runtime::{builder::RuntimeBuilder, sync_rt::PendingJulia}, +}; + +#[cfg(feature = "jlrs-derive")] +pub mod derive_impls; + +#[cfg(all(feature = "jlrs-derive", feature = "sync-rt"))] +#[allow(dead_code)] +pub static JLRS_DERIVE_TESTS_JL: &'static str = include_str!("JlrsDeriveTests.jl"); + +thread_local! { + #[cfg(all(feature = "jlrs-derive", feature = "sync-rt"))] + #[doc(hidden)] + pub static JULIA_DERIVE: RefCell = { + let mut frame = StackFrame::new(); + let r = RefCell::new(unsafe {RuntimeBuilder::new().start().unwrap() }); + r.borrow_mut().instance(&mut frame).scope(|mut frame| unsafe { + Value::eval_string(&mut frame, JLRS_DERIVE_TESTS_JL).expect("failed to evaluate contents of JlrsTests.jl"); + Ok(()) + }).unwrap(); + r + }; +} diff --git a/jlrs/tests/eval_string.rs b/jlrs/tests/eval_string.rs index 88cf95c1..b71eba26 100644 --- a/jlrs/tests/eval_string.rs +++ b/jlrs/tests/eval_string.rs @@ -30,6 +30,7 @@ mod tests { }); } + #[cfg(not(feature = "julia-1-10"))] fn syntax_error() { eval_string("asdf fdsa asdf fdsa", |result| { assert_eq!( @@ -39,6 +40,16 @@ mod tests { }); } + #[cfg(feature = "julia-1-10")] + fn syntax_error() { + eval_string("asdf fdsa asdf fdsa", |result| { + assert_eq!( + result.unwrap_err().datatype_name().unwrap(), + "UndefVarError" + ); + }); + } + fn define_then_use() { eval_string("increase(x) = x + Int32(1)", |result| { assert!(result.is_ok()); diff --git a/jlrs/tests/functions.rs b/jlrs/tests/functions.rs index 9bfc4756..329c45c3 100644 --- a/jlrs/tests/functions.rs +++ b/jlrs/tests/functions.rs @@ -477,9 +477,7 @@ mod tests { let arg1 = Value::new(&mut frame, 2u32); let arg2 = Value::new(&mut frame, 3u32); let arg3 = Value::new(&mut frame, 4u32); - let out = func - .call(&mut frame, &mut [arg0, arg1, arg2, arg3]) - .unwrap(); + let out = func.call(&mut frame, [arg0, arg1, arg2, arg3]).unwrap(); out.unbox::() }); @@ -498,7 +496,7 @@ mod tests { let arg1 = Value::new(&mut frame, 2u32); let arg2 = Value::new(&mut frame, 3u32); let arg3 = Value::new(&mut frame, 4u32); - let out = func.call(&frame, &mut [arg0, arg1, arg2, arg3]).unwrap(); + let out = func.call(&frame, [arg0, arg1, arg2, arg3]).unwrap(); out.as_managed().unbox::() }); @@ -521,7 +519,7 @@ mod tests { let arg2 = Value::new(&mut frame, 3u32); let arg3 = Value::new(&mut frame, 4u32); - Ok(func.call(output, &mut [arg0, arg1, arg2, arg3])) + Ok(func.call(output, [arg0, arg1, arg2, arg3])) })? .unwrap() .unbox::() @@ -546,7 +544,7 @@ mod tests { let arg2 = Value::new(&mut frame, 3u32); let arg3 = Value::new(&mut frame, 4u32); - Ok(func.call(output, &mut [arg0, arg1, arg2, arg3])) + Ok(func.call(output, [arg0, arg1, arg2, arg3])) })? .unwrap() .unbox::() @@ -571,7 +569,7 @@ mod tests { let arg2 = Value::new(&mut frame, 3u32); let arg3 = Value::new(&mut frame, 4u32); - Ok(func.clone().call(output, &mut [arg0, arg1, arg2, arg3])) + Ok(func.clone().call(output, [arg0, arg1, arg2, arg3])) })? .unwrap() .unbox::() diff --git a/jlrs/tests/inline_array.rs b/jlrs/tests/inline_array.rs index bd45cc64..6e8e36f5 100644 --- a/jlrs/tests/inline_array.rs +++ b/jlrs/tests/inline_array.rs @@ -14,8 +14,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.inline_data::()? }; @@ -35,8 +34,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.inline_data::()? }; @@ -58,8 +56,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.inline_data::()? }; @@ -79,8 +76,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.inline_data::()? }; @@ -101,8 +97,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let arr = arr_val; let data = unsafe { arr.inline_data::()? }; @@ -123,8 +118,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let mut arr = arr_val; let data = arr.bits_data_mut::()?; @@ -143,8 +137,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let mut arr = arr_val; let mut data = unsafe { arr.bits_data_mut::()? }; @@ -170,8 +163,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let mut arr = arr_val; let data = unsafe { arr.bits_data_mut::()? }; @@ -192,8 +184,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let mut arr = arr_val; let mut data = unsafe { arr.bits_data_mut::()? }; @@ -215,8 +206,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2.0f32]; - let arr_val = Array::from_vec(frame.as_extended_target(), data, (1, 2))? - .into_jlrs_result()?; + let arr_val = Array::from_vec(&mut frame, data, (1, 2))?.into_jlrs_result()?; let mut arr = arr_val; let data = unsafe { arr.bits_data_mut::()? }; @@ -237,8 +227,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { let data = vec![1.0f32, 2.0f32]; - let arr_val = - Array::from_vec_unchecked(frame.as_extended_target(), data, (1, 2))?; + let arr_val = Array::from_vec_unchecked(&mut frame, data, (1, 2))?; let mut arr = arr_val; let data = arr.bits_data_mut::()?; diff --git a/jlrs/tests/kw_func.rs b/jlrs/tests/kw_func.rs index d9a8f71e..0392f3ea 100644 --- a/jlrs/tests/kw_func.rs +++ b/jlrs/tests/kw_func.rs @@ -19,10 +19,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let v = func - .call(&mut frame, &mut [a_value]) - .unwrap() - .unbox::()?; + let v = func.call(&mut frame, [a_value]).unwrap().unbox::()?; assert_eq!(v, 2); Ok(()) @@ -46,7 +43,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call1(&mut frame, a_value) @@ -74,7 +71,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call0(&mut frame) @@ -103,7 +100,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call1(&mut frame, a_value) @@ -133,7 +130,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call2(&mut frame, a_value, c_value) @@ -163,7 +160,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call2(&mut frame, a_value, c_value) @@ -194,7 +191,7 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call3(&mut frame, a_value, c_value, d_value) @@ -226,10 +223,10 @@ mod tests { .function(&frame, "funcwithkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? - .call(&mut frame, &mut [a_value, c_value, d_value, e_value]) + .call(&mut frame, [a_value, c_value, d_value, e_value]) .unwrap() .unbox::()?; @@ -255,7 +252,7 @@ mod tests { .function(&frame, "funcwithabstractkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call1(&mut frame, a_value) @@ -284,7 +281,7 @@ mod tests { .function(&frame, "funcwithabstractkw")? .as_managed(); - let kw = named_tuple!(frame.as_extended_target(), "b" => b_value); + let kw = named_tuple!(&mut frame, "b" => b_value); let v = func .provide_keywords(kw)? .call1(&mut frame, a_value) diff --git a/jlrs/tests/large_array.rs b/jlrs/tests/large_array.rs index 8ffb54ed..ea1aaca3 100644 --- a/jlrs/tests/large_array.rs +++ b/jlrs/tests/large_array.rs @@ -12,10 +12,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let array = Array::new::( - frame.as_extended_target(), - &[1, 1, 1, 1, 1, 1, 1, 1, 1][..], - ); + let array = Array::new::(&mut frame, &[1, 1, 1, 1, 1, 1, 1, 1, 1]); assert!(array.is_ok()); Ok(()) }) @@ -30,11 +27,8 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let array = Array::from_vec( - frame.as_extended_target(), - vec![1u64], - &[1, 1, 1, 1, 1, 1, 1, 1, 1][..], - ); + let array = + Array::from_vec(&mut frame, vec![1u64], &[1, 1, 1, 1, 1, 1, 1, 1, 1]); assert!(array.is_ok()); Ok(()) }) @@ -51,12 +45,8 @@ mod tests { .scope(|mut frame| { let mut data = vec![1u32]; let array = { - Array::from_slice( - frame.as_extended_target(), - &mut data, - &[1, 1, 1, 1, 1, 1, 1, 1, 1][..], - )? - .into_jlrs_result() + Array::from_slice(&mut frame, &mut data, &[1, 1, 1, 1, 1, 1, 1, 1, 1])? + .into_jlrs_result() }; assert!(array.is_ok()); Ok(()) @@ -72,10 +62,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let array = TypedArray::::new( - frame.as_extended_target(), - &[1, 1, 1, 1, 1, 1, 1, 1, 1][..], - ); + let array = TypedArray::::new(&mut frame, &[1, 1, 1, 1, 1, 1, 1, 1, 1]); assert!(array.is_ok()); Ok(()) }) @@ -90,11 +77,8 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let array = TypedArray::from_vec( - frame.as_extended_target(), - vec![1u64], - &[1, 1, 1, 1, 1, 1, 1, 1, 1][..], - ); + let array = + TypedArray::from_vec(&mut frame, vec![1u64], &[1, 1, 1, 1, 1, 1, 1, 1, 1]); assert!(array.is_ok()); Ok(()) }) @@ -111,12 +95,8 @@ mod tests { .scope(|mut frame| { let mut data = vec![1u32]; let array = { - TypedArray::from_slice( - frame.as_extended_target(), - &mut data, - &[1, 1, 1, 1, 1, 1, 1, 1, 1][..], - )? - .into_jlrs_result() + TypedArray::from_slice(&mut frame, &mut data, &[1, 1, 1, 1, 1, 1, 1, 1, 1])? + .into_jlrs_result() }; assert!(array.is_ok()); Ok(()) diff --git a/jlrs/tests/managed_array.rs b/jlrs/tests/managed_array.rs index 319d8ad7..b1598abd 100644 --- a/jlrs/tests/managed_array.rs +++ b/jlrs/tests/managed_array.rs @@ -14,8 +14,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), 3) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, 3).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -37,10 +36,7 @@ mod tests { .scope(|mut frame| { let output = frame.output(); let array = frame - .scope(|mut frame| { - let output = output.into_extended_target(&mut frame); - Ok(Array::new::(output, 3)) - })? + .scope(|_frame| Ok(Array::new::(output, 3)))? .into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) @@ -62,8 +58,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), 3) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, 3).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -85,8 +81,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), 3) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, 3).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -107,8 +102,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), 3) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, 3).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -129,8 +123,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), 3) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, 3).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -152,8 +146,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), 3) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, 3).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -174,8 +168,8 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), (3, 4)) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, (3, 4)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -197,8 +191,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), (3, 4)) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, (3, 4)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -221,8 +215,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), (3, 4)) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, (3, 4)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -244,8 +238,8 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), (3, 4)) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, (3, 4)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -268,8 +262,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -293,8 +286,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -316,8 +308,8 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), (3, 4, 5)) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, (3, 4, 5)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -341,8 +333,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -367,8 +358,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -391,8 +381,8 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| { - let new_array = Array::new::(frame.as_extended_target(), (3, 4, 5)) - .into_jlrs_result()?; + let new_array = + Array::new::(&mut frame, (3, 4, 5)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -416,8 +406,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -442,8 +431,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -467,8 +455,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5, 6)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -493,8 +480,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5, 6)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -520,8 +506,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5, 6)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -546,8 +531,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + Array::new::(&mut frame, (3, 4, 5, 6)).into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -571,9 +555,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, (3, 4, 5, 6)) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -598,9 +581,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, (3, 4, 5, 6)) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -625,9 +607,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, (3, 4, 5, 6)) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -652,9 +633,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| { - let new_array = - Array::new::(frame.as_extended_target(), (3, 4, 5, 6)) - .into_jlrs_result()?; + let new_array = Array::new::(&mut frame, (3, 4, 5, 6)) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -678,8 +658,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), 3) }; + let new_array = { Array::new_unchecked::(&mut frame, 3) }; { new_array.copy_inline_data::() } @@ -702,8 +681,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let output = frame.output(); - let array = frame.scope(|mut frame| unsafe { - let output = output.into_extended_target(&mut frame); + let array = frame.scope(|_frame| unsafe { Ok(Array::new_unchecked::(output, 3)) })?; unsafe { array.copy_inline_data::() } @@ -726,8 +704,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), 3) }; + let new_array = { Array::new_unchecked::(&mut frame, 3) }; { new_array.copy_inline_data::() } @@ -751,8 +728,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), 3) }; + let new_array = { Array::new_unchecked::(&mut frame, 3) }; { new_array.copy_inline_data::() } @@ -775,8 +751,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), 3) }; + let new_array = { Array::new_unchecked::(&mut frame, 3) }; { new_array.copy_inline_data::() } @@ -799,8 +774,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), 3) }; + let new_array = { Array::new_unchecked::(&mut frame, 3) }; { new_array.copy_inline_data::() } @@ -824,8 +798,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), 3) }; + let new_array = { Array::new_unchecked::(&mut frame, 3) }; { new_array.copy_inline_data::() } @@ -848,8 +821,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), (3, 4)) }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4)) }; { new_array.copy_inline_data::() } @@ -873,9 +845,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4)) }; { new_array.copy_inline_data::() } @@ -900,9 +870,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4)) }; { new_array.copy_inline_data::() } @@ -926,8 +894,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), (3, 4)) }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4)) }; { new_array.copy_inline_data::() } @@ -951,9 +918,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4)) }; new_array.copy_inline_data::() }) }) @@ -976,9 +941,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4)) }; new_array.copy_inline_data::() }) }) @@ -1000,8 +963,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = - { Array::new_unchecked::(frame.as_extended_target(), (3, 4, 5)) }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4, 5)) }; new_array.copy_inline_data::() }) .unwrap(); @@ -1024,9 +986,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4, 5)) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5)) }; new_array.copy_inline_data::() }) }) @@ -1050,9 +1011,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4, 5)) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5)) }; new_array.copy_inline_data::() }) }) @@ -1075,9 +1035,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4, 5)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4, 5)) }; new_array.copy_inline_data::() }) .unwrap(); @@ -1100,12 +1058,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5)) }; new_array.copy_inline_data::() }) @@ -1130,12 +1084,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5)) }; new_array.copy_inline_data::() }) }) @@ -1158,9 +1108,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4, 5, 6)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) .unwrap(); @@ -1184,12 +1132,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5, 6), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) }) @@ -1214,12 +1158,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5, 6), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) }) @@ -1243,9 +1183,7 @@ mod tests { let unboxed = jlrs .instance(&mut frame) .scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::(frame.as_extended_target(), (3, 4, 5, 6)) - }; + let new_array = { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) .unwrap(); @@ -1269,12 +1207,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5, 6), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) }) @@ -1299,12 +1233,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5, 6), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) }) @@ -1329,12 +1259,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5, 6), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) }) @@ -1359,12 +1285,8 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { frame.scope(|mut frame| unsafe { - let new_array = { - Array::new_unchecked::( - frame.as_extended_target(), - (3, 4, 5, 6), - ) - }; + let new_array = + { Array::new_unchecked::(&mut frame, (3, 4, 5, 6)) }; new_array.copy_inline_data::() }) @@ -1390,12 +1312,9 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let global = frame.unrooted(); - let new_array = Array::new_for( - frame.as_extended_target(), - 3, - DataType::float32_type(&global).as_value(), - ) - .into_jlrs_result()?; + let new_array = + Array::new_for(&mut frame, 3, DataType::float32_type(&global).as_value()) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -1418,8 +1337,7 @@ mod tests { let global = frame.unrooted(); let output = frame.output(); let array = frame - .scope(|mut frame| { - let output = output.into_extended_target(&mut frame); + .scope(|_frame| { Ok(Array::new_for( output, 3, @@ -1449,7 +1367,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, 3, DataType::float64_type(&global).as_value(), ) @@ -1476,12 +1394,9 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); frame.scope(|mut frame| { - let new_array = Array::new_for( - frame.as_extended_target(), - 3, - DataType::int8_type(&global).as_value(), - ) - .into_jlrs_result()?; + let new_array = + Array::new_for(&mut frame, 3, DataType::int8_type(&global).as_value()) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -1503,12 +1418,9 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let global = frame.unrooted(); - let new_array = Array::new_for( - frame.as_extended_target(), - 3, - DataType::int16_type(&global).as_value(), - ) - .into_jlrs_result()?; + let new_array = + Array::new_for(&mut frame, 3, DataType::int16_type(&global).as_value()) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) .unwrap(); @@ -1530,12 +1442,9 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); frame.scope(|mut frame| { - let new_array = Array::new_for( - frame.as_extended_target(), - 3, - DataType::int32_type(&global).as_value(), - ) - .into_jlrs_result()?; + let new_array = + Array::new_for(&mut frame, 3, DataType::int32_type(&global).as_value()) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -1558,12 +1467,9 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); frame.scope(|mut frame| { - let new_array = Array::new_for( - frame.as_extended_target(), - 3, - DataType::int64_type(&global).as_value(), - ) - .into_jlrs_result()?; + let new_array = + Array::new_for(&mut frame, 3, DataType::int64_type(&global).as_value()) + .into_jlrs_result()?; unsafe { new_array.copy_inline_data::() } }) }) @@ -1586,7 +1492,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint8_type(&global).as_value(), ) @@ -1614,7 +1520,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint16_type(&global).as_value(), ) @@ -1643,7 +1549,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| { let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint32_type(&global).as_value(), ) @@ -1671,7 +1577,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint64_type(&global).as_value(), ) @@ -1699,7 +1605,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint64_type(&global).as_value(), ) @@ -1728,7 +1634,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::int64_type(&global).as_value(), ) @@ -1756,7 +1662,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint8_type(&global).as_value(), ) @@ -1785,7 +1691,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint16_type(&global).as_value(), ) @@ -1815,7 +1721,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| { let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint32_type(&global).as_value(), ) @@ -1844,7 +1750,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint64_type(&global).as_value(), ) @@ -1873,7 +1779,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| { let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint64_type(&global).as_value(), ) @@ -1903,7 +1809,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::int64_type(&global).as_value(), ) @@ -1932,7 +1838,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint8_type(&global).as_value(), ) @@ -1962,7 +1868,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| { let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint16_type(&global).as_value(), ) @@ -1993,7 +1899,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint32_type(&global).as_value(), ) @@ -2023,7 +1929,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint64_type(&global).as_value(), ) @@ -2053,7 +1959,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint64_type(&global).as_value(), ) @@ -2084,7 +1990,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::int64_type(&global).as_value(), ) @@ -2115,7 +2021,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::bool_type(&global).as_value(), ) @@ -2146,7 +2052,7 @@ mod tests { frame.scope(|mut frame| { let global = frame.unrooted(); let new_array = Array::new_for( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::char_type(&global).as_value(), ) @@ -2176,7 +2082,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, 3, DataType::float32_type(&global).as_value(), ); @@ -2201,8 +2107,7 @@ mod tests { .scope(|mut frame| { let global = frame.unrooted(); let output = frame.output(); - let array = frame.scope(|mut frame| unsafe { - let output = output.into_extended_target(&mut frame); + let array = frame.scope(|_frame| unsafe { Ok(Array::new_for_unchecked( output, 3, @@ -2231,7 +2136,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, 3, DataType::float64_type(&global).as_value(), ); @@ -2258,7 +2163,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, 3, DataType::int8_type(&global).as_value(), ); @@ -2284,7 +2189,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, 3, DataType::int16_type(&global).as_value(), ); @@ -2310,7 +2215,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, 3, DataType::int32_type(&global).as_value(), ); @@ -2337,7 +2242,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, 3, DataType::int64_type(&global).as_value(), ); @@ -2363,7 +2268,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint8_type(&global).as_value(), ); @@ -2390,7 +2295,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint16_type(&global).as_value(), ); @@ -2418,7 +2323,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint32_type(&global).as_value(), ); @@ -2445,7 +2350,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint64_type(&global).as_value(), ); @@ -2472,7 +2377,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::uint64_type(&global).as_value(), ); @@ -2500,7 +2405,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4), DataType::int64_type(&global).as_value(), ); @@ -2527,7 +2432,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint8_type(&global).as_value(), ); @@ -2555,7 +2460,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint16_type(&global).as_value(), ); @@ -2584,7 +2489,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint32_type(&global).as_value(), ); @@ -2612,7 +2517,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint64_type(&global).as_value(), ); @@ -2640,7 +2545,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::uint64_type(&global).as_value(), ); @@ -2669,7 +2574,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5), DataType::int64_type(&global).as_value(), ); @@ -2697,7 +2602,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint8_type(&global).as_value(), ); @@ -2726,7 +2631,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint16_type(&global).as_value(), ); @@ -2756,7 +2661,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint32_type(&global).as_value(), ); @@ -2785,7 +2690,7 @@ mod tests { .scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint64_type(&global).as_value(), ); @@ -2814,7 +2719,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::uint64_type(&global).as_value(), ); @@ -2844,7 +2749,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::int64_type(&global).as_value(), ); @@ -2874,7 +2779,7 @@ mod tests { let global = frame.unrooted(); frame.scope(|mut frame| unsafe { let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::bool_type(&global).as_value(), ); @@ -2904,7 +2809,7 @@ mod tests { frame.scope(|mut frame| unsafe { let global = frame.unrooted(); let new_array = Array::new_for_unchecked( - frame.as_extended_target(), + &mut frame, (3, 4, 5, 6), DataType::char_type(&global).as_value(), ); diff --git a/jlrs/tests/move_array.rs b/jlrs/tests/move_array.rs index f0e1bd0a..2180d3aa 100644 --- a/jlrs/tests/move_array.rs +++ b/jlrs/tests/move_array.rs @@ -15,8 +15,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let data = vec![1.0f32, 2., 3.]; - let array = - Array::from_vec(frame.as_extended_target(), data, 3)?.into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) .unwrap(); @@ -39,10 +38,7 @@ mod tests { let output = frame.output(); let data = vec![1.0f32, 2., 3.]; let array = frame - .scope(|mut frame| { - let output = output.into_extended_target(&mut frame); - Array::from_vec(output, data, 3) - })? + .scope(|_frame| Array::from_vec(output, data, 3))? .into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) @@ -65,8 +61,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1.0f64, 2., 3.]; - let array = Array::from_vec(frame.as_extended_target(), data, 3)? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -89,8 +84,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1i8, 2, 3]; - let array = Array::from_vec(frame.as_extended_target(), data, 3)? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -112,8 +106,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let data = vec![1i16, 2, 3]; - let array = - Array::from_vec(frame.as_extended_target(), data, 3)?.into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) .unwrap(); @@ -135,8 +128,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1i32, 2, 3]; - let array = Array::from_vec(frame.as_extended_target(), data, 3)? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -159,8 +151,7 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1i64, 2, 3]; - let array = Array::from_vec(frame.as_extended_target(), data, 3)? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, 3)?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -182,8 +173,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let data = vec![1u8, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4]; - let array = Array::from_vec(frame.as_extended_target(), data, (3, 4))? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, (3, 4))?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) .unwrap(); @@ -206,8 +196,8 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1u16, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4]; - let array = Array::from_vec(frame.as_extended_target(), data, (3, 4))? - .into_jlrs_result()?; + let array = + Array::from_vec(&mut frame, data, (3, 4))?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -231,8 +221,8 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1u32, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4]; - let array = Array::from_vec(frame.as_extended_target(), data, (3, 4))? - .into_jlrs_result()?; + let array = + Array::from_vec(&mut frame, data, (3, 4))?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -255,8 +245,7 @@ mod tests { .instance(&mut frame) .scope(|mut frame| { let data = vec![1u64, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4]; - let array = Array::from_vec(frame.as_extended_target(), data, (3, 4))? - .into_jlrs_result()?; + let array = Array::from_vec(&mut frame, data, (3, 4))?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) .unwrap(); @@ -279,8 +268,8 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1usize, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4]; - let array = Array::from_vec(frame.as_extended_target(), data, (3, 4))? - .into_jlrs_result()?; + let array = + Array::from_vec(&mut frame, data, (3, 4))?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) @@ -304,8 +293,8 @@ mod tests { .scope(|mut frame| { frame.scope(|mut frame| { let data = vec![1isize, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4]; - let array = Array::from_vec(frame.as_extended_target(), data, (3, 4))? - .into_jlrs_result()?; + let array = + Array::from_vec(&mut frame, data, (3, 4))?.into_jlrs_result()?; unsafe { array.copy_inline_data::() } }) }) diff --git a/jlrs/tests/named_tuple.rs b/jlrs/tests/named_tuple.rs index 73cea69a..143f4fac 100644 --- a/jlrs/tests/named_tuple.rs +++ b/jlrs/tests/named_tuple.rs @@ -1,7 +1,7 @@ mod util; #[cfg(feature = "sync-rt")] mod tests { - use jlrs::{data::types::typecheck::NamedTuple, prelude::*}; + use jlrs::{convert::to_symbol::ToSymbol, data::types::typecheck::NamedTuple, prelude::*}; use super::util::JULIA; @@ -14,7 +14,8 @@ mod tests { .scope(|mut frame| { let name = "foo"; let value = Value::new(&mut frame, 1u32); - let nt = Value::new_named_tuple(frame.as_extended_target(), [name], [value])?; + let name = name.to_symbol(&frame); + let nt = Value::new_named_tuple(&mut frame, &[(name, value)]); assert!(nt.is::()); assert_eq!(nt.get_field(&mut frame, "foo")?.unbox::()?, 1u32); Ok(()) @@ -33,8 +34,7 @@ mod tests { let a_name = "a"; let a_value = Value::new(&mut frame, 1u32); let b_value = Value::new(&mut frame, 2u64); - let nt = - named_tuple!(frame.as_extended_target(), a_name => a_value, "b" => b_value); + let nt = named_tuple!(&mut frame, a_name => a_value, "b" => b_value); assert!(nt.is::()); assert_eq!(nt.get_field(&mut frame, a_name)?.unbox::()?, 1u32); assert_eq!(nt.get_field(&mut frame, "b")?.unbox::()?, 2u64); diff --git a/jlrs/tests/ndarray.rs b/jlrs/tests/ndarray.rs index 86477942..2d32278a 100644 --- a/jlrs/tests/ndarray.rs +++ b/jlrs/tests/ndarray.rs @@ -21,9 +21,8 @@ mod tests { .scope(|mut frame| { let mut data = vec![1usize, 2, 3, 4, 5, 6]; let slice = &mut data.as_mut_slice(); - let borrowed = unsafe { - Array::from_slice_unchecked(frame.as_extended_target(), slice, (3, 2))? - }; + let borrowed = + unsafe { Array::from_slice_unchecked(&mut frame, slice, (3, 2))? }; let data = unsafe { borrowed.bits_data::()? }; let x = data[(2, 1)]; @@ -47,8 +46,7 @@ mod tests { .scope(|mut frame| unsafe { let mut data = vec![1usize, 2, 3, 4, 5, 6]; let slice = &mut data.as_mut_slice(); - let mut borrowed = - Array::from_slice_unchecked(frame.as_extended_target(), slice, (3, 2))?; + let mut borrowed = Array::from_slice_unchecked(&mut frame, slice, (3, 2))?; let mut inline = borrowed.bits_data_mut::()?; let x = inline[(2, 1)]; @@ -78,9 +76,8 @@ mod tests { .scope(|mut frame| { let mut data = vec![1usize, 2, 3, 4, 5, 6]; let slice = &mut data.as_mut_slice(); - let borrowed = unsafe { - Array::from_slice_unchecked(frame.as_extended_target(), slice, (3, 2))? - }; + let borrowed = + unsafe { Array::from_slice_unchecked(&mut frame, slice, (3, 2))? }; let data = unsafe { borrowed.inline_data::()? }; let x = data[(2, 1)]; @@ -104,9 +101,8 @@ mod tests { .scope(|mut frame| { let mut data = vec![1usize, 2, 3, 4, 5, 6]; let slice = &mut data.as_mut_slice(); - let borrowed = unsafe { - TypedArray::from_slice_unchecked(frame.as_extended_target(), slice, (3, 2))? - }; + let borrowed = + unsafe { TypedArray::from_slice_unchecked(&mut frame, slice, (3, 2))? }; let copied = unsafe { borrowed.copy_inline_data()? }; let x = copied[(2, 1)]; @@ -130,8 +126,7 @@ mod tests { .scope(|mut frame| unsafe { let mut data = vec![1usize, 2, 3, 4, 5, 6]; let slice = &mut data.as_mut_slice(); - let mut borrowed = - Array::from_slice_unchecked(frame.as_extended_target(), slice, (3, 2))?; + let mut borrowed = Array::from_slice_unchecked(&mut frame, slice, (3, 2))?; let mut copied = borrowed.copy_inline_data()?; let x = copied[(2, 1)]; diff --git a/jlrs/tests/require.rs b/jlrs/tests/require.rs index cc9ec9bf..78e81629 100644 --- a/jlrs/tests/require.rs +++ b/jlrs/tests/require.rs @@ -54,10 +54,8 @@ mod tests { let mut arr1 = vec![1.0f64, 2.0f64]; let mut arr2 = vec![2.0f64, 3.0f64]; - let arr1_v = - Array::from_slice_unchecked(frame.as_extended_target(), &mut arr1, 2)?; - let arr2_v = - Array::from_slice_unchecked(frame.as_extended_target(), &mut arr2, 2)?; + let arr1_v = Array::from_slice_unchecked(&mut frame, &mut arr1, 2)?; + let arr2_v = Array::from_slice_unchecked(&mut frame, &mut arr2, 2)?; let res = func .call2(&mut frame, arr1_v.as_value(), arr2_v.as_value()) diff --git a/jlrs/tests/tokio_rt.rs b/jlrs/tests/tokio_rt.rs index 4f120c0b..fce36365 100644 --- a/jlrs/tests/tokio_rt.rs +++ b/jlrs/tests/tokio_rt.rs @@ -1,6 +1,6 @@ #[cfg(all(feature = "tokio-rt",))] #[cfg(test)] -mod util; +mod async_util; #[cfg(all(feature = "tokio-rt",))] #[cfg(test)] @@ -10,7 +10,7 @@ mod tests { use jlrs::prelude::*; use once_cell::sync::OnceCell; - use super::util::{async_tasks::*, ASYNC_TESTS_JL}; + use super::async_util::{async_tasks::*, ASYNC_TESTS_JL}; fn init() -> Arc> { unsafe { diff --git a/jlrs/tests/tokio_rt_workers.rs b/jlrs/tests/tokio_rt_workers.rs index 84d19e1a..822dd5a1 100644 --- a/jlrs/tests/tokio_rt_workers.rs +++ b/jlrs/tests/tokio_rt_workers.rs @@ -3,7 +3,7 @@ not(any(feature = "julia-1-6", feature = "julia-1-7", feature = "julia-1-8")), ))] #[cfg(test)] -mod util; +mod async_util; #[cfg(all( feature = "tokio-rt", @@ -16,7 +16,7 @@ mod tests { use jlrs::prelude::*; use once_cell::sync::OnceCell; - use super::util::{async_tasks::*, ASYNC_TESTS_JL}; + use super::async_util::{async_tasks::*, ASYNC_TESTS_JL}; fn init() -> Arc> { unsafe { diff --git a/jlrs/tests/tracked_array.rs b/jlrs/tests/tracked_array.rs index 4883aca0..24ae1803 100644 --- a/jlrs/tests/tracked_array.rs +++ b/jlrs/tests/tracked_array.rs @@ -13,8 +13,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr.track_shared().is_ok()); Ok(()) }) @@ -29,8 +28,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let t1 = arr.track_shared(); let t2 = arr.track_shared(); assert!(t1.is_ok()); @@ -48,8 +46,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let mut arr = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let mut arr = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr.track_exclusive().is_ok()); Ok(()) }) @@ -64,8 +61,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let mut arr = Array::new::(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let mut arr = Array::new::(&mut frame, (1, 2)).into_jlrs_result()?; let mut arr2 = arr; { @@ -95,8 +91,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr = TypedArray::::new(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr = TypedArray::::new(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr.track_shared().is_ok()); Ok(()) }) @@ -111,8 +106,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let arr = TypedArray::::new(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let arr = TypedArray::::new(&mut frame, (1, 2)).into_jlrs_result()?; let t1 = arr.track_shared(); let t2 = arr.track_shared(); assert!(t1.is_ok()); @@ -130,8 +124,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let mut arr = TypedArray::::new(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let mut arr = TypedArray::::new(&mut frame, (1, 2)).into_jlrs_result()?; assert!(arr.track_exclusive().is_ok()); Ok(()) }) @@ -146,8 +139,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| unsafe { - let mut arr = TypedArray::::new(frame.as_extended_target(), (1, 2)) - .into_jlrs_result()?; + let mut arr = TypedArray::::new(&mut frame, (1, 2)).into_jlrs_result()?; let mut arr2 = arr; { diff --git a/jlrs/tests/tuple.rs b/jlrs/tests/tuple.rs index 8aa92ad4..75996066 100644 --- a/jlrs/tests/tuple.rs +++ b/jlrs/tests/tuple.rs @@ -53,10 +53,28 @@ mod tests { }) } + fn create_tuple_from_values() { + JULIA.with(|j| { + let mut frame = StackFrame::new(); + let mut jlrs = j.borrow_mut(); + jlrs.instance(&mut frame) + .scope(|mut frame| { + let v1 = Value::new(&mut frame, 1u64); + let v2 = Value::new(&mut frame, -3i32); + let t = Tuple::new(&mut frame, [v1, v2]).unwrap(); + assert!(t.is::>()); + assert!(t.unbox::>().is_ok()); + Ok(()) + }) + .unwrap(); + }) + } + #[test] fn tuple_tests() { create_cast_tuple0(); create_cast_tuple1(); create_cast_tuple2(); + create_tuple_from_values(); } } diff --git a/jlrs/tests/type_construction.rs b/jlrs/tests/type_construction.rs index fd8da7cd..fc1d2ae1 100644 --- a/jlrs/tests/type_construction.rs +++ b/jlrs/tests/type_construction.rs @@ -25,13 +25,13 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let ty = > as ConstructType>::construct_type(frame.as_extended_target()); + let ty = > as ConstructType>::construct_type(&mut frame); assert!(ty.is::()); let inner_ty = unsafe {ty.cast_unchecked::()}; assert!(inner_ty.is::()); let elem_param = inner_ty.parameter(&mut frame, 0).unwrap(); - assert_eq!(elem_param, AbstractChar::construct_type(frame.as_extended_target())); + assert_eq!(elem_param, AbstractChar::construct_type(&mut frame)); assert!(elem_param.cast::().unwrap().is_abstract()); let rank_param = inner_ty.parameter(&mut frame, 1).unwrap(); @@ -49,12 +49,12 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let ty = >> as ConstructType>::construct_type(frame.as_extended_target()); + let ty = >> as ConstructType>::construct_type(&mut frame); let ua = ty.cast::().unwrap(); let base = ua.base_type(); let elem_param = base.parameter(&mut frame, 0).unwrap(); - assert_eq!(elem_param, AbstractChar::construct_type(frame.as_extended_target())); + assert_eq!(elem_param, AbstractChar::construct_type(&mut frame)); let rank_param = base.parameter(&mut frame, 1).unwrap(); assert!(rank_param.is::()); @@ -71,7 +71,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let ty = >, ConstantIsize<1>> as ConstructType>::construct_type(frame.as_extended_target()); + let ty = >, ConstantIsize<1>> as ConstructType>::construct_type(&mut frame); let ua = ty.cast::().unwrap(); let base = ua.base_type(); @@ -96,9 +96,7 @@ mod tests { let ty = , AbstractChar>, ConstantIsize<1>, - > as ConstructType>::construct_type( - frame.as_extended_target() - ); + > as ConstructType>::construct_type(&mut frame); let ua = ty.cast::().unwrap(); let base = ua.base_type(); @@ -120,13 +118,13 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { - let ty = as ConstructType>::construct_type(frame.as_extended_target()); + let ty = as ConstructType>::construct_type(&mut frame); let un = ty.cast::().unwrap(); let variants = un.variants(); assert_eq!(variants.len(), 2); - let abstr_char_ty = AbstractChar::construct_type(frame.as_extended_target()); - let integer_ty = Integer::construct_type(frame.as_extended_target()); + let abstr_char_ty = AbstractChar::construct_type(&mut frame); + let integer_ty = Integer::construct_type(&mut frame); if variants[0] == abstr_char_ty { assert!(variants[1] == integer_ty); @@ -151,9 +149,7 @@ mod tests { let ty = , - > as ConstructType>::construct_type( - frame.as_extended_target() - ); + > as ConstructType>::construct_type(&mut frame); let un = ty.cast::().unwrap(); let variants = un.variants(); assert_eq!(variants.len(), 3); @@ -174,9 +170,7 @@ mod tests { let ty = , - > as ConstructType>::construct_type( - frame.as_extended_target() - ); + > as ConstructType>::construct_type(&mut frame); let un = ty.cast::().unwrap(); let variants = un.variants(); assert_eq!(variants.len(), 2); // Integer <: Real diff --git a/jlrs/tests/typecheck.rs b/jlrs/tests/typecheck.rs index a422929d..d6c70576 100644 --- a/jlrs/tests/typecheck.rs +++ b/jlrs/tests/typecheck.rs @@ -270,7 +270,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let a = Value::new(&mut frame, 1usize); - let named_tuple = named_tuple!(frame.as_extended_target(), "a" => a); + let named_tuple = named_tuple!(&mut frame, "a" => a); assert!(NamedTuple::typecheck(named_tuple.datatype())); assert!(!NamedTuple::typecheck(DataType::bool_type(&frame))); diff --git a/jlrs/tests/union_array.rs b/jlrs/tests/union_array.rs index 7f4f5835..161f39b7 100644 --- a/jlrs/tests/union_array.rs +++ b/jlrs/tests/union_array.rs @@ -26,8 +26,7 @@ mod tests { ) .into_jlrs_result()?; - let mut arr = Array::new_for(frame.as_extended_target(), 4, union_ty) - .into_jlrs_result()?; + let mut arr = Array::new_for(&mut frame, 4, union_ty).into_jlrs_result()?; { let data = unsafe { arr.union_data()? }; @@ -64,8 +63,7 @@ mod tests { ) .into_jlrs_result()?; - let mut arr = Array::new_for(frame.as_extended_target(), 4, union_ty) - .into_jlrs_result()?; + let mut arr = Array::new_for(&mut frame, 4, union_ty).into_jlrs_result()?; { let mut data = arr.union_data_mut()?; @@ -113,8 +111,7 @@ mod tests { ) .into_jlrs_result()?; - let mut arr = Array::new_for(frame.as_extended_target(), 4, union_ty) - .into_jlrs_result()?; + let mut arr = Array::new_for(&mut frame, 4, union_ty).into_jlrs_result()?; { let mut data = arr.union_data_mut()?; @@ -154,8 +151,7 @@ mod tests { ) .into_jlrs_result()?; - let mut arr = Array::new_for(frame.as_extended_target(), 4, union_ty) - .into_jlrs_result()?; + let mut arr = Array::new_for(&mut frame, 4, union_ty).into_jlrs_result()?; unsafe { let mut data = arr.union_data_mut()?; diff --git a/jlrs/tests/util/JlrsDeriveTests.jl b/jlrs/tests/util/JlrsDeriveTests.jl deleted file mode 100644 index 1c625959..00000000 --- a/jlrs/tests/util/JlrsDeriveTests.jl +++ /dev/null @@ -1,212 +0,0 @@ -# include("./JlrsReflect.jl") - -module SingleFieldBits -struct BitsTypeBool - a::Bool -end - -struct BitsTypeChar - a::Char -end - -struct BitsTypeUInt8 - a::UInt8 -end - -struct BitsTypeUInt16 - a::UInt16 -end - -struct BitsTypeUInt32 - a::UInt32 -end - -struct BitsTypeUInt64 - a::UInt64 -end - -struct BitsTypeUInt - a::UInt -end - -struct BitsTypeInt8 - a::Int8 -end - -struct BitsTypeInt16 - a::Int16 -end - -struct BitsTypeInt32 - a::Int32 -end - -struct BitsTypeInt64 - a::Int64 -end - -struct BitsTypeInt - a::Int -end - -struct BitsTypeFloat32 - a::Float32 -end - -struct BitsTypeFloat64 - a::Float64 -end -end - -module MultiFieldBits -struct BitsIntBool - a::Int - b::Bool -end - -struct BitsCharFloat32Float64 - a::Char - b::Float32 - c::Float64 -end -end - -module BitsWithCustom -struct BitsIntChar - a::Int - b::Char -end - -struct BitsCharBitsIntChar - a::Char - b::BitsIntChar -end -end - -module BitsWithTuples -struct BitsUInt8TupleInt32Int64 - a::UInt8 - b::Tuple{Int32, Int64} -end - -struct BitsUInt8TupleInt32TupleInt16UInt16 - a::UInt8 - b::Tuple{Int32, Tuple{Int16, UInt16}} -end -end - -module WithBitsUnion -struct SingleVariant - a::Int8 - b::Union{Int32} - c::Int8 -end - -struct DoubleVariant - a::Int8 - b::Union{Int16, Int32} - c::Int8 -end - -struct SizeAlignMismatch - a::Int8 - b::Union{Tuple{Int16, Int16, Int16}, Int32} - c::Int8 -end - -struct UnionInTuple - a::Int8 - b::Tuple{Union{Int16, Int32}} - c::Int8 -end -end - -module WithNonBitsUnion -struct NonBitsUnion - a::Union{String,Real} -end -end - -module WithStrings -struct WithString - a::String -end -end - -module WithGeneric -struct WithGenericT{T} - a::T -end - -struct WithNestedGenericT{T} - a::WithGenericT{T} -end - -struct WithSetGeneric - a::WithGenericT{Int64} -end - -struct WithValueType{N} - a::Int64 -end - -withvaluetype(a::Int64) = WithValueType{2}(a) - -struct WithGenericUnionAll - a::WithGenericT -end - -struct WithSetGenericTuple - a::Tuple{WithGenericT{Int64}} -end - -struct WithPropagatedLifetime - a::WithGenericT{Module} -end - -struct WithPropagatedLifetimes - a::WithGenericT{Tuple{Int32, WithGenericT{Array{Int32, 2}}}} -end -end - -module ZST -struct ZeroSized end -end - - -# JlrsReflect.reflect([ -# SingleFieldBits.BitsTypeBool, -# SingleFieldBits.BitsTypeChar, -# SingleFieldBits.BitsTypeUInt8, -# SingleFieldBits.BitsTypeUInt16, -# SingleFieldBits.BitsTypeUInt32, -# SingleFieldBits.BitsTypeUInt64, -# SingleFieldBits.BitsTypeUInt, -# SingleFieldBits.BitsTypeInt8, -# SingleFieldBits.BitsTypeInt16, -# SingleFieldBits.BitsTypeInt32, -# SingleFieldBits.BitsTypeInt64, -# SingleFieldBits.BitsTypeInt, -# SingleFieldBits.BitsTypeFloat32, -# SingleFieldBits.BitsTypeFloat64, -# MultiFieldBits.BitsIntBool, -# MultiFieldBits.BitsCharFloat32Float64, -# BitsWithCustom.BitsIntChar, -# BitsWithCustom.BitsCharBitsIntChar, -# BitsWithTuples.BitsUInt8TupleInt32Int64, -# BitsWithTuples.BitsUInt8TupleInt32TupleInt16UInt16, -# WithBitsUnion.SingleVariant, -# WithBitsUnion.DoubleVariant, -# WithBitsUnion.SizeAlignMismatch, -# WithBitsUnion.UnionInTuple, -# WithNonBitsUnion.NonBitsUnion, -# WithGeneric.WithGenericT, -# WithGeneric.WithNestedGenericT, -# WithGeneric.WithSetGeneric, -# WithGeneric.WithValueType, -# WithGeneric.WithGenericUnionAll, -# WithGeneric.WithSetGenericTuple, -# WithGeneric.WithPropagatedLifetime, -# WithGeneric.WithPropagatedLifetimes, -# ZST.ZeroSized -# ]) \ No newline at end of file diff --git a/jlrs/tests/util/derive_impls.rs b/jlrs/tests/util/derive_impls.rs deleted file mode 100644 index 739893f3..00000000 --- a/jlrs/tests/util/derive_impls.rs +++ /dev/null @@ -1,312 +0,0 @@ -use jlrs::prelude::*; - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.BitsWithCustom.BitsCharBitsIntChar")] -pub struct BitsCharBitsIntChar { - pub a: ::jlrs::data::layout::char::Char, - pub b: BitsIntChar, -} - -#[cfg(target_pointer_width = "64")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.BitsWithCustom.BitsIntChar")] -pub struct BitsIntChar { - pub a: i64, - pub b: ::jlrs::data::layout::char::Char, -} - -#[cfg(target_pointer_width = "32")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.BitsWithCustom.BitsIntChar")] -pub struct BitsIntChar { - pub a: i32, - pub b: ::jlrs::data::layout::char::Char, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.BitsWithTuples.BitsUInt8TupleInt32Int64")] -pub struct BitsUInt8TupleInt32Int64 { - pub a: u8, - pub b: ::jlrs::data::layout::tuple::Tuple2, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.BitsWithTuples.BitsUInt8TupleInt32TupleInt16UInt16")] -pub struct BitsUInt8TupleInt32TupleInt16UInt16 { - pub a: u8, - pub b: ::jlrs::data::layout::tuple::Tuple2>, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.MultiFieldBits.BitsCharFloat32Float64")] -pub struct BitsCharFloat32Float64 { - pub a: ::jlrs::data::layout::char::Char, - pub b: f32, - pub c: f64, -} - -#[cfg(target_pointer_width = "64")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.MultiFieldBits.BitsIntBool")] -pub struct BitsIntBool { - pub a: i64, - pub b: ::jlrs::data::layout::bool::Bool, -} - -#[cfg(target_pointer_width = "32")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.MultiFieldBits.BitsIntBool")] -pub struct BitsIntBool { - pub a: i32, - pub b: ::jlrs::data::layout::bool::Bool, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeBool")] -pub struct BitsTypeBool { - pub a: ::jlrs::data::layout::bool::Bool, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeChar")] -pub struct BitsTypeChar { - pub a: ::jlrs::data::layout::char::Char, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeFloat32")] -pub struct BitsTypeFloat32 { - pub a: f32, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeFloat64")] -pub struct BitsTypeFloat64 { - pub a: f64, -} - -#[cfg(target_pointer_width = "64")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeInt")] -pub struct BitsTypeInt { - pub a: i64, -} - -#[cfg(target_pointer_width = "32")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeInt")] -pub struct BitsTypeInt { - pub a: i32, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeInt16")] -pub struct BitsTypeInt16 { - pub a: i16, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeInt32")] -pub struct BitsTypeInt32 { - pub a: i32, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeInt64")] -pub struct BitsTypeInt64 { - pub a: i64, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeInt8")] -pub struct BitsTypeInt8 { - pub a: i8, -} - -#[cfg(target_pointer_width = "64")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeUInt")] -pub struct BitsTypeUInt { - pub a: u64, -} - -#[cfg(target_pointer_width = "32")] -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeUInt")] -pub struct BitsTypeUInt { - pub a: u32, -} -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeUInt16")] -pub struct BitsTypeUInt16 { - pub a: u16, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeUInt32")] -pub struct BitsTypeUInt32 { - pub a: u32, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeUInt64")] -pub struct BitsTypeUInt64 { - pub a: u64, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.SingleFieldBits.BitsTypeUInt8")] -pub struct BitsTypeUInt8 { - pub a: u8, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithBitsUnion.DoubleVariant")] -pub struct DoubleVariant { - pub a: i8, - #[jlrs(bits_union_align)] - _b_align: ::jlrs::data::layout::union::Align4, - #[jlrs(bits_union)] - pub b: ::jlrs::data::layout::union::BitsUnion<4>, - #[jlrs(bits_union_flag)] - pub b_flag: u8, - pub c: i8, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.WithBitsUnion.SingleVariant")] -pub struct SingleVariant { - pub a: i8, - pub b: i32, - pub c: i8, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithBitsUnion.SizeAlignMismatch")] -pub struct SizeAlignMismatch { - pub a: i8, - #[jlrs(bits_union_align)] - _b_align: ::jlrs::data::layout::union::Align4, - #[jlrs(bits_union)] - pub b: ::jlrs::data::layout::union::BitsUnion<6>, - #[jlrs(bits_union_flag)] - pub b_flag: u8, - pub c: i8, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithBitsUnion.UnionInTuple")] -pub struct UnionInTuple<'frame, 'data> { - pub a: i8, - pub b: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'frame, 'data>>, - pub c: i8, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, ConstructType)] -#[jlrs(julia_type = "Main.WithGeneric.WithGenericT")] -pub struct WithGenericT -where - T: ::jlrs::data::layout::valid_layout::ValidField + Clone, -{ - pub a: T, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithGeneric.WithGenericUnionAll")] -pub struct WithGenericUnionAll<'frame, 'data> { - pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'frame, 'data>>, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithGeneric.WithNestedGenericT")] -pub struct WithNestedGenericT -where - T: ::jlrs::data::layout::valid_layout::ValidField + Clone, -{ - pub a: WithGenericT, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithGeneric.WithPropagatedLifetime")] -pub struct WithPropagatedLifetime<'frame> { - pub a: WithGenericT<::std::option::Option<::jlrs::data::managed::module::ModuleRef<'frame>>>, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithGeneric.WithPropagatedLifetimes")] -pub struct WithPropagatedLifetimes<'frame, 'data> { - pub a: WithGenericT< - ::jlrs::data::layout::tuple::Tuple2< - i32, - WithGenericT< - ::std::option::Option<::jlrs::data::managed::array::ArrayRef<'frame, 'data>>, - >, - >, - >, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.WithGeneric.WithSetGeneric")] -pub struct WithSetGeneric { - pub a: WithGenericT, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.WithGeneric.WithSetGenericTuple")] -pub struct WithSetGenericTuple { - pub a: ::jlrs::data::layout::tuple::Tuple1>, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithGeneric.WithValueType")] -pub struct WithValueType { - pub a: i64, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck)] -#[jlrs(julia_type = "Main.WithNonBitsUnion.NonBitsUnion")] -pub struct NonBitsUnion<'frame, 'data> { - pub a: ::std::option::Option<::jlrs::data::managed::value::ValueRef<'frame, 'data>>, -} - -#[repr(C)] -#[derive(Clone, Debug, Unbox, ValidLayout, ValidField, Typecheck, IntoJulia)] -#[jlrs(julia_type = "Main.ZST.ZeroSized", zero_sized_type)] -pub struct ZeroSized {} diff --git a/jlrs/tests/util/mod.rs b/jlrs/tests/util/mod.rs index b84f8272..be77ebdd 100644 --- a/jlrs/tests/util/mod.rs +++ b/jlrs/tests/util/mod.rs @@ -16,10 +16,6 @@ static JLRS_TESTS_JL: &'static str = include_str!("JlrsTests.jl"); #[allow(dead_code)] static JLRS_STABLE_TESTS_JL: &'static str = include_str!("JlrsStableTests.jl"); -#[cfg(all(feature = "jlrs-derive", feature = "sync-rt"))] -#[allow(dead_code)] -pub static JLRS_DERIVE_TESTS_JL: &'static str = include_str!("JlrsNewDeriveTests.jl"); - #[cfg(all(feature = "sync-rt", not(feature = "julia-1-6")))] #[allow(dead_code)] pub static MIXED_BAG_JL: &'static str = include_str!("MixedBagStable.jl"); @@ -28,16 +24,6 @@ pub static MIXED_BAG_JL: &'static str = include_str!("MixedBagStable.jl"); #[allow(dead_code)] pub static MIXED_BAG_JL: &'static str = include_str!("MixedBagLTS.jl"); -#[cfg(all(feature = "async-rt",))] -#[allow(dead_code)] -pub static ASYNC_TESTS_JL: &'static str = include_str!("AsyncTests.jl"); - -#[cfg(all(feature = "async-rt",))] -pub mod async_tasks; - -#[cfg(feature = "jlrs-derive")] -pub mod new_derive_impls; - thread_local! { #[cfg(feature = "sync-rt")] #[doc(hidden)] @@ -52,16 +38,4 @@ thread_local! { }).unwrap(); r }; - - #[cfg(all(feature = "jlrs-derive", feature = "sync-rt"))] - #[doc(hidden)] - pub static JULIA_DERIVE: RefCell = { - let mut frame = StackFrame::new(); - let r = RefCell::new(unsafe {RuntimeBuilder::new().start().unwrap() }); - r.borrow_mut().instance(&mut frame).scope(|mut frame| unsafe { - Value::eval_string(&mut frame, JLRS_DERIVE_TESTS_JL).expect("failed to evaluate contents of JlrsTests.jl"); - Ok(()) - }).unwrap(); - r - }; } diff --git a/jlrs/tests/valid_layout.rs b/jlrs/tests/valid_layout.rs index 5734d39b..6605895f 100644 --- a/jlrs/tests/valid_layout.rs +++ b/jlrs/tests/valid_layout.rs @@ -162,7 +162,7 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { unsafe { - let v = Array::new::(frame.as_extended_target(), (2, 2)) + let v = Array::new::(&mut frame, (2, 2)) .into_jlrs_result()? .as_value(); assert!(ArrayRef::valid_layout(v.datatype().as_value())); @@ -183,7 +183,7 @@ mod tests { let mut jlrs = j.borrow_mut(); jlrs.instance(&mut frame) .scope(|mut frame| { - let v = Array::new::(frame.as_extended_target(), (2, 2)) + let v = Array::new::(&mut frame, (2, 2)) .into_jlrs_result()? .as_value(); assert!(!bool::valid_layout(v)); diff --git a/jlrs/tests/value_array.rs b/jlrs/tests/value_array.rs index d9b75984..4d7c4716 100644 --- a/jlrs/tests/value_array.rs +++ b/jlrs/tests/value_array.rs @@ -15,12 +15,9 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let global = frame.unrooted(); - let mut arr = Array::new_for( - frame.as_extended_target(), - 4, - DataType::module_type(&global).as_value(), - ) - .into_jlrs_result()?; + let mut arr = + Array::new_for(&mut frame, 4, DataType::module_type(&global).as_value()) + .into_jlrs_result()?; { let data = unsafe { arr.value_data()? }; @@ -56,12 +53,9 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let global = frame.unrooted(); - let mut arr = Array::new_for( - frame.as_extended_target(), - 4, - DataType::module_type(&global).as_value(), - ) - .into_jlrs_result()?; + let mut arr = + Array::new_for(&mut frame, 4, DataType::module_type(&global).as_value()) + .into_jlrs_result()?; let module = Module::core(&frame).as_value(); @@ -113,12 +107,9 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let global = frame.unrooted(); - let mut arr = Array::new_for( - frame.as_extended_target(), - 4, - DataType::module_type(&global).as_value(), - ) - .into_jlrs_result()?; + let mut arr = + Array::new_for(&mut frame, 4, DataType::module_type(&global).as_value()) + .into_jlrs_result()?; let module = Value::nothing(&frame); @@ -146,12 +137,9 @@ mod tests { jlrs.instance(&mut frame) .scope(|mut frame| { let global = frame.unrooted(); - let mut arr = Array::new_for( - frame.as_extended_target(), - 4, - DataType::module_type(&global).as_value(), - ) - .into_jlrs_result()?; + let mut arr = + Array::new_for(&mut frame, 4, DataType::module_type(&global).as_value()) + .into_jlrs_result()?; { let data = unsafe { arr.value_data_mut()? }; diff --git a/jlrs_macros/Cargo.toml b/jlrs_macros/Cargo.toml index b0198cd6..8ad8b16a 100644 --- a/jlrs_macros/Cargo.toml +++ b/jlrs_macros/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "jlrs-macros" -version = "0.1.2" +version = "0.2.0" authors = ["Thomas van Doornmalen "] description = """ jlrs-macros contains the custom derives offered by jlrs. @@ -14,11 +14,13 @@ license = "MIT" edition = "2018" [features] +default = [] julia-1-6 = [] julia-1-7 = [] julia-1-8 = [] julia-1-9 = [] julia-1-10 = [] +julia-1-11 = [] windows = [] derive = ["proc-macro2", "syn", "quote"] @@ -29,8 +31,9 @@ proc-macro = true [dependencies] proc-macro2 = { version = "1", optional = true } -syn = { version = "2", features = ["full"], optional = true } +syn = { version = "2", features = ["full", "extra-traits"], optional = true } quote = { version = "1", optional = true } +itertools = "0.11" [package.metadata.docs.rs] features = ["ccall", "derive", "julia-1-10"] diff --git a/jlrs_macros/src/derive.rs b/jlrs_macros/src/derive.rs index f5973fab..c52380c0 100644 --- a/jlrs_macros/src/derive.rs +++ b/jlrs_macros/src/derive.rs @@ -1,7 +1,7 @@ use proc_macro::TokenStream; use proc_macro2::TokenStream as TS2; -use quote::quote; -use syn::{self, punctuated::Punctuated, token::Comma, Expr, Lit, Meta, Token, WherePredicate}; +use quote::{format_ident, quote}; +use syn::{self, punctuated::Punctuated, token::Comma, Token}; #[derive(Default)] pub struct ClassifiedFields<'a> { @@ -65,37 +65,128 @@ impl<'a> ClassifiedFields<'a> { pub struct JlrsTypeAttrs { julia_type: Option, + constructor_for: Option, zst: bool, + scope_lifetime: bool, + data_lifetime: bool, + layout_params: Vec, + elided_params: Vec, + all_params: Vec, } impl JlrsTypeAttrs { fn parse(ast: &syn::DeriveInput) -> Self { let mut julia_type: Option = None; + let mut constructor_for: Option = None; + let mut scope_lifetime = false; + let mut data_lifetime = false; + let mut layout_params = Vec::new(); + let mut elided_params = Vec::new(); + let mut all_params = Vec::new(); let mut zst = false; + for attr in &ast.attrs { if attr.path().is_ident("jlrs") { let nested = attr - .parse_args_with(Punctuated::::parse_terminated) + .parse_args_with(Punctuated::::parse_terminated) .unwrap(); for meta in nested { match meta { - Meta::Path(path) if path.is_ident("zero_sized_type") => { + syn::Meta::Path(path) if path.is_ident("zero_sized_type") => { zst = true; } - Meta::NameValue(mnv) if mnv.path.is_ident("julia_type") => { - if let Expr::Lit(lit) = mnv.value { - if let Lit::Str(s) = lit.lit { + syn::Meta::NameValue(mnv) if mnv.path.is_ident("julia_type") => { + if let syn::Expr::Lit(lit) = mnv.value { + if let syn::Lit::Str(s) = lit.lit { julia_type = Some(s.value()); } } } - _ => todo!(), + syn::Meta::NameValue(mnv) if mnv.path.is_ident("constructor_for") => { + if let syn::Expr::Lit(lit) = mnv.value { + if let syn::Lit::Str(s) = lit.lit { + constructor_for = Some(s.value()); + } + } + } + syn::Meta::NameValue(mnv) if mnv.path.is_ident("scope_lifetime") => { + if let syn::Expr::Lit(lit) = mnv.value { + if let syn::Lit::Bool(b) = lit.lit { + scope_lifetime = b.value; + } + } + } + syn::Meta::NameValue(mnv) if mnv.path.is_ident("data_lifetime") => { + if let syn::Expr::Lit(lit) = mnv.value { + if let syn::Lit::Bool(b) = lit.lit { + data_lifetime = b.value; + } + } + } + syn::Meta::NameValue(mnv) if mnv.path.is_ident("layout_params") => { + if let syn::Expr::Array(arr) = mnv.value { + let tys = arr.elems.iter().filter_map(|x| match x { + syn::Expr::Lit(lit) => { + if let syn::Lit::Str(ref s) = lit.lit { + Some(s.value()) + } else { + None + } + } + _ => None, + }); + + layout_params.extend(tys) + } + } + syn::Meta::NameValue(mnv) if mnv.path.is_ident("elided_params") => { + if let syn::Expr::Array(arr) = mnv.value { + let tys = arr.elems.iter().filter_map(|x| match x { + syn::Expr::Lit(lit) => { + if let syn::Lit::Str(ref s) = lit.lit { + Some(s.value()) + } else { + None + } + } + _ => None, + }); + + elided_params.extend(tys) + } + } + syn::Meta::NameValue(mnv) if mnv.path.is_ident("all_params") => { + if let syn::Expr::Array(arr) = mnv.value { + let tys = arr.elems.iter().filter_map(|x| match x { + syn::Expr::Lit(lit) => { + if let syn::Lit::Str(ref s) = lit.lit { + Some(s.value()) + } else { + None + } + } + _ => None, + }); + + all_params.extend(tys) + } + } + _ => (), } } } } - JlrsTypeAttrs { julia_type, zst } + JlrsTypeAttrs { + julia_type, + zst, + constructor_for, + scope_lifetime, + data_lifetime, + layout_params, + elided_params, + all_params, + } } } @@ -109,11 +200,11 @@ impl JlrsFieldAttr { pub fn parse(attr: &syn::Attribute) -> Option { if attr.path().is_ident("jlrs") { let nested = attr - .parse_args_with(Punctuated::::parse_terminated) + .parse_args_with(Punctuated::::parse_terminated) .unwrap(); for meta in nested { - let Meta::Path(path) = meta else { - return None + let syn::Meta::Path(path) = meta else { + return None; }; if path.is_ident("bits_union") { @@ -136,63 +227,18 @@ pub fn impl_into_julia(ast: &syn::DeriveInput) -> TokenStream { panic!("IntoJulia can only be derived for types with the attribute #[repr(C)]."); } - let mut attrs = JlrsTypeAttrs::parse(ast); - let jl_type = attrs.julia_type - .take() - .expect("IntoJulia can only be derived if the corresponding Julia type is set with #[julia_type = \"Main.MyModule.Submodule.StructType\"]"); - - let mut type_it = jl_type.split('.'); - let func: syn::Expr = match type_it.next() { - Some("Main") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::main(&global) - } - }, - Some("Base") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::base(&global) - } - }, - Some("Core") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::core(&global) - } - }, - Some(pkg) => syn::parse_quote! { - { - let module = ::jlrs::data::managed::module::Module::package_root_module(&global, #pkg); - match module { - Some(module) => module, - _ => panic!("Package {} cannot be found", #pkg) - } - } - }, - _ => panic!("IntoJulia can only be derived if the first module of \"julia_type\" is either \"Main\", \"Base\" or \"Core\", or a package name."), - }; - - let mut modules = type_it.collect::>(); - let ty = modules.pop().expect("IntoJulia can only be derived if the corresponding Julia type is set with #[jlrs(julia_type = \"Main.MyModule.Submodule.StructType\")]"); - let modules_it = modules.iter(); - let modules_it_b = modules_it.clone(); - + let attrs = JlrsTypeAttrs::parse(ast); let into_julia_fn = impl_into_julia_fn(&attrs); let into_julia_impl = quote! { unsafe impl ::jlrs::convert::into_julia::IntoJulia for #name { + #[inline] fn julia_type<'scope, T>(target: T) -> ::jlrs::data::managed::datatype::DataTypeData<'scope, T> where T: ::jlrs::memory::target::Target<'scope>, { unsafe { - let global = target.unrooted(); - #func - #( - .submodule(&global, #modules_it) - .expect(&format!("Submodule {} cannot be found", #modules_it_b)) - .as_managed() - )* - .global(&global, #ty) - .expect(&format!("Type {} cannot be found in module", #ty)) + ::construct_type(&target) .as_value() .cast::<::jlrs::data::managed::datatype::DataType>() .expect("Type is not a DataType") @@ -210,6 +256,7 @@ pub fn impl_into_julia(ast: &syn::DeriveInput) -> TokenStream { pub fn impl_into_julia_fn(attrs: &JlrsTypeAttrs) -> Option { if attrs.zst { Some(quote! { + #[inline] fn into_julia<'target, T>(self, target: T) -> ::jlrs::data::managed::value::ValueData<'target, 'static, T> where T: ::jlrs::memory::target::Target<'target>, @@ -219,7 +266,6 @@ pub fn impl_into_julia_fn(attrs: &JlrsTypeAttrs) -> Option { ty.as_managed() .instance() .expect("Instance is undefined") - .as_value() .root(target) } } @@ -240,7 +286,7 @@ pub fn impl_unbox(ast: &syn::DeriveInput) -> TokenStream { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: Clone }; wc.predicates.push(clause) @@ -250,7 +296,7 @@ pub fn impl_unbox(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: Clone }; predicates.push(clause) @@ -281,13 +327,13 @@ pub fn impl_typecheck(ast: &syn::DeriveInput) -> TokenStream { let where_clause = match ast.generics.where_clause.as_ref() { Some(wc) => { let mut wc = wc.clone(); - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { Self: ::jlrs::data::layout::valid_layout::ValidLayout }; wc.predicates.push(clause); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { - #generic: ::jlrs::data::layout::valid_layout::ValidLayout + let clause: syn::WherePredicate = syn::parse_quote! { + #generic: ::jlrs::data::layout::valid_layout::ValidField }; wc.predicates.push(clause) } @@ -295,14 +341,14 @@ pub fn impl_typecheck(ast: &syn::DeriveInput) -> TokenStream { } None => { let mut predicates = Punctuated::<_, Comma>::new(); - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { Self: ::jlrs::data::layout::valid_layout::ValidLayout }; predicates.push(clause); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { - #generic: ::jlrs::data::layout::valid_layout::ValidLayout + let clause: syn::WherePredicate = syn::parse_quote! { + #generic: ::jlrs::data::layout::valid_layout::ValidField }; predicates.push(clause) } @@ -315,6 +361,7 @@ pub fn impl_typecheck(ast: &syn::DeriveInput) -> TokenStream { let typecheck_impl = quote! { unsafe impl #generics ::jlrs::data::types::typecheck::Typecheck for #name #generics #where_clause { + #[inline] fn typecheck(dt: ::jlrs::data::managed::datatype::DataType) -> bool { ::valid_layout(dt.as_value()) } @@ -331,48 +378,21 @@ pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { .take() .expect("ConstructType can only be derived if the corresponding Julia type is set with #[julia_type = \"Main.MyModule.Submodule.StructType\"]"); - let mut type_it = jl_type.split('.'); - let func: syn::Expr = match type_it.next() { - Some("Main") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::main(&frame) - } - }, - Some("Base") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::base(&frame) - } - }, - Some("Core") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::core(&frame) - } - }, - Some(pkg) => syn::parse_quote! { - { - let module = ::jlrs::data::managed::module::Module::package_root_module(&frame, #pkg); - match module { - Some(module) => module, - _ => panic!("Package {} cannot be found", #pkg) - } - } - }, - _ => panic!("ConstructType can only be derived if the first module of \"julia_type\" is either \"Main\", \"Base\" or \"Core\", or a package name."), - }; + let lifetimes = ast.generics.lifetimes().map(|_| -> syn::LifetimeParam { + syn::parse_quote! { 'static } + }); - let mut modules = type_it.collect::>(); - let ty = modules.pop().expect("ConstructType can only be derived if the corresponding Julia type is set with #[jlrs(julia_type = \"Main.MyModule.Submodule.StructType\")]"); - let modules_it = modules.iter(); - let modules_it_b = modules_it.clone(); - let modules_it_c = modules_it.clone(); - let modules_it_d = modules_it.clone(); + let static_types = ast.generics.type_params().map(|p| -> syn::Type { + let name = &p.ident; + syn::parse_quote! { #name::Static } + }); let generics = &ast.generics; let wc = match ast.generics.where_clause.as_ref() { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::types::construct_type::ConstructType }; wc.predicates.push(clause) @@ -382,7 +402,7 @@ pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::types::construct_type::ConstructType }; predicates.push(clause) @@ -393,79 +413,72 @@ pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { } } }; + let n_generics = ast.generics.params.len(); + + let (cacheable, construct_expr): (Option, syn::Expr) = if n_generics == 0 { + let cacheable = syn::parse_quote! { + const CACHEABLE: bool = false; + }; + + let construct_expr = syn::parse_quote! { + base_type.root(target) + }; + + (Some(cacheable), construct_expr) + } else { + let param_names = ast.generics.type_params().map(|p| &p.ident); + + let n_slots = n_generics + 2; + let nth_generic = 0..n_generics; + + let construct_expr = syn::parse_quote! { + target.with_local_scope::<_, _, #n_slots>(|target, mut frame| { + let mut types: [Option<::jlrs::data::managed::value::Value>; #n_generics] = [None; #n_generics]; + #( + types[#nth_generic] = Some(<#param_names as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame)); + )* + unsafe { + let types = std::mem::transmute::<&[Option<::jlrs::data::managed::value::Value>; #n_generics], &[::jlrs::data::managed::value::Value; #n_generics]>(&types); + let applied = base_type + .apply_type(&mut frame, types).into_jlrs_result()?; + Ok(::jlrs::data::managed::union_all::UnionAll::rewrap( + target, + applied.cast_unchecked::<::jlrs::data::managed::datatype::DataType>(), + )) + } + }).unwrap() + }; - let param_names = ast - .generics - .type_params() - .map(|p| &p.ident) - .collect::>(); - let n_generics = param_names.len(); - let param_names = param_names.iter(); - let nth_generic = 0..n_generics; + (None, construct_expr) + }; let construct_type_impl = quote! { unsafe impl #generics ::jlrs::data::types::construct_type::ConstructType for #name #generics #wc { - fn construct_type<'target, Tgt>( - target: ::jlrs::memory::target::ExtendedTarget<'target, '_, '_, Tgt>, + type Static = #name <#(#lifetimes,)* #(#static_types,)*>; + + #cacheable + + fn construct_type_uncached<'target, Tgt>( + target: Tgt, ) -> ::jlrs::data::managed::value::ValueData<'target, 'static, Tgt> where Tgt: ::jlrs::memory::target::Target<'target>, { - let (target, frame) = target.split(); - - frame.scope(|mut frame| { - let base_type = unsafe { - #func - #( - .submodule(&frame, #modules_it) - .expect(&format!("Submodule {} cannot be found", #modules_it_b)) - .as_managed() - )* - .global(&frame, #ty) - .expect(&format!("Type {} cannot be found in module", #ty)) - .as_value() - }; - - if base_type.is::<::jlrs::data::managed::datatype::DataType>() { - return Ok(base_type.root(target)) - } - - let mut types: [Option<::jlrs::data::managed::value::Value>; #n_generics] = [None; #n_generics]; - #( - types[#nth_generic] = Some(<#param_names as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target())); - )* - unsafe { - let types = std::mem::transmute::<&[Option<::jlrs::data::managed::value::Value>; #n_generics], &[::jlrs::data::managed::value::Value; #n_generics]>(&types); - let applied = base_type - .apply_type_unchecked(&mut frame, types); - Ok(::jlrs::data::managed::union_all::UnionAll::rewrap( - target.into_extended_target(&mut frame), - applied.cast_unchecked::<::jlrs::data::managed::datatype::DataType>(), - )) - } - }).unwrap() + let base_type = Self::base_type(&target).unwrap(); + #construct_expr } + #[inline] fn base_type<'target, Tgt>( target: &Tgt ) -> Option<::jlrs::data::managed::value::Value<'target, 'static>> where Tgt: ::jlrs::memory::target::Target<'target>, { - let frame = target; - let base_type = unsafe { - #func - #( - .submodule(target, #modules_it_c) - .expect(&format!("Submodule {} cannot be found", #modules_it_d)) - .as_managed() - )* - .global(target, #ty) - .expect(&format!("Type {} cannot be found in module", #ty)) - .as_value() - }; - - Some(base_type) + unsafe { + let value = ::jlrs::inline_static_ref!(STATIC, Value, #jl_type, target); + Some(value) + } } } }; @@ -473,55 +486,89 @@ pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { construct_type_impl.into() } -/* -pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { +pub fn impl_has_layout(ast: &syn::DeriveInput) -> TokenStream { let name = &ast.ident; - let mut attrs = JlrsTypeAttrs::parse(ast); - let jl_type = attrs.julia_type - .take() - .expect("ConstructType can only be derived if the corresponding Julia type is set with #[julia_type = \"Main.MyModule.Submodule.StructType\"]"); + let attrs = JlrsTypeAttrs::parse(ast); + + let layout_type = format_ident!( + "{}", + attrs + .constructor_for + .as_ref() + .expect("HasLayout can only be implemented when a layout type is provided") + ); + + let all_params = attrs.all_params.iter().map(|i| format_ident!("{}", i)); + let all_params2 = all_params.clone(); + let all_generics: syn::Generics = syn::parse_quote! { + <'scope, 'data, #(#all_params,)*> + }; - let mut type_it = jl_type.split('.'); - let func: syn::Expr = match type_it.next() { - Some("Main") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::main(target) - } - }, - Some("Base") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::base(target) - } - }, - Some("Core") => syn::parse_quote! { - { - ::jlrs::data::managed::module::Module::corr(target) - } - }, - Some(pkg) => syn::parse_quote! { - { - let module = ::jlrs::data::managed::module::Module::package_root_module(target, #pkg); - match module { - Some(module) => module, - _ => panic!("Package {} cannot be found", #pkg) - } - } - }, - _ => panic!("ConstructType can only be derived if the first module of \"julia_type\" is either \"Main\", \"Base\" or \"Core\", or a package name."), + let constructor_generics: syn::Generics = syn::parse_quote! { + <#(#all_params2,)*> }; - let mut modules = type_it.collect::>(); - let ty = modules.pop().expect("ConstructType can only be derived if the corresponding Julia type is set with #[jlrs(julia_type = \"Main.MyModule.Submodule.StructType\")]"); - let modules_it = modules.iter(); - let modules_it_b = modules_it.clone(); + let layout_params = attrs.layout_params.iter().map(|i| format_ident!("{}", i)); + let mut layout_generics: syn::Generics = syn::parse_quote! { + <#(#layout_params,)*> + }; + + if attrs.scope_lifetime { + layout_generics + .params + .insert(0, syn::parse_quote! { 'scope }); + } + + // 'data implies 'scope + if attrs.data_lifetime { + layout_generics + .params + .insert(1, syn::parse_quote! { 'data }); + } + + let where_clause: syn::WhereClause = { + let mut predicates = Punctuated::<_, Comma>::new(); + + for generic in attrs.layout_params.iter().map(|i| format_ident!("{}", i)) { + let clause: syn::WherePredicate = syn::parse_quote! { + #generic: ::jlrs::data::types::construct_type::ConstructType + ::jlrs::data::layout::valid_layout::ValidField + }; + + predicates.push(clause) + } + + for generic in attrs.elided_params.iter().map(|i| format_ident!("{}", i)) { + let clause: syn::WherePredicate = syn::parse_quote! { + #generic: ::jlrs::data::types::construct_type::ConstructType + }; + + predicates.push(clause) + } + + syn::parse_quote! { + where #predicates + } + }; + + let has_layout_impl = quote! { + unsafe impl #all_generics ::jlrs::data::layout::typed_layout::HasLayout<'scope, 'data> for #name #constructor_generics #where_clause { + type Layout = #layout_type #layout_generics; + } + }; + + has_layout_impl.into() +} + +pub fn impl_is_bits(ast: &syn::DeriveInput) -> TokenStream { + let name = &ast.ident; let generics = &ast.generics; let wc = match ast.generics.where_clause.as_ref() { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { - #generic: ::jlrs::convert::construct_type::ConstructType + let clause: syn::WherePredicate = syn::parse_quote! { + #generic: ::jlrs::data::layout::is_bits::IsBits }; wc.predicates.push(clause) } @@ -530,8 +577,8 @@ pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { - #generic: ::jlrs::convert::construct_type::ConstructType + let clause: syn::WherePredicate = syn::parse_quote! { + #generic: ::jlrs::data::layout::is_bits::IsBits }; predicates.push(clause) } @@ -542,73 +589,12 @@ pub fn impl_construct_type(ast: &syn::DeriveInput) -> TokenStream { } }; - let param_names = ast - .generics - .type_params() - .map(|p| &p.ident) - .collect::>(); - let n_generics = param_names.len(); - let param_names = param_names.iter(); - let nth_generic = 0..n_generics; - - let construct_type_impl = quote! { - unsafe impl #generics ::jlrs::convert::construct_type::ConstructType for #name #generics #wc { - fn base_type<'target, TARGET>(target: &TARGET) -> ::jlrs::data::managed::value::Value<'target, 'static> - where - TARGET: ::jlrs::memory::target::Target<'target>, - { - unsafe { - #func - #( - .submodule(target, #modules_it) - .expect(&format!("Submodule {} cannot be found", #modules_it_b)) - .as_managed() - )* - .global(target, #ty) - .expect(&format!("Type {} cannot be found in module", #ty)) - .as_value() - } - } - - fn construct_type<'target, 'current, 'borrow, TARGET>( - target: ::jlrs::memory::target::ExtendedTarget<'target, '_, '_, TARGET>, - ) -> ::jlrs::data::managed::datatype::DataTypeData<'target, TARGET> - where - TARGET: ::jlrs::memory::target::Target<'target>, - { - let (target, frame) = target.split(); - - frame.scope(|mut frame| { - let base_type = Self::base_type(&frame); - if let Ok(ty) = base_type.cast::<::jlrs::data::managed::datatype::DataType>() { - Ok(ty.root(target)) - } else if let Ok(ua) = base_type.cast::<::jlrs::data::managed::union_all::UnionAll>() { - let mut types: [Option<::jlrs::data::managed::value::Value>; #n_generics] = [None; #n_generics]; - #( - types[#nth_generic] = Some(<#param_names as ::jlrs::convert::construct_type::ConstructType>::construct_type(frame.as_extended_target()).as_value()); - )* - unsafe { - let types = std::mem::transmute::<&[Option<::jlrs::data::managed::value::Value>; #n_generics], &[::jlrs::data::managed::value::Value; #n_generics]>(&types); - let applied = ua - .apply_types_unchecked(&target, types) - .as_value() - .cast::<::jlrs::data::managed::datatype::DataType>() - .expect("UnionAll is not a DataType after applying generic types") - .root(target); - - Ok(applied) - } - } else { - panic!("Type is neither a DataType or UnionAll") - } - }).unwrap() - } - } + let is_bits_impl = quote! { + unsafe impl #generics ::jlrs::data::layout::is_bits::IsBits for #name #generics #wc {} }; - construct_type_impl.into() + is_bits_impl.into() } -*/ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { let name = &ast.ident; @@ -621,7 +607,7 @@ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::layout::valid_layout::ValidField }; wc.predicates.push(clause) @@ -631,7 +617,7 @@ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::layout::valid_layout::ValidField }; predicates.push(clause) @@ -654,6 +640,11 @@ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { _ => panic!("ValidLayout cannot be derived for tuple structs."), }; + let mut attrs = JlrsTypeAttrs::parse(ast); + let jl_type = attrs.julia_type + .take() + .expect("IntoJulia can only be derived if the corresponding Julia type is set with #[julia_type = \"Main.MyModule.Submodule.StructType\"]"); + let rs_flag_fields = classified_fields.rs_flag_fields.iter(); let rs_align_fields = classified_fields.rs_align_fields.iter(); let rs_union_fields = classified_fields.rs_union_fields.iter(); @@ -668,7 +659,8 @@ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { unsafe impl #generics ::jlrs::data::layout::valid_layout::ValidLayout for #name #generics #where_clause { fn valid_layout(v: ::jlrs::data::managed::value::Value) -> bool { unsafe { - if let Ok(dt) = v.cast::<::jlrs::data::managed::datatype::DataType>() { + if v.is::<::jlrs::data::managed::datatype::DataType>() { + let dt = unsafe { v.cast_unchecked::<::jlrs::data::managed::datatype::DataType>() }; if dt.n_fields().unwrap() as usize != #n_fields { return false; } @@ -686,12 +678,16 @@ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { )* #( - if let Ok(u) = field_types[#jl_union_field_idxs].unwrap().as_managed().cast::<::jlrs::data::managed::union::Union>() { - if !::jlrs::data::layout::union::correct_layout_for::<#rs_align_fields, #rs_union_fields, #rs_flag_fields>(u) { + { + let field_type = field_types[#jl_union_field_idxs].unwrap().as_managed(); + if field_type.is::<::jlrs::data::managed::union::Union>() { + let u = field_type.cast_unchecked::<::jlrs::data::managed::union::Union>(); + if !::jlrs::data::layout::union::correct_layout_for::<#rs_align_fields, #rs_union_fields, #rs_flag_fields>(u) { + return false + } + } else { return false } - } else { - return false } )* @@ -703,6 +699,18 @@ pub fn impl_valid_layout(ast: &syn::DeriveInput) -> TokenStream { false } + #[inline] + fn type_object<'target, Tgt>( + target: &Tgt + ) -> ::jlrs::data::managed::value::Value<'target, 'static> + where + Tgt: ::jlrs::memory::target::Target<'target>, + { + unsafe { + ::jlrs::data::managed::module::Module::typed_global_cached::<::jlrs::data::managed::value::Value, _, _>(target, #jl_type).unwrap() + } + } + const IS_REF: bool = false; } }; @@ -721,7 +729,7 @@ pub fn impl_valid_field(ast: &syn::DeriveInput) -> TokenStream { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::layout::valid_layout::ValidField }; wc.predicates.push(clause) @@ -731,7 +739,7 @@ pub fn impl_valid_field(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::layout::valid_layout::ValidField }; predicates.push(clause) @@ -745,6 +753,7 @@ pub fn impl_valid_field(ast: &syn::DeriveInput) -> TokenStream { let valid_field_impl = quote! { unsafe impl #generics ::jlrs::data::layout::valid_layout::ValidField for #name #generics #where_clause { + #[inline] fn valid_field(v: ::jlrs::data::managed::value::Value) -> bool { ::valid_layout(v) } @@ -765,7 +774,7 @@ pub fn impl_ccall_arg(ast: &syn::DeriveInput) -> TokenStream { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::types::construct_type::ConstructType }; wc.predicates.push(clause) @@ -775,7 +784,7 @@ pub fn impl_ccall_arg(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::types::construct_type::ConstructType }; predicates.push(clause) @@ -808,7 +817,7 @@ pub fn impl_ccall_return(ast: &syn::DeriveInput) -> TokenStream { Some(wc) => { let mut wc = wc.clone(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::types::construct_type::ConstructType }; wc.predicates.push(clause) @@ -818,7 +827,7 @@ pub fn impl_ccall_return(ast: &syn::DeriveInput) -> TokenStream { None => { let mut predicates = Punctuated::<_, Comma>::new(); for generic in generics.type_params() { - let clause: WherePredicate = syn::parse_quote! { + let clause: syn::WherePredicate = syn::parse_quote! { #generic: ::jlrs::data::types::construct_type::ConstructType }; predicates.push(clause) @@ -834,6 +843,12 @@ pub fn impl_ccall_return(ast: &syn::DeriveInput) -> TokenStream { unsafe impl #generics ::jlrs::convert::ccall_types::CCallReturn for #name #generics #wc { type CCallReturnType = Self; type FunctionReturnType = Self; + type ReturnAs = Self; + + #[inline] + unsafe fn return_or_throw(self) -> Self::ReturnAs { + self + } } }; diff --git a/jlrs_macros/src/lib.rs b/jlrs_macros/src/lib.rs index f8830f25..30baf0ab 100644 --- a/jlrs_macros/src/lib.rs +++ b/jlrs_macros/src/lib.rs @@ -31,9 +31,6 @@ use self::version::emit_if_compatible; /// /// // Exports the function `foo` as `bar` with documentation. /// // -/// // The `unsafe extern "C" part of the signature must be elided, the signature is verified -/// // in the generated code to ensure it's correct and that the function uses the C ABI. -/// // /// // The `as ` part is optional, by default the function is exported with the /// // name it has in Rust, the exposed name can end in an exclamation mark. /// // @@ -41,9 +38,13 @@ use self::version::emit_if_compatible; /// // with the same name it shoud only be documented once. All exported items can be /// // documented, a multi-line docstring can be created by providing multiple doc attributes /// // for the same item. +/// // +/// // If the function doesn't need to call into Julia, you can annotate it with `#[gc_safe]` +/// // to allow the GC to run without having to wait until the function has returned. /// #[doc = " bar(arr::Array)"] /// #[doc = ""] /// #[doc = "Documentation for this function"] +/// #[gc_safe] /// fn foo(arr: Array) -> usize as bar; /// /// // Exports the function `foo` as `bar!` in the `Base` module. @@ -56,17 +57,19 @@ use self::version::emit_if_compatible; /// struct MyType as MyForeignType; /// /// // Exports `MyType::new` as `MyForeignType`, turning it into a constructor for that type. -/// // -/// // A Rust function is generated to call this method, so unlike free-standing functions -/// // exported methods don't have to use the C ABI. /// in MyType fn new(arg0: TypedValue) -> TypedValueRet as MyForeignType; /// /// // Exports `MyType::add` as the function `increment!`. /// // -/// // Methods that take `self` in some way must return a `RustResultRet` because the -/// // generated function tracks the borrow of `self` before calling the exported method. If -/// // `self` is taken by value, it's cloned after being tracked. +/// // If a method takes `self` in some way, it is tracked by default. You can opt out of this +/// // behavior with the `#[untracked_self]` attribute. +/// #[untracked_self] /// in MyType fn add(&mut self, incr: u32) -> RustResultRet as increment!; +/// +/// // Exports the alias `MyTypeAlias` for `MyType`. +/// // +/// // This is exposes as `const MyTypeAlias = MyType`. +/// type MyTypeAlias = MyType; /// /// // Exports the function `long_running_func`, the returned closure is executed on another /// // thread. @@ -81,6 +84,8 @@ use self::version::emit_if_compatible; /// // for `(Typed)Value` and `(Typed)Array` with static lifetimes. The generated Julia /// // function guarantees all data passed as an argument lives at least until the closure has /// // finished, the tracked data must only be shared with that closure. +/// // +/// // In practice calling a function annotated with `#[gc_safe]` is much more performant. /// async fn long_running_func( /// array: ArrayUnbound /// ) -> JlrsResult>; @@ -159,6 +164,26 @@ pub fn into_julia_derive(input: TokenStream) -> TokenStream { impl_into_julia(&ast) } +/// Derive `IsBits`. +/// +/// Should only be used in combination with layouts generated by JlrsReflect.jl +#[cfg(feature = "derive")] +#[proc_macro_derive(IsBits, attributes(jlrs))] +pub fn is_bits_derive(input: TokenStream) -> TokenStream { + let ast = syn::parse(input).unwrap(); + impl_is_bits(&ast) +} + +/// Derive `HasLayout`. +/// +/// Should only be used in combination with layouts generated by JlrsReflect.jl +#[cfg(feature = "derive")] +#[proc_macro_derive(HasLayout, attributes(jlrs))] +pub fn is_has_layout(input: TokenStream) -> TokenStream { + let ast = syn::parse(input).unwrap(); + impl_has_layout(&ast) +} + /// Derive `Unbox`. /// /// Should only be used in combination with layouts generated by JlrsReflect.jl diff --git a/jlrs_macros/src/module.rs b/jlrs_macros/src/module.rs deleted file mode 100644 index 17432ceb..00000000 --- a/jlrs_macros/src/module.rs +++ /dev/null @@ -1,2105 +0,0 @@ -use std::iter::FromIterator; - -use proc_macro::TokenStream; -use proc_macro2::Span; -use quote::{format_ident, ToTokens}; -use syn::{ - parse::{Parse, ParseStream}, - parse_quote, parse_quote_spanned, - punctuated::Punctuated, - spanned::Spanned, - token::Comma, - AttrStyle, Attribute, Error, Expr, ExprLit, FnArg, GenericArgument, Ident, ItemFn, Lit, Meta, - Path, PathArguments, Result, ReturnType, Signature, Token, Type, TypeImplTrait, TypeParamBound, -}; - -type RenameFragments = Punctuated; - -struct InitFn { - _become_token: Token![become], - init_fn: Ident, -} - -impl Parse for InitFn { - fn parse(input: ParseStream) -> Result { - let init_fn_token = input.parse()?; - let init_fn = input.parse()?; - - Ok(InitFn { - _become_token: init_fn_token, - init_fn, - }) - } -} - -struct ExportedType { - _struct_token: Token![struct], - name: Ident, - _as_token: Option, - name_override: Option, -} - -impl Parse for ExportedType { - fn parse(input: ParseStream) -> Result { - let struct_token = input.parse()?; - let name = input.parse()?; - - let lookahead = input.lookahead1(); - if lookahead.peek(Token![as]) { - let as_token = input.parse()?; - let name_override = RenameFragments::parse_separated_nonempty(input)?; - - Ok(ExportedType { - _struct_token: struct_token, - name, - _as_token: Some(as_token), - name_override: Some(name_override), - }) - } else { - Ok(ExportedType { - _struct_token: struct_token, - name, - _as_token: None, - name_override: None, - }) - } - } -} - -struct ExportedFunction { - func: Signature, - _as_token: Option, - name_override: Option, - exclamation_mark_token: Option, -} - -impl Parse for ExportedFunction { - fn parse(input: ParseStream) -> Result { - let func = input.parse()?; - - let lookahead = input.lookahead1(); - if lookahead.peek(Token![as]) { - let as_token = input.parse()?; - let name_override = RenameFragments::parse_separated_nonempty(input)?; - let exclamation_mark_token = input.parse()?; - - Ok(ExportedFunction { - func, - _as_token: Some(as_token), - name_override: Some(name_override), - exclamation_mark_token, - }) - } else { - Ok(ExportedFunction { - func, - _as_token: None, - name_override: None, - exclamation_mark_token: None, - }) - } - } -} - -struct ExportedMethod { - _in_token: Token![in], - parent: Type, - func: Signature, - _as_token: Option, - name_override: Option, - exclamation_mark_token: Option, -} - -impl Parse for ExportedMethod { - fn parse(input: ParseStream) -> Result { - let in_token = input.parse()?; - let parent = input.parse()?; - let func = input.parse()?; - - let lookahead = input.lookahead1(); - if lookahead.peek(Token![as]) { - let as_token = input.parse()?; - let name_override = RenameFragments::parse_separated_nonempty(input)?; - let exclamation_mark_token = input.parse()?; - - Ok(ExportedMethod { - _in_token: in_token, - parent, - func, - _as_token: Some(as_token), - name_override: Some(name_override), - exclamation_mark_token, - }) - } else { - Ok(ExportedMethod { - _in_token: in_token, - parent, - func, - _as_token: None, - name_override: None, - exclamation_mark_token: None, - }) - } - } -} - -struct ExportedAsyncCallback { - _async_token: Token![async], - func: Signature, - _as_token: Option, - name_override: Option, - exclamation_mark_token: Option, -} - -impl Parse for ExportedAsyncCallback { - fn parse(input: ParseStream) -> Result { - let async_token = input.parse()?; - let func = input.parse()?; - - let lookahead = input.lookahead1(); - if lookahead.peek(Token![as]) { - let as_token = input.parse()?; - let name_override = RenameFragments::parse_separated_nonempty(input)?; - let exclamation_mark_token = input.parse()?; - - Ok(ExportedAsyncCallback { - _async_token: async_token, - func, - _as_token: Some(as_token), - name_override: Some(name_override), - exclamation_mark_token, - }) - } else { - Ok(ExportedAsyncCallback { - _async_token: async_token, - func, - _as_token: None, - name_override: None, - exclamation_mark_token: None, - }) - } - } -} - -struct ExportedConst { - _const_token: Token![const], - name: Ident, - _colon: Token![:], - ty: Type, - _as_token: Option, - name_override: Option, -} - -impl Parse for ExportedConst { - fn parse(input: ParseStream) -> Result { - let const_token = input.parse()?; - let name = input.parse()?; - let colon = input.parse()?; - let ty = input.parse()?; - - let lookahead = input.lookahead1(); - if lookahead.peek(Token![as]) { - let as_token = input.parse()?; - let name_override = input.parse()?; - - Ok(ExportedConst { - _const_token: const_token, - name: name, - _colon: colon, - ty: ty, - _as_token: Some(as_token), - name_override: Some(name_override), - }) - } else { - Ok(ExportedConst { - _const_token: const_token, - name: name, - _colon: colon, - ty: ty, - _as_token: None, - name_override: None, - }) - } - } -} - -struct ExportedGlobal { - _static_token: Token![static], - name: Ident, - _colon: Token![:], - ty: Type, - _as_token: Option, - name_override: Option, -} - -impl Parse for ExportedGlobal { - fn parse(input: ParseStream) -> Result { - let static_token = input.parse()?; - let name = input.parse()?; - let colon = input.parse()?; - let ty = input.parse()?; - - let lookahead = input.lookahead1(); - if lookahead.peek(Token![as]) { - let as_token = input.parse()?; - let name_override = input.parse()?; - - Ok(ExportedGlobal { - _static_token: static_token, - name: name, - _colon: colon, - ty: ty, - _as_token: Some(as_token), - name_override: Some(name_override), - }) - } else { - Ok(ExportedGlobal { - _static_token: static_token, - name: name, - _colon: colon, - ty: ty, - _as_token: None, - name_override: None, - }) - } - } -} - -struct ItemWithAttrs { - attrs: Vec, - item: Box, -} - -impl ItemWithAttrs { - fn get_docstr(&self) -> Result { - let mut doc = String::new(); - for attr in self.attrs.iter() { - match attr.style { - AttrStyle::Outer => (), - _ => Err(syn::Error::new_spanned( - attr.to_token_stream(), - "expected `#[doc = \"docs...\"]`", - ))?, - } - - let line = match &attr.meta { - Meta::NameValue(kv) => { - if kv.path.is_ident("doc") { - match &kv.value { - Expr::Lit(ExprLit { - lit: Lit::Str(s), .. - }) => s.value(), - _ => Err(syn::Error::new_spanned( - attr.to_token_stream(), - "expected `#[doc = \"docs...\"]`", - ))?, - } - } else { - Err(syn::Error::new_spanned( - attr.to_token_stream(), - "expected `#[doc = \"docs...\"]`", - ))? - } - } - _ => Err(syn::Error::new_spanned( - attr.to_token_stream(), - "expected `#[doc = \"docs...\"]`", - ))?, - }; - - match doc.len() { - 0 => doc.push_str(&line), - _ => { - doc.push('\n'); - doc.push_str(&line); - } - } - } - - Ok(doc) - } -} - -impl Parse for ItemWithAttrs { - fn parse(input: ParseStream) -> Result { - let attr: Vec = input.call(Attribute::parse_outer)?; - let item: ModuleItem = input.parse()?; - Ok(ItemWithAttrs { - attrs: attr, - item: Box::new(item), - }) - } -} - -enum ModuleItem { - InitFn(InitFn), - ExportedType(ExportedType), - ExportedFunction(ExportedFunction), - ExportedMethod(ExportedMethod), - ExportedAsyncCallback(ExportedAsyncCallback), - ExportedConst(ExportedConst), - ExportedGlobal(ExportedGlobal), - ItemWithAttrs(ItemWithAttrs), -} - -impl ModuleItem { - fn is_init_fn(&self) -> bool { - match self { - ModuleItem::InitFn(_) => true, - _ => false, - } - } - - fn get_init_fn(&self) -> &InitFn { - match self { - ModuleItem::InitFn(ref init_fn) => init_fn, - _ => panic!(), - } - } - - fn is_exported_fn(&self) -> bool { - match self { - ModuleItem::ExportedFunction(_) => true, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_fn() => true, - _ => false, - } - } - - fn get_exported_fn(&self) -> &ExportedFunction { - match self { - ModuleItem::ExportedFunction(ref exported_fn) => exported_fn, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_fn() => { - item.get_exported_fn() - } - _ => panic!(), - } - } - - fn is_exported_method(&self) -> bool { - match self { - ModuleItem::ExportedMethod(_) => true, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_method() => { - true - } - _ => false, - } - } - - fn get_exported_method(&self) -> &ExportedMethod { - match self { - ModuleItem::ExportedMethod(ref exported_method) => exported_method, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_method() => { - item.get_exported_method() - } - _ => panic!(), - } - } - - fn is_exported_async_callback(&self) -> bool { - match self { - ModuleItem::ExportedAsyncCallback(_) => true, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) - if item.is_exported_async_callback() => - { - true - } - _ => false, - } - } - - fn get_exported_async_callback(&self) -> &ExportedAsyncCallback { - match self { - ModuleItem::ExportedAsyncCallback(ref exported_async_callback) => { - exported_async_callback - } - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) - if item.is_exported_async_callback() => - { - item.get_exported_async_callback() - } - _ => panic!(), - } - } - - fn is_exported_type(&self) -> bool { - match self { - ModuleItem::ExportedType(_) => true, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_type() => { - true - } - _ => false, - } - } - - fn get_exported_type(&self) -> &ExportedType { - match self { - ModuleItem::ExportedType(ref exported_type) => exported_type, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_type() => { - item.get_exported_type() - } - _ => panic!(), - } - } - - fn is_exported_const(&self) -> bool { - match self { - ModuleItem::ExportedConst(_) => true, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_const() => { - true - } - _ => false, - } - } - - fn get_exported_const(&self) -> &ExportedConst { - match self { - ModuleItem::ExportedConst(ref exported_const) => exported_const, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_const() => { - item.get_exported_const() - } - _ => panic!(), - } - } - - fn is_exported_global(&self) -> bool { - match self { - ModuleItem::ExportedGlobal(_) => true, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_global() => { - true - } - _ => false, - } - } - - fn get_exported_global(&self) -> &ExportedGlobal { - match self { - ModuleItem::ExportedGlobal(ref exported_global) => exported_global, - ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_global() => { - item.get_exported_global() - } - _ => panic!(), - } - } - - fn has_attrs(&self) -> bool { - match self { - ModuleItem::ItemWithAttrs(_) => true, - _ => false, - } - } - - fn get_attrs(&self) -> &ItemWithAttrs { - match self { - ModuleItem::ItemWithAttrs(ref item) => item, - _ => panic!(), - } - } -} - -impl Parse for ModuleItem { - fn parse(input: ParseStream) -> Result { - let lookahead = input.lookahead1(); - if lookahead.peek(Token![become]) { - input.parse().map(ModuleItem::InitFn) - } else if lookahead.peek(Token![struct]) { - input.parse().map(ModuleItem::ExportedType) - } else if lookahead.peek(Token![fn]) { - input.parse().map(ModuleItem::ExportedFunction) - } else if lookahead.peek(Token![in]) { - input.parse().map(ModuleItem::ExportedMethod) - } else if lookahead.peek(Token![async]) { - input.parse().map(ModuleItem::ExportedAsyncCallback) - } else if lookahead.peek(Token![const]) { - input.parse().map(ModuleItem::ExportedConst) - } else if lookahead.peek(Token![static]) { - input.parse().map(ModuleItem::ExportedGlobal) - } else if lookahead.peek(Token![#]) { - input.parse().map(ModuleItem::ItemWithAttrs) - } else { - Err(Error::new( - input.span(), - "Expected `become`, `fn`, `in`, `struct`, `const`, or `static`.", - )) - } - } -} - -pub(crate) struct JuliaModule { - items: Punctuated, -} - -impl Parse for JuliaModule { - fn parse(input: ParseStream) -> Result { - let content = input; - let items = content.parse_terminated(ModuleItem::parse, Token![;])?; - - Ok(JuliaModule { items: items }) - } -} - -impl JuliaModule { - pub(crate) fn generate_init_code(self) -> Result { - let init_fn = self.get_init_fn()?; - let init_fn_ident = &init_fn.init_fn; - - let fn_fragments = FunctionFragments::generate(&self, init_fn)?; - let method_fragments = MethodFragments::generate(&self, init_fn); - let async_callback_fragments = AsyncCallbackFragments::generate(&self, init_fn)?; - let type_fragments = TypeFragments::generate(&self, init_fn); - let const_fragments = ConstFragments::generate(&self, init_fn); - let global_fragments = GlobalFragments::generate(&self, init_fn); - let doc_fragments = DocFragments::generate(&self, init_fn)?; - - let type_init_fn = type_fragments.type_init_fn; - let type_init_fn_ident = type_fragments.type_init_ident; - let type_reinit_fn = type_fragments.type_reinit_fn; - let type_reinit_fn_ident = type_fragments.type_reinit_ident; - let function_init_fn = fn_fragments.init_functions_fn; - let function_init_fn_ident = fn_fragments.init_functions_fn_ident; - let method_init_fn = method_fragments.init_methods_fn; - let method_init_fn_ident = method_fragments.init_methods_fn_ident; - let async_callback_init_fn = async_callback_fragments.init_async_callbacks_fn; - let async_callback_init_fn_ident = async_callback_fragments.init_async_callbacks_fn_ident; - let const_init_fn = const_fragments.const_init_fn; - let const_init_fn_ident = const_fragments.const_init_ident; - let global_init_fn = global_fragments.global_init_fn; - let global_init_fn_ident = global_fragments.global_init_ident; - let doc_init_fn = doc_fragments.init_docs_fn; - let doc_init_fn_ident = doc_fragments.init_docs_fn_ident; - - let invoke_type_init: Expr = if type_reinit_fn_ident.is_none() { - parse_quote! { - { - #type_init_fn_ident(&mut frame, module); - } - } - } else { - parse_quote! { - if precompiling == 1 { - #type_init_fn_ident(&mut frame, module); - } else { - #type_reinit_fn_ident(&mut frame, module); - } - } - }; - - let invoke_const_init: Expr = parse_quote! { - if precompiling == 1 { - #const_init_fn_ident(&mut frame, module); - } - }; - - let invoke_global_init: Expr = parse_quote! { - if precompiling == 1 { - #global_init_fn_ident(&mut frame, module); - } - }; - - let generated = quote::quote! { - - #[no_mangle] - pub unsafe extern "C" fn #init_fn_ident( - module: ::jlrs::data::managed::module::Module, - precompiling: u8, - ) -> ::jlrs::data::managed::value::ValueRet { - #type_init_fn - - #type_reinit_fn - - #function_init_fn - - #method_init_fn - - #async_callback_init_fn - - #const_init_fn - - #global_init_fn - - #doc_init_fn - - static IS_INIT: ::std::sync::atomic::AtomicBool = ::std::sync::atomic::AtomicBool::new(false); - if IS_INIT.compare_exchange(false, true, ::std::sync::atomic::Ordering::Relaxed, ::std::sync::atomic::Ordering::Relaxed).is_err() { - let unrooted = <::jlrs::data::managed::module::Module as ::jlrs::data::managed::Managed>::unrooted_target(module); - return ::jlrs::data::managed::value::Value::nothing(&unrooted).as_ref().leak(); - } - - let mut stack_frame = ::jlrs::memory::stack_frame::StackFrame::new(); - let mut ccall = ::jlrs::ccall::CCall::new(&mut stack_frame); - - ccall.init_jlrs(&::jlrs::InstallJlrsCore::Default, Some(module)); - - ccall.scope(|mut frame| { - let wrap_mod = ::jlrs::data::managed::module::Module::main(&frame) - .submodule(&frame, "JlrsCore") - .unwrap() - .as_managed() - .submodule(&frame, "Wrap") - .unwrap() - .as_managed(); - - let function_info_ty = wrap_mod - .global(&frame, "JlrsFunctionInfo") - .unwrap() - .as_value() - .cast_unchecked::<::jlrs::data::managed::datatype::DataType>(); - - let doc_item_ty = wrap_mod - .global(&frame, "DocItem") - .unwrap() - .as_value() - .cast_unchecked::<::jlrs::data::managed::datatype::DataType>(); - - let module_info_ty = wrap_mod - .global(&frame, "JlrsModuleInfo") - .unwrap() - .as_value() - .cast_unchecked::<::jlrs::data::managed::datatype::DataType>(); - - #invoke_type_init; - #invoke_const_init; - #invoke_global_init; - - let mut arr = ::jlrs::data::managed::array::Array::new_for_unchecked(frame.as_extended_target(), 0, function_info_ty.as_value()); - #function_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); - #method_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); - #async_callback_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); - - let mut doc_items = ::jlrs::data::managed::array::Array::new_for_unchecked(frame.as_extended_target(), 0, doc_item_ty.as_value()); - if precompiling == 1 { - #doc_init_fn_ident(&mut frame, &mut doc_items, module, doc_item_ty); - } - Ok(module_info_ty.instantiate_unchecked(&frame, [arr.as_value(), doc_items.as_value()]).leak()) - }).unwrap() - } - }; - - Ok(generated.into()) - } - - fn get_init_fn(&self) -> Result<&InitFn> { - let n_init_fns = self.items.iter().filter(|it| it.is_init_fn()).count(); - if n_init_fns != 1 { - let msg = format!("Expected 1 init fn, found {}", n_init_fns); - Err(Error::new(Span::call_site(), msg))?; - } - - let init_fn = self - .items - .iter() - .find(|it| it.is_init_fn()) - .unwrap() - .get_init_fn(); - - Ok(init_fn) - } - - fn get_exported_functions(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.is_exported_fn()) - .map(|it| it.get_exported_fn()) - } - - fn get_exported_methods(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.is_exported_method()) - .map(|it| it.get_exported_method()) - } - - fn get_exported_async_callbacks(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.is_exported_async_callback()) - .map(|it| it.get_exported_async_callback()) - } - - fn get_exported_types(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.is_exported_type()) - .map(|it| it.get_exported_type()) - } - - fn get_exported_consts(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.is_exported_const()) - .map(|it| it.get_exported_const()) - } - - fn get_exported_globals(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.is_exported_global()) - .map(|it| it.get_exported_global()) - } - - fn get_items_with_attrs(&self) -> impl Iterator { - self.items - .iter() - .filter(|it| it.has_attrs()) - .map(|it| it.get_attrs()) - } -} - -struct DocFragments { - init_docs_fn_ident: Ident, - init_docs_fn: ItemFn, -} - -impl DocFragments { - fn generate(module: &JuliaModule, init_fn: &InitFn) -> Result { - let init_docs_fn_ident = format_ident!("{}_docs", init_fn.init_fn); - let n_docs = module.get_items_with_attrs().count(); - - let doc_init_fragments = module - .get_items_with_attrs() - .enumerate() - .map(doc_info_fragment); - - let mut fragments = Vec::with_capacity(n_docs); - for fragment in doc_init_fragments { - fragments.push(fragment?); - } - - let init_docs_fn = parse_quote! { - unsafe fn #init_docs_fn_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, - module: ::jlrs::data::managed::module::Module, - doc_item_ty: ::jlrs::data::managed::datatype::DataType, - ) { - frame.scope(move |mut frame| { - array.grow_end_unchecked(#n_docs); - let mut accessor = array.indeterminate_data_mut(); - - #( - #fragments - )* - - Ok(()) - }).unwrap() - } - }; - - Ok(DocFragments { - init_docs_fn_ident, - init_docs_fn, - }) - } -} - -struct FunctionFragments { - init_functions_fn_ident: Ident, - init_functions_fn: ItemFn, -} - -impl FunctionFragments { - fn generate(module: &JuliaModule, init_fn: &InitFn) -> Result { - let init_functions_fn_ident = format_ident!("{}_functions", init_fn.init_fn); - let n_functions = module.get_exported_functions().count(); - - let function_init_fragments = module - .get_exported_functions() - .enumerate() - .map(function_info_fragment); - - let mut fragments = Vec::with_capacity(n_functions); - for fragment in function_init_fragments { - fragments.push(fragment?); - } - - let init_functions_fn = parse_quote! { - unsafe fn #init_functions_fn_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, - module: ::jlrs::data::managed::module::Module, - function_info_ty: ::jlrs::data::managed::datatype::DataType, - ) { - frame.scope(move |mut frame| { - array.grow_end_unchecked(#n_functions); - let mut accessor = array.value_data_mut().unwrap(); - - #( - #fragments - )* - - Ok(()) - }).unwrap() - } - }; - - Ok(FunctionFragments { - init_functions_fn_ident, - init_functions_fn, - }) - } -} - -struct MethodFragments { - init_methods_fn_ident: Ident, - init_methods_fn: ItemFn, -} - -impl MethodFragments { - fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { - let init_methods_fn_ident = format_ident!("{}_methods", init_fn.init_fn); - let n_methods = module.get_exported_methods().count(); - - let method_init_fragments = module - .get_exported_methods() - .enumerate() - .map(method_info_fragment); - - let init_methods_fn = parse_quote! { - unsafe fn #init_methods_fn_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, - module: ::jlrs::data::managed::module::Module, - function_info_ty: ::jlrs::data::managed::datatype::DataType, - ) { - frame.scope(move |mut frame| { - array.grow_end_unchecked(#n_methods); - let mut accessor = array.value_data_mut().unwrap(); - let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()) - #n_methods; - - #( - #method_init_fragments - )* - - Ok(()) - }).unwrap() - } - }; - - MethodFragments { - init_methods_fn_ident, - init_methods_fn, - } - } -} - -struct AsyncCallbackFragments { - init_async_callbacks_fn_ident: Ident, - init_async_callbacks_fn: ItemFn, -} - -impl AsyncCallbackFragments { - fn generate(module: &JuliaModule, init_fn: &InitFn) -> Result { - let init_async_callbacks_fn_ident = format_ident!("{}_async_callbacks", init_fn.init_fn); - let n_async_callbacks = module.get_exported_async_callbacks().count(); - - let async_callback_init_fragments = module - .get_exported_async_callbacks() - .enumerate() - .map(async_callback_info_fragment); - - let mut fragments = Vec::with_capacity(n_async_callbacks); - for fragment in async_callback_init_fragments { - fragments.push(fragment?); - } - - let init_async_callbacks_fn = parse_quote! { - unsafe fn #init_async_callbacks_fn_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, - module: ::jlrs::data::managed::module::Module, - function_info_ty: ::jlrs::data::managed::datatype::DataType, - ) { - frame.scope(move |mut frame| { - array.grow_end_unchecked(#n_async_callbacks); - let mut accessor = array.value_data_mut().unwrap(); - let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()) - #n_async_callbacks; - - #( - #fragments - )* - - Ok(()) - }).unwrap() - } - }; - - Ok(AsyncCallbackFragments { - init_async_callbacks_fn_ident, - init_async_callbacks_fn, - }) - } -} - -struct TypeFragments { - type_init_fn: ItemFn, - type_init_ident: Ident, - type_reinit_fn: Option, - type_reinit_ident: Option, -} - -impl TypeFragments { - fn generate(info: &JuliaModule, init_fn: &InitFn) -> Self { - let init_types_fn_ident = format_ident!("{}_types", init_fn.init_fn); - let init_types_fragments = info.get_exported_types().map(init_type_fragment); - - let type_init_fn = parse_quote! { - unsafe fn #init_types_fn_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - module: ::jlrs::data::managed::module::Module, - ) { - frame.scope(|frame| { - let mut output = frame.output(); - - #( - #init_types_fragments - )* - - Ok(()) - }).unwrap(); - } - }; - - let reinit_types_fn_ident = format_ident!("{}_reinittypes", init_fn.init_fn); - let reinit_types_fragments = info.get_exported_types().map(reinit_type_fragment); - - let type_reinit_fn = parse_quote! { - unsafe fn #reinit_types_fn_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - module: jlrs::data::managed::module::Module - ) { - frame.scope(|frame| { - let mut output = frame.output(); - - #( - #reinit_types_fragments - )* - - Ok(()) - }).unwrap(); - } - }; - - TypeFragments { - type_init_fn, - type_init_ident: init_types_fn_ident, - type_reinit_fn: Some(type_reinit_fn), - type_reinit_ident: Some(reinit_types_fn_ident), - } - } -} - -struct ConstFragments { - const_init_fn: ItemFn, - const_init_ident: Ident, -} - -impl ConstFragments { - fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { - let const_init_ident = format_ident!("{}_consts", init_fn.init_fn); - - let const_init_fragments = module.get_exported_consts().map(const_info_fragment); - - let const_init_fn = parse_quote! { - unsafe fn #const_init_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - module: ::jlrs::data::managed::module::Module, - ) { - #( - #const_init_fragments - )* - } - }; - - ConstFragments { - const_init_ident, - const_init_fn, - } - } -} - -struct GlobalFragments { - global_init_fn: ItemFn, - global_init_ident: Ident, -} - -impl GlobalFragments { - fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { - let global_init_ident = format_ident!("{}_globals", init_fn.init_fn); - - let global_init_fragments = module.get_exported_globals().map(global_info_fragment); - - let global_init_fn = parse_quote! { - unsafe fn #global_init_ident( - frame: &mut ::jlrs::memory::target::frame::GcFrame, - module: ::jlrs::data::managed::module::Module, - ) { - #( - #global_init_fragments - )* - } - }; - - GlobalFragments { - global_init_ident, - global_init_fn, - } - } -} - -fn doc_info_fragment((index, info): (usize, &ItemWithAttrs)) -> Result { - match info.item.as_ref() { - ModuleItem::InitFn(i) => Err(syn::Error::new_spanned( - i.init_fn.to_token_stream(), - "init function cannot be documented", - ))?, - ModuleItem::ExportedType(ty) => { - let override_module_fragment = override_module_fragment(&ty.name_override); - let name_ident = &ty.name; - - let rename = ty - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - let doc = info.get_docstr()?; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - unsafe { - let module = #override_module_fragment; - let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); - let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); - - let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); - accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - }; - - Ok(q) - } - ModuleItem::ExportedFunction(func) => { - let name_ident = &func.func.ident; - - let override_module_fragment = override_module_fragment(&func.name_override); - let mut rename = func - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - if func.exclamation_mark_token.is_some() { - rename.push('!') - } - - let doc = info.get_docstr()?; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - unsafe { - let module = #override_module_fragment; - let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); - let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); - - let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); - accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - - }; - - Ok(q) - } - ModuleItem::ExportedMethod(func) => { - let name_ident = &func.func.ident; - - let override_module_fragment = override_module_fragment(&func.name_override); - let mut rename = func - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - if func.exclamation_mark_token.is_some() { - rename.push('!') - } - - let doc = info.get_docstr()?; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - unsafe { - let module = #override_module_fragment; - let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); - let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); - - let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); - accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - - }; - - Ok(q) - } - ModuleItem::ExportedAsyncCallback(func) => { - let name_ident = &func.func.ident; - - let override_module_fragment = override_module_fragment(&func.name_override); - let mut rename = func - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - if func.exclamation_mark_token.is_some() { - rename.push('!') - } - - let doc = info.get_docstr()?; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - unsafe { - let module = #override_module_fragment; - let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); - let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); - - let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); - accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - - }; - - Ok(q) - } - ModuleItem::ExportedConst(val) => { - let name_ident = &val.name; - let rename = val.name_override.as_ref().unwrap_or(name_ident).to_string(); - let doc = info.get_docstr()?; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - unsafe { - let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); - let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); - - let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); - accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - - }; - - Ok(q) - } - ModuleItem::ExportedGlobal(val) => { - let name_ident = &val.name; - let rename = val.name_override.as_ref().unwrap_or(name_ident).to_string(); - let doc = info.get_docstr()?; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - unsafe { - let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); - let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); - - let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); - accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - - }; - - Ok(q) - } - ModuleItem::ItemWithAttrs(_) => unreachable!(), - } -} - -fn function_info_fragment((index, info): (usize, &ExportedFunction)) -> Result { - let n_args = info.func.inputs.len(); - let name_ident = &info.func.ident; - - let override_module_fragment = override_module_fragment(&info.name_override); - let mut rename = info - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - if info.exclamation_mark_token.is_some() { - rename.push('!') - } - - let tys = info.func.inputs.iter().map(|x| match x { - FnArg::Typed(pat) => &pat.ty, - _ => unreachable!(), - }); - - let punctuated_tys = Punctuated::<_, Comma>::from_iter(tys); - let ret_ty = &info.func.output; - - let (ccall_ret_type, julia_ret_type) = return_type_fragments(&info.func.output); - - let ccall_arg_idx = 0..n_args; - let julia_arg_idx = 0..n_args; - - let (ccall_arg_types, julia_arg_types) = arg_type_fragments(info)?; - - let expr = parse_quote! { - { - frame.scope(|mut frame| { - let name = Symbol::new(&frame, #rename); - let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&frame).as_value(); - // Ensure a compile error happens if the signatures of the function don't match. - let func: unsafe extern "C" fn(#punctuated_tys) #ret_ty = #name_ident; - let func = Value::new(&mut frame, func as *mut ::std::ffi::c_void); - - unsafe { - let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( - frame.as_extended_target(), - #n_args, - type_type); - - let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); - - let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( - frame.as_extended_target(), - #n_args, - type_type); - - let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); - - #( - ccall_arg_types_ref.set(#ccall_arg_idx, Some(#ccall_arg_types.as_value())).unwrap(); - julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); - )* - - let ccall_return_type = #ccall_ret_type; - let julia_return_type = #julia_ret_type; - - let module = #override_module_fragment; - - let false_v = ::jlrs::data::managed::value::Value::false_v(&frame); - let instance = function_info_ty.instantiate_unchecked(&mut frame, [ - name.as_value(), - ccall_arg_types.as_value(), - julia_arg_types.as_value(), - ccall_return_type.as_value(), - julia_return_type.as_value(), - func, - module.as_value(), - false_v - ]); - - accessor.set(#index, Some(instance)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - }; - - Ok(expr) -} - -fn override_module_fragment(name_override: &Option) -> Expr { - let name_override = name_override.as_ref(); - if name_override.is_none() { - return parse_quote! { { module } }; - } - let name_override = name_override.unwrap(); - let n_parts = name_override.len(); - if n_parts == 1 { - return parse_quote! { { module } }; - } - - let modules = name_override - .iter() - .take(n_parts - 1) - .map(|ident| ident.to_string()); - - let parsed = parse_quote! { - { - let mut module = Module::main(&frame); - - #( - module = module - .submodule(&frame, #modules) - .expect("Submodule does not exist") - .as_managed(); - )* - - module - } - }; - - parsed -} - -fn return_type_fragments(ret_ty: &ReturnType) -> (Expr, Expr) { - match ret_ty { - ReturnType::Default => { - let ccall_ret_type: Expr = parse_quote! { - ::jlrs::data::managed::datatype::DataType::nothing_type(&frame).as_value() - }; - - let julia_ret_type = ccall_ret_type.clone(); - (ccall_ret_type, julia_ret_type) - } - ReturnType::Type(_, ref ty) => { - let span = ty.span(); - let ccall_ret_type = parse_quote_spanned! { - span=> <<#ty as ::jlrs::convert::ccall_types::CCallReturn>::CCallReturnType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - }; - let julia_ret_type = parse_quote_spanned! { - span=> <<#ty as ::jlrs::convert::ccall_types::CCallReturn>::FunctionReturnType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - }; - - (ccall_ret_type, julia_ret_type) - } - } -} - -// FIXME - -fn extract_return_type_from_impl_trait(timplt: &TypeImplTrait) -> Option { - let bounds_iter = timplt.bounds.iter(); - for bound in bounds_iter { - match bound { - TypeParamBound::Trait(t) => { - let segment = t.path.segments.last(); - if segment.is_none() { - continue; - } - - match &segment.unwrap().arguments { - PathArguments::AngleBracketed(p) => { - let arg = p.args.iter().last(); - if arg.is_none() { - continue; - } - - match arg.unwrap() { - GenericArgument::Type(ref t) => return Some(t.clone()), - _ => continue, - } - } - _ => continue, - } - } - _ => continue, - } - } - - None -} - -fn extract_inner_return_type_from_path(path: &Path) -> Option { - if let Some(segment) = path.segments.last() { - match segment.arguments { - PathArguments::AngleBracketed(ref args) => { - if let Some(arg) = args.args.first() { - match arg { - GenericArgument::Type(t) => match t { - &Type::ImplTrait(ref timplt) => { - return extract_return_type_from_impl_trait(timplt) - } - _ => (), - }, - _ => (), - } - } - } - _ => (), - } - } - - None -} - -fn extract_inner_return_type(ty: &Type) -> Option { - match ty { - Type::Path(ref p) => extract_inner_return_type_from_path(&p.path), - _ => None, - } -} - -fn async_callbackreturn_type_fragments(ret_ty: &ReturnType) -> Option { - match ret_ty { - ReturnType::Type(_, ty) => extract_inner_return_type(&*ty), - _ => None, - } -} - -fn arg_type_fragments<'a>( - info: &'a ExportedFunction, -) -> Result<( - impl 'a + Iterator, - impl 'a + Iterator, -)> { - let inputs = &info.func.inputs; - let n_args = inputs.len(); - - if n_args > 0 { - if let FnArg::Receiver(r) = inputs.first().unwrap() { - Err(syn::Error::new_spanned( - r.to_token_stream(), - "exported function must be a free-standing function, use `in fn ...` to export methods", - ))?; - } - } - - let ccall_arg_types = inputs - .iter() - .map(|arg| match arg { - FnArg::Typed(ty) => &ty.ty, - _ => unreachable!(), - }) - .map(|ty| { - parse_quote! { - <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }); - - let julia_arg_types = inputs - .iter() - .map(|arg| match arg { - FnArg::Typed(ty) => &ty.ty, - _ => unreachable!(), - }) - .map(|ty| { - parse_quote! { - <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }); - - Ok((ccall_arg_types, julia_arg_types)) -} - -fn init_type_fragment(info: &ExportedType) -> Expr { - let override_module_fragment = override_module_fragment(&info.name_override); - let name_ident = &info.name; - - let rename = info - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - let ty = format_ident!("{}", info.name); - - parse_quote! { - { - let sym = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); - let module = #override_module_fragment; - let ty = <#ty as ::jlrs::data::types::foreign_type::OpaqueType>::create_type(&mut output, sym, module); - module.set_const_unchecked(sym, <::jlrs::data::managed::datatype::DataType as ::jlrs::data::managed::Managed>::as_value(ty)); - } - } -} - -fn reinit_type_fragment(info: &ExportedType) -> Expr { - { - let override_module_fragment = override_module_fragment(&info.name_override); - let name_ident = &info.name; - - let rename = info - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - let ty = format_ident!("{}", info.name); - - parse_quote! { - { - let module = #override_module_fragment; - - let dt = module - .global(&frame, #rename) - .unwrap() - .as_value() - .cast::<::jlrs::data::managed::datatype::DataType>() - .unwrap(); - - <#ty as ::jlrs::data::types::foreign_type::OpaqueType>::reinit_type(dt); - } - } - } -} - -fn method_info_fragment((index, info): (usize, &ExportedMethod)) -> Expr { - let n_args = info.func.inputs.len(); - let name_ident = &info.func.ident; - - let override_module_fragment = override_module_fragment(&info.name_override); - let mut rename = info - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - if info.exclamation_mark_token.is_some() { - rename.push('!') - } - - let ret_ty = &info.func.output; - let (ccall_ret_type, julia_ret_type) = return_type_fragments(ret_ty); - - let ccall_arg_idx = 0..n_args; - let julia_arg_idx = 0..n_args; - - let (ccall_arg_types, julia_arg_types, invoke_fn) = method_arg_type_fragments(info); - - parse_quote! { - { - frame.scope(|mut frame| { - let unrooted = frame.unrooted(); - let name = Symbol::new(&frame, #rename); - let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&unrooted).as_value(); - - #invoke_fn; - - let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); - - unsafe { - let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( - frame.as_extended_target(), - #n_args, - type_type); - - let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); - - let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( - frame.as_extended_target(), - #n_args, - type_type); - - let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); - - #( - ccall_arg_types_ref.set(#ccall_arg_idx, Some(#ccall_arg_types.as_value())).unwrap(); - julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); - )* - - let ccall_return_type = #ccall_ret_type; - let julia_return_type = #julia_ret_type; - - let module = #override_module_fragment; - - let false_v = ::jlrs::data::managed::value::Value::false_v(&frame); - let instance = function_info_ty.instantiate_unchecked(&mut frame, [ - name.as_value(), - ccall_arg_types.as_value(), - julia_arg_types.as_value(), - ccall_return_type, - julia_return_type, - func, - module.as_value(), - false_v - ]); - - accessor.set(#index + offset, Some(instance)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - } -} - -fn async_callback_info_fragment((index, info): (usize, &ExportedAsyncCallback)) -> Result { - let n_args = info.func.inputs.len(); - let name_ident = &info.func.ident; - - let override_module_fragment = override_module_fragment(&info.name_override); - let mut rename = info - .name_override - .as_ref() - .map(|parts| parts.last()) - .flatten() - .unwrap_or(name_ident) - .to_string(); - - if info.exclamation_mark_token.is_some() { - rename.push('!') - } - - let ret_ty = &info.func.output; - let inner_ret_ty = async_callbackreturn_type_fragments(ret_ty); - if inner_ret_ty.is_none() { - return Ok(parse_quote_spanned! { - name_ident.span() => { - compile_error!("Async callback must return JlrsResult> where T is some type that implements IntoJulia"); - } - }); - } - - let inner_ret_ty = inner_ret_ty.unwrap(); - let ccall_ret_type: Expr = parse_quote! { - <::jlrs::ccall::AsyncCCall as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - }; - let julia_ret_type: Expr = parse_quote! { - <#inner_ret_ty as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - }; - - let (ccall_arg_types, julia_arg_types, invoke_fn) = - async_callback_arg_type_fragments(info, &inner_ret_ty)?; - - let first_arg: Expr = syn::parse_quote! { - <*mut ::std::ffi::c_void as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - }; - - let ccall_arg_idx = 0..n_args; - let julia_arg_idx = 0..n_args; - - let q = parse_quote! { - { - frame.scope(|mut frame| { - let unrooted = frame.unrooted(); - let name = Symbol::new(&frame, #rename); - let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&unrooted).as_value(); - - #invoke_fn; - - let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); - - unsafe { - let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( - frame.as_extended_target(), - #n_args + 1, - type_type); - - let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); - - let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( - frame.as_extended_target(), - #n_args, - type_type); - - let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); - - ccall_arg_types_ref.set(0, Some(#first_arg)).unwrap(); - #( - ccall_arg_types_ref.set(#ccall_arg_idx + 1, Some(#ccall_arg_types.as_value())).unwrap(); - julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); - )* - - let ccall_return_type = #ccall_ret_type; - let julia_return_type = #julia_ret_type; - - let module = #override_module_fragment; - - let true_v = ::jlrs::data::managed::value::Value::true_v(&frame); - let instance = function_info_ty.instantiate_unchecked(&mut frame, [ - name.as_value(), - ccall_arg_types.as_value(), - julia_arg_types.as_value(), - ccall_return_type, - julia_return_type, - func, - module.as_value(), - true_v - ]); - - accessor.set(#index + offset, Some(instance)).unwrap(); - } - - Ok(()) - }).unwrap(); - } - }; - - Ok(q) -} - -fn const_info_fragment(info: &ExportedConst) -> Expr { - let name = &info.name; - let rename = info.name_override.as_ref().unwrap_or(name).to_string(); - let ty = &info.ty; - - parse_quote! { - { - frame.scope(move |mut frame| { - let v: #ty = #name; - let value = ::jlrs::data::managed::value::Value::new(&mut frame, v); - - unsafe { - module.set_const_unchecked(#rename, value); - } - - Ok(()) - - }).unwrap(); - } - } -} - -fn global_info_fragment(info: &ExportedGlobal) -> Expr { - let name = &info.name; - let rename = info.name_override.as_ref().unwrap_or(name).to_string(); - let ty = &info.ty; - - parse_quote! { - { - frame.scope(move |mut frame| { - let v: #ty = #name; - let value = ::jlrs::data::managed::value::Value::new(&mut frame, v); - - unsafe { - module.set_global_unchecked(#rename, value); - } - - Ok(()) - - }).unwrap(); - } - } -} - -fn method_arg_type_fragments<'a>( - info: &'a ExportedMethod, -) -> ( - impl 'a + Iterator, - impl 'a + Iterator, - Option, -) { - let inputs = &info.func.inputs; - let n_args = inputs.len(); - - let takes_self = if n_args > 0 { - match inputs.first().unwrap() { - FnArg::Receiver(r) => Some((r.mutability.is_some(), r.reference.is_some())), - FnArg::Typed(_) => None, - } - } else { - None - }; - - let invoke_fn = match takes_self { - None => Some(invoke_fn_no_self_method_fragment(info)), - Some((true, true)) => Some(invoke_fn_mut_self_method_fragment(info)), - Some((false, true)) => Some(invoke_fn_ref_self_method_fragment(info)), - Some((_, false)) => Some(invoke_fn_move_self_method_fragment(info)), - }; - - let parent = &info.parent; - let ccall_arg_types = inputs - .iter() - .map(move |arg| { - match arg { - FnArg::Typed(ty) => { - let ty = &ty.ty; - let span = ty.span(); - parse_quote_spanned! { - span=> <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }, - _ => { - let span = parent.span(); - parse_quote_spanned! { - span=> < as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }, - } - }); - - let julia_arg_types = inputs - .iter() - .map(move |arg| { - match arg { - FnArg::Typed(ty) => { - let ty = &ty.ty; - let span = ty.span(); - parse_quote_spanned! { - span=> <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }, - _ => { - let span = parent.span(); - parse_quote_spanned! { - span=> <<::jlrs::data::managed::value::typed::TypedValue<#parent> as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }, - } - }); - - (ccall_arg_types, julia_arg_types, invoke_fn) -} - -fn async_callback_arg_type_fragments<'a>( - info: &'a ExportedAsyncCallback, - inner_ret_ty: &Type, -) -> Result<( - impl 'a + Iterator, - impl 'a + Iterator, - Option, -)> { - let inputs = &info.func.inputs; - let n_args = inputs.len(); - - if n_args > 0 { - if let FnArg::Receiver(r) = inputs.first().unwrap() { - Err(syn::Error::new_spanned( - r.to_token_stream(), - "async callback must be a free-standing function", - ))?; - } - } - - let invoke_fn = invoke_async_callback(info, inner_ret_ty); - - let ccall_arg_types = inputs - .iter() - .map(move |arg| { - match arg { - FnArg::Typed(ty) => { - let ty = &ty.ty; - parse_quote! { - <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }, - _ => unreachable!() - } - }); - - let julia_arg_types = inputs - .iter() - .map(move |arg| { - match arg { - FnArg::Typed(ty) => { - let ty = &ty.ty; - parse_quote! { - <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(frame.as_extended_target()) - } - }, - _ => unreachable!() - } - }); - - Ok((ccall_arg_types, julia_arg_types, Some(invoke_fn))) -} - -// FIXME: require impl AsyncCallback -fn invoke_async_callback(info: &ExportedAsyncCallback, ret_ty: &Type) -> ItemFn { - let name = &info.func.ident; - let args = &info.func.inputs; - let span = info.func.ident.span(); - let mut extended_args = args.clone(); - extended_args.insert( - 0, - syn::parse_quote! { jlrs_async_condition_handle: ::jlrs::ccall::AsyncConditionHandle }, - ); - - let names = args.iter().map(|arg| match arg { - FnArg::Typed(ty) => &ty.pat, - _ => unreachable!(), - }); - - let names = Punctuated::<_, Comma>::from_iter(names); - - parse_quote_spanned! { - span=> unsafe extern "C" fn invoke(#extended_args) -> ::jlrs::ccall::AsyncCCall { - let join_handle: ::std::sync::Arc<::jlrs::ccall::DispatchHandle<#ret_ty>> = match #name(#names) { - Ok(callback) => { - ::jlrs::ccall::CCall::dispatch_to_pool(move |dispatch_handle| { - let handle = jlrs_async_condition_handle; - let res = callback(); - unsafe { dispatch_handle.set(res); } - ::jlrs::ccall::CCall::uv_async_send(handle.0); - }) - }, - Err(e) => { - ::jlrs::ccall::CCall::dispatch_to_pool(move |dispatch_handle| { - let handle = jlrs_async_condition_handle; - let res: ::jlrs::error::JlrsResult<#ret_ty> = Err(e); - unsafe { dispatch_handle.set(res); } - ::jlrs::ccall::CCall::uv_async_send(handle.0); - }) - } - }; - - let join_handle = ::std::sync::Arc::into_raw(join_handle); - - unsafe extern "C" fn join_func( - handle: *mut ::jlrs::ccall::DispatchHandle<#ret_ty> - ) -> ::jlrs::data::managed::rust_result::RustResultRet<#ret_ty> { - let handle = ::std::sync::Arc::from_raw(handle); - ::jlrs::ccall::CCall::invoke_fallible(|mut frame| { - let unrooted = frame.unrooted(); - let res = ::jlrs::data::managed::value::typed::TypedValue::new(&mut frame, handle.join()?); - Ok(::jlrs::data::managed::rust_result::RustResult::ok(unrooted.into_extended_target(&mut frame), res).leak()) - }) - } - - ::jlrs::ccall::AsyncCCall { - join_handle: join_handle as *mut ::jlrs::ccall::DispatchHandle<#ret_ty> as *mut ::std::ffi::c_void, - join_func: join_func as *mut ::std::ffi::c_void - } - } - } -} - -fn invoke_fn_no_self_method_fragment(info: &ExportedMethod) -> ItemFn { - let name = &info.func.ident; - let span = info.func.ident.span(); - let ty = &info.parent; - let ret_ty = &info.func.output; - let args = &info.func.inputs; - let names = args.iter().map(|arg| match arg { - FnArg::Typed(ty) => &ty.pat, - _ => unreachable!(), - }); - - let names = Punctuated::<_, Comma>::from_iter(names); - - parse_quote_spanned! { - span=> unsafe extern "C" fn invoke(#args) #ret_ty { - <#ty>::#name(#names) - } - } -} - -fn invoke_fn_ref_self_method_fragment(info: &ExportedMethod) -> ItemFn { - let name = &info.func.ident; - let span = info.func.ident.span(); - let ty = &info.parent; - let ret_ty = &info.func.output; - let args = &info.func.inputs; - let mut cloned_args = args.clone(); - let first = cloned_args.first_mut().unwrap(); - - *first = parse_quote! { - this: ::jlrs::data::managed::value::typed::TypedValue<#ty> - }; - - let args_self_renamed = cloned_args; - - let names = args.iter().skip(1).map(|arg| match arg { - FnArg::Typed(ty) => &ty.pat, - _ => unreachable!(), - }); - - let names = Punctuated::<_, Comma>::from_iter(names); - - parse_quote_spanned! { - span=> unsafe extern "C" fn invoke(#args_self_renamed) #ret_ty { - match (&this).track_shared() { - Ok(this) => this.#name(#names), - Err(_) => ::jlrs::data::managed::rust_result::RustResult::borrow_error_internal() - } - } - } -} - -fn invoke_fn_move_self_method_fragment(info: &ExportedMethod) -> ItemFn { - let name = &info.func.ident; - let span = info.func.ident.span(); - let ty = &info.parent; - let ret_ty = &info.func.output; - let args = &info.func.inputs; - let mut cloned_args = args.clone(); - let first = cloned_args.first_mut().unwrap(); - - *first = parse_quote! { - this: ::jlrs::data::managed::value::typed::TypedValue<#ty> - }; - - let args_self_renamed = cloned_args; - - let names = args.iter().skip(1).map(|arg| match arg { - FnArg::Typed(ty) => &ty.pat, - _ => unreachable!(), - }); - - let names = Punctuated::<_, Comma>::from_iter(names); - - parse_quote_spanned! { - span=> unsafe extern "C" fn invoke(#args_self_renamed) #ret_ty { - match (&this).track_shared() { - Ok(this) => this.clone().#name(#names), - Err(_) => ::jlrs::data::managed::rust_result::RustResult::borrow_error_internal() - } - } - } -} - -fn invoke_fn_mut_self_method_fragment(info: &ExportedMethod) -> ItemFn { - let name = &info.func.ident; - let span = info.func.ident.span(); - let ty = &info.parent; - let ret_ty = &info.func.output; - let args = &info.func.inputs; - let mut cloned_args = args.clone(); - let first = cloned_args.first_mut().unwrap(); - - *first = parse_quote! { - mut this: ::jlrs::data::managed::value::typed::TypedValue<#ty> - }; - - let args_self_renamed = cloned_args; - - let names = args.iter().skip(1).map(|arg| match arg { - FnArg::Typed(ty) => &ty.pat, - _ => unreachable!(), - }); - - let names = Punctuated::<_, Comma>::from_iter(names); - - parse_quote_spanned! { - span=> unsafe extern "C" fn invoke(#args_self_renamed) #ret_ty { - match (&mut this).track_exclusive() { - Ok(mut this) => this.#name(#names), - Err(_) => ::jlrs::data::managed::rust_result::RustResult::borrow_error_internal() - } - } - } -} diff --git a/jlrs_macros/src/module/mod.rs b/jlrs_macros/src/module/mod.rs new file mode 100644 index 00000000..d4992070 --- /dev/null +++ b/jlrs_macros/src/module/mod.rs @@ -0,0 +1,3832 @@ +mod parameters; +use std::iter::FromIterator; + +use itertools::Itertools; +use parameters::{ParameterEnvironment, ParameterList}; +use proc_macro::TokenStream; +use proc_macro2::Span; +use quote::{format_ident, ToTokens}; +use syn::{ + braced, bracketed, + parse::{Parse, ParseStream}, + parse_quote, parse_quote_spanned, + punctuated::Punctuated, + spanned::Spanned, + token::{Brace, Bracket, Comma}, + AttrStyle, Attribute, Error, Expr, ExprLit, FnArg, GenericArgument, Ident, ItemFn, Lit, Meta, + Path, PathArguments, Result, ReturnType, Signature, Token, Type, TypeImplTrait, TypeParamBound, +}; + +use self::parameters::{Apply, ResolvedParameterList}; +use crate::module::parameters::{as_return_as, take_type}; + +type RenameFragments = Punctuated; + +struct InitFn { + _become_token: Token![become], + init_fn: Ident, +} + +impl Parse for InitFn { + fn parse(input: ParseStream) -> Result { + let init_fn_token = input.parse()?; + let init_fn = input.parse()?; + + Ok(InitFn { + _become_token: init_fn_token, + init_fn, + }) + } +} + +struct ExportedType { + _struct_token: Token![struct], + name: Path, + _as_token: Option, + name_override: Option, +} + +impl ExportedType { + fn init_with_env( + &self, + generic: &GenericEnvironment, + env: Option<&ParameterEnvironment>, + ) -> Expr { + let override_module_fragment = override_module_fragment(&self.name_override); + let name = &self.name; + let name_ident = &name.segments.last().unwrap().ident; + + let rename = self + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + let env = ParameterEnvironment::new(generic, env); + let mut list = ParameterList::new(&env); + let mut resolver = list.resolver(); + + env.nth_combination(&mut list, 0); + list.resolve(&mut resolver); + let ty = resolver.apply(name); + + let variants = (0..env.n_combinations()).map(|i| -> Expr { + env.nth_combination(&mut list, i); + list.resolve(&mut resolver); + let ty = resolver.apply(name); + + parse_quote! { + <#ty as ::jlrs::data::types::foreign_type::ParametricVariant>::create_variant(&mut output, sym) + } + }).unique(); + + parse_quote! { + { + let sym = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let module = #override_module_fragment; + let ty = <#ty as ::jlrs::data::types::foreign_type::ParametricBase>::create_type(&mut output, sym, module); + let ty = ::jlrs::data::managed::erase_scope_lifetime(ty); + let ty = ::jlrs::data::managed::union_all::UnionAll::rewrap(&mut output, ty); + module.set_const_unchecked(sym, ty); + + #( + #variants; + )* + } + } + } + + fn reinit_with_env( + &self, + generic: &GenericEnvironment, + env: Option<&ParameterEnvironment>, + ) -> Expr { + { + let override_module_fragment = override_module_fragment(&self.name_override); + let name = &self.name; + let name_ident = &name.segments.last().unwrap().ident; + + let rename = self + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + let env = ParameterEnvironment::new(generic, env); + let mut list = ParameterList::new(&env); + let mut resolver = list.resolver(); + + env.nth_combination(&mut list, 0); + list.resolve(&mut resolver); + let ty = resolver.apply(name); + + let variants = (0..env.n_combinations()).map(|i| -> Expr { + env.nth_combination(&mut list, i); + list.resolve(&mut resolver); + let ty = resolver.apply(name); + + parse_quote! { + { + let params = <#ty as ::jlrs::data::types::foreign_type::ParametricVariant>::variant_parameters(&mut output); + let params = ::jlrs::data::managed::erase_scope_lifetime(params); + let param_slice = params.value_slice_unchecked(); + let dt = ua.apply_types_unchecked(&mut output, param_slice).cast::<::jlrs::data::managed::datatype::DataType>().unwrap(); + let dt = ::jlrs::data::managed::erase_scope_lifetime(dt); + + <#ty as ::jlrs::data::types::foreign_type::ParametricVariant>::reinit_variant(dt); + } + } + }).unique(); + + parse_quote! { + { + let module = #override_module_fragment; + + let ua = module + .global(&frame, #rename) + .unwrap() + .as_value() + .cast::<::jlrs::data::managed::union_all::UnionAll>() + .unwrap(); + + let dt = ua.base_type(); + + <#ty as ::jlrs::data::types::foreign_type::ParametricBase>::reinit_type(dt); + + #( + #variants; + )* + } + } + } + } +} + +impl Parse for ExportedType { + fn parse(input: ParseStream) -> Result { + let struct_token = input.parse()?; + let name = input.parse()?; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![as]) { + let as_token = input.parse()?; + let name_override = RenameFragments::parse_separated_nonempty(input)?; + + Ok(ExportedType { + _struct_token: struct_token, + name, + _as_token: Some(as_token), + name_override: Some(name_override), + }) + } else { + Ok(ExportedType { + _struct_token: struct_token, + name, + _as_token: None, + name_override: None, + }) + } + } +} + +struct ExportedFunction { + func: Signature, + _as_token: Option, + name_override: Option, + exclamation_mark_token: Option, +} + +impl Parse for ExportedFunction { + fn parse(input: ParseStream) -> Result { + let func = input.parse()?; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![as]) { + let as_token = input.parse()?; + let name_override = RenameFragments::parse_separated_nonempty(input)?; + let exclamation_mark_token = input.parse()?; + + Ok(ExportedFunction { + func, + _as_token: Some(as_token), + name_override: Some(name_override), + exclamation_mark_token, + }) + } else { + Ok(ExportedFunction { + func, + _as_token: None, + name_override: None, + exclamation_mark_token: None, + }) + } + } +} + +impl ExportedFunction { + fn init_with_env( + &self, + generic: &GenericEnvironment, + env: Option<&ParameterEnvironment>, + offset: &mut usize, + gc_safe: bool, + ) -> Result { + let n_args = self.func.inputs.len(); + let name_ident = &self.func.ident; + let start = *offset; + + let override_module_fragment = override_module_fragment(&self.name_override); + let mut rename = self + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if self.exclamation_mark_token.is_some() { + rename.push('!') + } + + let env = ParameterEnvironment::new(generic, env); + let n_combinations = env.n_combinations(); + + let mut list = ParameterList::new(&env); + let mut resolver = list.resolver(); + + let exprs = (0..n_combinations).map(|i| -> Result { + env.nth_combination(&mut list, i); + list.resolve(&mut resolver); + + let inputs = resolver.apply(&self.func.inputs); + let (ccall_arg_types, function_arg_types) = arg_type_fragments(&inputs)?; + let ret_ty = resolver.apply(&self.func.output); + let (ccall_ret_type, julia_ret_type) = return_type_fragments(&ret_ty); + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let ccall_arg_idx = 0..n_args; + let julia_arg_idx = 0..n_args; + let args = resolver.apply(&self.func.inputs); + + let names = args.iter().map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + let names = Punctuated::<_, Comma>::from_iter(names); + + let call_expr: Expr = if gc_safe { + parse_quote! { ::jlrs::memory::gc::gc_safe(|| #name_ident(#names)) } + } else { + parse_quote! { #name_ident(#names) } + }; + + let span = self.func.span(); + let invoke_fn: ItemFn = parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args) #new_ret_ty { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + } + }; + + let ex = parse_quote! { + { + let name = Symbol::new(&frame, #rename); + let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&frame).as_value(); + + #invoke_fn + + let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); + + unsafe { + let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); + + let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); + + #( + ccall_arg_types_ref.set(#ccall_arg_idx, Some(#ccall_arg_types.as_value())).unwrap(); + julia_arg_types_ref.set(#julia_arg_idx, Some(#function_arg_types.as_value())).unwrap(); + )* + + let ccall_return_type = #ccall_ret_type; + let julia_return_type = #julia_ret_type; + + let module = #override_module_fragment; + let nothing = ::jlrs::data::managed::value::Value::nothing(&frame); + + let false_v = ::jlrs::data::managed::value::Value::false_v(&frame); + function_info_ty.instantiate_unchecked(&mut frame, [ + name.as_value(), + ccall_arg_types.as_value(), + julia_arg_types.as_value(), + ccall_return_type.as_value(), + julia_return_type.as_value(), + func, + module.as_value(), + false_v + ]) + } + } + }; + + Ok(ex) + }).collect::>>()? + .into_iter() + .unique() + .enumerate() + .map(|(idx, expr)| -> Expr { + parse_quote! { + { + frame.scope(|mut frame| { + let instance = #expr; + let n = offset + #start + #idx; + accessor.set(n, Some(instance)).unwrap(); + + Ok(()) + }).unwrap(); + } + } + }).collect::>(); + + let n_unique = exprs.len(); + *offset += n_unique; + let ex = parse_quote! { + { + accessor.grow_end_unchecked(#n_unique); + #(#exprs)* + } + }; + + Ok(ex) + } +} + +struct ExportedMethod { + _in_token: Token![in], + parent: Type, + func: Signature, + _as_token: Option, + name_override: Option, + exclamation_mark_token: Option, +} + +impl Parse for ExportedMethod { + fn parse(input: ParseStream) -> Result { + let in_token = input.parse()?; + let parent = input.parse()?; + let func = input.parse()?; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![as]) { + let as_token = input.parse()?; + let name_override = RenameFragments::parse_separated_nonempty(input)?; + let exclamation_mark_token = input.parse()?; + + Ok(ExportedMethod { + _in_token: in_token, + parent, + func, + _as_token: Some(as_token), + name_override: Some(name_override), + exclamation_mark_token, + }) + } else { + Ok(ExportedMethod { + _in_token: in_token, + parent, + func, + _as_token: None, + name_override: None, + exclamation_mark_token: None, + }) + } + } +} + +impl ExportedMethod { + fn init_with_env( + &self, + generic: &GenericEnvironment, + env: Option<&ParameterEnvironment>, + offset: &mut usize, + untracked_self: bool, + gc_safe: bool, + ) -> Result { + let n_args = self.func.inputs.len(); + let name_ident = &self.func.ident; + let start = *offset; + + let override_module_fragment = override_module_fragment(&self.name_override); + let mut rename = self + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if self.exclamation_mark_token.is_some() { + rename.push('!') + } + + let env = ParameterEnvironment::new(generic, env); + let n_combinations = env.n_combinations(); + + let mut list = ParameterList::new(&env); + let mut resolver = list.resolver(); + + let exprs = (0..n_combinations).map(|i| -> Result { + env.nth_combination(&mut list, i); + list.resolve(&mut resolver); + + let ret_ty = resolver.apply(&self.func.output); + let (ccall_ret_type, julia_ret_type) = return_type_fragments(&ret_ty); + + let ccall_arg_idx = 0..n_args; + let julia_arg_idx = 0..n_args; + + let (ccall_arg_types, julia_arg_types, invoke_fn) = method_arg_type_fragments_in_env(self, &resolver, untracked_self, gc_safe); + + let ex = parse_quote! { + { + let unrooted = frame.unrooted(); + let name = Symbol::new(&frame, #rename); + let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&unrooted).as_value(); + + #invoke_fn; + + let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); + + unsafe { + let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); + + let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); + + #( + ccall_arg_types_ref.set(#ccall_arg_idx, Some(#ccall_arg_types.as_value())).unwrap(); + julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); + )* + + let ccall_return_type = #ccall_ret_type; + let julia_return_type = #julia_ret_type; + + let module = #override_module_fragment; + let nothing = ::jlrs::data::managed::value::Value::nothing(&frame); + + let false_v = ::jlrs::data::managed::value::Value::false_v(&frame); + function_info_ty.instantiate_unchecked(&mut frame, [ + name.as_value(), + ccall_arg_types.as_value(), + julia_arg_types.as_value(), + ccall_return_type, + julia_return_type, + func, + module.as_value(), + false_v + ]) + } + } + }; + + Ok(ex) + }).collect::>>()? + .into_iter() + .unique() + .enumerate() + .map(|(idx, expr)| -> Expr { + parse_quote! { + { + frame.scope(|mut frame| { + let instance = #expr; + let start = #start; + let idx = #idx; + let n = offset + start + idx; + accessor.set(n, Some(instance)).unwrap(); + + Ok(()) + }).unwrap(); + } + } + }).collect::>(); + + let n_unique = exprs.len(); + *offset += n_unique; + let ex = parse_quote! { + { + accessor.grow_end_unchecked(#n_unique); + #(#exprs)* + } + }; + + Ok(ex) + } +} + +struct ExportedAsyncCallback { + _async_token: Token![async], + func: Signature, + _as_token: Option, + name_override: Option, + exclamation_mark_token: Option, +} + +impl Parse for ExportedAsyncCallback { + fn parse(input: ParseStream) -> Result { + let async_token = input.parse()?; + let func = input.parse()?; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![as]) { + let as_token = input.parse()?; + let name_override = RenameFragments::parse_separated_nonempty(input)?; + let exclamation_mark_token = input.parse()?; + + Ok(ExportedAsyncCallback { + _async_token: async_token, + func, + _as_token: Some(as_token), + name_override: Some(name_override), + exclamation_mark_token, + }) + } else { + Ok(ExportedAsyncCallback { + _async_token: async_token, + func, + _as_token: None, + name_override: None, + exclamation_mark_token: None, + }) + } + } +} + +impl ExportedAsyncCallback { + fn init_with_env( + &self, + generic: &GenericEnvironment, + env: Option<&ParameterEnvironment>, + offset: &mut usize, + ) -> Result { + let n_args = self.func.inputs.len(); + let name_ident = &self.func.ident; + let start = *offset; + + let override_module_fragment = override_module_fragment(&self.name_override); + let mut rename = self + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if self.exclamation_mark_token.is_some() { + rename.push('!') + } + + let env = ParameterEnvironment::new(generic, env); + let n_combinations = env.n_combinations(); + + let mut list = ParameterList::new(&env); + let mut resolver = list.resolver(); + + let exprs = (0..n_combinations).map(|i| -> Result { + env.nth_combination(&mut list, i); + list.resolve(&mut resolver); + + let (inner_ret_ty, ccall_arg_types, julia_arg_types, invoke_fn) = + async_callback_arg_type_fragments_in_env(self, &resolver)?; + + let ccall_arg_idx = 0..n_args; + let julia_arg_idx = 0..n_args; + + let ccall_ret_type: Expr = parse_quote! { + <::jlrs::ccall::AsyncCCall as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + let julia_ret_type: Expr = parse_quote! { + <#inner_ret_ty as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + + let first_arg: Expr = syn::parse_quote! { + <*mut ::std::ffi::c_void as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + + let ex = parse_quote! { + { + let unrooted = frame.unrooted(); + let name = Symbol::new(&frame, #rename); + let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&unrooted).as_value(); + + #invoke_fn; + + let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); + + unsafe { + let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args + 1, + type_type); + + let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); + + let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); + + ccall_arg_types_ref.set(0, Some(#first_arg)).unwrap(); + #( + ccall_arg_types_ref.set(#ccall_arg_idx + 1, Some(#ccall_arg_types.as_value())).unwrap(); + julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); + )* + + let ccall_return_type = #ccall_ret_type; + let julia_return_type = #julia_ret_type; + + let module = #override_module_fragment; + let nothing = ::jlrs::data::managed::value::Value::nothing(&frame); + + let true_v = ::jlrs::data::managed::value::Value::true_v(&frame); + function_info_ty.instantiate_unchecked(&mut frame, [ + name.as_value(), + ccall_arg_types.as_value(), + julia_arg_types.as_value(), + ccall_return_type, + julia_return_type, + func, + module.as_value(), + true_v + ]) + } + } + }; + + Ok(ex) + }).collect::>>()? + .into_iter() + .unique() + .enumerate() + .map(|(idx, expr)| -> Expr { + parse_quote! { + { + frame.scope(|mut frame| { + let instance = #expr; + let n = offset + #start + #idx; + accessor.set(n, Some(instance)).unwrap(); + + Ok(()) + }).unwrap(); + } + } + }).collect::>(); + + let n_unique = exprs.len(); + *offset += n_unique; + let ex = parse_quote! { + { + accessor.grow_end_unchecked(#n_unique); + #(#exprs)* + } + }; + + Ok(ex) + } +} + +struct ExportedConst { + _const_token: Token![const], + name: Ident, + _colon: Token![:], + ty: Type, + _as_token: Option, + name_override: Option, +} + +impl Parse for ExportedConst { + fn parse(input: ParseStream) -> Result { + let const_token = input.parse()?; + let name = input.parse()?; + let colon = input.parse()?; + let ty = input.parse()?; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![as]) { + let as_token = input.parse()?; + let name_override = input.parse()?; + + Ok(ExportedConst { + _const_token: const_token, + name: name, + _colon: colon, + ty: ty, + _as_token: Some(as_token), + name_override: Some(name_override), + }) + } else { + Ok(ExportedConst { + _const_token: const_token, + name: name, + _colon: colon, + ty: ty, + _as_token: None, + name_override: None, + }) + } + } +} + +struct ExportedGlobal { + _static_token: Token![static], + name: Ident, + _colon: Token![:], + ty: Type, + _as_token: Option, + name_override: Option, +} + +impl Parse for ExportedGlobal { + fn parse(input: ParseStream) -> Result { + let static_token = input.parse()?; + let name = input.parse()?; + let colon = input.parse()?; + let ty = input.parse()?; + + let lookahead = input.lookahead1(); + if lookahead.peek(Token![as]) { + let as_token = input.parse()?; + let name_override = input.parse()?; + + Ok(ExportedGlobal { + _static_token: static_token, + name: name, + _colon: colon, + ty: ty, + _as_token: Some(as_token), + name_override: Some(name_override), + }) + } else { + Ok(ExportedGlobal { + _static_token: static_token, + name: name, + _colon: colon, + ty: ty, + _as_token: None, + name_override: None, + }) + } + } +} + +struct ExportedAlias { + _type_token: Token![type], + name: Ident, + _is: Token![=], + ty: Type, +} + +impl Parse for ExportedAlias { + fn parse(input: ParseStream) -> Result { + let type_token = input.parse()?; + let name = input.parse()?; + let is = input.parse()?; + let ty = input.parse()?; + + Ok(ExportedAlias { + _type_token: type_token, + name, + _is: is, + ty, + }) + } +} + +struct ItemWithAttrs { + attrs: Vec, + item: Box, +} + +impl ItemWithAttrs { + fn has_docstr(&self) -> bool { + for attr in self.attrs.iter() { + match attr.style { + AttrStyle::Outer => (), + _ => continue, + } + + match &attr.meta { + Meta::NameValue(kv) => { + if kv.path.is_ident("doc") { + return true; + } else { + continue; + } + } + _ => continue, + }; + } + + false + } + + fn get_docstr(&self) -> Result { + let mut doc = String::new(); + for attr in self.attrs.iter() { + match attr.style { + AttrStyle::Outer => (), + _ => continue, + } + + let line = match &attr.meta { + Meta::NameValue(kv) => { + if kv.path.is_ident("doc") { + match &kv.value { + Expr::Lit(ExprLit { + lit: Lit::Str(s), .. + }) => s.value(), + _ => continue, + } + } else { + continue; + } + } + _ => continue, + }; + + match doc.len() { + 0 => doc.push_str(&line), + _ => { + doc.push('\n'); + doc.push_str(&line); + } + } + } + + Ok(doc) + } +} + +impl Parse for ItemWithAttrs { + fn parse(input: ParseStream) -> Result { + let attr: Vec = input.call(Attribute::parse_outer)?; + let item: ModuleItem = input.parse()?; + Ok(ItemWithAttrs { + attrs: attr, + item: Box::new(item), + }) + } +} + +struct ExportedGenerics { + _for: Token![for], + type_param: Ident, + _in: Token![in], + _bracket: Bracket, + types: Punctuated, + _brace: Brace, + items: Punctuated, +} + +impl ExportedGenerics { + fn to_generic_environment(&self) -> GenericEnvironment { + GenericEnvironment::new(self) + } +} + +struct GenericEnvironment<'a> { + parameter: &'a Ident, + values: Vec<&'a Path>, + items: Vec<&'a ModuleItem>, + subenvs: Vec>, +} + +impl<'a> GenericEnvironment<'a> { + fn new(generics: &'a ExportedGenerics) -> Self { + let parameter = &generics.type_param; + let values: Vec<_> = generics.types.iter().collect(); + + let n_globals = generics + .items + .iter() + .filter(|f| f.is_exported_const() || f.is_exported_global()) + .count(); + + if n_globals != 0 { + panic!("Globals and constants must be defined outside a `for` block.") + } + + let items: Vec<_> = generics + .items + .iter() + .filter(|f| { + f.is_exported_fn() + || f.is_exported_method() + || f.is_exported_type() + || f.is_exported_async_callback() + }) + .collect(); + + let subenvs: Vec<_> = generics + .items + .iter() + .filter(|f| f.is_exported_generics()) + .map(|f| f.get_exported_generics()) + .map(GenericEnvironment::new) + .collect(); + + GenericEnvironment { + parameter, + values, + items, + subenvs, + } + } + + fn init_type_fragments(&self) -> impl Iterator { + let mut out = vec![]; + self.init_type_fragments_env(None, &mut out); + out.into_iter() + } + + fn init_type_fragments_env( + &'a self, + env: Option<&ParameterEnvironment<'a>>, + out: &mut Vec, + ) { + for sub_env in self.subenvs.iter() { + let env = ParameterEnvironment::new(self, env); + sub_env.init_type_fragments_env(Some(&env), out); + } + + let exprs = self + .items + .iter() + .copied() + .filter(|it| it.is_exported_type()) + .map(|it| it.get_exported_type()) + .map(|it| it.init_with_env(self, env)); + + out.extend(exprs); + } + + fn reinit_type_fragments(&self) -> impl Iterator { + let mut out = vec![]; + self.reinit_type_fragments_env(None, &mut out); + out.into_iter() + } + + fn reinit_type_fragments_env( + &'a self, + env: Option<&ParameterEnvironment<'a>>, + out: &mut Vec, + ) { + for sub_env in self.subenvs.iter() { + let env = ParameterEnvironment::new(self, env); + sub_env.reinit_type_fragments_env(Some(&env), out); + } + + let exprs = self + .items + .iter() + .copied() + .filter(|it| it.is_exported_type()) + .map(|it| it.get_exported_type()) + .map(|it| it.reinit_with_env(self, env)); + + out.extend(exprs); + } + + fn init_function_fragments_env( + &'a self, + env: Option<&ParameterEnvironment<'a>>, + offset: &mut usize, + ) -> Result { + let mut sup_exprs = vec![]; + + for sub_env in self.subenvs.iter() { + let env = ParameterEnvironment::new(self, env); + let ex = sub_env.init_function_fragments_env(Some(&env), offset)?; + sup_exprs.push(ex); + } + + let exprs = self + .items + .iter() + .copied() + .filter(|it| it.is_exported_fn()) + .map(|it| it.get_exported_fn()) + .map(|it| { + let mut gc_safe = false; + if let Some(attrs) = it.1 { + gc_safe = has_outer_path_attr(attrs, "gc_safe"); + } + it.0.init_with_env(self, env, offset, gc_safe) + }) + .collect::>>()?; + + let ex = parse_quote! { + { + #(#sup_exprs;)* + #(#exprs;)* + } + }; + + Ok(ex) + } + + fn init_method_fragments_env( + &'a self, + env: Option<&ParameterEnvironment<'a>>, + offset: &mut usize, + ) -> Result { + let mut sup_exprs = vec![]; + + for sub_env in self.subenvs.iter() { + let env = ParameterEnvironment::new(self, env); + let ex = sub_env.init_method_fragments_env(Some(&env), offset)?; + sup_exprs.push(ex); + } + + let exprs = self + .items + .iter() + .copied() + .filter(|it| it.is_exported_method()) + .map(|it| it.get_exported_method()) + .map(|it| { + let mut untracked_self = false; + let mut gc_safe = false; + if let Some(attrs) = it.1 { + untracked_self = has_outer_path_attr(attrs, "untracked_self"); + gc_safe = has_outer_path_attr(attrs, "gc_safe"); + } + it.0.init_with_env(self, env, offset, untracked_self, gc_safe) + }) // TODO: attrs + .collect::>>()?; + + let ex = parse_quote! { + { + #(#sup_exprs;)* + #(#exprs;)* + } + }; + + Ok(ex) + } + + fn init_async_callback_fragments_env( + &'a self, + env: Option<&ParameterEnvironment<'a>>, + offset: &mut usize, + ) -> Result { + let mut sup_exprs = vec![]; + + for sub_env in self.subenvs.iter() { + let env = ParameterEnvironment::new(self, env); + let ex = sub_env.init_async_callback_fragments_env(Some(&env), offset)?; + sup_exprs.push(ex); + } + + let exprs = self + .items + .iter() + .copied() + .filter(|it| it.is_exported_async_callback()) + .map(|it| it.get_exported_async_callback()) + .map(|it| it.init_with_env(self, env, offset)) + .collect::>>()?; + + let ex = parse_quote! { + { + #(#sup_exprs;)* + #(#exprs;)* + } + }; + + Ok(ex) + } +} + +impl Parse for ExportedGenerics { + fn parse(input: ParseStream) -> Result { + let for_token = input.parse()?; + let type_param = input.parse()?; + let in_token = input.parse()?; + + let content; + let bracket = bracketed!(content in input); + let types = content.parse_terminated(Path::parse, Token![,])?; + + let content; + let brace = braced!(content in input); + let items = content.parse_terminated(ModuleItem::parse, Token![;])?; + + Ok(ExportedGenerics { + _for: for_token, + type_param, + _in: in_token, + _bracket: bracket, + types, + _brace: brace, + items, + }) + } +} + +enum ModuleItem { + InitFn(InitFn), + ExportedType(ExportedType), + ExportedFunction(ExportedFunction), + ExportedMethod(ExportedMethod), + ExportedAsyncCallback(ExportedAsyncCallback), + ExportedConst(ExportedConst), + ExportedGlobal(ExportedGlobal), + ItemWithAttrs(ItemWithAttrs), + ExportedGenerics(ExportedGenerics), + ExportedAlias(ExportedAlias), +} + +impl ModuleItem { + fn is_init_fn(&self) -> bool { + match self { + ModuleItem::InitFn(_) => true, + _ => false, + } + } + + fn get_init_fn(&self) -> &InitFn { + match self { + ModuleItem::InitFn(ref init_fn) => init_fn, + _ => panic!(), + } + } + + fn is_exported_fn(&self) -> bool { + match self { + ModuleItem::ExportedFunction(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_fn() => true, + _ => false, + } + } + + fn get_exported_fn(&self) -> (&ExportedFunction, Option<&[Attribute]>) { + match self { + ModuleItem::ExportedFunction(ref exported_fn) => (exported_fn, None), + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, attrs }) if item.is_exported_fn() => { + (item.get_exported_fn().0, Some(attrs)) + } + _ => panic!(), + } + } + + fn is_exported_method(&self) -> bool { + match self { + ModuleItem::ExportedMethod(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_method() => { + true + } + _ => false, + } + } + + fn get_exported_method(&self) -> (&ExportedMethod, Option<&[Attribute]>) { + match self { + ModuleItem::ExportedMethod(ref exported_method) => (exported_method, None), + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, ref attrs }) + if item.is_exported_method() => + { + (item.get_exported_method().0, Some(attrs.as_ref())) + } + _ => panic!(), + } + } + + fn is_exported_async_callback(&self) -> bool { + match self { + ModuleItem::ExportedAsyncCallback(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) + if item.is_exported_async_callback() => + { + true + } + _ => false, + } + } + + fn get_exported_async_callback(&self) -> &ExportedAsyncCallback { + match self { + ModuleItem::ExportedAsyncCallback(ref exported_async_callback) => { + exported_async_callback + } + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) + if item.is_exported_async_callback() => + { + item.get_exported_async_callback() + } + _ => panic!(), + } + } + + fn is_exported_type(&self) -> bool { + match self { + ModuleItem::ExportedType(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_type() => { + true + } + _ => false, + } + } + + fn get_exported_type(&self) -> &ExportedType { + match self { + ModuleItem::ExportedType(ref exported_type) => exported_type, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_type() => { + item.get_exported_type() + } + _ => panic!(), + } + } + + fn is_exported_const(&self) -> bool { + match self { + ModuleItem::ExportedConst(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_const() => { + true + } + _ => false, + } + } + + fn get_exported_const(&self) -> &ExportedConst { + match self { + ModuleItem::ExportedConst(ref exported_const) => exported_const, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_const() => { + item.get_exported_const() + } + _ => panic!(), + } + } + + fn is_exported_alias(&self) -> bool { + match self { + ModuleItem::ExportedAlias(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_alias() => { + true + } + _ => false, + } + } + + fn get_exported_alias(&self) -> &ExportedAlias { + match self { + ModuleItem::ExportedAlias(ref exported_alias) => exported_alias, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_alias() => { + item.get_exported_alias() + } + _ => panic!(), + } + } + + fn is_exported_global(&self) -> bool { + match self { + ModuleItem::ExportedGlobal(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_global() => { + true + } + _ => false, + } + } + + fn get_exported_global(&self) -> &ExportedGlobal { + match self { + ModuleItem::ExportedGlobal(ref exported_global) => exported_global, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) if item.is_exported_global() => { + item.get_exported_global() + } + _ => panic!(), + } + } + + fn is_exported_generics(&self) -> bool { + match self { + ModuleItem::ExportedGenerics(_) => true, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) + if item.is_exported_generics() => + { + true + } + _ => false, + } + } + + fn get_exported_generics(&self) -> &ExportedGenerics { + match self { + ModuleItem::ExportedGenerics(ref exported_generics) => exported_generics, + ModuleItem::ItemWithAttrs(ItemWithAttrs { item, .. }) + if item.is_exported_generics() => + { + item.get_exported_generics() + } + _ => panic!(), + } + } + + fn get_all_with_docs(&self) -> Vec<&ItemWithAttrs> { + let mut items = vec![]; + match self { + ModuleItem::ExportedGenerics(ref exported_generics) => { + for item in exported_generics.items.iter() { + item.get_all_with_docs_inner(&mut items); + } + } + ModuleItem::ItemWithAttrs(item) => { + if item.has_docstr() { + items.push(item) + } + } + _ => (), + } + + items + } + + fn get_all_with_docs_inner<'a>(&'a self, items: &mut Vec<&'a ItemWithAttrs>) { + match self { + ModuleItem::ExportedGenerics(ref exported_generics) => { + for item in exported_generics.items.iter() { + item.get_all_with_docs_inner(items); + } + } + ModuleItem::ItemWithAttrs(item) => { + if item.has_docstr() { + items.push(item) + } + } + _ => (), + } + } +} + +impl Parse for ModuleItem { + fn parse(input: ParseStream) -> Result { + let lookahead = input.lookahead1(); + if lookahead.peek(Token![become]) { + input.parse().map(ModuleItem::InitFn) + } else if lookahead.peek(Token![struct]) { + input.parse().map(ModuleItem::ExportedType) + } else if lookahead.peek(Token![fn]) { + input.parse().map(ModuleItem::ExportedFunction) + } else if lookahead.peek(Token![in]) { + input.parse().map(ModuleItem::ExportedMethod) + } else if lookahead.peek(Token![async]) { + input.parse().map(ModuleItem::ExportedAsyncCallback) + } else if lookahead.peek(Token![const]) { + input.parse().map(ModuleItem::ExportedConst) + } else if lookahead.peek(Token![type]) { + input.parse().map(ModuleItem::ExportedAlias) + } else if lookahead.peek(Token![static]) { + input.parse().map(ModuleItem::ExportedGlobal) + } else if lookahead.peek(Token![#]) { + input.parse().map(ModuleItem::ItemWithAttrs) + } else if lookahead.peek(Token![for]) { + input.parse().map(ModuleItem::ExportedGenerics) + } else { + Err(Error::new( + input.span(), + "Expected `become`, `fn`, `in`, `struct`, `const`, or `static`.", + )) + } + } +} + +pub(crate) struct JuliaModule { + items: Punctuated, +} + +impl Parse for JuliaModule { + fn parse(input: ParseStream) -> Result { + let content = input; + let items = content.parse_terminated(ModuleItem::parse, Token![;])?; + + Ok(JuliaModule { items: items }) + } +} + +impl JuliaModule { + pub(crate) fn generate_init_code(self) -> Result { + let init_fn = self.get_init_fn()?; + let init_fn_ident = &init_fn.init_fn; + + let fn_fragments = FunctionFragments::generate(&self, init_fn)?; + let generic_fn_fragments = FunctionFragments::generate_generic(&self, init_fn)?; + let method_fragments = MethodFragments::generate(&self, init_fn); + let async_callback_fragments = AsyncCallbackFragments::generate(&self, init_fn)?; + let generic_async_callback_fragments = + AsyncCallbackFragments::generate_generic(&self, init_fn)?; + let generic_method_fragments = MethodFragments::generate_generic(&self, init_fn)?; + let type_fragments = TypeFragments::generate(&self, init_fn); + let generic_type_fragments = TypeFragments::generate_generic(&self, init_fn); + let const_fragments = ConstFragments::generate(&self, init_fn); + let alias_fragments = AliasFragments::generate(&self, init_fn); + let global_fragments = GlobalFragments::generate(&self, init_fn); + let doc_fragments = DocFragments::generate(&self, init_fn)?; + + let type_init_fn = type_fragments.type_init_fn; + let type_init_fn_ident = type_fragments.type_init_ident; + let type_reinit_fn = type_fragments.type_reinit_fn; + let type_reinit_fn_ident = type_fragments.type_reinit_ident; + let generic_type_init_fn = generic_type_fragments.type_init_fn; + let generic_type_init_fn_ident = generic_type_fragments.type_init_ident; + let generic_type_reinit_fn = generic_type_fragments.type_reinit_fn; + let generic_type_reinit_fn_ident = generic_type_fragments.type_reinit_ident; + let function_init_fn = fn_fragments.init_functions_fn; + let function_init_fn_ident = fn_fragments.init_functions_fn_ident; + let generic_function_init_fn = generic_fn_fragments.init_functions_fn; + let generic_function_init_fn_ident = generic_fn_fragments.init_functions_fn_ident; + let method_init_fn = method_fragments.init_methods_fn; + let method_init_fn_ident = method_fragments.init_methods_fn_ident; + let generic_method_init_fn = generic_method_fragments.init_methods_fn; + let generic_method_init_fn_ident = generic_method_fragments.init_methods_fn_ident; + let async_callback_init_fn = async_callback_fragments.init_async_callbacks_fn; + let async_callback_init_fn_ident = async_callback_fragments.init_async_callbacks_fn_ident; + let generic_async_callback_init_fn = + generic_async_callback_fragments.init_async_callbacks_fn; + let generic_async_callback_init_fn_ident = + generic_async_callback_fragments.init_async_callbacks_fn_ident; + let const_init_fn = const_fragments.const_init_fn; + let const_init_fn_ident = const_fragments.const_init_ident; + let alias_init_fn = alias_fragments.alias_init_fn; + let alias_init_fn_ident = alias_fragments.alias_init_ident; + let global_init_fn = global_fragments.global_init_fn; + let global_init_fn_ident = global_fragments.global_init_ident; + let doc_init_fn = doc_fragments.init_docs_fn; + let doc_init_fn_ident = doc_fragments.init_docs_fn_ident; + + let invoke_type_init: Expr = parse_quote! { + if precompiling == 1 { + #type_init_fn_ident(&mut frame, module); + } else { + #type_reinit_fn_ident(&mut frame, module); + } + }; + + let invoke_generic_type_init: Expr = parse_quote! { + if precompiling == 1 { + #generic_type_init_fn_ident(&mut frame, module); + } else { + #generic_type_reinit_fn_ident(&mut frame, module); + } + }; + + let invoke_const_init: Expr = parse_quote! { + if precompiling == 1 { + #const_init_fn_ident(&mut frame, module); + } + }; + + let invoke_alias_init: Expr = parse_quote! { + if precompiling == 1 { + #alias_init_fn_ident(&frame, module); + } + }; + + let invoke_global_init: Expr = parse_quote! { + if precompiling == 1 { + #global_init_fn_ident(&mut frame, module); + } + }; + + let generated = quote::quote! { + + #[no_mangle] + pub unsafe extern "C" fn #init_fn_ident( + module: ::jlrs::data::managed::module::Module, + precompiling: u8, + ) -> ::jlrs::data::managed::value::ValueRet { + #type_init_fn + + #type_reinit_fn + + #generic_type_init_fn + + #generic_type_reinit_fn + + #function_init_fn + + #generic_function_init_fn + + #method_init_fn + + #generic_method_init_fn + + #async_callback_init_fn + + #generic_async_callback_init_fn + + #const_init_fn + + #alias_init_fn + + #global_init_fn + + #doc_init_fn + + static IS_INIT: ::std::sync::atomic::AtomicBool = ::std::sync::atomic::AtomicBool::new(false); + if IS_INIT.compare_exchange(false, true, ::std::sync::atomic::Ordering::Relaxed, ::std::sync::atomic::Ordering::Relaxed).is_err() { + let unrooted = <::jlrs::data::managed::module::Module as ::jlrs::data::managed::Managed>::unrooted_target(module); + return ::jlrs::data::managed::value::Value::nothing(&unrooted).as_ref().leak(); + } + + let mut stack_frame = ::jlrs::memory::stack_frame::StackFrame::new(); + let mut ccall = ::jlrs::ccall::CCall::new(&mut stack_frame); + + ccall.init_jlrs(&::jlrs::InstallJlrsCore::Default, Some(module)); + + ccall.scope(|mut frame| { + let wrap_mod = ::jlrs::data::managed::module::Module::main(&frame) + .submodule(&frame, "JlrsCore") + .unwrap() + .as_managed() + .submodule(&frame, "Wrap") + .unwrap() + .as_managed(); + + let function_info_ty = wrap_mod + .global(&frame, "JlrsFunctionInfo") + .unwrap() + .as_value() + .cast_unchecked::<::jlrs::data::managed::datatype::DataType>(); + + let doc_item_ty = wrap_mod + .global(&frame, "DocItem") + .unwrap() + .as_value() + .cast_unchecked::<::jlrs::data::managed::datatype::DataType>(); + + let module_info_ty = wrap_mod + .global(&frame, "JlrsModuleInfo") + .unwrap() + .as_value() + .cast_unchecked::<::jlrs::data::managed::datatype::DataType>(); + + #invoke_type_init; + #invoke_generic_type_init; + #invoke_const_init; + #invoke_global_init; + #invoke_alias_init; + + let mut arr = ::jlrs::data::managed::array::Array::new_for_unchecked(&mut frame, 0, function_info_ty.as_value()); + #function_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); + #generic_function_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); + #method_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); + #generic_method_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); + #async_callback_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); + #generic_async_callback_init_fn_ident(&mut frame, &mut arr, module, function_info_ty); + + let mut doc_items = ::jlrs::data::managed::array::Array::new_for_unchecked(&mut frame, 0, doc_item_ty.as_value()); + if precompiling == 1 { + #doc_init_fn_ident(&mut frame, &mut doc_items, module, doc_item_ty); + } + Ok(module_info_ty.instantiate_unchecked(&frame, [arr.as_value(), doc_items.as_value()]).leak()) + }).unwrap() + } + }; + + Ok(generated.into()) + } + + fn get_init_fn(&self) -> Result<&InitFn> { + let n_init_fns = self.items.iter().filter(|it| it.is_init_fn()).count(); + if n_init_fns != 1 { + let msg = format!("Expected 1 init fn, found {}", n_init_fns); + Err(Error::new(Span::call_site(), msg))?; + } + + let init_fn = self + .items + .iter() + .find(|it| it.is_init_fn()) + .unwrap() + .get_init_fn(); + + Ok(init_fn) + } + + fn get_exported_functions( + &self, + ) -> impl Iterator)> { + self.items + .iter() + .filter(|it| it.is_exported_fn()) + .map(|it| it.get_exported_fn()) + } + + fn get_exported_methods( + &self, + ) -> impl Iterator)> { + self.items + .iter() + .filter(|it| it.is_exported_method()) + .map(|it| it.get_exported_method()) + } + + fn get_exported_async_callbacks(&self) -> impl Iterator { + self.items + .iter() + .filter(|it| it.is_exported_async_callback()) + .map(|it| it.get_exported_async_callback()) + } + + fn get_exported_types(&self) -> impl Iterator { + self.items + .iter() + .filter(|it| it.is_exported_type()) + .map(|it| it.get_exported_type()) + } + + fn get_exported_consts(&self) -> impl Iterator { + self.items + .iter() + .filter(|it| it.is_exported_const()) + .map(|it| it.get_exported_const()) + } + + fn get_exported_aliases(&self) -> impl Iterator { + self.items + .iter() + .filter(|it| it.is_exported_alias()) + .map(|it| it.get_exported_alias()) + } + + fn get_exported_globals(&self) -> impl Iterator { + self.items + .iter() + .filter(|it| it.is_exported_global()) + .map(|it| it.get_exported_global()) + } + + fn get_exported_generics(&self) -> impl Iterator { + self.items + .iter() + .filter(|it| it.is_exported_generics()) + .map(|it| it.get_exported_generics()) + } + + fn get_items_with_docs(&self) -> impl Iterator { + self.items + .iter() + .map(|it| it.get_all_with_docs()) + .concat() + .into_iter() + } +} + +struct DocFragments { + init_docs_fn_ident: Ident, + init_docs_fn: ItemFn, +} + +impl DocFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Result { + let init_docs_fn_ident = format_ident!("{}_docs", init_fn.init_fn); + let n_docs = module.get_items_with_docs().count(); + + let doc_init_fragments = module + .get_items_with_docs() + .enumerate() + .map(doc_info_fragment); + + let mut fragments = Vec::with_capacity(n_docs); + for fragment in doc_init_fragments { + fragments.push(fragment?); + } + + let init_docs_fn = parse_quote! { + unsafe fn #init_docs_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + doc_item_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + array.grow_end_unchecked(#n_docs); + let mut accessor = array.indeterminate_data_mut(); + + #( + #fragments + )* + + Ok(()) + }).unwrap() + } + }; + + Ok(DocFragments { + init_docs_fn_ident, + init_docs_fn, + }) + } +} + +struct FunctionFragments { + init_functions_fn_ident: Ident, + init_functions_fn: ItemFn, +} + +impl FunctionFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Result { + let init_functions_fn_ident = format_ident!("{}_functions", init_fn.init_fn); + let n_functions = module.get_exported_functions().count(); + + let fragments = module + .get_exported_functions() + .enumerate() + .map(function_info_fragment) + .collect::>>()?; + + let init_functions_fn = parse_quote! { + unsafe fn #init_functions_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + function_info_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + array.grow_end_unchecked(#n_functions); + let mut accessor = array.value_data_mut().unwrap(); + #(#fragments)* + + Ok(()) + }).unwrap() + } + }; + + Ok(FunctionFragments { + init_functions_fn_ident, + init_functions_fn, + }) + } + + fn generate_generic(info: &JuliaModule, init_fn: &InitFn) -> Result { + let mut offset = 0; + + let init_functions_fn_ident = format_ident!("{}_generic_functions", init_fn.init_fn); + let init_functions_fragments = info + .get_exported_generics() + .map(|g| { + g.to_generic_environment() + .init_function_fragments_env(None, &mut offset) + }) + .collect::>>()?; + + let init_functions_fn = parse_quote! { + unsafe fn #init_functions_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + function_info_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + let mut accessor = array.value_data_mut().unwrap(); + let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()); + #(#init_functions_fragments)* + Ok(()) + }).unwrap() + } + }; + + let fragments = FunctionFragments { + init_functions_fn_ident, + init_functions_fn, + }; + + Ok(fragments) + } +} + +struct MethodFragments { + init_methods_fn_ident: Ident, + init_methods_fn: ItemFn, +} + +impl MethodFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { + let init_methods_fn_ident = format_ident!("{}_methods", init_fn.init_fn); + let n_methods = module.get_exported_methods().count(); + + let method_init_fragments = module + .get_exported_methods() + .enumerate() + .map(method_info_fragment); + + let init_methods_fn = parse_quote! { + unsafe fn #init_methods_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + function_info_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + array.grow_end_unchecked(#n_methods); + let mut accessor = array.value_data_mut().unwrap(); + let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()) - #n_methods; + + #( + #method_init_fragments + )* + + Ok(()) + }).unwrap() + } + }; + + MethodFragments { + init_methods_fn_ident, + init_methods_fn, + } + } + + fn generate_generic(info: &JuliaModule, init_fn: &InitFn) -> Result { + let mut offset = 0; + + let init_methods_fn_ident = format_ident!("{}_generic_methods", init_fn.init_fn); + let init_methods_fragments = info + .get_exported_generics() + .map(|g| { + g.to_generic_environment() + .init_method_fragments_env(None, &mut offset) + }) + .collect::>>()?; + + let init_methods_fn = parse_quote! { + unsafe fn #init_methods_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + function_info_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + let mut accessor = array.value_data_mut().unwrap(); + let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()); + #(#init_methods_fragments)* + Ok(()) + }).unwrap() + } + }; + + let fragments = MethodFragments { + init_methods_fn_ident, + init_methods_fn, + }; + + Ok(fragments) + } +} + +struct AsyncCallbackFragments { + init_async_callbacks_fn_ident: Ident, + init_async_callbacks_fn: ItemFn, +} + +impl AsyncCallbackFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Result { + let init_async_callbacks_fn_ident = format_ident!("{}_async_callbacks", init_fn.init_fn); + let n_async_callbacks = module.get_exported_async_callbacks().count(); + + let async_callback_init_fragments = module + .get_exported_async_callbacks() + .enumerate() + .map(async_callback_info_fragment); + + let mut fragments = Vec::with_capacity(n_async_callbacks); + for fragment in async_callback_init_fragments { + fragments.push(fragment?); + } + + let init_async_callbacks_fn = parse_quote! { + unsafe fn #init_async_callbacks_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + function_info_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + array.grow_end_unchecked(#n_async_callbacks); + let mut accessor = array.value_data_mut().unwrap(); + let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()) - #n_async_callbacks; + + #( + #fragments + )* + + Ok(()) + }).unwrap() + } + }; + + Ok(AsyncCallbackFragments { + init_async_callbacks_fn_ident, + init_async_callbacks_fn, + }) + } + + fn generate_generic(info: &JuliaModule, init_fn: &InitFn) -> Result { + let mut offset = 0; + + let init_async_callbacks_fn_ident = + format_ident!("{}_generic_async_callbacks", init_fn.init_fn); + let init_async_callback_fragments = info + .get_exported_generics() + .map(|g| { + g.to_generic_environment() + .init_async_callback_fragments_env(None, &mut offset) + }) + .collect::>>()?; + + let init_async_callbacks_fn = parse_quote! { + unsafe fn #init_async_callbacks_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + array: &mut ::jlrs::data::managed::array::Array<'_, 'static>, + module: ::jlrs::data::managed::module::Module, + function_info_ty: ::jlrs::data::managed::datatype::DataType, + ) { + frame.scope(move |mut frame| { + let mut accessor = array.value_data_mut().unwrap(); + let offset = ::jlrs::data::managed::array::dimensions::Dims::size(&accessor.dimensions()); + #(#init_async_callback_fragments)* + Ok(()) + }).unwrap() + } + }; + + let fragments = AsyncCallbackFragments { + init_async_callbacks_fn_ident, + init_async_callbacks_fn, + }; + + Ok(fragments) + } +} + +struct TypeFragments { + type_init_fn: ItemFn, + type_init_ident: Ident, + type_reinit_fn: ItemFn, + type_reinit_ident: Ident, +} + +impl TypeFragments { + fn generate(info: &JuliaModule, init_fn: &InitFn) -> Self { + let init_types_fn_ident = format_ident!("{}_types", init_fn.init_fn); + let init_types_fragments = info.get_exported_types().map(init_type_fragment); + + let type_init_fn = parse_quote! { + unsafe fn #init_types_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + module: ::jlrs::data::managed::module::Module, + ) { + frame.scope(|mut frame| { + let mut output = frame.output(); + + #( + #init_types_fragments + )* + + Ok(()) + }).unwrap(); + } + }; + + let reinit_types_fn_ident = format_ident!("{}_reinittypes", init_fn.init_fn); + let reinit_types_fragments = info.get_exported_types().map(reinit_type_fragment); + + let type_reinit_fn = parse_quote! { + unsafe fn #reinit_types_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + module: jlrs::data::managed::module::Module + ) { + frame.scope(|frame| { + let mut output = frame.output(); + + #( + #reinit_types_fragments + )* + + Ok(()) + }).unwrap(); + } + }; + + TypeFragments { + type_init_fn, + type_init_ident: init_types_fn_ident, + type_reinit_fn, + type_reinit_ident: reinit_types_fn_ident, + } + } + + fn generate_generic(info: &JuliaModule, init_fn: &InitFn) -> Self { + let init_types_fn_ident = format_ident!("{}_generic_types", init_fn.init_fn); + let init_types_fragments = info + .get_exported_generics() + .map(|g| g.to_generic_environment().init_type_fragments()) + .flatten(); + + let type_init_fn = parse_quote! { + unsafe fn #init_types_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + module: ::jlrs::data::managed::module::Module, + ) { + frame.scope(|mut frame| { + let mut output = frame.output(); + + #( + #init_types_fragments + )* + + Ok(()) + }).unwrap(); + } + }; + + let reinit_types_fn_ident = format_ident!("{}_reinit_generic_types", init_fn.init_fn); + let reinit_types_fragments = info + .get_exported_generics() + .map(|g| g.to_generic_environment().reinit_type_fragments()) + .flatten(); + + let type_reinit_fn = parse_quote! { + unsafe fn #reinit_types_fn_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + module: jlrs::data::managed::module::Module + ) { + frame.scope(|mut frame| { + let mut output = frame.output(); + + #( + #reinit_types_fragments + )* + + Ok(()) + }).unwrap(); + } + }; + + TypeFragments { + type_init_fn, + type_init_ident: init_types_fn_ident, + type_reinit_fn, + type_reinit_ident: reinit_types_fn_ident, + } + } +} + +struct ConstFragments { + const_init_fn: ItemFn, + const_init_ident: Ident, +} + +impl ConstFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { + let const_init_ident = format_ident!("{}_consts", init_fn.init_fn); + + let const_init_fragments = module.get_exported_consts().map(const_info_fragment); + + let const_init_fn = parse_quote! { + unsafe fn #const_init_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + module: ::jlrs::data::managed::module::Module, + ) { + #( + #const_init_fragments + )* + } + }; + + ConstFragments { + const_init_ident, + const_init_fn, + } + } +} + +struct AliasFragments { + alias_init_fn: ItemFn, + alias_init_ident: Ident, +} + +impl AliasFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { + let alias_init_ident = format_ident!("{}_aliases", init_fn.init_fn); + + let const_init_fragments = module.get_exported_aliases().map(alias_info_fragment); + + let alias_init_fn = parse_quote! { + unsafe fn #alias_init_ident( + frame: &::jlrs::memory::target::frame::GcFrame, + module: ::jlrs::data::managed::module::Module, + ) { + #( + #const_init_fragments + )* + } + }; + + AliasFragments { + alias_init_ident, + alias_init_fn, + } + } +} + +struct GlobalFragments { + global_init_fn: ItemFn, + global_init_ident: Ident, +} + +impl GlobalFragments { + fn generate(module: &JuliaModule, init_fn: &InitFn) -> Self { + let global_init_ident = format_ident!("{}_globals", init_fn.init_fn); + + let global_init_fragments = module.get_exported_globals().map(global_info_fragment); + + let global_init_fn = parse_quote! { + unsafe fn #global_init_ident( + frame: &mut ::jlrs::memory::target::frame::GcFrame, + module: ::jlrs::data::managed::module::Module, + ) { + #( + #global_init_fragments + )* + } + }; + + GlobalFragments { + global_init_ident, + global_init_fn, + } + } +} + +fn doc_info_fragment((index, info): (usize, &ItemWithAttrs)) -> Result { + match info.item.as_ref() { + ModuleItem::InitFn(i) => Err(syn::Error::new_spanned( + i.init_fn.to_token_stream(), + "init function cannot be documented", + ))?, + ModuleItem::ExportedType(ty) => { + let override_module_fragment = override_module_fragment(&ty.name_override); + let name_ident = &ty.name.segments.last().unwrap().ident; + + let rename = ty + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + let doc = info.get_docstr()?; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + unsafe { + let module = #override_module_fragment; + let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); + let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); + + let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); + accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + }; + + Ok(q) + } + ModuleItem::ExportedFunction(func) => { + let name_ident = &func.func.ident; + + let override_module_fragment = override_module_fragment(&func.name_override); + let mut rename = func + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if func.exclamation_mark_token.is_some() { + rename.push('!') + } + + let doc = info.get_docstr()?; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + unsafe { + let module = #override_module_fragment; + let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); + let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); + + let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); + accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + + }; + + Ok(q) + } + ModuleItem::ExportedMethod(func) => { + let name_ident = &func.func.ident; + + let override_module_fragment = override_module_fragment(&func.name_override); + let mut rename = func + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if func.exclamation_mark_token.is_some() { + rename.push('!') + } + + let doc = info.get_docstr()?; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + unsafe { + let module = #override_module_fragment; + let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); + let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); + + let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); + accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + + }; + + Ok(q) + } + ModuleItem::ExportedAsyncCallback(func) => { + let name_ident = &func.func.ident; + + let override_module_fragment = override_module_fragment(&func.name_override); + let mut rename = func + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if func.exclamation_mark_token.is_some() { + rename.push('!') + } + + let doc = info.get_docstr()?; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + unsafe { + let module = #override_module_fragment; + let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); + let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); + + let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); + accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + + }; + + Ok(q) + } + ModuleItem::ExportedConst(val) => { + let name_ident = &val.name; + let rename = val.name_override.as_ref().unwrap_or(name_ident).to_string(); + let doc = info.get_docstr()?; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + unsafe { + let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); + let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); + + let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); + accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + + }; + + Ok(q) + } + ModuleItem::ExportedGlobal(val) => { + let name_ident = &val.name; + let rename = val.name_override.as_ref().unwrap_or(name_ident).to_string(); + let doc = info.get_docstr()?; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + unsafe { + let item = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let signature = ::jlrs::data::managed::value::Value::bottom_type(&frame); + let doc = ::jlrs::data::managed::string::JuliaString::new(&mut frame, #doc); + + let doc_it = doc_item_ty.instantiate_unchecked(&mut frame, [module.as_value(), item.as_value(), signature, doc.as_value()]); + accessor.set_value_unchecked(#index, Some(doc_it)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + + }; + + Ok(q) + } + ModuleItem::ExportedAlias(a) => Err(syn::Error::new_spanned( + a.name.to_token_stream(), + "type alias cannot be documented", + ))?, + ModuleItem::ItemWithAttrs(_) => unreachable!(), + ModuleItem::ExportedGenerics(_) => unreachable!(), + } +} + +fn function_info_fragment( + (index, (info, attrs)): (usize, (&ExportedFunction, Option<&[Attribute]>)), +) -> Result { + let n_args = info.func.inputs.len(); + let name_ident = &info.func.ident; + + let override_module_fragment = override_module_fragment(&info.name_override); + let mut rename = info + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if info.exclamation_mark_token.is_some() { + rename.push('!') + } + + let ret_ty = &info.func.output; + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let (ccall_ret_type, julia_ret_type) = return_type_fragments(&info.func.output); + + let ccall_arg_idx = 0..n_args; + let julia_arg_idx = 0..n_args; + + let (ccall_arg_types, julia_arg_types) = arg_type_fragments(&info.func.inputs)?; + let args = &info.func.inputs; + + let names = args.iter().map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + let names = Punctuated::<_, Comma>::from_iter(names); + + let mut gc_safe = false; + if let Some(attrs) = attrs { + gc_safe = has_outer_path_attr(attrs, "gc_safe"); + } + + let call_expr: Expr = if gc_safe { + parse_quote! { ::jlrs::memory::gc::gc_safe(|| #name_ident(#names)) } + } else { + parse_quote! { #name_ident(#names) } + }; + + let span = info.func.span(); + let invoke_fn: ItemFn = parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args) #new_ret_ty { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + } + }; + + let expr = parse_quote! { + { + frame.scope(|mut frame| { + let name = Symbol::new(&frame, #rename); + let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&frame).as_value(); + // Ensure a compile error happens if the signatures of the function don't match. + + #invoke_fn + + let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); + + unsafe { + let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); + + let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); + + #( + ccall_arg_types_ref.set(#ccall_arg_idx, Some(#ccall_arg_types.as_value())).unwrap(); + julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); + )* + + let ccall_return_type = #ccall_ret_type; + let julia_return_type = #julia_ret_type; + + let module = #override_module_fragment; + let nothing = ::jlrs::data::managed::value::Value::nothing(&frame); + + let false_v = ::jlrs::data::managed::value::Value::false_v(&frame); + let instance = function_info_ty.instantiate_unchecked(&mut frame, [ + name.as_value(), + ccall_arg_types.as_value(), + julia_arg_types.as_value(), + ccall_return_type.as_value(), + julia_return_type.as_value(), + func, + module.as_value(), + false_v + ]); + + let n = #index; + accessor.set(n, Some(instance)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + }; + + Ok(expr) +} + +fn override_module_fragment(name_override: &Option) -> Expr { + let name_override = name_override.as_ref(); + if name_override.is_none() { + return parse_quote! { { module } }; + } + let name_override = name_override.unwrap(); + let n_parts = name_override.len(); + if n_parts == 1 { + return parse_quote! { { module } }; + } + + let modules = name_override + .iter() + .take(n_parts - 1) + .map(|ident| ident.to_string()); + + let parsed = parse_quote! { + { + let mut module = Module::main(&frame); + + #( + module = module + .submodule(&frame, #modules) + .expect("Submodule does not exist") + .as_managed(); + )* + + module + } + }; + + parsed +} + +fn return_type_fragments(ret_ty: &ReturnType) -> (Expr, Expr) { + match ret_ty { + ReturnType::Default => { + let ccall_ret_type: Expr = parse_quote! { + ::jlrs::data::managed::datatype::DataType::nothing_type(&frame).as_value() + }; + + let julia_ret_type = ccall_ret_type.clone(); + (ccall_ret_type, julia_ret_type) + } + ReturnType::Type(_, ref ty) => { + let span = ty.span(); + let ccall_ret_type = parse_quote_spanned! { + span=> <<#ty as ::jlrs::convert::ccall_types::CCallReturn>::CCallReturnType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + let julia_ret_type = parse_quote_spanned! { + span=> <<#ty as ::jlrs::convert::ccall_types::CCallReturn>::FunctionReturnType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + + (ccall_ret_type, julia_ret_type) + } + } +} + +// FIXME +fn extract_return_type_from_impl_trait(timplt: &TypeImplTrait) -> Option { + for bound in timplt.bounds.iter() { + match bound { + TypeParamBound::Trait(t) => { + let segment = t.path.segments.last(); + if segment.is_none() { + continue; + } + + match &segment.unwrap().arguments { + PathArguments::AngleBracketed(p) => match p.args.last() { + Some(GenericArgument::Type(ref t)) => return Some(t.clone()), + _ => continue, + }, + _ => continue, + } + } + _ => continue, + } + } + + None +} + +fn extract_inner_return_type_from_path(path: &Path) -> Option { + if let Some(segment) = path.segments.last() { + match segment.arguments { + PathArguments::AngleBracketed(ref args) => { + if let Some(arg) = args.args.first() { + match arg { + GenericArgument::Type(t) => match t { + &Type::ImplTrait(ref timplt) => { + return extract_return_type_from_impl_trait(timplt) + } + _ => (), + }, + _ => (), + } + } + } + _ => (), + } + } + + None +} + +fn extract_inner_return_type(ty: &Type) -> Option { + match ty { + Type::Path(ref p) => extract_inner_return_type_from_path(&p.path), + _ => None, + } +} + +fn async_callback_return_type_fragments(ret_ty: &ReturnType) -> Option { + match ret_ty { + ReturnType::Type(_, ty) => extract_inner_return_type(&*ty), + _ => None, + } +} + +fn arg_type_fragments<'a>( + inputs: &'a Punctuated, +) -> Result<( + impl 'a + Iterator, + impl 'a + Iterator, +)> { + let n_args = inputs.len(); + + if n_args > 0 { + if let FnArg::Receiver(r) = inputs.first().unwrap() { + Err(syn::Error::new_spanned( + r.to_token_stream(), + "exported function must be a free-standing function, use `in fn ...` to export methods", + ))?; + } + } + + let ccall_arg_types = inputs + .iter() + .map(|arg| match arg { + FnArg::Typed(ty) => &ty.ty, + _ => unreachable!(), + }) + .map(|ty| { + parse_quote! { + <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }); + + let julia_arg_types = inputs + .iter() + .map(|arg| match arg { + FnArg::Typed(ty) => &ty.ty, + _ => unreachable!(), + }) + .map(|ty| { + parse_quote! { + <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }); + + Ok((ccall_arg_types, julia_arg_types)) +} + +fn init_type_fragment(info: &ExportedType) -> Expr { + let override_module_fragment = override_module_fragment(&info.name_override); + let name_ident = &info.name.segments.last().unwrap().ident; + + let rename = info + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + let ty = format_ident!("{}", name_ident); + + parse_quote! { + { + let sym = ::jlrs::data::managed::symbol::Symbol::new(&frame, #rename); + let module = #override_module_fragment; + let ty = <#ty as ::jlrs::data::types::foreign_type::OpaqueType>::create_type(&mut output, sym, module); + module.set_const_unchecked(sym, <::jlrs::data::managed::datatype::DataType as ::jlrs::data::managed::Managed>::as_value(ty)); + } + } +} + +fn reinit_type_fragment(info: &ExportedType) -> Expr { + { + let override_module_fragment = override_module_fragment(&info.name_override); + let name_ident = &info.name.segments.last().unwrap().ident; + + let rename = info + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + let ty = format_ident!("{}", name_ident); + + parse_quote! { + { + let module = #override_module_fragment; + + let dt = module + .global(&frame, #rename) + .unwrap() + .as_value() + .cast::<::jlrs::data::managed::datatype::DataType>() + .unwrap(); + + <#ty as ::jlrs::data::types::foreign_type::OpaqueType>::reinit_type(dt); + } + } + } +} + +fn method_info_fragment<'a>( + (index, (info, attrs)): (usize, (&'a ExportedMethod, Option<&'a [Attribute]>)), +) -> Expr { + let n_args = info.func.inputs.len(); + let name_ident = &info.func.ident; + + let mut untracked_self = false; + let mut gc_safe = false; + + if let Some(attrs) = attrs { + untracked_self = has_outer_path_attr(attrs, "untracked_self"); + gc_safe = has_outer_path_attr(attrs, "gc_safe"); + } + + let override_module_fragment = override_module_fragment(&info.name_override); + let mut rename = info + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if info.exclamation_mark_token.is_some() { + rename.push('!') + } + + let ret_ty = &info.func.output; + let (ccall_ret_type, julia_ret_type) = return_type_fragments(ret_ty); + + let ccall_arg_idx = 0..n_args; + let julia_arg_idx = 0..n_args; + + let (ccall_arg_types, julia_arg_types, invoke_fn) = + method_arg_type_fragments(info, untracked_self, gc_safe); + + parse_quote! { + { + frame.scope(|mut frame| { + let unrooted = frame.unrooted(); + let name = Symbol::new(&frame, #rename); + let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&unrooted).as_value(); + + #invoke_fn; + + let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); + + unsafe { + let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); + + let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); + + #( + ccall_arg_types_ref.set(#ccall_arg_idx, Some(#ccall_arg_types.as_value())).unwrap(); + julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); + )* + + let ccall_return_type = #ccall_ret_type; + let julia_return_type = #julia_ret_type; + + let module = #override_module_fragment; + let nothing = ::jlrs::data::managed::value::Value::nothing(&frame); + + let false_v = ::jlrs::data::managed::value::Value::false_v(&frame); + let instance = function_info_ty.instantiate_unchecked(&mut frame, [ + name.as_value(), + ccall_arg_types.as_value(), + julia_arg_types.as_value(), + ccall_return_type, + julia_return_type, + func, + module.as_value(), + false_v + ]); + + let n = #index + offset; + accessor.set(n, Some(instance)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + } +} + +fn async_callback_info_fragment((index, info): (usize, &ExportedAsyncCallback)) -> Result { + let n_args = info.func.inputs.len(); + let name_ident = &info.func.ident; + + let override_module_fragment = override_module_fragment(&info.name_override); + let mut rename = info + .name_override + .as_ref() + .map(|parts| parts.last()) + .flatten() + .unwrap_or(name_ident) + .to_string(); + + if info.exclamation_mark_token.is_some() { + rename.push('!') + } + + let ret_ty = &info.func.output; + let inner_ret_ty = async_callback_return_type_fragments(ret_ty); + if inner_ret_ty.is_none() { + return Ok(parse_quote_spanned! { + name_ident.span() => { + compile_error!("Async callback must return JlrsResult> where T is some type that implements IntoJulia"); + } + }); + } + + let inner_ret_ty = inner_ret_ty.unwrap(); + let ccall_ret_type: Expr = parse_quote! { + <::jlrs::ccall::AsyncCCall as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + let julia_ret_type: Expr = parse_quote! { + <#inner_ret_ty as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + + let (ccall_arg_types, julia_arg_types, invoke_fn) = + async_callback_arg_type_fragments(info, &inner_ret_ty)?; + + let first_arg: Expr = syn::parse_quote! { + <*mut ::std::ffi::c_void as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + }; + + let ccall_arg_idx = 0..n_args; + let julia_arg_idx = 0..n_args; + + let q = parse_quote! { + { + frame.scope(|mut frame| { + let unrooted = frame.unrooted(); + let name = Symbol::new(&frame, #rename); + let type_type = ::jlrs::data::managed::union_all::UnionAll::type_type(&unrooted).as_value(); + + #invoke_fn; + + let func = Value::new(&mut frame, invoke as *mut ::std::ffi::c_void); + + unsafe { + let mut ccall_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args + 1, + type_type); + + let mut ccall_arg_types_ref = ccall_arg_types.value_data_mut().unwrap(); + + let mut julia_arg_types = ::jlrs::data::managed::array::Array::new_for_unchecked( + &mut frame, + #n_args, + type_type); + + let mut julia_arg_types_ref = julia_arg_types.value_data_mut().unwrap(); + + ccall_arg_types_ref.set(0, Some(#first_arg)).unwrap(); + #( + ccall_arg_types_ref.set(#ccall_arg_idx + 1, Some(#ccall_arg_types.as_value())).unwrap(); + julia_arg_types_ref.set(#julia_arg_idx, Some(#julia_arg_types.as_value())).unwrap(); + )* + + let ccall_return_type = #ccall_ret_type; + let julia_return_type = #julia_ret_type; + + let module = #override_module_fragment; + + let true_v = ::jlrs::data::managed::value::Value::true_v(&frame); + let nothing = ::jlrs::data::managed::value::Value::nothing(&frame); + + let instance = function_info_ty.instantiate_unchecked(&mut frame, [ + name.as_value(), + ccall_arg_types.as_value(), + julia_arg_types.as_value(), + ccall_return_type, + julia_return_type, + func, + module.as_value(), + true_v + ]); + + + let n = #index + offset; + accessor.set(n, Some(instance)).unwrap(); + } + + Ok(()) + }).unwrap(); + } + }; + + Ok(q) +} + +fn const_info_fragment(info: &ExportedConst) -> Expr { + let name = &info.name; + let rename = info.name_override.as_ref().unwrap_or(name).to_string(); + let ty = &info.ty; + + parse_quote! { + { + frame.scope(move |mut frame| { + let v: #ty = #name; + let value = ::jlrs::data::managed::value::Value::new(&mut frame, v); + + unsafe { + module.set_const_unchecked(#rename, value); + } + + Ok(()) + + }).unwrap(); + } + } +} + +fn alias_info_fragment(info: &ExportedAlias) -> Expr { + let name = &info.name.to_string(); + let ty = &info.ty; + + parse_quote! { + { + unsafe { + let value = <#ty as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&frame).as_value(); + module.set_const_unchecked(#name, value); + } + } + } +} + +fn global_info_fragment(info: &ExportedGlobal) -> Expr { + let name = &info.name; + let rename = info.name_override.as_ref().unwrap_or(name).to_string(); + let ty = &info.ty; + + parse_quote! { + { + frame.scope(move |mut frame| { + let v: #ty = #name; + let value = ::jlrs::data::managed::value::Value::new(&mut frame, v); + + unsafe { + module.set_global_unchecked(#rename, value); + } + + Ok(()) + + }).unwrap(); + } + } +} + +fn method_arg_type_fragments<'a>( + info: &'a ExportedMethod, + untracked_self: bool, + gc_safe: bool, +) -> ( + impl 'a + Iterator, + impl 'a + Iterator, + ItemFn, +) { + let inputs = &info.func.inputs; + + let takes_self = match inputs.first() { + Some(FnArg::Receiver(r)) => Some((r.mutability.is_some(), r.reference.is_some())), + _ => None, + }; + + let invoke_fn = match takes_self { + None => invoke_fn_no_self_method_fragment(info, gc_safe), + Some((true, true)) => invoke_fn_mut_self_method_fragment(info, untracked_self, gc_safe), + Some((false, true)) => invoke_fn_ref_self_method_fragment(info, untracked_self, gc_safe), + Some((_, false)) => invoke_fn_move_self_method_fragment(info, untracked_self, gc_safe), + }; + + let parent = &info.parent; + let ccall_arg_types = inputs + .iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = &ty.ty; + let span = ty.span(); + parse_quote_spanned! { + span=> <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => { + let span = parent.span(); + parse_quote_spanned! { + span=> < as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + } + }); + + let julia_arg_types = inputs + .iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = &ty.ty; + let span = ty.span(); + parse_quote_spanned! { + span=> <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => { + let span = parent.span(); + parse_quote_spanned! { + span=> <<::jlrs::data::managed::value::typed::TypedValue<#parent> as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + } + }); + + (ccall_arg_types, julia_arg_types, invoke_fn) +} + +fn method_arg_type_fragments_in_env<'a>( + info: &'a ExportedMethod, + resolver: &'a ResolvedParameterList, + untracked_self: bool, + gc_safe: bool, +) -> ( + impl 'a + Iterator, + impl 'a + Iterator, + ItemFn, +) { + let inputs = &info.func.inputs; + + let takes_self = match inputs.first() { + Some(FnArg::Receiver(r)) => Some((r.mutability.is_some(), r.reference.is_some())), + _ => None, + }; + + let invoke_fn = match takes_self { + None => invoke_fn_no_self_method_fragment_in_env(info, resolver, gc_safe), + Some((true, true)) => { + invoke_fn_mut_self_method_fragment_in_env(info, resolver, untracked_self, gc_safe) + } + Some((false, true)) => { + invoke_fn_ref_self_method_fragment_in_env(info, resolver, untracked_self, gc_safe) + } + Some((_, false)) => { + invoke_fn_move_self_method_fragment_in_env(info, resolver, untracked_self, gc_safe) + } + }; + + let parent = resolver.apply(&info.parent); + let parent2 = parent.clone(); + + let ccall_arg_types = inputs + .iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = resolver.apply(ty.ty.as_ref()); + let span = ty.span(); + parse_quote_spanned! { + span=> <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => { + let span = parent.span(); + parse_quote_spanned! { + span=> < as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + } + }); + + let julia_arg_types = inputs + .iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = resolver.apply(ty.ty.as_ref()); + let span = ty.span(); + parse_quote_spanned! { + span=> <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => { + let span = parent2.span(); + parse_quote_spanned! { + span=> <<::jlrs::data::managed::value::typed::TypedValue<#parent2> as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + } + }); + + (ccall_arg_types, julia_arg_types, invoke_fn) +} + +fn async_callback_arg_type_fragments<'a>( + info: &'a ExportedAsyncCallback, + inner_ret_ty: &Type, +) -> Result<( + impl 'a + Iterator, + impl 'a + Iterator, + ItemFn, +)> { + let inputs = &info.func.inputs; + let n_args = inputs.len(); + + if n_args > 0 { + if let FnArg::Receiver(r) = inputs.first().unwrap() { + Err(syn::Error::new_spanned( + r.to_token_stream(), + "async callback must be a free-standing function", + ))?; + } + } + + let invoke_fn = invoke_async_callback(info, inner_ret_ty); + + let ccall_arg_types = inputs + .iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = &ty.ty; + parse_quote! { + <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => unreachable!() + } + }); + + let julia_arg_types = inputs + .iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = &ty.ty; + parse_quote! { + <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => unreachable!() + } + }); + + Ok((ccall_arg_types, julia_arg_types, invoke_fn)) +} + +fn async_callback_arg_type_fragments_in_env<'a>( + info: &'a ExportedAsyncCallback, + resolver: &'a ResolvedParameterList, +) -> Result<( + Type, + impl 'a + Iterator, + impl 'a + Iterator, + ItemFn, +)> { + let inputs = resolver.apply(&info.func.inputs); + let n_args = inputs.len(); + + if n_args > 0 { + if let FnArg::Receiver(r) = inputs.first().unwrap() { + Err(syn::Error::new_spanned( + r.to_token_stream(), + "async callback must be a free-standing function", + ))?; + } + } + + let ret_ty: &ReturnType = &info.func.output; + let inner_ret_ty = async_callback_return_type_fragments(ret_ty); + let Some(inner_ret_ty) = inner_ret_ty else { + Err(syn::Error::new_spanned( + ret_ty.to_token_stream(), + "Async callback must return JlrsResult> where T is some type that implements IntoJulia", + ))?; + unreachable!() + }; + + let inner_ret_ty = resolver.apply(&inner_ret_ty); + let name = &info.func.ident; + let invoke_fn = invoke_async_callback_in_env(name, &inputs, &inner_ret_ty); + + let ccall_arg_types = inputs + .clone() + .into_iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = &ty.ty; + parse_quote! { + <<#ty as ::jlrs::convert::ccall_types::CCallArg>::CCallArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => unreachable!() + } + }); + + let julia_arg_types = inputs + .into_iter() + .map(move |arg| { + match arg { + FnArg::Typed(ty) => { + let ty = &ty.ty; + parse_quote! { + <<#ty as ::jlrs::convert::ccall_types::CCallArg>::FunctionArgType as ::jlrs::data::types::construct_type::ConstructType>::construct_type(&mut frame) + } + }, + _ => unreachable!() + } + }); + + Ok((inner_ret_ty, ccall_arg_types, julia_arg_types, invoke_fn)) +} + +// TODO: invoke fix exc +// FIXME: require impl AsyncCallback +fn invoke_async_callback(info: &ExportedAsyncCallback, ret_ty: &Type) -> ItemFn { + let name = &info.func.ident; + let args = &info.func.inputs; + let span = info.func.ident.span(); + let mut extended_args = args.clone(); + extended_args.insert( + 0, + syn::parse_quote! { jlrs_async_condition_handle: ::jlrs::ccall::AsyncConditionHandle }, + ); + + let names = args.iter().map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#extended_args) -> ::jlrs::ccall::AsyncCCall { + let join_handle: ::std::sync::Arc<::jlrs::ccall::DispatchHandle<#ret_ty>> = match #name(#names) { + Ok(callback) => { + ::jlrs::ccall::CCall::dispatch_to_pool(move |dispatch_handle| { + let handle = jlrs_async_condition_handle; + let res: ::jlrs::error::JlrsResult<#ret_ty> = callback(); + unsafe { dispatch_handle.set(res); } + ::jlrs::ccall::CCall::uv_async_send(handle.0); + }) + }, + Err(e) => { + ::jlrs::ccall::CCall::dispatch_to_pool(move |dispatch_handle| { + let handle = jlrs_async_condition_handle; + let res: ::jlrs::error::JlrsResult<#ret_ty> = Err(e); + unsafe { dispatch_handle.set(res); } + ::jlrs::ccall::CCall::uv_async_send(handle.0); + }) + } + }; + + let join_handle = ::std::sync::Arc::into_raw(join_handle); + + unsafe extern "C" fn join_func( + handle: *mut ::jlrs::ccall::DispatchHandle<#ret_ty> + ) -> #ret_ty { + let handle = ::std::sync::Arc::from_raw(handle); + let res = handle.join(); + <::jlrs::error::JlrsResult<#ret_ty> as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + } + + ::jlrs::ccall::AsyncCCall { + join_handle: join_handle as *mut ::jlrs::ccall::DispatchHandle<#ret_ty> as *mut ::std::ffi::c_void, + join_func: join_func as *mut ::std::ffi::c_void + } + } + } +} + +fn invoke_async_callback_in_env<'a>( + name: &Ident, + inputs: &Punctuated, + ret_ty: &Type, +) -> ItemFn { + let span = name.span(); + let mut extended_args = inputs.clone(); + extended_args.insert( + 0, + syn::parse_quote! { jlrs_async_condition_handle: ::jlrs::ccall::AsyncConditionHandle }, + ); + + let names = inputs.iter().map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#extended_args) -> ::jlrs::ccall::AsyncCCall { + let join_handle: ::std::sync::Arc<::jlrs::ccall::DispatchHandle<#ret_ty>> = match #name(#names) { + Ok(callback) => { + ::jlrs::ccall::CCall::dispatch_to_pool(move |dispatch_handle| { + let handle = jlrs_async_condition_handle; + let res = callback(); + unsafe { dispatch_handle.set(res); } + ::jlrs::ccall::CCall::uv_async_send(handle.0); + }) + }, + Err(e) => { + ::jlrs::ccall::CCall::dispatch_to_pool(move |dispatch_handle| { + let handle = jlrs_async_condition_handle; + let res: ::jlrs::error::JlrsResult<#ret_ty> = Err(e); + unsafe { dispatch_handle.set(res); } + ::jlrs::ccall::CCall::uv_async_send(handle.0); + }) + } + }; + + let join_handle = ::std::sync::Arc::into_raw(join_handle); + + unsafe extern "C" fn join_func( + handle: *mut ::jlrs::ccall::DispatchHandle<#ret_ty> + ) -> #ret_ty { + let handle = ::std::sync::Arc::from_raw(handle); + let res = handle.join(); + <::jlrs::error::JlrsResult<#ret_ty> as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + } + + ::jlrs::ccall::AsyncCCall { + join_handle: join_handle as *mut ::jlrs::ccall::DispatchHandle<#ret_ty> as *mut ::std::ffi::c_void, + join_func: join_func as *mut ::std::ffi::c_void + } + } + } +} + +fn invoke_fn_no_self_method_fragment(info: &ExportedMethod, gc_safe: bool) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = &info.parent; + let ret_ty = &info.func.output; + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let args = &info.func.inputs; + let names = args.iter().map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + <#ty>::#name(#names) + }) + } + } else { + parse_quote! { <#ty>::#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args) #new_ret_ty { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + } + } +} + +fn invoke_fn_no_self_method_fragment_in_env( + info: &ExportedMethod, + resolver: &ResolvedParameterList, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = resolver.apply(&info.parent); + let ret_ty = resolver.apply(&info.func.output); + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty); + + let args = resolver.apply(&info.func.inputs); + let names: Punctuated<_, Comma> = args + .iter() + .map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }) + .collect(); + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + <#ty>::#name(#names) + }) + } + } else { + parse_quote! { <#ty>::#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args) #new_ret_ty { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + } + } +} + +fn invoke_fn_ref_self_method_fragment( + info: &ExportedMethod, + untracked_self: bool, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = &info.parent; + let ret_ty = &info.func.output; + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let args = &info.func.inputs; + let mut cloned_args = args.clone(); + let first = cloned_args.first_mut().unwrap(); + + *first = parse_quote! { + this: ::jlrs::data::managed::value::typed::TypedValue<#ty> + }; + + let args_self_renamed = cloned_args; + + let names = args.iter().skip(1).map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let to_ref_expr: Expr = if untracked_self { + parse_quote! { ::std::result::Result::<_, ()>::Ok((&this).data_ptr().cast::<#ty>().as_ref()) } + } else { + parse_quote! { (&this).track_shared() } + }; + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + this.#name(#names) + }) + } + } else { + parse_quote! { this.#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args_self_renamed) #new_ret_ty { + match #to_ref_expr { + Ok(this) => { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + }, + Err(_) => ::jlrs::ccall::CCall::throw_borrow_exception() + } + } + } +} + +fn invoke_fn_ref_self_method_fragment_in_env( + info: &ExportedMethod, + resolver: &ResolvedParameterList, + untracked_self: bool, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = resolver.apply(&info.parent); + let ret_ty = resolver.apply(&info.func.output); + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let args = &info.func.inputs; + let mut cloned_args = args.clone(); + let first = cloned_args.first_mut().unwrap(); + + *first = parse_quote! { + this: ::jlrs::data::managed::value::typed::TypedValue<#ty> + }; + + let args_self_renamed = resolver.apply(&cloned_args); + + let names = args.iter().skip(1).map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let to_ref_expr: Expr = if untracked_self { + parse_quote! { ::std::result::Result::<_, ()>::Ok((&this).data_ptr().cast::<#ty>().as_ref()) } + } else { + parse_quote! { (&this).track_shared() } + }; + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + this.#name(#names) + }) + } + } else { + parse_quote! { this.#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args_self_renamed) #new_ret_ty { + match #to_ref_expr { + Ok(this) => { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + }, + Err(_) => ::jlrs::ccall::CCall::throw_borrow_exception() + } + } + } +} + +fn invoke_fn_move_self_method_fragment( + info: &ExportedMethod, + untracked_self: bool, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = &info.parent; + let ret_ty = &info.func.output; + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let args = &info.func.inputs; + let mut cloned_args = args.clone(); + let first = cloned_args.first_mut().unwrap(); + + *first = parse_quote! { + this: ::jlrs::data::managed::value::typed::TypedValue<#ty> + }; + + let args_self_renamed = cloned_args; + + let names = args.iter().skip(1).map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let to_ref_expr: Expr = if untracked_self { + parse_quote! { ::std::result::Result::<_, ()>::Ok((&this).data_ptr().cast::<#ty>().as_ref()) } + } else { + parse_quote! { (&this).track_shared() } + }; + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + this.clone().#name(#names) + }) + } + } else { + parse_quote! { this.clone().#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args_self_renamed) #new_ret_ty { + match #to_ref_expr { + Ok(this) => { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + }, + Err(_) => ::jlrs::ccall::CCall::throw_borrow_exception() + } + } + } +} + +fn invoke_fn_move_self_method_fragment_in_env( + info: &ExportedMethod, + resolver: &ResolvedParameterList, + untracked_self: bool, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = resolver.apply(&info.parent); + let ret_ty = resolver.apply(&info.func.output); + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + let args = &info.func.inputs; + let mut cloned_args = args.clone(); + let first = cloned_args.first_mut().unwrap(); + + *first = parse_quote! { + this: ::jlrs::data::managed::value::typed::TypedValue<#ty> + }; + + let args_self_renamed = resolver.apply(&cloned_args); + + let names = args.iter().skip(1).map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let to_ref_expr: Expr = if untracked_self { + parse_quote! { ::std::result::Result::<_, ()>::Ok((&this).data_ptr().cast::<#ty>().as_ref()) } + } else { + parse_quote! { (&this).track_shared() } + }; + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + this.clone().#name(#names) + }) + } + } else { + parse_quote! { this.clone().#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args_self_renamed) #new_ret_ty { + match #to_ref_expr { + Ok(this) => { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + }, + Err(_) => ::jlrs::ccall::CCall::throw_borrow_exception() + } + } + } +} + +fn invoke_fn_mut_self_method_fragment( + info: &ExportedMethod, + untracked_self: bool, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = &info.parent; + let ret_ty = &info.func.output; + let args = &info.func.inputs; + let mut cloned_args = args.clone(); + let first = cloned_args.first_mut().unwrap(); + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + + *first = parse_quote! { + mut this: ::jlrs::data::managed::value::typed::TypedValue<#ty> + }; + + let args_self_renamed = cloned_args; + + let names = args.iter().skip(1).map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let to_ref_expr: Expr = if untracked_self { + parse_quote! { ::std::result::Result::<_, ()>::Ok((&mut this).data_ptr().cast::<#ty>().as_mut()) } + } else { + parse_quote! { (&mut this).track_exclusive() } + }; + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + this.#name(#names) + }) + } + } else { + parse_quote! { this.#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args_self_renamed) #new_ret_ty { + match #to_ref_expr { + #[allow(unused_mut)] + Ok(mut this) => { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + }, + Err(_) => ::jlrs::ccall::CCall::throw_borrow_exception() + } + } + } +} + +fn invoke_fn_mut_self_method_fragment_in_env( + info: &ExportedMethod, + resolver: &ResolvedParameterList, + untracked_self: bool, + gc_safe: bool, +) -> ItemFn { + let name = &info.func.ident; + let span = info.func.ident.span(); + let ty = resolver.apply(&info.parent); + let ret_ty = resolver.apply(&info.func.output); + let new_ret_ty = as_return_as(&ret_ty); + let ret_ty = take_type(ret_ty.clone()); + let args = &info.func.inputs; + let mut cloned_args = args.clone(); + let first = cloned_args.first_mut().unwrap(); + + *first = parse_quote! { + mut this: ::jlrs::data::managed::value::typed::TypedValue<#ty> + }; + + let args_self_renamed = resolver.apply(&cloned_args); + + let names = args.iter().skip(1).map(|arg| match arg { + FnArg::Typed(ty) => &ty.pat, + _ => unreachable!(), + }); + + let names = Punctuated::<_, Comma>::from_iter(names); + + let to_ref_expr: Expr = if untracked_self { + parse_quote! { ::std::result::Result::<_, ()>::Ok((&mut this).data_ptr().cast::<#ty>().as_mut()) } + } else { + parse_quote! { (&mut this).track_exclusive() } + }; + + let call_expr: Expr = if gc_safe { + parse_quote! { + ::jlrs::memory::gc::gc_safe(|| { + this.#name(#names) + }) + } + } else { + parse_quote! { this.#name(#names) } + }; + + parse_quote_spanned! { + span=> unsafe extern "C" fn invoke(#args_self_renamed) #new_ret_ty { + match #to_ref_expr { + #[allow(unused_mut)] + Ok(mut this) => { + let res = #call_expr; + <#ret_ty as ::jlrs::convert::ccall_types::CCallReturn>::return_or_throw(res) + }, + Err(_) => ::jlrs::ccall::CCall::throw_borrow_exception() + } + } + } +} + +fn has_outer_path_attr(attrs: &[Attribute], name: &str) -> bool { + for attr in attrs { + match attr.style { + AttrStyle::Outer => (), + _ => continue, + } + + match attr.meta { + Meta::Path(ref p) => { + if p.is_ident(name) { + return true; + } + } + _ => continue, + } + } + + false +} diff --git a/jlrs_macros/src/module/parameters.rs b/jlrs_macros/src/module/parameters.rs new file mode 100644 index 00000000..9e1e572c --- /dev/null +++ b/jlrs_macros/src/module/parameters.rs @@ -0,0 +1,270 @@ +use syn::{ + parse_quote, punctuated::Punctuated, FnArg, GenericArgument, Ident, PatType, Path, + PathArguments, ReturnType, Type, TypePath, +}; + +use super::GenericEnvironment; + +#[derive(Debug)] +pub(super) struct ParameterEnvironment<'a> { + parameter: &'a Ident, + paths: &'a Vec<&'a Path>, + super_env: Option<&'a ParameterEnvironment<'a>>, +} + +impl<'a> ParameterEnvironment<'a> { + pub(super) fn new( + generic_env: &'a GenericEnvironment<'a>, + super_env: Option<&'a ParameterEnvironment<'a>>, + ) -> Self { + let parameter = generic_env.parameter; + let paths = &generic_env.values; + ParameterEnvironment { + paths, + parameter, + super_env, + } + } + + pub(super) fn n_parameters(&self) -> usize { + if let Some(env) = self.super_env { + return 1 + env.n_parameters(); + } + + 1 + } + + pub(super) fn n_combinations(&self) -> usize { + if let Some(super_env) = self.super_env { + return self.paths.len() * super_env.n_combinations(); + } + + self.paths.len() + } + + pub(super) fn nth_combination(&self, list: &mut ParameterList<'a>, nth: usize) { + list.clear_paths(); + self.nth_combination_inner(list, nth, 1); + } + + fn nth_combination_inner(&self, list: &mut ParameterList<'a>, nth: usize, prod: usize) { + let n_values = self.paths.len(); + let mth = (nth / prod) % n_values; + + let path = self.paths[mth]; + list.push_path(path); + + if let Some(env) = self.super_env { + env.nth_combination_inner(list, nth, prod * n_values) + } + } +} + +#[derive(Debug)] +pub(super) struct ParameterList<'a> { + parameters: Vec<&'a Ident>, + paths: Vec<&'a Path>, +} + +impl<'a> ParameterList<'a> { + pub(super) fn new(env: &'a ParameterEnvironment) -> Self { + let n_params = env.n_parameters(); + let mut list = ParameterList { + parameters: Vec::with_capacity(n_params), + paths: Vec::with_capacity(n_params), + }; + + list.insert_parameters(env); + list + } + + pub(super) fn resolver(&self) -> ResolvedParameterList<'a> { + ResolvedParameterList { + parameters: self.parameters.clone(), + paths: Vec::with_capacity(self.n_parameters()), + } + } + + pub(super) fn clear_paths(&mut self) { + self.paths.clear(); + } + + pub(super) fn push_path(&mut self, path: &'a Path) { + self.paths.push(path) + } + + pub(super) fn resolve(&self, resolver: &mut ResolvedParameterList<'a>) { + resolver.clear(); + let n_params = self.n_parameters(); + + for i in 0..n_params { + let mut path = self.paths[i].clone(); + for j in i + 1..n_params { + apply_parameter(&mut path, self.parameters[j], self.paths[j]); + } + + resolver.push(path); + } + } + + fn insert_parameters(&mut self, env: &'a ParameterEnvironment) { + let parameter = env.parameter; + self.parameters.push(parameter); + + if let Some(env) = env.super_env { + self.insert_parameters(env); + } + } + + fn n_parameters(&self) -> usize { + self.parameters.len() + } +} + +#[derive(Clone, Debug)] +pub(super) struct ResolvedParameterList<'a> { + parameters: Vec<&'a Ident>, + paths: Vec, +} + +pub(super) trait Apply { + fn apply(&self, to: &To) -> To; +} + +impl<'a> Apply for ResolvedParameterList<'a> { + fn apply(&self, to: &Path) -> Path { + self.assert_resolved(); + + for (parameter, parameter_path) in self.parameters.iter().copied().zip(self.paths.iter()) { + if to.is_ident(parameter) { + return parameter_path.clone(); + } + } + + let mut path = to.clone(); + for (parameter, parameter_path) in self.parameters.iter().copied().zip(self.paths.iter()) { + apply_parameter(&mut path, parameter, parameter_path) + } + + path + } +} + +impl<'a> Apply for ResolvedParameterList<'a> { + fn apply(&self, to: &Type) -> Type { + self.assert_resolved(); + + match to { + Type::Path(TypePath { path, .. }) => { + for (parameter, parameter_path) in + self.parameters.iter().copied().zip(self.paths.iter()) + { + if path.is_ident(parameter) { + return Type::Path(TypePath { + path: parameter_path.clone(), + qself: None, + }); + } + } + + Type::Path(TypePath { + path: self.apply(path), + qself: None, + }) + } + _ => todo!(), + } + } +} + +impl<'a> Apply for ResolvedParameterList<'a> { + fn apply(&self, to: &ReturnType) -> ReturnType { + match to { + ReturnType::Default => ReturnType::Default, + ReturnType::Type(arr, ty) => { + ReturnType::Type(arr.clone(), Box::new(self.apply(ty.as_ref()))) + } + } + } +} + +impl<'a> Apply for ResolvedParameterList<'a> { + fn apply(&self, to: &PatType) -> PatType { + PatType { + attrs: to.attrs.clone(), + pat: to.pat.clone(), + colon_token: to.colon_token.clone(), + ty: Box::new(self.apply(to.ty.as_ref())), + } + } +} + +impl<'a> Apply for ResolvedParameterList<'a> { + fn apply(&self, to: &FnArg) -> FnArg { + match to { + FnArg::Receiver(_) => todo!(), + FnArg::Typed(pat) => FnArg::Typed(self.apply(pat)), + } + } +} +impl<'a, T, P> Apply> for ResolvedParameterList<'a> +where + Self: Apply, + P: Default, +{ + fn apply(&self, to: &Punctuated) -> Punctuated { + to.iter().map(|arg| self.apply(arg)).collect() + } +} + +impl<'a> ResolvedParameterList<'a> { + fn clear(&mut self) { + self.paths.clear(); + } + + fn push(&mut self, path: Path) { + self.paths.push(path); + } + + fn assert_resolved(&self) { + if self.parameters.len() != self.paths.len() { + panic!("Parameters are unresolved") + } + } +} + +fn apply_parameter(path: &mut Path, parameter: &Ident, parameter_path: &Path) { + if path.is_ident(parameter) { + *path = parameter_path.clone(); + return; + } + + let segment = path.segments.last_mut().unwrap(); + if let PathArguments::AngleBracketed(bracketed) = &mut segment.arguments { + for arg in bracketed.args.iter_mut() { + if let GenericArgument::Type(Type::Path(ty)) = arg { + apply_parameter(&mut ty.path, parameter, parameter_path) + } + } + } +} + +pub(super) fn as_return_as(ret_ty: &ReturnType) -> ReturnType { + let mut new_ty = ret_ty.clone(); + + if let ReturnType::Type(_, ty) = &mut new_ty { + let new_ty: Type = parse_quote! { + <#ty as ::jlrs::convert::ccall_types::CCallReturn>::ReturnAs + }; + **ty = new_ty; + } + + new_ty +} + +pub(super) fn take_type(ty: ReturnType) -> Type { + match ty { + ReturnType::Default => parse_quote! { () }, + ReturnType::Type(_, ty) => *ty, + } +} diff --git a/jlrs_macros/src/version.rs b/jlrs_macros/src/version.rs index 2193f2dc..b05c10ed 100644 --- a/jlrs_macros/src/version.rs +++ b/jlrs_macros/src/version.rs @@ -4,7 +4,7 @@ use proc_macro::{Delimiter, TokenStream, TokenTree}; const MAJOR_VERSION: usize = 1; const LTS_MINOR_VERSION: usize = 6; -const NIGHTLY_MINOR_VERSION: usize = 10; +const NIGHTLY_MINOR_VERSION: usize = 11; #[cfg(feature = "julia-1-6")] const SELECTED_MINOR_VERSION: usize = 6; @@ -16,6 +16,8 @@ const SELECTED_MINOR_VERSION: usize = 8; const SELECTED_MINOR_VERSION: usize = 9; #[cfg(feature = "julia-1-10")] const SELECTED_MINOR_VERSION: usize = 10; +#[cfg(feature = "julia-1-11")] +const SELECTED_MINOR_VERSION: usize = 11; pub fn emit_if_compatible(attr: TokenStream, item: TokenStream) -> TokenStream { let mut tts = attr.into_iter(); diff --git a/julia_module_test/Cargo.toml b/julia_module_test/Cargo.toml index b0b24b4f..e2ca6564 100644 --- a/julia_module_test/Cargo.toml +++ b/julia_module_test/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "julia_module_test" version = "0.1.0" -edition = "2021" +edition = "2018" [profile.release] panic = "abort" diff --git a/julia_module_test/JuliaModule.jl b/julia_module_test/JuliaModule.jl new file mode 100644 index 00000000..44532bd9 --- /dev/null +++ b/julia_module_test/JuliaModule.jl @@ -0,0 +1,16 @@ +try + using JlrsCore +catch e + import Pkg; Pkg.add("JlrsCore") + using JlrsCore +end + +module JuliaModuleTest +using JlrsCore.Wrap + +@wrapmodule("./libjulia_module_test", :julia_module_tests_init_fn) + +function __init__() + @initjlrs +end +end \ No newline at end of file diff --git a/julia_module_test/JuliaModuleBenches.jl b/julia_module_test/JuliaModuleBenches.jl new file mode 100644 index 00000000..5c7ce13f --- /dev/null +++ b/julia_module_test/JuliaModuleBenches.jl @@ -0,0 +1,161 @@ +include("JuliaModule.jl") + +using BenchmarkTools + +scrubgc() = (GC.enable(true); GC.gc(); GC.gc(); GC.gc(); GC.gc(); GC.enable(false)) +const opaque_int = JuliaModuleTest.OpaqueInt(Int32(-1)); +const arr = Int[1, 2, 3, 4]; + +function runbenches() + println("Benchmark freestanding_func_trivial") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_trivial() gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_noargs") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_noargs() gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_bitsarg") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_bitsarg(UInt(3)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_ref_bitsarg") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_ref_bitsarg(UInt(3)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_ref_mutarg") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_ref_mutarg(Main) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_ref_any") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_ref_any(Main) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_ref_abstract") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_ref_abstract(1) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_arrayarg") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_arrayarg(Vector{UInt32}()) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark assoc_func") + scrubgc() + b = @benchmark JuliaModuleTest.assoc_func() gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_typevaluearg") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_typevaluearg(UInt(3)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_ret_array") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_ret_array(Int32) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark freestanding_func_ret_rust_result") + scrubgc() + b = @benchmark JuliaModuleTest.freestanding_func_ret_rust_result(false) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark POpaqueInt") + scrubgc() + b = @benchmark JuliaModuleTest.OpaqueInt(Int32(-1)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark POpaque64") + scrubgc() + b = @benchmark JuliaModuleTest.POpaque64(Float64(1.0)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark unbox_opaque") + scrubgc() + b = @benchmark JuliaModuleTest.unbox_opaque(opaque_int) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark unbox_opaque_untracked") + scrubgc() + b = @benchmark JuliaModuleTest.unbox_opaque_untracked(opaque_int) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark increment!") + scrubgc() + b = @benchmark JuliaModuleTest.increment!(opaque_int) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark increment_unchecked!") + scrubgc() + b = @benchmark JuliaModuleTest.increment_unchecked!(opaque_int) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark increment_unchecked_nogc!") + scrubgc() + b = @benchmark JuliaModuleTest.increment_unchecked_nogc!(opaque_int) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark has_generic{Float32}") + scrubgc() + b = @benchmark JuliaModuleTest.has_generic(Float32(1.0)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark has_generic{Float64}") + scrubgc() + b = @benchmark JuliaModuleTest.has_generic(Float64(1.0)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark POpaqueTwo") + scrubgc() + b = @benchmark JuliaModuleTest.POpaqueTwo(Float32(1.0), Float32(2.0)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark ForeignThing") + scrubgc() + b = @benchmark JuliaModuleTest.ForeignThing(Int32(-1)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark async_callback") + scrubgc() + b = @benchmark JuliaModuleTest.async_callback(arr) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") + + println("Benchmark generic_async_callback") + scrubgc() + b = @benchmark JuliaModuleTest.generic_async_callback(Float32(1.0)) gctrial = false gcsample = false + show(stdout, MIME"text/plain"(), b) + print("\n\n") +end + +runbenches() diff --git a/julia_module_test/JuliaModuleTest.jl b/julia_module_test/JuliaModuleTest.jl index 41f791d0..905eff73 100644 --- a/julia_module_test/JuliaModuleTest.jl +++ b/julia_module_test/JuliaModuleTest.jl @@ -1,24 +1,8 @@ -module JuliaModuleTestTests -try - using JlrsCore -catch e - import Pkg; Pkg.add("JlrsCore") - using JlrsCore -end +include("JuliaModule.jl") using JlrsCore.Ledger using Test -module JuliaModuleTest -using JlrsCore.Wrap - -@wrapmodule("./libjulia_module_test", :julia_module_tests_init_fn) - -function __init__() - @initjlrs -end -end - @testset "Freestanding functions" begin @test isnothing(JuliaModuleTest.freestanding_func_trivial()) @inferred JuliaModuleTest.freestanding_func_trivial() @@ -120,34 +104,56 @@ end @test !isconst(JuliaModuleTest, :STATIC_U8) end -# using BenchmarkTools -# -# v = Vector{UInt32}() -# v2 = Vector{AbstractChar}() -# ty = Int32 -# -# println("Benchmark freestanding_func_trivial") -# @btime JuliaModuleTest.freestanding_func_trivial() -# println("Benchmark freestanding_func_noargs") -# @btime JuliaModuleTest.freestanding_func_noargs() -# println("Benchmark freestanding_func_bitsarg") -# @btime JuliaModuleTest.freestanding_func_bitsarg(UInt(3)) -# println("Benchmark freestanding_func_ref_bitsarg") -# @btime JuliaModuleTest.freestanding_func_ref_bitsarg(UInt(3)) -# println("Benchmark freestanding_func_ref_mutarg") -# @btime JuliaModuleTest.freestanding_func_ref_mutarg(Main) -# println("Benchmark freestanding_func_ref_any") -# @btime JuliaModuleTest.freestanding_func_ref_any(Main) -# println("Benchmark freestanding_func_ref_abstract") -# @btime JuliaModuleTest.freestanding_func_ref_abstract(1) -# println("Benchmark freestanding_func_arrayarg") -# @btime JuliaModuleTest.freestanding_func_arrayarg(v) -# println("Benchmark freestanding_func_arrayarg") -# @btime JuliaModuleTest.freestanding_func_arrayarg(v2) -# println("Benchmark freestanding_func_typevaluearg") -# @btime JuliaModuleTest.freestanding_func_typevaluearg(UInt(3)) -# println("Benchmark freestanding_func_ret_array") -# @btime JuliaModuleTest.freestanding_func_ret_array(ty) -# println("Benchmark freestanding_func_ret_rust_result") -# @btime JuliaModuleTest.freestanding_func_ret_rust_result(false) +@testset "POpaque" begin + @test JuliaModuleTest.POpaque isa UnionAll + + p32 = JuliaModuleTest.POpaque(Float32(1.0)) + @test JuliaModuleTest.popaque_get(p32) === Float32(1.0) + + p64 = JuliaModuleTest.POpaque(Float64(1.0)) + @test JuliaModuleTest.popaque_get(p64) === Float64(1.0) + + p64 = JuliaModuleTest.POpaque64(Float64(1.0)) + @test JuliaModuleTest.popaque_get(p64) === Float64(1.0) +end + +@testset "has_generic" begin + @test JuliaModuleTest.has_generic(Float32(1.0)) == Float32(1.0) + @test JuliaModuleTest.has_generic(Float64(1.0)) == Float64(1.0) +end + +@testset "generic_callback" begin + @test JuliaModuleTest.generic_async_callback(Float32(1.0)) == Float32(1.0) + @test JuliaModuleTest.generic_async_callback(Float64(1.0)) == Float64(1.0) +end + +@testset "POpaqueTwo" begin + @test JuliaModuleTest.POpaqueTwo isa UnionAll + + f32f32 = JuliaModuleTest.POpaqueTwo(Float32(1.0), Float32(2.0)) + @test typeof(f32f32) === JuliaModuleTest.POpaqueTwo{Float32, Float32} + @test JuliaModuleTest.get_v1(f32f32) === Float32(1.0) + @test JuliaModuleTest.get_v2(f32f32) === Float32(2.0) + + f32i32 = JuliaModuleTest.POpaqueTwo(Float32(1.0), Int32(2)) + @test typeof(f32i32) === JuliaModuleTest.POpaqueTwo{Float32, Int32} + @test JuliaModuleTest.get_v1(f32i32) === Float32(1.0) + @test JuliaModuleTest.get_v2(f32i32) === Int32(2) + + f64f64 = JuliaModuleTest.POpaqueTwo(Float64(1.0), Float64(2.0)) + @test typeof(f64f64) === JuliaModuleTest.POpaqueTwo{Float64, Float64} + @test JuliaModuleTest.get_v1(f64f64) === Float64(1.0) + @test JuliaModuleTest.get_v2(f64f64) === Float64(2.0) + + f64i32 = JuliaModuleTest.POpaqueTwo(Float64(1.0), Int32(2)) + @test typeof(f64i32) === JuliaModuleTest.POpaqueTwo{Float64, Int32} + @test JuliaModuleTest.get_v1(f64i32) === Float64(1.0) + @test JuliaModuleTest.get_v2(f64i32) === Int32(2) +end + +@testset "has_two_generics" begin + @test JuliaModuleTest.has_two_generics(Float32(1.0), Float32(2.0)) === Float32(1.0) + @test JuliaModuleTest.has_two_generics(Float32(1.0), Int32(2)) === Float32(1.0) + @test JuliaModuleTest.has_two_generics(Float64(1.0), Float64(2.0)) === Float64(1.0) + @test JuliaModuleTest.has_two_generics(Float64(1.0), Int32(2)) === Float64(1.0) end diff --git a/julia_module_test/src/lib.rs b/julia_module_test/src/lib.rs index 8606d423..47866670 100644 --- a/julia_module_test/src/lib.rs +++ b/julia_module_test/src/lib.rs @@ -1,37 +1,48 @@ +use std::ops::AddAssign; + use jlrs::{ ccall::AsyncCallback, data::{ managed::{ array::{ArrayRet, TypedArrayUnbound}, ccall_ref::CCallRef, - rust_result::{RustResult, RustResultRet}, - value::typed::{TypedValue, TypedValueRef, TypedValueRet}, + value::{ + typed::{TypedValue, TypedValueRet}, + ValueRet, + }, }, types::{ abstract_types::{AnyType, Number}, - foreign_type::{ForeignType, OpaqueType}, + construct_type::ConstructType, + foreign_type::{ForeignType, OpaqueType, ParametricBase, ParametricVariant}, }, }, error::JlrsError, + impl_type_parameters, impl_variant_parameters, memory::gc::{mark_queue_obj, write_barrier}, prelude::*, }; -unsafe extern "C" fn freestanding_func_trivial() {} +#[inline] +fn freestanding_func_trivial() {} -unsafe extern "C" fn freestanding_func_noargs() -> usize { +#[inline] +fn freestanding_func_noargs() -> usize { 0 } -unsafe extern "C" fn freestanding_func_bitsarg(a: usize) -> usize { +#[inline] +fn freestanding_func_bitsarg(a: usize) -> usize { a + 1 } -unsafe extern "C" fn freestanding_func_ref_bitsarg(usize_ref: CCallRef) -> usize { +#[inline] +fn freestanding_func_ref_bitsarg(usize_ref: CCallRef) -> usize { usize_ref.as_ref().unwrap() + 1 } -unsafe extern "C" fn freestanding_func_arrayarg(a: Array) -> usize { +#[inline] +fn freestanding_func_arrayarg(a: Array) -> usize { let elty = a.element_type(); if let Ok(elty) = elty.cast::() { @@ -41,50 +52,49 @@ unsafe extern "C" fn freestanding_func_arrayarg(a: Array) -> usize { } } -unsafe extern "C" fn freestanding_func_ref_mutarg(module_ref: CCallRef) -> usize { +#[inline] +fn freestanding_func_ref_mutarg(module_ref: CCallRef) -> usize { let _module = module_ref.as_managed().unwrap(); //let target = module.unrooted_target(); //module.set_global_unchecked("MyGlobal", Value::nothing(&target)); 0 } -unsafe extern "C" fn freestanding_func_ref_any(value_ref: CCallRef) -> usize { +#[inline] +fn freestanding_func_ref_any(value_ref: CCallRef) -> usize { let _dt = value_ref.as_value_ref().datatype(); //println!("freestanding_func_ref_any {:?}", value.datatype()); 0 } -unsafe extern "C" fn freestanding_func_ref_abstract(value_ref: CCallRef) -> usize { +#[inline] +fn freestanding_func_ref_abstract(value_ref: CCallRef) -> usize { let _dt = value_ref.as_value().unwrap().datatype(); //println!("freestanding_func_ref_abstract {:?}", value.datatype()); 0 } -unsafe extern "C" fn freestanding_func_typevaluearg(a: TypedValue) -> usize { +#[inline] +unsafe fn freestanding_func_typevaluearg(a: TypedValue) -> usize { a.unbox_unchecked::() } -unsafe extern "C" fn freestanding_func_ret_array(dt: DataType) -> ArrayRet { - CCall::invoke(|mut frame| { - Array::new_for::<_, _>(frame.as_extended_target(), (2, 2), dt.as_value()) +#[inline] +unsafe fn freestanding_func_ret_array(dt: DataType) -> ArrayRet { + CCall::stackless_invoke(|unrooted| { + Array::new_for::<_, _>(unrooted, (2, 2), dt.as_value()) .unwrap() .leak() }) } -unsafe extern "C" fn freestanding_func_ret_rust_result(throw_err: Bool) -> RustResultRet { - CCall::invoke(|mut frame| { - if throw_err.as_bool() { - RustResult::jlrs_error( - frame.as_extended_target(), - jlrs::error::JlrsError::exception("Error"), - ) - } else { - let v = TypedValue::new(&mut frame, 3); - RustResult::ok(frame.as_extended_target(), v) - } - .leak() - }) +#[inline] +fn freestanding_func_ret_rust_result(throw_err: Bool) -> JlrsResult { + if throw_err.as_bool() { + Err(jlrs::error::JlrsError::exception("Error"))? + } else { + Ok(3) + } } #[derive(Clone, Debug)] @@ -95,60 +105,144 @@ struct OpaqueInt { unsafe impl OpaqueType for OpaqueInt {} impl OpaqueInt { + #[inline] fn new(value: i32) -> TypedValueRet { unsafe { - CCall::invoke(|mut frame| TypedValue::new(&mut frame, OpaqueInt { a: value }).leak()) + CCall::stackless_invoke(|unrooted| TypedValue::new(unrooted, OpaqueInt { a: value }).leak()) } } - fn increment(&mut self) -> RustResultRet { + #[inline] + fn increment(&mut self) { self.a += 1; + } - unsafe { - CCall::invoke(|mut frame| { - let nothing = Value::nothing(&frame).as_typed_unchecked::(); - RustResult::ok(frame.as_extended_target(), nothing).leak() - }) - } + #[inline] + fn get(&self) -> i32 { + self.a + } + + #[inline] + fn get_cloned(self) -> i32 { + self.a } +} - fn get(&self) -> RustResultRet { +#[derive(Clone)] +pub struct POpaque { + value: T, +} + +impl POpaque +where + T: 'static + Send + ConstructType + AddAssign + Copy + jlrs::convert::into_julia::IntoJulia, +{ + #[inline] + fn new(value: T) -> TypedValueRet { unsafe { CCall::invoke(|mut frame| { - let data = TypedValue::new(&mut frame, self.a); - RustResult::ok(frame.as_extended_target(), data).leak() + let data = POpaque { value }; + TypedValue::new(&mut frame, data).leak() }) } } - fn get_cloned(self) -> RustResultRet { + #[inline] + fn get(&self) -> T { + self.value + } + + #[inline] + fn get_cloned(self) -> T { + self.value + } + + #[inline] + fn set(&mut self, value: T) { + self.value = value; + } +} + +#[derive(Clone)] +pub struct POpaqueTwo { + value: T, + value2: U, +} + +unsafe impl ParametricBase for POpaque +where + T: 'static + Send + ConstructType, +{ + type Key = POpaque<()>; + impl_type_parameters!('T'); +} + +unsafe impl ParametricVariant for POpaque { + impl_variant_parameters!(T); +} + +pub struct ForeignThing { + a: ValueRef<'static, 'static>, +} +impl POpaqueTwo +where + T: 'static + Send + ConstructType + AddAssign + Copy + jlrs::convert::into_julia::IntoJulia, + U: 'static + Send + ConstructType + AddAssign + Copy + jlrs::convert::into_julia::IntoJulia, +{ + #[inline] + fn new(value: T, value2: U) -> TypedValueRet { unsafe { - CCall::invoke(|mut frame| { - let data = TypedValue::new(&mut frame, self.a); - RustResult::ok(frame.as_extended_target(), data).leak() + CCall::stackless_invoke(|unrooted| { + let data = POpaqueTwo { value, value2 }; + TypedValue::new(unrooted, data).leak() }) } } + + #[inline] + fn get_v1(&self) -> T { + self.value + } + + #[inline] + fn get_v2(&self) -> U { + self.value2 + } } -pub struct ForeignThing { - a: ValueRef<'static, 'static>, +unsafe impl ParametricBase for POpaqueTwo +where + T: 'static + Send + ConstructType, + U: 'static + Send + ConstructType, +{ + type Key = POpaqueTwo<(), ()>; + impl_type_parameters!('T', 'U'); +} + +unsafe impl ParametricVariant for POpaqueTwo +where + T: 'static + Send + ConstructType, + U: 'static + Send + ConstructType, +{ + impl_variant_parameters!(T, U); } unsafe impl Send for ForeignThing {} unsafe impl ForeignType for ForeignThing { + #[inline] fn mark(ptls: jlrs::memory::PTls, data: &Self) -> usize { unsafe { mark_queue_obj(ptls, data.a) as usize } } } impl ForeignThing { + #[inline] fn new(value: Value) -> TypedValueRet { unsafe { - CCall::invoke(|mut frame| { + CCall::stackless_invoke(|unrooted| { TypedValue::new( - &mut frame, + &unrooted, ForeignThing { a: value.assume_owned().leak(), }, @@ -158,23 +252,16 @@ impl ForeignThing { } } - fn get(&self) -> RustResultRet { - unsafe { - let leaked = self.a.assume_owned().leak(); - let typed = TypedValueRef::::from_value_ref(leaked).as_managed(); - CCall::invoke(|mut frame| RustResult::ok(frame.as_extended_target(), typed).leak()) - } + #[inline] + fn get(&self) -> ValueRet { + unsafe { self.a.assume_owned().leak() } } - fn set(&mut self, value: Value) -> RustResultRet { + #[inline] + fn set(&mut self, value: Value) { unsafe { self.a = value.assume_owned().leak(); write_barrier(self, value); - - CCall::invoke(|mut frame| { - let nothing = Value::nothing(&frame).as_typed_unchecked::(); - RustResult::ok(frame.as_extended_target(), nothing).leak() - }) } } } @@ -182,25 +269,49 @@ impl ForeignThing { struct UnexportedType; impl UnexportedType { + #[inline] fn assoc_func() -> isize { 1 } } +#[inline] fn async_callback(arr: TypedArrayUnbound) -> JlrsResult> { let arr = arr.track_shared_unbound()?; Ok(move || Ok(arr.as_slice().iter().sum())) } +#[inline] fn async_callback_init_err() -> JlrsResult> { Err(JlrsError::exception("Err"))?; Ok(move || Ok(0)) } +#[inline] fn async_callback_callback_err() -> JlrsResult> { Ok(move || Err(JlrsError::exception("Err"))?) } +#[inline] +fn generic_async_callback(t: T) -> JlrsResult> +where + T: jlrs::convert::into_julia::IntoJulia + + Send + + jlrs::data::types::construct_type::ConstructType, +{ + Ok(move || Ok(t)) +} + +#[inline] +fn has_generic(t: T) -> T { + t +} + +#[inline] +fn has_two_generics(t: T, _u: U) -> T { + t +} + const CONST_U8: u8 = 1; static STATIC_U8: u8 = 2; @@ -209,6 +320,7 @@ julia_module! { fn freestanding_func_trivial(); fn freestanding_func_noargs() -> usize; + fn freestanding_func_bitsarg(a: usize) -> usize; fn freestanding_func_arrayarg(a: Array) -> usize; fn freestanding_func_ref_bitsarg(usize_ref: CCallRef) -> usize; @@ -217,18 +329,28 @@ julia_module! { fn freestanding_func_ref_abstract(value_ref: CCallRef) -> usize; fn freestanding_func_typevaluearg(a: TypedValue) -> usize; fn freestanding_func_ret_array(dt: DataType) -> ArrayRet; - fn freestanding_func_ret_rust_result(throw_err: Bool) -> RustResultRet; + fn freestanding_func_ret_rust_result(throw_err: Bool) -> JlrsResult; struct OpaqueInt; in OpaqueInt fn new(value: i32) -> TypedValueRet as OpaqueInt; - in OpaqueInt fn increment(&mut self) -> RustResultRet as increment!; - in OpaqueInt fn get(&self) -> RustResultRet as unbox_opaque; - in OpaqueInt fn get_cloned(self) -> RustResultRet; + in OpaqueInt fn increment(&mut self) as increment!; + #[untracked_self] + in OpaqueInt fn increment(&mut self) as increment_unchecked!; + + #[untracked_self] + #[gc_safe] + in OpaqueInt fn increment(&mut self) as increment_unchecked_nogc!; + in OpaqueInt fn get(&self) -> i32 as unbox_opaque; + + #[untracked_self] + in OpaqueInt fn get(&self) -> i32 as unbox_opaque_untracked; + in OpaqueInt fn get_cloned(self) -> i32; struct ForeignThing; in ForeignThing fn new(value: Value) -> TypedValueRet as ForeignThing; - in ForeignThing fn get(&self) -> RustResultRet as extract_inner; - in ForeignThing fn set(&mut self, value: Value) -> RustResultRet as set_inner!; + + in ForeignThing fn get(&self) -> ValueRet as extract_inner; + in ForeignThing fn set(&mut self, value: Value) as set_inner!; in UnexportedType fn assoc_func() -> isize; @@ -239,8 +361,37 @@ julia_module! { async fn async_callback_init_err() -> JlrsResult>; async fn async_callback_callback_err() -> JlrsResult>; + for T in [f64, f32, f64] { + fn has_generic(t: T) -> T; + + struct POpaque; + + in POpaque fn new(value: T) -> TypedValueRet> as POpaque; + in POpaque fn get(&self) -> T as popaque_get; + in POpaque fn get_cloned(self) -> T as popaque_get_cloned; + in POpaque fn set(&mut self, value: T) as popaque_set; + + #[doc = " generic_async_callback{T}(t::T)::T"] + #[doc = ""] + #[doc = "...docs for generic_async_callback"] + async fn generic_async_callback(t: T) -> JlrsResult>; + + for U in [T, i32] { + struct POpaqueTwo; + + in POpaqueTwo fn new(value: T, value2: U) -> TypedValueRet> as POpaqueTwo; + in POpaqueTwo fn get_v1(&self) -> T as get_v1; + in POpaqueTwo fn get_v2(&self) -> U as get_v2; + + fn has_two_generics(t: T, u: U) -> T; + } + }; + const CONST_U8: u8; static CONST_U8: u8 as STATIC_CONST_U8; const STATIC_U8: u8 as CONST_STATIC_U8; static STATIC_U8: u8; + + type POpaque64 = POpaque; + in POpaque fn new(value: f64) -> TypedValueRet> as POpaque64 } diff --git a/julia_module_test/test.sh b/julia_module_test/test.sh index 9b2b1eef..77056919 100755 --- a/julia_module_test/test.sh +++ b/julia_module_test/test.sh @@ -2,6 +2,6 @@ version=julia-$(julia --version | grep -oEe "1.[0-9]+" | sed "s/\./-/g") julia_dir="$(dirname $(dirname $(which julia)))" -JULIA_DIR=$julia_dir cargo build --features $version --release -cp ./target/release/libjulia_module_test.so . +JULIA_DIR=$julia_dir cargo build --features $version --release || exit 1 +cp ./target/release/libjulia_module_test.so . || exit 1 julia JuliaModuleTest.jl