crashappsec / libcon4m

Base Compiler and Runtime Support for con4m
Apache License 2.0
0 stars 0 forks source link

Foreign Function interface #36

Closed viega closed 3 months ago

viega commented 3 months ago

I took the FFI about as far as I'm going to take it for now, which is farther than it was in v2. Specifically:

  1. If the extern decl specifies cstring for a parameter, I automatically convert from c4m_utf8_t * (i.e., pass in the data pointer).
  2. For return values marked as cstring, I wrap them in a c4m_utf8_t after return.
  3. the holds parameter in is honored; the GC won't collect objects where this has been marked, until c4m_gc_remove_hold is called on the object.

The things I'm deferring still:

  1. Handling varargs calls (not going to do this until I do keyword parameters).
  2. Implementing the allocs parameter. It'd be easy to put allocs in an object wrapper that has a finalizer attached to it, but I need to think about how people should specify what deallocator to use, etc. This isn't important, so I'm not in a hurry on it.
viega commented 3 months ago

Also fixed the nits from yesterday.