Python: Add more type stubs to the internal Rust API

This commit is contained in:
Simon Hausmann 2025-02-12 11:32:26 +01:00 committed by Simon Hausmann
parent 7c75720c9a
commit c111098e49
4 changed files with 29 additions and 1 deletions

View file

@ -3,9 +3,11 @@
use pyo3::prelude::*;
use pyo3::types::PyDict;
use pyo3_stub_gen::{derive::gen_stub_pyclass, derive::gen_stub_pymethods};
use std::collections::HashMap;
#[gen_stub_pyclass]
pub struct PyValue(pub slint_interpreter::Value);
struct PyValueRef<'a>(&'a slint_interpreter::Value);
@ -120,12 +122,14 @@ impl From<slint_interpreter::Value> for PyValue {
}
}
#[gen_stub_pyclass]
#[pyclass(subclass, unsendable)]
#[derive(Clone, Default)]
pub struct PyStruct {
data: slint_interpreter::Struct,
}
#[gen_stub_pymethods]
#[pymethods]
impl PyStruct {
#[new]
@ -171,11 +175,13 @@ impl From<slint_interpreter::Struct> for PyStruct {
}
}
#[gen_stub_pyclass]
#[pyclass(unsendable)]
struct PyStructFieldIterator {
inner: std::collections::hash_map::IntoIter<String, slint_interpreter::Value>,
}
#[gen_stub_pymethods]
#[pymethods]
impl PyStructFieldIterator {
fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> {