commit 3657b8de6030aeec6c95b5d6b2f6e2d38e33b74f Author: Dane Johnson Date: Thu Oct 10 18:16:13 2024 -0500 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/demo.scm b/demo.scm new file mode 100644 index 0000000..fc71c56 --- /dev/null +++ b/demo.scm @@ -0,0 +1,6 @@ +(use-modules (petri) + (agar gui)) + +(petri-app + (let ([window (make-window)]) + (show-window window))) diff --git a/guile-agar/Makefile b/guile-agar/Makefile new file mode 100644 index 0000000..6903427 --- /dev/null +++ b/guile-agar/Makefile @@ -0,0 +1,21 @@ +CFLAGS:=`pkg-config --cflags guile-3.0 agar` -I./include/ +LDLIBS:=`pkg-config --libs guile-3.0 agar` +SRCS:=$(wildcard src/*.c) +OBJS:=$(SRCS:.c=.o) +SCMS:=$(patsubst src/%.o,scm/agar/%.scm,$(OBJS)) +OBJS+=$(patsubst scm/agar/%.scm,scm/agar_%_wrap.o,$(SCMS)) + +.PHONY: driver +all: libguileagar.so $(SCMS) + +clean: + rm -rf libguileagar.so $(SCMS) $(OBJS) $(WRAPS) + +libguileagar.so: $(OBJS) + $(CC) -shared -fPIC -o $@ $^ $(LDLIBS) + +scm/agar/%.scm scm/agar_%_wrap.c: scm/%.i include/%.h + swig -I./include -guile -Linkage module -scmstub -package agar -o scm/agar_$*_wrap.c scm/$*.i + +driver: + GUILE_EXTENSIONS_PATH=. guile -L scm driver.scm diff --git a/guile-agar/driver.scm b/guile-agar/driver.scm new file mode 100644 index 0000000..384572d --- /dev/null +++ b/guile-agar/driver.scm @@ -0,0 +1,12 @@ +(use-modules (agar core)) +(use-modules (agar gui)) + +(init-core) +(init-gui) + +(define my-window (make-window)) +(define my-label (make-label my-window)) +(set-label-text my-label "Hi Agar") + +(show-window my-window) +(event-loop) diff --git a/guile-agar/include/core.h b/guile-agar/include/core.h new file mode 100644 index 0000000..404f4dd --- /dev/null +++ b/guile-agar/include/core.h @@ -0,0 +1,9 @@ +#ifndef __CORE_H__ +#define __CORE_H_ + +#include + +void init_core(); +void event_loop(); + +#endif // __CORE_H__ diff --git a/guile-agar/include/gui.h b/guile-agar/include/gui.h new file mode 100644 index 0000000..6c504ee --- /dev/null +++ b/guile-agar/include/gui.h @@ -0,0 +1,15 @@ +#ifndef __GUI_H__ +#define __GUI_H__ + +#include +#include + +void init_gui(); + +AG_Window* make_window(); +void show_window(AG_Window*); + +AG_Label* make_label(void* parent); +void set_label_text(AG_Label* label, const char* text); + +#endif // __GUI_H__ diff --git a/guile-agar/scm/core.i b/guile-agar/scm/core.i new file mode 100644 index 0000000..730e39e --- /dev/null +++ b/guile-agar/scm/core.i @@ -0,0 +1,6 @@ +%module core +%scheme %{(load-extension "libguileagar" "scm_init_agar_core_module")%} +%{ +#include +%} +%include "core.h" diff --git a/guile-agar/scm/gui.i b/guile-agar/scm/gui.i new file mode 100644 index 0000000..fd7ba06 --- /dev/null +++ b/guile-agar/scm/gui.i @@ -0,0 +1,7 @@ +%module gui +%scheme %{(load-extension "libguileagar" "scm_init_agar_gui_module")%} +%{ +#include +%} + +%include "gui.h" diff --git a/guile-agar/src/core.c b/guile-agar/src/core.c new file mode 100644 index 0000000..c7a7f25 --- /dev/null +++ b/guile-agar/src/core.c @@ -0,0 +1,9 @@ +#include + +void init_core() { + AG_InitCore("agar", 0); +} + +void event_loop() { + AG_EventLoop(); +} diff --git a/guile-agar/src/gui.c b/guile-agar/src/gui.c new file mode 100644 index 0000000..3213091 --- /dev/null +++ b/guile-agar/src/gui.c @@ -0,0 +1,22 @@ +#include + +void init_gui() { + AG_InitGraphics(0); +} + +AG_Window *make_window() { + return AG_WindowNew(AG_WINDOW_MAIN); +} + +void show_window(AG_Window *win) { + AG_WindowShow(win); +} + +AG_Label* make_label(void* parent) { + return AG_LabelNew(parent, 0, ""); +} + +void set_label_text(AG_Label* label, const char* text) { + AG_LabelText(label, text); +} + diff --git a/petri.scm b/petri.scm new file mode 100644 index 0000000..46a7dc5 --- /dev/null +++ b/petri.scm @@ -0,0 +1,11 @@ +(define-module (petri) + :use-module (agar core) + :use-module (agar gui) + :export (petri-app)) + +(define-syntax-rule (petri-app exp ...) + (begin + (init-core) + (init-gui) + exp ... + (event-loop)))