On Sat, Jun 25, 2011 at 4:23 PM, Stephan Beal <[email protected]> wrote:
> On Sun, Jun 26, 2011 at 12:44 AM, Louis Santillan <[email protected]>
> wrote:
>>
>> To be honest, I've been working on this idea (using macros) too. To
>
> Macros are, long-term, problematic and normally not compile-time-typesafe.
> One of the main benefits of a template-based binding mechanism is that we
> can catch all kinds of errors at compile-time. If a binding compiles, it's
> legal. (That's not to say that the data passed in at runtime will
> necessarily be semantically legal, of course.)
>
>>
>> bring some sort standards to this work, I've been trying to follow
>> some of the ideas in mozilla's ctypes interface. A kind of ctypes-lite
>
> i'm not familiar with ctypes.

ctypes was originally a python library based on libffi. ctypes and
similar libraries let you invoke native code directly without writing
a shim in C or C++. libffi knows how to construct a function call at
runtime, and also how to make trampolines so you can invoke a closure
with only a c function pointer.

The advantage of that kind of interface is you can distribute wrapper
for native libraries in pure python/javascript/etc. Also, if you have
multiple implementations that implement ctypes, then your library
wrappers are totally decoupled from implementation.

In practice, it works pretty well for wrapping C libraries, not so
much for C++ since C++'s ABI is way more complex. Type safety is also
less automatic than the template based approach.

I think having both kinds of FFI standardized for javascript would be
really valuable to different people...

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to