Skip to content

Commit 667965d

Browse files
committed
Add some more UI stuff
1 parent 2fd045c commit 667965d

File tree

27 files changed

+2327
-875
lines changed

27 files changed

+2327
-875
lines changed

Justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ install target="": (build target)
2525

2626
build-ui target="":
2727
@echo "Building UI for target: {{target}}"
28-
cd playground && {{env_vars}} pnpm tauri build
28+
cd playground && {{env_vars}} pnpm tauri build --bundles app
2929

3030
run-ui:
3131
@echo "Running UI"
32-
cd playground && {{env_vars}} pnpm tauri dev
32+
cd playground && pnpm i && {{env_vars}} pnpm tauri dev
3333

3434
# Print inventory of registered modules and structs
3535
print-inventory:

bindings/deno/mod.ts

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,41 @@ const RustSliceT = { "struct": ["pointer", "usize"] } as const;
1212

1313
function loadDylib() {
1414
let libSuffix = "";
15-
15+
1616
switch (Deno.build.os) {
17-
case "windows":
18-
libSuffix = "dll";
19-
break;
20-
case "darwin":
21-
libSuffix = "dylib";
22-
break;
23-
default:
24-
libSuffix = "so";
25-
break;
17+
case "windows":
18+
libSuffix = "dll";
19+
break;
20+
case "darwin":
21+
libSuffix = "dylib";
22+
break;
23+
default:
24+
libSuffix = "so";
25+
break;
2626
}
2727

2828
const libName = `libdivvun_runtime.${libSuffix}`;
2929
const fullLibPath = libPath ? path.join(libPath, libName) : libName;
3030

3131
dylib = Deno.dlopen(fullLibPath, {
32-
DRT_Bundle_fromBundle: { parameters: [RustSliceT, "function"], result: "pointer" },
32+
DRT_Bundle_fromBundle: {
33+
parameters: [RustSliceT, "function"],
34+
result: "pointer",
35+
},
3336
DRT_Bundle_drop: { parameters: ["pointer"], result: "void" },
34-
DRT_Bundle_fromPath: { parameters: [RustSliceT, "function"], result: "pointer" },
35-
DRT_Bundle_create: { parameters: ["pointer", RustSliceT, "function"], result: "pointer" },
37+
DRT_Bundle_fromPath: {
38+
parameters: [RustSliceT, "function"],
39+
result: "pointer",
40+
},
41+
DRT_Bundle_create: {
42+
parameters: ["pointer", RustSliceT, "function"],
43+
result: "pointer",
44+
},
3645
DRT_PipelineHandle_drop: { parameters: ["pointer"], result: "void" },
37-
DRT_PipelineHandle_forward: { parameters: ["pointer", RustSliceT, "function"], result: RustSliceT },
46+
DRT_PipelineHandle_forward: {
47+
parameters: ["pointer", RustSliceT, "function"],
48+
result: RustSliceT,
49+
},
3850
DRT_Vec_drop: { parameters: [RustSliceT], result: "void" },
3951
});
4052
}
@@ -44,23 +56,25 @@ const encoder = new TextEncoder();
4456
const errCallback = new Deno.UnsafeCallback(
4557
{ parameters: ["pointer", "usize"], result: "void" } as const,
4658
(ptr, len) => {
47-
if (ptr == null) {
48-
throw new Error("Unknown error");
49-
}
50-
51-
const message = new TextDecoder().decode(new Uint8Array(Deno.UnsafePointerView.getArrayBuffer(ptr, Number(len))));
52-
throw new Error(message);
59+
if (ptr == null) {
60+
throw new Error("Unknown error");
61+
}
62+
63+
const message = new TextDecoder().decode(
64+
new Uint8Array(Deno.UnsafePointerView.getArrayBuffer(ptr, Number(len))),
65+
);
66+
throw new Error(message);
5367
},
5468
);
5569

5670
function makeRustString(str: string): ArrayBuffer {
5771
const encoded = encoder.encode(str);
5872
const ptr = Deno.UnsafePointer.of<Uint8Array>(encoded);
59-
73+
6074
return new BigUint64Array([
6175
Deno.UnsafePointer.value(ptr),
6276
BigInt(encoded.length),
63-
]).buffer
77+
]).buffer;
6478
}
6579

6680
export class Bundle {
@@ -79,7 +93,7 @@ export class Bundle {
7993
errCallback.pointer,
8094
) as Deno.PointerValue<Bundle>;
8195

82-
return new Bundle(bundleRawPtr)
96+
return new Bundle(bundleRawPtr);
8397
} catch (e) {
8498
throw e;
8599
}
@@ -98,7 +112,7 @@ export class Bundle {
98112
errCallback.pointer,
99113
) as Deno.PointerValue<Bundle>;
100114

