AzurIce / AzurIce/ranim

Separate Front-end and Back-end

Open
#65 4 comments 2 reactions 0 assignees View on GitHub
Not Planned For Now
Dominant language
Rust
Stars
647
Forks
37
Avg merge
6h 12m
Merged PRs (30d)
17

Description

# Separate Front-end and Back-end.
Use Egglog and a suit of Predefined Ranim Egglog Type to separate Front-end and Back-end to support interactive mode.

The procedure is like:

1. Guest send Ranim DSL to Host
2. Host interpret the DSL to Rabject
3. when Rabject on Host is triggered (clicked dragged...) call Guest defined Function
4. Guest send incremental Ranim DSL to Host to update the rendered Rabject

And the situation can be more complex when touching persistence (undo some operation).
Luckily we can deal with it easily with egglog (similar to persistent database which minimize the memory occupation).

I wrote a proc-macro lib by which you can easily define a suit of Predefined Ranim Egglog Type by #[egglog_ty] attribute.

```rust
#[allow(unused)]
#[egglog_ty]
enum Fn {
Builtin {
function: BuiltinF,
},
WasmGuestExtern {
name: String,
},
}
```
Ref:
[https://github.com/MilkBlock/egglog_wrap_test/blob/master/crates/egglog_wrapper/src/lib.rs](url)

And you can simply call such generated function to generate egglog statemnt in String.

```rust
let p = Point::::new_fixed_point(&Offset::new_d_vec2(1.0, 0.));
```
while the Rx type specifiy a Receiver (Host). It will automatically call user defined `receive` function.

All code that user need write is here.

```rust
fn main() {
let p1 = Point::::new_fixed_point(&Offset::new_d_vec2(1.0, 0.));
let p2 = Point::new_fixed_point(&Offset::new_d_vec2(1.0, 2.));
let ps = Points::new(vec![&p1,&p2]);
Rx::singleton().to_dot(PathBuf::from("egraph"));
}
```
which also enable users to inspect the graph they generated.
[https://github.com/MilkBlock/egglog_wrap_test/blob/master/src/main.rs](url)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.