mirror of
https://github.com/janet-lang/janet
synced 2026-09-19 15:50:41 +00:00
Allow passing user signals to (signal) as keywords.
This commit is contained in:
+12
-1
@@ -124,7 +124,8 @@ void void_fn(void) {
|
||||
printf("void fn ran\n");
|
||||
}
|
||||
|
||||
EXPORTER void_fn_2(double y) {
|
||||
EXPORTER
|
||||
void void_fn_2(double y) {
|
||||
printf("y = %f\n", y);
|
||||
}
|
||||
|
||||
@@ -132,3 +133,13 @@ EXPORTER
|
||||
void void_ret_fn(int x) {
|
||||
printf("void fn ran: %d\n", x);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int a, b;
|
||||
float c, d;
|
||||
} Split;
|
||||
|
||||
EXPORTER
|
||||
float split_fn(Split s) {
|
||||
return s.a * s.c + s.b * s.d;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
j :double])
|
||||
(ffi/defbind void-fn-2 :void [y :double])
|
||||
|
||||
(def split (ffi/struct :int :int :float :float))
|
||||
(ffi/defbind split-fn :float [s split])
|
||||
#
|
||||
# Struct reading and writing
|
||||
#
|
||||
@@ -85,6 +87,7 @@
|
||||
# Call functions
|
||||
#
|
||||
|
||||
(tracev (split-fn [5 6 1.2 3.4]))
|
||||
(tracev (void-fn-2 10.3))
|
||||
(tracev (double-many 1 2 3 4 5 6))
|
||||
(tracev (string/format "%.17g" (double-many 1 2 3 4 5 6)))
|
||||
|
||||
Reference in New Issue
Block a user