tea_ffi is a portable C FFI for Teascript based on libffi and an API design similar to that of LuaJIT, but written using the Teascript C API.
It aims to be the standard FFI module interface to C for Teascript implementations.
This project was inspired by:
import ffi
// Define a C struct
ffi.cdef(```
typedef struct {
int x;
int y;
const char* name;
} Point;
```)
const p = ffi.cnew("Point", {
x = 10,
y = 20,
name = "origin"
})
print("Point: x=%d, y=%d, name=%s".format(p.x, p.y, ffi.string(p.name)))
Signed and unsigned platform-sized C types:
void
bool
char
short
int
long
float
double
The C99 <stdint.h>
types are also available to use:
int8_t
int16_t
int32_t
int64_t
uint8_t
uint16_t
uint32_t
uint64_t
size_t
Make sure to have the latest commit of Teascript compiled.
You may need to modify the Makefile to point to the correct library paths used by your system.
git clone https://github.com/RevengerWizard/tea_ffi && cd tea_ffi
make
Licenced under MIT License. Copy of the license can be found here