// mybasicAdapter.h -- my-basic engine adapter for the broker.
//
// Exposes broker-registered native functions into a my-basic interpreter,
// marshals values between my-basic and CalogValueT by value (LIST/DICT <-> the hybrid
// aggregate), and exports BASIC routines as refcounted CalogFnT handles.
//
// Routine export and any CalogFnT-backed BASIC routine can only be evaluated
// while the context is "serving" -- that is, while a native call is on the
// my-basic stack, so a live argument cursor (void** l) exists. mb_eval_routine
// requires it. The actor layer keeps a context parked in a serve frame; in the
// core, fetch and invoke an exported routine from within a native call.

#ifndef MYBASIC_ADAPTER_H
#define MYBASIC_ADAPTER_H

#include "calogInternal.h"

typedef struct CalogMyBasicT CalogMyBasicT;

int32_t calogMyBasicCreate(CalogMyBasicT **out, CalogT *broker, uint64_t ctxId);
void    calogMyBasicDestroy(CalogMyBasicT *context);
int32_t calogMyBasicExportRoutine(CalogMyBasicT *context, const char *routineName, CalogFnT **out);
int32_t calogMyBasicExpose(CalogMyBasicT *context, const char *name);
int32_t calogMyBasicRun(CalogMyBasicT *context, const char *source);

#endif
