about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins2025-06-27 12:27:16 +0200
committerPjotr Prins2025-06-27 12:27:16 +0200
commit10d264572460c9e4bac22ae73674e478d46f2308 (patch)
treea533b9759f5b7fd0d80046c0ca55e1b0eaa1d700
parentf380f7aaf66d0fc39b9d47b93bd9ba3f69eef26e (diff)
downloadpangemma-master.tar.gz
First working Guile binding HEAD master
-rw-r--r--premake5.lua5
-rw-r--r--src/gemma_api.cpp18
2 files changed, 20 insertions, 3 deletions
diff --git a/premake5.lua b/premake5.lua
index 4502e74..c5cf597 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -13,6 +13,11 @@
 -- Run
 --
 --   LD_LIBRARY_PATH=$GUIX_ENVIRONMENT/lib ./build/bin/Debug/PanGemma
+--
+-- Next we start using the API from guile with
+--
+--   env LD_LIBRARY_PATH=./build/bin/Debug/:$GUIX_ENVIRONMENT/lib guile
+--   (load-extension "libgemmalib" "init_module")
 
 workspace "PanGemma"
    configurations { "Debug", "Release" }
diff --git a/src/gemma_api.cpp b/src/gemma_api.cpp
index 618f283..77c1d56 100644
--- a/src/gemma_api.cpp
+++ b/src/gemma_api.cpp
@@ -3,10 +3,17 @@
 
 #include <stdio.h>
 #include <libguile.h>
-#include <libguile/boolean.h>
-#include <libguile/numbers.h>
+// #include <libguile/boolean.h>
+// #include <libguile/numbers.h>
+
+// extern SCM my_incrementing_function (SCM a, SCM flag);
+
+// extern "C" SCM my_ping(SCM i);
+
+static SCM my_ping(SCM i) {
+    return i;
+}
 
-extern SCM my_incrementing_zig_function (SCM a, SCM flag);
 
 SCM my_incrementing_function (SCM a, SCM flag)
 {
@@ -19,3 +26,8 @@ SCM my_incrementing_function (SCM a, SCM flag)
 
   return result;
 }
+
+
+extern "C" void init_module() {
+    scm_c_define_gsubr("my-ping", 1, 0, 0, (scm_t_subr)my_ping);
+}