101-
return new Bundle(bundleRawPtr)
115+
return new Bundle(bundleRawPtr);
102116
} catch (e) {
103117
throw e;
104118
}
@@ -124,13 +138,14 @@ export class Bundle {
124138
const rsConfig = makeRustString(configStr);
125139

126140
try {
127-
const pipeRawPtr: Deno.PointerValue<PipelineHandle> = dylib.symbols.DRT_Bundle_create(
128-
this.#ptr,
129-
rsConfig,
130-
errCallback.pointer,
131-
) as Deno.PointerValue<PipelineHandle>;
132-
133-
return new PipelineHandle(pipeRawPtr)
141+
const pipeRawPtr: Deno.PointerValue<PipelineHandle> = dylib.symbols
142+
.DRT_Bundle_create(
143+
this.#ptr,
144+
rsConfig,
145+
errCallback.pointer,
146+
) as Deno.PointerValue<PipelineHandle>;
147+
148+
return new PipelineHandle(pipeRawPtr);
134149
} catch (e) {
135150
throw e;
136151
}
@@ -153,7 +168,7 @@ class PipelineResponse {
153168

154169
const ptrBuf = Deno.UnsafePointerView.getArrayBuffer(ptr, 8);
155170
const lenBuf = Deno.UnsafePointerView.getArrayBuffer(ptr, 8, 8);
156-
171+
157172
this.#ptr = Deno.UnsafePointer.create(new BigUint64Array(ptrBuf)[0]);
158173
this.#len = Number(new BigUint64Array(lenBuf)[0]);
159174
}
@@ -234,4 +249,4 @@ export class PipelineHandle {
234249
throw e;
235250
}
236251
}
237-
}
252+
}

bindings/example/test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Bundle, setLibPath } from "../deno/mod.ts";
22

3-
console.log("Hello")
3+
console.log("Hello");
44

55
setLibPath("./target/release");
66

77
function main() {
8-
using bundle = Bundle.fromBundle("/Users/brendan/git/necessary/divvun/pipeline-examples/grammar-sme/bundle.drb");
9-
using pipe = bundle.create();
10-
console.log("Pipin'")
11-
const out = pipe.forward("hi").json();
12-
console.log(out)
8+
using bundle = Bundle.fromBundle(
9+
"/Users/brendan/git/necessary/divvun/pipeline-examples/grammar-sme/bundle.drb",
10+
);
11+
using pipe = bundle.create();
12+
console.log("Pipin'");
13+
const out = pipe.forward("hi").json();
14+
console.log(out);
1315
}
1416

15-
main()
17+
main();

bindings/java/pom.xml

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,52 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<modelVersion>4.0.0</modelVersion>
2+
<project
3+
xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
6+
>
7+
<modelVersion>4.0.0</modelVersion>
68

7-
<groupId>com.divvun</groupId>
8-
<artifactId>divvun-runtime</artifactId>
9-
<version>1.0-SNAPSHOT</version>
9+
<groupId>com.divvun</groupId>
10+
<artifactId>divvun-runtime</artifactId>
11+
<version>1.0-SNAPSHOT</version>
1012

11-
<properties>
12-
<maven.compiler.source>11</maven.compiler.source>
13-
<maven.compiler.target>11</maven.compiler.target>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15-
<jna.version>5.13.0</jna.version>
16-
<jackson.version>2.15.2</jackson.version>
17-
</properties>
13+
<properties>
14+
<maven.compiler.source>11</maven.compiler.source>
15+
<maven.compiler.target>11</maven.compiler.target>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<jna.version>5.13.0</jna.version>
18+
<jackson.version>2.15.2</jackson.version>
19+
</properties>
1820

19-
<dependencies>
20-
<dependency>
21-
<groupId>net.java.dev.jna</groupId>
22-
<artifactId>jna</artifactId>
23-
<version>${jna.version}</version>
24-
</dependency>
25-
<dependency>
26-
<groupId>net.java.dev.jna</groupId>
27-
<artifactId>jna-platform</artifactId>
28-
<version>${jna.version}</version>
29-
</dependency>
30-
<dependency>
31-
<groupId>com.fasterxml.jackson.core</groupId>
32-
<artifactId>jackson-databind</artifactId>
33-
<version>${jackson.version}</version>
34-
</dependency>
35-
</dependencies>
21+
<dependencies>
22+
<dependency>
23+
<groupId>net.java.dev.jna</groupId>
24+
<artifactId>jna</artifactId>
25+
<version>${jna.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>net.java.dev.jna</groupId>
29+
<artifactId>jna-platform</artifactId>
30+
<version>${jna.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>com.fasterxml.jackson.core</groupId>
34+
<artifactId>jackson-databind</artifactId>
35+
<version>${jackson.version}</version>
36+
</dependency>
37+
</dependencies>
3638

37-
<build>
38-
<plugins>
39-
<plugin>
40-
<groupId>org.apache.maven.plugins</groupId>
41-
<artifactId>maven-compiler-plugin</artifactId>
42-
<version>3.11.0</version>
43-
<configuration>
44-
<source>11</source>
45-
<target>11</target>
46-
</configuration>
47-
</plugin>
48-
</plugins>
49-
</build>
50-
</project>
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-compiler-plugin</artifactId>
44+
<version>3.11.0</version>
45+
<configuration>
46+
<source>11</source>
47+
<target>11</target>
48+
</configuration>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
</project>

0 commit comments

Comments
 (0)