[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tool to allow embedded C in Lua
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Sun, 20 Jul 2008 20:35:54 -0400
That one is a similar but more recent project:
http://luatcc.luaforge.net/
http://luaforge.net/projects/luatcc/
It includes a C module loader (which loads Lua C modules from
sources), and it's the basis of a gem for the Lua Programming Gems
book.
2008/7/20 Eike Decker <eike@cube3d.de>:
> 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
>>
>>
>
>
>
>