Skip to content

Commit b33fb40

Browse files
committed
add koto bindings
1 parent e34fca2 commit b33fb40

25 files changed

+1798
-21
lines changed

Diff for: Cargo.lock

+93
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[workspace]
22
members = [
3+
"bindlang",
4+
"lang_bindings",
35
"gen",
46
"core",
57
"synth",

Diff for: bindlang/Cargo.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "bindlang"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
proc-macro = true
8+
9+
[dependencies]
10+
syn = { version = "1.0", features = ["extra-traits", "full", "fold", "parsing", "proc-macro"] }
11+
quote = "1.0"
12+
koto = { git = "https://github.com/llogiq/koto", branch = "vtable" }
13+
koto_runtime = { git = "https://github.com/llogiq/koto", branch = "vtable" }
14+
lang_bindings = { path = "../lang_bindings" }
15+
lazy_static = "1.4.0"

Diff for: bindlang/examples/ex.rs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
use bindlang::{bindlang, bindlang_main};
2+
use std::fmt::{Display, Formatter, Result as FmtResult};
3+
4+
#[bindlang]
5+
pub fn bound(_b: bool, _i: i64, _f: f32, _u: u8) {
6+
// nothing to see here
7+
}
8+
9+
#[bindlang]
10+
pub fn anotherone() {
11+
// still nothing
12+
}
13+
14+
#[bindlang]
15+
#[derive(Clone, Debug, Default)]
16+
pub struct MyType;
17+
18+
//#[bindlang]
19+
impl Display for MyType {
20+
fn fmt(&self, f: &mut Formatter) -> FmtResult {
21+
write!(f, "{:?}", self)
22+
}
23+
}
24+
25+
#[bindlang]
26+
impl MyType {
27+
pub fn new() -> Self { MyType }
28+
29+
pub fn answer(&self) -> usize {
30+
42
31+
}
32+
}
33+
34+
bindlang_main!();
35+
36+
fn main() -> Result<(), Box<dyn std::error::Error>> {
37+
let mut koto = koto::Koto::default();
38+
bindlang_init(&mut koto.prelude());
39+
koto.compile("import MyType\nMyType.new().answer()")?;
40+
println!("{}", koto.run()?);
41+
Ok(())
42+
}

0 commit comments

Comments
 (0)