Last active
June 21, 2017 18:36
-
-
Save jddurand/09954a5984596ceaf113 to your computer and use it in GitHub Desktop.
Marpa/LUA bindings proof of concept
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!env sh -v | |
# | |
# Marpa in Lua proof of concept - Assumption: Debian/Linux | |
# | |
# Prologue: apt-get -t unstable install lua5.1 liblua5.1-dev swig | |
# | |
# Please go to Marpa-R2-2.096000/engine/read_only and execute this file | |
# --------------------------------------------------------------------- | |
# | |
[ -r ./Makefile ] && make distclean | |
./configure --enable-shared | |
make | |
swig -lua -o ./luaMarpa.c ./marpa.i | |
cc -I/usr/include/lua5.1 -o ./luaMarpa.o -c ./luaMarpa.c -g | |
cc -I/usr/include/lua5.1 -o ./luaMarpa.so -shared ./luaMarpa.o -L`pwd`/.libs -lmarpa | |
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/.libs lua5.1 <<EOF | |
require("luaMarpa") | |
v = luaMarpa.new_intArray(3); | |
r=luaMarpa.marpa_version(v) | |
print("marpa_version return code: ", r) | |
print("Marpa major version :", luaMarpa.intArray_getitem(v, 0)) | |
print("Marpa minor version :", luaMarpa.intArray_getitem(v, 1)) | |
print("Marpa micro version :", luaMarpa.intArray_getitem(v, 2)) | |
luaMarpa.delete_intArray(v) | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%module luaMarpa | |
%{ | |
#include "marpa.h" | |
%} | |
/* | |
* Helper functions for lua to play with int arrays within the luaMarpa namespace | |
*/ | |
%include <carrays.i> | |
%array_functions(int, intArray) | |
%include "marpa.h" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With "luaMarpa.delete_intArray(v)" valgrind output is perfect: