Skip to content

RevengerWizard/tea_ffi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tea_ffi

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:

Example

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)))

Basic types supported

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

Building

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

License

Licenced under MIT License. Copy of the license can be found here

About

Teascript C FFI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published