RE: Small helper FFI cdef generator script (in perl)

  • From: William Adams <william_a_adams@xxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Tue, 28 May 2013 13:42:52 +0000

I think the cool thing about lcpp, and various other tools, is that you can 
quickly go from a header file to a type reflection interface (reflect.lua) 
without much trouble.  I think that's pretty darned useful.

You could parse a ton of header files, and then have a function: 
whatis(something) which would go through an internal database of all known 
things (types, function prototypes, constants) and feed you back the signature 
for that thing.  For example:

whatis("GetProcessHeaps");

> function => int_32_t GetProcessHeaps(int32_t NumberOfHeaps, void 
> **ProcessHeaps);

That's pretty useful when you're spelunking APIs, and does not require the 
fullness of a compiler runtime.

One suggestion for lcpp... Could it be possible to implement another "compile" 
which was an iterator?  Basically:

lcpp.items(someheader)

Then I could do some filtering on the stream of items as they come out.  They 
could be strings, or a well known data structure, like what the reflect.lua 
creates.  That way, I could either generate a massive string, or I could do 
"other stuff".

-- William

===============================
- Shaping clay is easier than digging it out of the ground.


----------------------------------------
> Date: Tue, 28 May 2013 15:18:22 +0300
> From: alex@xxxxxxxxxxx
> To: luajit@xxxxxxxxxxxxx
> CC: michael@xxxxxxxxxxxx
> Subject: Re: Small helper FFI cdef generator script (in perl)
>
> On 28.05.2013 14:56, Michael Willigens wrote:
>> Did you check lcpp? Its an C PreProcessor written in Lua5.1 (wihtout any
>> depencies). It still has some flaws but I can use it to include tons of
>> headers and defines.
>>
>> https://github.com/willsteel/lcpp
>>
>
> Yes, I bookmarked (starred) lcpp for future use immediately after your
> announce ;-)
>
>                                         

Other related posts: