// luaAdapter.h -- Lua 5.4 engine adapter for the broker.
//
// Exposes broker-registered native functions into a Lua state, marshals values
// between Lua and CalogValueT by value (binary-safe strings; tables <-> the hybrid
// aggregate), and exports Lua functions as refcounted CalogFnT handles that
// any language can invoke through the broker.
//
// Lifetime note: release every CalogFnT obtained from calogLuaExport (and drop every
// function value marshalled out of this state) BEFORE calogLuaDestroy, because
// the underlying luaL_ref lives in this state's registry.

#ifndef LUA_ADAPTER_H
#define LUA_ADAPTER_H

#include "calogInternal.h"

typedef struct CalogLuaT CalogLuaT;

int32_t calogLuaCreate(CalogLuaT **out, CalogT *broker, uint64_t ctxId);
void    calogLuaDestroy(CalogLuaT *context);
int32_t calogLuaExport(CalogLuaT *context, const char *globalName, CalogFnT **out);
int32_t calogLuaExpose(CalogLuaT *context, const char *name);
int32_t calogLuaRun(CalogLuaT *context, const char *source);

#endif
