All Projects → edubart → nelua-decl

edubart / nelua-decl

Licence: other
C binding generator for Nelua using GCC Lua plugin.

Programming Languages

lua
6591 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to nelua-decl

C-Cpp-Coverage-for-CLion
Get coverage data in CLion using gcov or llvm-cov
Stars: ✭ 37 (+23.33%)
Mutual labels:  gcc
naas
⚙️ Schedule notebooks, run them like APIs, expose securely your assets: Jupyter as a viable ⚡️ Production environment
Stars: ✭ 219 (+630%)
Mutual labels:  binder
mTower
mTower is Trusted Execution Environment specially designed to be used on MicroController Units (MCUs) supporting ARM TrustZone technology (e.g., Cortex-M23/33/35p). mTower operates well under restrictions typical for such environment – small RAM and ROM sizes, relatively low performance, absence of rich OSes providing variety of services availab…
Stars: ✭ 34 (+13.33%)
Mutual labels:  gcc
quickstart-fortran
An easy Windows installer for GFortran and the Fortran Package Manager
Stars: ✭ 44 (+46.67%)
Mutual labels:  gcc
wasm4
Build retro games using WebAssembly for a fantasy console.
Stars: ✭ 711 (+2270%)
Mutual labels:  nelua
school21
Как подготовиться к бассйну Школы 21: изучаем терминал, vim, работаем с gcc, norminette, git, пишем первую программу на Си.
Stars: ✭ 41 (+36.67%)
Mutual labels:  gcc
PuzzleBox
Generate 3D puzzle box (OpenSCAD source)
Stars: ✭ 92 (+206.67%)
Mutual labels:  gcc
voila-gpx-viewer
GPX Viewer web app built with Jupyter, ipywidgets, ipyleaflet, bqplot and voila
Stars: ✭ 43 (+43.33%)
Mutual labels:  binder
demos-linux
Demos for instruction and exploration of the Linux C/C++ API
Stars: ✭ 78 (+160%)
Mutual labels:  gcc
minilib
A c standard system library with a focus on size, headeronly, "singlefile", intended for static linking. 187 Bytes for "Hello World"(regular elf), compiled with the standard gcc toolchain.
Stars: ✭ 29 (-3.33%)
Mutual labels:  gcc
pipeVFX
A Visual Effects pipeline to manage jobs, shots and software assignment, with a simple asset manager. Its extensively integrated with CortexVFX and Gaffer. (and it builds booth, with support for Maya, Houdini and Nuke, if you have then installed!)
Stars: ✭ 47 (+56.67%)
Mutual labels:  gcc
TraditionalMitigation
Traditional Mitigation in GCC to defend Memory Corruption Vulnerability
Stars: ✭ 16 (-46.67%)
Mutual labels:  gcc
Apriori-and-Eclat-Frequent-Itemset-Mining
Implementation of the Apriori and Eclat algorithms, two of the best-known basic algorithms for mining frequent item sets in a set of transactions, implementation in Python.
Stars: ✭ 36 (+20%)
Mutual labels:  gcc
homebrew-macos-cross-toolchains
macOS cross compiler toolchains
Stars: ✭ 404 (+1246.67%)
Mutual labels:  gcc
appmode
Creating web applications with Jupyter and Binder
Stars: ✭ 37 (+23.33%)
Mutual labels:  binder
NLP
Natural Language Processing For Everyone
Stars: ✭ 112 (+273.33%)
Mutual labels:  binder
JBC SolderingStation
JBC_SolderingStation
Stars: ✭ 63 (+110%)
Mutual labels:  gcc
workshop
Workshop: Micromagnetics with Ubermag
Stars: ✭ 19 (-36.67%)
Mutual labels:  binder
libsrcnn
Super-Resolution imaging with Convolutional Neural Network library for G++, Non-OpenCV model.
Stars: ✭ 14 (-53.33%)
Mutual labels:  gcc
navo-workshop
Tutorial notebooks for how to use PyVO to access NASA and other data in Python.
Stars: ✭ 27 (-10%)
Mutual labels:  binder

C binding generator for Nelua using GCC Lua plugin.

This tool assists creating C bindings for any C library for Nelua in a few steps, also enables the possibility to customize each library bindings via Lua scripts. Requires GCC to run.

Note: You need GCC plugin mechanism to use this (only available in Linux systems).

Bindings example

The following cross-platform libraries bindings are ready and generated as example:

How to generate bindings

Make sure you are using Lua 5.3+, GCC 9+ and have GCC plugin installed.

First clone and compile the gcc-lua plugin and compile it:

git clone --recurse-submodules https://github.com/edubart/nelua-decl.git
make -C gcc-lua

Some libraries such as SDL2, GLFW must be installed on your system.

To generate bindings for a library simply do make generate in its folder. For example, the following will generate libs/sdl2/sdl2.nelua and then run a test to check if it's working:

cd libs/sdl2
make generate
make test

Some single header libraries you must be downloaded with make download, for example:

cd libs/minilua
make download
make generate
make test

How to generate bindings for a new library

Suppose you want generate bindings for mylib, create a new folder mylib in libs/, then you must create the following files:

  • mylib.c - A C file including all C headers that have the functions we want to bind.
  • mylib.lua - A lua file with binding generator rules.
  • Makefile - A Makefile script to assist generating the bindings.

For a quick start, see the Makefile, .lua and .c files of the current bundled libraries as an example.

How it works

The bindings are generated using the following command:

gcc -S libs/lua/lua.c \
    -fplugin=./gcc-lua/gcc/gcclua.so \
    -fplugin-arg-gcclua-script=libs/lua/lua.lua \
    > libs/lua/lua.nelua

Command explanation:

  • -S libs/lua/lua.c tells GCC to compile only the assembly instructions for the file, this is sufficient for parsing.
  • -fplugin=./gcc-lua/gcc/gcclua.so tells GCC to load the gcc-lua plugin before compiling.
  • -fplugin-arg-gcclua-script=libs/lua/lua.lua is the lua script loaded with configurations to generate the bindings.
  • libs/lua/lua.nelua is the output file.

Caveats

Some limitations:

  • C bit fields are not supported.
  • C unnamed fields are not supported.
  • C math complex type is not supported.
  • C macros are hidden and requires some manual work to expose them.
  • Currently GCC plugin does not work on Windows, thus you have to generate bindings from a Linux machine.

Usually to create bindings for a new library requires little manual work for C libraries that are binding friendly to other languages. A binding friendly C libraries have the following characteristics:

  • No use of platform dependent function declarations, constants and structs in its API.
  • Constants are declared as enums instead of macros.
  • Functions are declared as C functions and not macros.
  • It doesn't use unnamed fields.
  • It doesn't use bit fields.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].