41 lines
750 B
C
41 lines
750 B
C
#ifndef DEVER_FFI_H
|
|
#define DEVER_FFI_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define DEVER_FFI_ABI_V1 1
|
|
#define DEVER_FFI_OK 0
|
|
#define DEVER_FFI_ERROR 1
|
|
#define DEVER_FFI_FAULT 2
|
|
|
|
typedef struct {
|
|
const char *data;
|
|
uint64_t size;
|
|
} dever_ffi_slice;
|
|
|
|
typedef struct {
|
|
char *data;
|
|
uint64_t capacity;
|
|
uint64_t size;
|
|
} dever_ffi_output;
|
|
|
|
typedef struct {
|
|
uint32_t abi;
|
|
void *context;
|
|
int (*open)(void *context, dever_ffi_slice setting);
|
|
int (*invoke)(void *context, dever_ffi_slice operation, dever_ffi_slice payload, dever_ffi_output *output);
|
|
void (*close)(void *context);
|
|
} dever_ffi_handler;
|
|
|
|
int dever_ffi_serve(const dever_ffi_handler *handler);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|