diff options
-rw-r--r-- | CleanC.dcl | 10 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | interface.c | 2 | ||||
-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
@@ -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 @@ -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" @@ -29,7 +29,7 @@ SOFTWARE. */ #include <elf.h> #include <libelf.h> -#include "hacking.h" +#include "magic.h" Callable* newCallable() { Callable* c = malloc(sizeof(Callable)); |