Skip to content

Commit

Permalink
V1.0.1 (#42)
Browse files Browse the repository at this point in the history
* Working on fmt strings

* Added some tests and a bytecode dump

* Starting work on Date conversion in bindings

* Removed some warnings by building the thing correctly

* Started some js tests

* Have good binding tests

* Get top makefile to run wasm tests

* working on token loc

* Add ast dump util

* Converting tokenizer to have loc info

* Have some changes in source location

* Have some good location things

* Working on explain app

* Have source locations working well i think

* Update python bindings

* Working on some wasm bindings

* About to revert

* Revert "About to revert"

This reverts commit 9afd214.

* Revert "Working on some wasm bindings"

This reverts commit 35bd97a.

* Improved wasm binding types

* Fix workflow

* Working on getting example back up and running

* Removed some callbacks from the compiler code

* Removed a Large number of callbacks from compiler

* Update version and wasm description

* Removed pass by ref and Cow for type prop

* Changed the signature of CelFunc to not pass refs

---------

Co-authored-by: matt <[email protected]>
  • Loading branch information
1BADragon and CedarMatt authored Jul 21, 2024
1 parent 5802df2 commit a70b4a3
Show file tree
Hide file tree
Showing 53 changed files with 6,622 additions and 1,713 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:

- uses: Swatinem/rust-cache@v2

- name: Install wasm-pack
run: cargo install wasm-pack

- name: Run tests
run: make run-all-tests

Expand Down
10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ members = [
default-members = ["rscel"]
resolver="2"

[workspace.package]
version = "1.0.1"
edition = "2021"
description = "Cel interpreter in rust"
license = "MIT"

[profile.release-with-debug]
inherits = "release"
debug = true
lto = false

[profile.release]
lto = true

[workspace.dependencies]
chrono = { version = "0.4.38", features = ["serde"] }
Expand Down
11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ build:

wasm-binding:
$(MAKE_COMMAND) -C wasm wasm-binding

wasm-binding-release:
$(MAKE_COMMAND) -C wasm wasm-binding-release

python-binding: .env
. .env/bin/activate && cd python && maturin build $(CARGO_ARGS)

python-binding-release: .env
. .env/bin/activate && cd python && maturin build --release $(CARGO_ARGS)

Expand Down Expand Up @@ -50,6 +50,9 @@ run-all-python-tests: .env python-binding
pip install --force-reinstall target/wheels/$(shell ls target/wheels) && \
cd test && \
python -m pytest test*.py $(PYTEST_ARGS)


run-wasm-tests:
$(MAKE_COMMAND) -C wasm wasm-tests

.PHONY: run-all-tests
run-all-tests: run-tests run-no-feature-tests run-python-tests
run-all-tests: run-tests run-no-feature-tests run-python-tests run-wasm-tests
16 changes: 0 additions & 16 deletions build.rs

This file was deleted.

9 changes: 6 additions & 3 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "rscel_python"
version = "1.0.0"
edition = "2021"
version = { workspace = true }
edition = { workspace = true }
description = "Python bindings for the rscel package"
license = "MIT"
license = { workspace = true }

[lib]
name = "rscel"
Expand All @@ -15,3 +15,6 @@ pyo3 = { version = "0.21.2", features = ["extension-module", "chrono"] }
chrono = { workspace = true }
serde_json = { workspace = true }
bincode = "1.3.3"

[build-dependencies]
pyo3-build-config = "0.21.2"
3 changes: 3 additions & 0 deletions python/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
pyo3_build_config::add_extension_module_link_args();
}
18 changes: 9 additions & 9 deletions python/src/celpycallable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ impl CelPyCallable {
}
}

