aboutsummaryrefslogtreecommitdiff
path: root/docs/notes/simple_ffi.txt
blob: c32f144f840483e7684c4eddcdeccfb11ae8fb61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

proglang automatic "simple"(?) FFI interface
--------------------------------------------

functions:

    void ffi_get_info(const char *language, const FFIInfo *info);

    FFI *ffi_new(const char *language);
    int ffi_add_system(FFI *ffi, const char *name);
    int ffi_add_local(FFI *ffi, const char *path, const char *name);
    
    int ffi_load(FFI *ffi);
    
    /* or have a list of pointers (then records can have variable size!) */
    int ffi_get_symbols(FFI *ffi, FFISymbol **syms, size_t *count);
    void ffi_free_symbols(FFI *ffi, FFISymbol *syms, size_t count);
    
    void ffi_free(FFI *ffi);
    
    
    typedef struct {
        FFIKind kind;     /* language-dependent type of symbol (e.g. function, variable, type, etc.) */
        FFIBits flags;    /* language-dependent bits */
        const char *name; /* name. not all symbols have names */
        size_t ref1, ref2, ref3;
    } FFISymbol;


    typedef enum {
        Decl_
    } FFIInfoType;

    typedef struct {
        size_t num_kinds;
        /* bits --> string that is semi-"standardized". e.g "c-function" or "se.kodafritt.ffi.kinds.function" */
        size_t num_flags;
        /* bits --> string that is semi-"standardized". e.g "bits.const" or "se.kodafritt.ffi.bits.const" */
    } FFIInfo;