]> git.mdlowis.com Git - projs/onward.git/commitdiff
added x11 commands master
authorMichael D. Lowis <mike@mdlowis.com>
Sun, 25 Aug 2024 16:34:08 +0000 (12:34 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Sun, 25 Aug 2024 16:34:08 +0000 (12:34 -0400)
.gitignore
Makefile
source/main.c
source/onward.ft
source/onward_sys.h
x11.f [new file with mode: 0644]

index 5cabc309ba1d4424cc184105f19dc4f5de214c6f..a43a25cc109e5e2b1ad0a6827f5112a880e5133e 100644 (file)
@@ -6,3 +6,4 @@
 *.exe
 .rsconscache
 config.mk
+onward
index bf00ca340423c951903dad1456360b784934cb38..01fc7cbbac0c89fc7b18bd1c62363c0e30179eec 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ AR = ar
 # flags
 INCS      = -Isource/ -Itests/
 CPPFLAGS  = -D_XOPEN_SOURCE=700
-CFLAGS   += ${INCS} ${CPPFLAGS} --std=c99 -pedantic -Wall -Wextra
+CFLAGS   += ${INCS} ${CPPFLAGS} --std=c99 -Wall -Wextra
 LDFLAGS  += ${LIBS}
 ARFLAGS   = rcs
 
index 17f27eead006f9633c13a90bfc5a37defaa84540..6312824430e7b9a16f833ac4d3088d888a3ba847 100644 (file)
@@ -34,15 +34,126 @@ defcode("load-sym", load_sym, &load_lib, 0u) {
     onward_aspush((value_t)val);
 }
 
-defcode("ccall", ccall, &load_sym, 0u) {
+defcode("ccall0", ccall0, &load_sym, 0u) {
+    void* func = (void*)onward_aspop();
+    ((void (*)(void))func)();
+}
+
+defcode("ccall1", ccall1, &ccall0, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg1 = onward_aspop();
+    ((void (*)(value_t))func)(arg1);
+}
+
+defcode("ccall2", ccall2, &ccall1, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    ((void (*)(value_t,value_t))func)(arg1, arg2);
+}
+
+defcode("ccall3", ccall3, &ccall2, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    ((void (*)(value_t,value_t,value_t))func)( arg1, arg2, arg3 );
+}
+
+defcode("ccall4", ccall4, &ccall3, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg4 = onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    ((void (*)(value_t,value_t,value_t,value_t))func)( arg1, arg2, arg3, arg4 );
+}
+
+defcode("ccall5", ccall5, &ccall4, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg5 = onward_aspop();
+    value_t arg4 = onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    ((void (*)(value_t,value_t,value_t,value_t,value_t))func)( arg1, arg2, arg3, arg4, arg5 );
+}
 
+defcode("ccall6", ccall6, &ccall5, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg6 = onward_aspop();
+    value_t arg5 = onward_aspop();
+    value_t arg4 = onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    ((void (*)(value_t,value_t,value_t,value_t,value_t,value_t))func)( arg1, arg2, arg3, arg4, arg5, arg6 );
 }
 
-defcode("ccall-ret", ccall_ret, &ccall, 0u) {
+defcode("ccall0-ret", ccall0_ret, &ccall6, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t result = ((value_t (*)(void))func)();
+    onward_aspush(result);
+}
+
+defcode("ccall1-ret", ccall1_ret, &ccall0_ret, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg1 = onward_aspop();
+    value_t result = ((value_t (*)(value_t))func)(arg1);
+    onward_aspush(result);
+}
+
+defcode("ccall2-ret", ccall2_ret, &ccall1_ret, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    value_t result = ((value_t (*)(value_t,value_t))func)(arg1, arg2);
+    onward_aspush(result);
+}
+
+defcode("ccall3-ret", ccall3_ret, &ccall2_ret, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    value_t result = ((value_t (*)(value_t,value_t,value_t))func)( arg1, arg2, arg3 );
+    onward_aspush(result);
+}
+
+defcode("ccall4-ret", ccall4_ret, &ccall3_ret, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg4 = onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    value_t result = ((value_t (*)(value_t,value_t,value_t,value_t))func)( arg1, arg2, arg3, arg4 );
+    onward_aspush(result);
+}
+
+defcode("ccall5-ret", ccall5_ret, &ccall4_ret, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg5 = onward_aspop();
+    value_t arg4 = onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    value_t result = ((value_t (*)(value_t,value_t,value_t,value_t,value_t))func)( arg1, arg2, arg3, arg4, arg5 );
+    onward_aspush(result);
+}
 
+defcode("ccall6-ret", ccall6_ret, &ccall5_ret, 0u) {
+    void* func = (void*)onward_aspop();
+    value_t arg6 = onward_aspop();
+    value_t arg5 = onward_aspop();
+    value_t arg4 = onward_aspop();
+    value_t arg3 = onward_aspop();
+    value_t arg2 = onward_aspop();
+    value_t arg1 = onward_aspop();
+    value_t result = ((value_t (*)(value_t,value_t,value_t,value_t,value_t,value_t))func)( arg1, arg2, arg3, arg4, arg5, arg6 );
+    onward_aspush(result);
 }
 
-defcode("dumpw", dumpw, &load_sym, 0u) {
+defcode("dumpw", dumpw, &ccall6_ret, 0u) {
     word_t* word = (word_t*)onward_aspop();
     printf("name:\t'%s'\n", word->name);
     printf("flags:\t%#zx\n", word->flags);
index b21b43e06045147cfb1468c9d642c4cd2b0a7a20..f01734fadd3c6c9a0dacbd1568ad88b08dcc7072 100644 (file)
 
 : const word create [compile] literal 0 , ;
 
-\ Stack Manipulation Words
-\ -----------------------------------------------------------------------------
-: nip swap drop ;
-: tuck swap over ;
-: pick
-    1 + CELLSZ *   \ Calculate the offset of the desired element
-    asp @ swap - @ \ Fetch the element
-;
-
 \ Boolean Words
 \ -----------------------------------------------------------------------------
 : negate 0 swap - ;
index 8110c13b0abdeafc011833dabe454c7e30e4a978..98af380a2d1b276f72caf8543f1d9209909563de 100644 (file)
@@ -18,7 +18,7 @@
 #endif
 
 #ifndef WORD_BUF_SZ
-#define WORD_BUF_SZ (256 * sizeof(value_t))
+#define WORD_BUF_SZ (4096 * sizeof(value_t))
 #endif
 
 extern value_t Argument_Stack[ARG_STACK_SZ];
diff --git a/x11.f b/x11.f
new file mode 100644 (file)
index 0000000..9e286c6
--- /dev/null
+++ b/x11.f
@@ -0,0 +1,23 @@
+variable Xlib
+variable Display
+
+: lib
+    word load-lib ;
+
+: ->
+    @ word load-sym ;
+
+# load xlib and store it's handle off
+Xlib
+    lib libX11.so !
+
+: sync
+    Display @ 0 [ Xlib -> XSync ] literal ccall2 ;
+
+
+# Open the display and sync
+Display
+    0 [ Xlib -> XOpenDisplay ] ccall1-ret !
+sync
+
+