pony-tutorial icon indicating copy to clipboard operation
pony-tutorial copied to clipboard

Improve FFI documentation

Open SeanTAllen opened this issue 9 years ago • 4 comments

SeanTAllen avatar Apr 06 '16 16:04 SeanTAllen

I added an issue (#83) for wanting a section about callbacks, but maybe that should be in here?

aturley avatar Apr 06 '16 16:04 aturley

I think that is reasonable for now

SeanTAllen avatar Apr 06 '16 16:04 SeanTAllen

These resources talk about, among other things, how to statically and dynamically link C libraries.

0joshuaolson1 avatar Apr 23 '16 17:04 0joshuaolson1

Two more for this list

  • FFI functions raising errors talks about how Pony code should declare and handle errors from C but doesn't talk about how the C side should raise an error. We're guessing this is via pony_error() with notes in ponyc/src/libponyrt/pony.h and some examples in ponyc/src/libponyrt/lang/time.c, ponyc/src/libponyrt/lang/posix_except.c, and ponyc/src/libponyrt/lang/socket.c.

  • Linking to C Libraries doesn't mention C++. Maybe another section? I've had some success with this method, happy to discuss. ** Write a C wrapper to manage C++ object storage and method invocations. This wrapper would FFI to Pony as normal. ** Make sure the wrapper functions which need to be seen in Pony FFI are declared extern "C" { ... }. ** When linking with GNU tools, be sure to use ponyc --linker g++ because the C++ mangled names and also because of the runtime environment is needed AND be sure to have libstdc++ on your system

mnp avatar Aug 21 '20 13:08 mnp