27 lines
1.2 KiB
C
27 lines
1.2 KiB
C
// berryAdapter.h -- Berry engine adapter for the broker.
|
|
//
|
|
// Exposes broker-registered native functions into a Berry VM, marshals values between
|
|
// Berry and CalogValueT by value (binary-safe strings; scalars), and exports Berry
|
|
// functions as refcounted CalogFnT handles (kept alive by a GC-rooted hidden global,
|
|
// dropped on release). An aggregate crossing OUT to a script becomes a Berry list or map
|
|
// instance (so a host record is readable as user['name']); reading a script's list/map
|
|
// back IN is a v1 limit -> calogErrUnsupportedE.
|
|
//
|
|
// Lifetime note (as with Lua/JS): release every CalogFnT obtained from calogBerryExport
|
|
// (and drop every function value marshalled out) BEFORE calogBerryDestroy, since the
|
|
// release touches the Berry VM.
|
|
|
|
#ifndef BERRY_ADAPTER_H
|
|
#define BERRY_ADAPTER_H
|
|
|
|
#include "calogInternal.h"
|
|
|
|
typedef struct CalogBerryT CalogBerryT;
|
|
|
|
int32_t calogBerryCreate(CalogBerryT **out, CalogT *broker, uint64_t ctxId);
|
|
void calogBerryDestroy(CalogBerryT *context);
|
|
int32_t calogBerryExport(CalogBerryT *context, const char *globalName, CalogFnT **out);
|
|
int32_t calogBerryExpose(CalogBerryT *context, const char *name);
|
|
int32_t calogBerryRun(CalogBerryT *context, const char *source);
|
|
|
|
#endif
|