// s7Adapter.h -- s7 Scheme engine adapter for the broker.
//
// Exposes broker-registered native functions into an s7 interpreter, marshals values
// between Scheme and CalogValueT by value (binary-safe strings; scalars; aggregates both
// ways -- OUT as a Scheme list or a hash-table when keyed so a record reads as (user
// "name"), IN by iterating a list or hash-table back), and moves Scheme procedures out as
// refcounted CalogFnT handles (kept alive by s7_gc_protect). A foreign CalogFnT pushed IN
// becomes an applicable c-object the script calls as (f ...).
//
// Lifetime note (as with Lua/JS): release every CalogFnT obtained from calogS7Export
// (and drop every procedure value marshalled out) BEFORE calogS7Destroy, since the
// release touches the s7 interpreter.

#ifndef S7_ADAPTER_H
#define S7_ADAPTER_H

#include "calogInternal.h"

typedef struct CalogS7T CalogS7T;

int32_t calogS7Create(CalogS7T **out, CalogT *broker, uint64_t ctxId);
void    calogS7Destroy(CalogS7T *context);
int32_t calogS7Export(CalogS7T *context, const char *globalName, CalogFnT **out);
int32_t calogS7Expose(CalogS7T *context, const char *name);
int32_t calogS7Run(CalogS7T *context, const char *source);

#endif
