GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - phyunsj/lua-to-c: Generate Lua-to-C wrapper out of *.h (for my own reference)

This repository was archived by the owner on Nov 16, 2020. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
CL_LUA.c
CL_LUA.c
 
 
CL_LUA.include
CL_LUA.include
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
cl_calc.c
cl_calc.c
 
 
cl_calc.h
cl_calc.h
 
 
cl_calc.i
cl_calc.i
 
 
cl_calc_assert.lua
cl_calc_assert.lua
 
 
codeTemplate.py
codeTemplate.py
 
 
generator.py
generator.py
 
 

Repository files navigation

Lua-to-C

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

Suggested readings for "calling C functions from Lua":

  • https://chsasank.github.io/lua-c-wrapping.html
  • http://lua-users.org/wiki/BindingCodeToLua
  • http://acamara.es/blog/2012/08/calling-c-functions-from-lua-5-2/
  • https://www.cs.usfca.edu/~galles/cs420/lecture/LuaLectures/LuaAndC.html

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)

phyunsj.github.io

Topics

ccodegeneratorluapycparserpythonunittest

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.