On Wed, Aug 11, 2010 at 8:08 PM, David Cournapeau <[email protected]> wrote: > On Wed, Aug 11, 2010 at 3:42 PM, Carl Witty <[email protected]> wrote: >> In my opinion, the major advantage of C++/CLI over C# with P/Invoke is >> that C++/CLI has a working C++ header file parser. This means that we >> can keep the current Cython semantics, where users describe to Cython >> the API (rather than the ABI) of the library they're trying to call; >> then Cython generates C, C++, or C++/CLI code that conforms to this >> API, and the compiler handles the rest. > > So just to be sure I understand, using C++/CLI gives you a way to > generate the C++ wrapper needed to expose a C-like ABI to cython (and > python runtime) ? A bit like python boost does ?
Well, not exactly. Cython can already deal with a C++ API (better in the not-yet-released 0.13 than in previous versions); I would say that Cython itself is the tool that takes a C++ API and exposes a C ABI to the Python runtime. The advantage of C++/CLI is that it can directly consume C and C++ APIs (as expected, since it's basically a superset of C++). With C++/CLI there isn't really a wrapper. I identified two reasons for a wrapper; one is to translate C or C++ APIs into known ABIs, and the other is to catch and deal with C++ exceptions. With C++/CLI, neither is needed (just like we don't need a wrapper when generating C++ to target CPython). > It seems to me that having a "toolchain" to do this would also be > useful for auto-generating .pxd from header files directly. May be > enough to motivate me to continue the work I started there using clang > > It seems that fixing this would solve the issue for both java and C# > output at the same time, which is a good point. You're talking about a toolchain to generate C-ABI wrappers for arbitrary C++ code? That would indeed be a good place to start for JVM or C# Cython backends. (Although there would still be a lot of work involved; like I said, Cython currently targets C++ APIs directly, so there would be a lot of changes to make it target your wrappers instead.) Carl _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