impl FnOnce<(CelValue, &[CelValue])> for CelPyCallable {
impl FnOnce<(CelValue, Vec<CelValue>)> for CelPyCallable {
type Output = CelValue;

extern "rust-call" fn call_once(self, args: (CelValue, &[CelValue])) -> Self::Output {
extern "rust-call" fn call_once(self, args: (CelValue, Vec<CelValue>)) -> Self::Output {
Python::with_gil(|py| {
match self.func.call_bound(
py,
Expand All @@ -28,7 +28,7 @@ impl FnOnce<(CelValue, &[CelValue])> for CelPyCallable {
.chain(
args.1
.into_iter()
.map(|x| PyCelValueRef::new(x).to_object(py)),
.map(|x| PyCelValueRef::new(&x).to_object(py)),
)
.collect::<Vec<PyObject>>(),
),
Expand All @@ -41,8 +41,8 @@ impl FnOnce<(CelValue, &[CelValue])> for CelPyCallable {
}
}

impl FnMut<(CelValue, &[CelValue])> for CelPyCallable {
extern "rust-call" fn call_mut(&mut self, args: (CelValue, &[CelValue])) -> Self::Output {
impl FnMut<(CelValue, Vec<CelValue>)> for CelPyCallable {
extern "rust-call" fn call_mut(&mut self, args: (CelValue, Vec<CelValue>)) -> Self::Output {
Python::with_gil(|py| {
match self.func.call_bound(
py,
Expand All @@ -55,7 +55,7 @@ impl FnMut<(CelValue, &[CelValue])> for CelPyCallable {
.chain(
args.1
.into_iter()
.map(|x| PyCelValueRef::new(x).to_object(py)),
.map(|x| PyCelValueRef::new(&x).to_object(py)),
)
.collect::<Vec<PyObject>>(),
),
Expand All @@ -68,8 +68,8 @@ impl FnMut<(CelValue, &[CelValue])> for CelPyCallable {
}
}

impl Fn<(CelValue, &[CelValue])> for CelPyCallable {
extern "rust-call" fn call(&self, args: (CelValue, &[CelValue])) -> Self::Output {
impl Fn<(CelValue, Vec<CelValue>)> for CelPyCallable {
extern "rust-call" fn call(&self, args: (CelValue, Vec<CelValue>)) -> Self::Output {
Python::with_gil(|py| {
match self.func.call_bound(
py,
Expand All @@ -82,7 +82,7 @@ impl Fn<(CelValue, &[CelValue])> for CelPyCallable {
.chain(
args.1
.into_iter()
.map(|x| PyCelValueRef::new(x).to_object(py)),
.map(|x| PyCelValueRef::new(&x).to_object(py)),
)
.collect::<Vec<PyObject>>(),
),
Expand Down
15 changes: 15 additions & 0 deletions python/src/py_cel_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ impl PyCelProgram {
Err(PyValueError::new_err("Program source not set"))
}
}

fn details_json(slf: PyRefMut<'_, PyCelProgram>, pretty: bool) -> PyResult<String> {
if let Some(program) = &slf.program {
match if pretty {
serde_json::to_string_pretty(program.details().ast().unwrap())
} else {
serde_json::to_string(program.details().ast().unwrap())
} {
Ok(s) => Ok(s),
Err(e) => Err(PyValueError::new_err(format!("{e}"))),
}
} else {
Err(PyValueError::new_err("Program source not set"))
}
}
}

impl PyCelProgram {
Expand Down
12 changes: 6 additions & 6 deletions rscel/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "rscel"
version = "1.0.0"
edition = "2021"
description = "Cel interpreter in rust"
license = "MIT"
version = {workspace = true}
edition = {workspace = true}
description = {workspace = true}
license = {workspace = true}


[features]
Expand All @@ -14,8 +14,8 @@ type_prop = []
protobuf = ["dep:protobuf"]

[build-dependencies]
protobuf-codegen = "3.4.0"
protoc-bin-vendored = "3.0.0"
protobuf-codegen = { version = "3.4.0" }
protoc-bin-vendored = { version = "3.0.0" }

[dependencies]
test-case = "3.3.1"
Expand Down
1 change: 1 addition & 0 deletions rscel/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::env;

fn main() {
println!("cargo::rustc-check-cfg=cfg(test_protos)");
println!("cargo:rerun-if-env-changed=RSCEL_TEST_PROTO");

if let Ok(_) = env::var("RSCEL_TEST_PROTO") {
Expand Down
Loading

0 comments on commit a70b4a3

Please sign in to comment.