https://github.com/rrthomas/mork
Automatic C bindings for Lua, using alien and ctypesgen-json
https://github.com/rrthomas/mork
Last synced: 9 months ago
JSON representation
Automatic C bindings for Lua, using alien and ctypesgen-json
- Host: GitHub
- URL: https://github.com/rrthomas/mork
- Owner: rrthomas
- Created: 2011-05-19T20:45:26.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2020-03-19T17:32:31.000Z (about 6 years ago)
- Last Synced: 2025-04-02T18:55:59.712Z (about 1 year ago)
- Language: Lua
- Homepage:
- Size: 6.84 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
mork
----
(c) Reuben Thomas 2011
https://github.com/rrthomas/mork
Mork provides automatic C bindings for Lua using ctypesgen-json and
alien. (Mork is a friendly alien. However, it cannot drink through its
fingers. Indeed, it does not have fingers. It is a shallow analogy.)
Mork is distributed under the MIT License, like Lua itself.
alien is a libffi binding for Lua: http://mascarenhas.github.com/alien/
ctypesgen-json turns C headers into JSON for use with libffi:
http://code.google.com/p/ctypesgen/
It might be better to use cparser: http://sourceforge.net/projects/cparser/
Usage
-----
First, turn a header file into JSON using ctypesgen-json:
$ ctypesgen.py --all-headers --builtin-symbols --output-language=json /usr/include/foo.h -o foo.json
Then in Lua, Mork slurps up the JSON and generates alien bindings on
the fly, returning a module:
require "mork"
require "json"
module = mork.bind (json.decode (io.open ("foo.json"):read ("*a")))