luajit-ffi

Alex Rønne Petersen xtzgzorex at gmail.com
Tue May 1 09:46:31 PDT 2012


On 01-05-2012 18:15, so wrote:
> On Tuesday, 1 May 2012 at 15:56:32 UTC, Alex Rønne Petersen wrote:
>
>> What are you talking about? The link you posted clearly shows that
>> LuaJIT has a C parser built in. It has everything to do with syntax
>> (note that FFI is not anything spectacular or innovative; see libffi,
>> Mono, Lisp, ...). And no, D does not "have all the structures". If it
>> did, we wouldn't be redefining them in D bindings.
>
> What am "i" talking about? How hard to understand these two things?

Very hard! You're not making it clear what it is you want!

Do you want something like LuaJIT's FFI so you can just drop a C header 
in and get a binding or what? You really need to make this clear. I'm 
not even sure what we're discussing at this point.

> ABI compatibility and "already" being able to call C natively? If you
> need any syntax you "already" have it.
>
>> What does enum have to do with the C preprocessor? Anyway, it's not
>> that simple. Any arbitrary symbol can have multiple definitions
>> depending on what path you take in the preprocessor forest.
>
> Have you ever used a C api, say OpenGL?

Yes... I wrote the libffi-d binding. You might want to have a look at 
your local ffi.h and ffitarget.h to see why the preprocessor is a 
serious problem in automated binding generation. As another example, 
look at gc.h from libgc.

> What are they using preprocessor for? other than enum and alias?

C libraries use the preprocessor everywhere to deal with funny 
differences between operating systems, libc implementations, 
architectures, ...

> It is that damn simple.

No, not really. See above. It may be that simple for the OpenGL headers, 
but frankly, OpenGL is an example of a reasonably designed library, 
something that can't be said for 98% of all C libraries.

> I am not talking about supporting Boost level
> preprocessor exploit. I am talking about mature "C" libraries.

"Mature" C libraries are exactly the ones that exploit the preprocessor 
the most to deal with the aforementioned funny differences!

Again, I direct you to ffi.h, ffitarget.h, and gc.h for "simple" examples.

-- 
- Alex


More information about the Digitalmars-d mailing list