aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CleanC.dcl10
-rw-r--r--Makefile2
-rw-r--r--interface.c2
-rw-r--r--magic.c (renamed from hacking.c)2
-rw-r--r--magic.h (renamed from hacking.h)0
5 files changed, 13 insertions, 3 deletions
diff --git a/CleanC.dcl b/CleanC.dcl
index ba744cd..a385a50 100644
--- a/CleanC.dcl
+++ b/CleanC.dcl
@@ -62,21 +62,31 @@ instance toCParamList (a,b,c,d,e) | toCParam a & toCParam b & toCParam c & toCPa
instance toCParamList (a,b,c,d,e,f) | toCParam a & toCParam b & toCParam c & toCParam d & toCParam e & toCParam f
instance toCParamList (a,b,c,d,e,f,g) | toCParam a & toCParam b & toCParam c & toCParam d & toCParam e & toCParam f & toCParam g
+// Must be called before using any other function, initialises the interface
cInit :: !*State -> *State
+// Low-level functions to send function arguments to C
cPuti :: !Int !*State -> *State
cPuts :: !String !*State -> *State
cPutr :: !Real !*State -> *State
+// Low-level: send any function argument to C
cPutParam :: !CParam -> *State -> *State
+// Low-level: set the return type of the function you're going to call
cSetReturnType :: !CType -> *State -> *State
+// Low-level: call a function
cCall_ :: !String !*State -> *State
+// Low-level: get the return value of a function
cGeti :: !*State -> (!Int, !*State)
cGets :: !*State -> (!String, !*State)
cGetr :: !*State -> (!Real, !*State)
+// Call a function with arguments and get the return value
+//
+// E.g., for a function int add(int x, int y) you would use:
+// (sum, st) = cCall Int "add" (15, 20) st
cCall :: !CType !String !a !*State -> (!CParam, !*State) | toCParamList a
diff --git a/Makefile b/Makefile
index 786a992..0cfd63d 100644
--- a/Makefile
+++ b/Makefile
@@ -24,7 +24,7 @@ CFLAGS=-O0 -Wall
NAME=CleanC
OBJ=$(NAME).o
-INTERMEDIATE=interface.o cleanstring.o hacking.o
+INTERMEDIATE=interface.o cleanstring.o magic.o
TEST_SCRIPT=test
CLM=clm
diff --git a/interface.c b/interface.c
index 5002a6c..2a9a106 100644
--- a/interface.c
+++ b/interface.c
@@ -26,7 +26,7 @@ SOFTWARE. */
#include <inttypes.h>
#include <ffi.h>
-#include "hacking.h"
+#include "magic.h"
#include "Clean.h"
#include "cleanstring.h"
diff --git a/hacking.c b/magic.c
index 44f6bd3..c99fb06 100644
--- a/hacking.c
+++ b/magic.c
@@ -29,7 +29,7 @@ SOFTWARE. */
#include <elf.h>
#include <libelf.h>
-#include "hacking.h"
+#include "magic.h"
Callable* newCallable() {
Callable* c = malloc(sizeof(Callable));
diff --git a/hacking.h b/magic.h
index 9d7835f..9d7835f 100644
--- a/hacking.h
+++ b/magic.h