|
Hi,I've been working on a toy tool to allow C code to be embedded inline in Lua. So you can write code like this:
: -- example.clua : x=1 : y=2 : : cfunction add : { : float a = luaL_checknumber(L, 1); : float b = luaL_checknumber(L, 2); : lua_pushnumber(L, a+b); : return 1; : } end : : print(add(x,y))To run this example, you would run this code through the attached tool 'clua':
$ clua example.clua exampleand it would produce two output files: "example.out.lua" and "libexample.out.c". Then you would compile "libexample.out.c" into a shared library called "libexample.so" and run "example.out.lua" using a normal Lua interpreter.
I'm not sure what this is good for. The current version doesn't allow any header files other than <lua.h> and <lauxlib.h>, so at present it's useless for interfacing with C libraries. However, that would be an easy feature to add if anybody is interested in this tool.
Tim Maxwell
Attachment:
clua.c
Description: Binary data
Attachment:
clua.lex
Description: Binary data
Attachment:
tokens.h
Description: Binary data