Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 10 additions & 37 deletions src/fable-library-py/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/fable-library-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name = "_core"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.27.2", features = ["extension-module", "chrono"] }
pyo3 = { version = "0.28.2", features = ["extension-module", "chrono"] }
byteorder = "1.5.0"
chrono = "0.4.42"
regex = "1.12.1"
Expand Down
16 changes: 12 additions & 4 deletions src/fable-library-py/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use pyo3::{
};
use std::sync::{Arc, Mutex};

#[pyclass(module = "fable", subclass)]
#[pyclass(module = "fable", subclass, from_py_object)]
#[derive(Clone, Debug)]

pub struct FSharpArray {
Expand Down Expand Up @@ -480,7 +480,11 @@ impl FSharpArray {
pub fn __iter__(slf: PyRef<'_, Self>, py: Python<'_>) -> PyResult<Py<PyAny>> {
let len = slf.storage.len();
// SAFETY: slf.as_ptr() is valid and from_borrowed_ptr increments refcount
let array: Py<FSharpArray> = unsafe { Py::from_borrowed_ptr(py, slf.as_ptr()) };
let array: Py<FSharpArray> = unsafe {
Bound::from_borrowed_ptr(py, slf.as_ptr())
.cast_into_unchecked::<FSharpArray>()
}
.unbind();
let iter = FSharpArrayIter {
array,
index: 0,
Expand All @@ -496,7 +500,11 @@ impl FSharpArray {
pub fn GetEnumerator(slf: PyRef<'_, Self>, py: Python<'_>, _unit: Option<&Bound<'_, PyAny>>) -> PyResult<Py<PyAny>> {
let len = slf.storage.len();
// SAFETY: slf.as_ptr() is valid and from_borrowed_ptr increments refcount
let array: Py<FSharpArray> = unsafe { Py::from_borrowed_ptr(py, slf.as_ptr()) };
let array: Py<FSharpArray> = unsafe {
Bound::from_borrowed_ptr(py, slf.as_ptr())
.cast_into_unchecked::<FSharpArray>()
}
.unbind();
let enumerator = FSharpArrayEnumerator {
array,
index: -1, // Before first element
Expand Down Expand Up @@ -4377,7 +4385,7 @@ pub fn of_seq(
}

// Constructor class for array allocation
#[pyclass(module = "fable")]
#[pyclass(module = "fable", from_py_object)]
#[derive(Clone)]
struct FSharpCons {
#[pyo3(get, set)]
Expand Down
2 changes: 1 addition & 1 deletion src/fable-library-py/src/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::ops::Deref;
// Macro to generate float wrapper types (Float32, Float64)
macro_rules! float_variant {
($name:ident, $type:ty) => {
#[pyclass(module = "fable", frozen)]
#[pyclass(module = "fable", frozen, from_py_object)]
#[derive(Clone, Copy)] // Floats are typically Copy
pub struct $name(pub $type);

Expand Down
2 changes: 1 addition & 1 deletion src/fable-library-py/src/ints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ macro_rules! integer_variant {
/// - Full Python special method support
/// - Type-safe operations with automatic conversions
/// - Direct access to the underlying value via Deref
#[pyclass(module = "fable", frozen)]
#[pyclass(module = "fable", frozen, from_py_object)]
#[derive(Clone)]
pub struct $name(pub $type); // Make the inner field public

Expand Down
6 changes: 3 additions & 3 deletions src/fable-library-py/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod printf {
/// def fail(msg): raise Exception(msg)
/// printf("Error: %s").cont(fail)("something went wrong") # raises Exception
/// ```
#[pyclass(module = "fable")]
#[pyclass(module = "fable", from_py_object)]
pub struct IPrintfFormat {
/// The original format string with placeholders
input: String,
Expand Down Expand Up @@ -633,7 +633,7 @@ mod printf {
}

/// Console printer wrapper that maintains F# currying semantics
#[pyclass]
#[pyclass(from_py_object)]
#[derive(Clone)]
pub struct ConsolePrinter {
format: IPrintfFormat,
Expand Down Expand Up @@ -1676,7 +1676,7 @@ mod formatting {
}

/// String comparison enumeration
#[pyclass(module = "fable")]
#[pyclass(module = "fable", from_py_object)]
#[derive(Clone, Copy)]
pub struct StringComparison {
pub value: i32,
Expand Down
Loading