lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You might be interested in LuaTCC

http://luaforge.net/projects/lua-tcc/

Eike

> 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 example
> 
> and 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
> 
>