Skip to content
This repository has been archived by the owner on Nov 16, 2020. It is now read-only.

phyunsj/lua-to-c

Repository files navigation

Lua-to-C

Generate Lua-to-C wrapper out of *.h directly.

Suggested readings for "calling C functions from Lua":

cl_calc_xxxx ( ... )

cl_calc.c Just random funtions for the test. C struct is mapped to lua table and vice versa.

Code Generation

Start with extracting FuncDecl by visiting AST (created by pycparser).

The following files are generated :

  • CL_LUA.c
  • CL_LUA.include

Build & Run

$ make 
$ lua -i -e "_PROMPT='lua$ '"
Lua 5.2.0  Copyright (C) 1994-2011 Lua.org, PUC-Rio
lua$
lua$ dofile("cl_calc_test.lua")
...
lua$

if you wish to display the virtual stack, type make debug instead

Closing Remarks

This is a proof of concept to demonstrate testing C fuctions with help of lua (stand-alone ) interpreter (+ pycparser + code generator).

About

Generate Lua-to-C wrapper out of *.h (for my own reference)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published