mrc-ide / odin

ᚩ A DSL for describing and solving differential equations in R
https://mrc-ide.github.io/odin
Other
104 stars 13 forks source link

Allow use with R_forceSymbols #239

Open richfitz opened 3 years ago

richfitz commented 3 years ago

This fails because deSolve will not accept function pointers of this type. Get this working with dde then try and get this ported to work with deSolve - doing this will help with getting odin and odin.dust to cohabit more gracefully as cpp11 adds this

richfitz commented 3 years ago

Doing this appears hard as we want to write:

SEXP registered_address(SEXP ptr) {
  R_RegisteredNativeSymbol *sym =
    (R_RegisteredNativeSymbol *) R_ExternalPtrAddr(ptr);
  return sym->symbol.c->fun;
}

but this requires definitions that are in R's src/include/Rdynpriv.h

typedef struct {
    char       *name;
    DL_FUNC     fun;
    int         numArgs;

    R_NativePrimitiveArgType *types;   
} Rf_DotCSymbol;

struct Rf_RegisteredNativeSymbol {
    NativeSymbolType type;
    union {
        Rf_DotCSymbol        *c;
        Rf_DotCallSymbol     *call;
        Rf_DotFortranSymbol  *fortran;
        Rf_DotExternalSymbol *external;
    } symbol;
    DllInfo *dll;
};