make •FFI read relative to file
This commit is contained in:
parent
c7e0b59e88
commit
af194b55ae
@ -12,7 +12,6 @@
|
||||
/* sysfn.c*/M(repr,"•Repr") M(fmt,"•Fmt") A(asrt,"!") A(casrt,"!") M(out,"•Out") M(show,"•Show") A(bqn,"•BQN") A(sh,"•SH") M(fromUtf8,"•FromUTF8") M(currentError,"•CurrentError") \
|
||||
/* sysfn.c*/D(cmp,"•Cmp") A(hash,"•Hash") M(unixTime,"•UnixTime") M(monoTime,"•MonoTime") M(delay,"•Delay") M(makeRand,"•MakeRand") M(reBQN,"•ReBQN") M(exit,"•Exit") M(getLine,"•GetLine") \
|
||||
/* sysfn.c*/M(fName,"•file.Name") \
|
||||
/* ffi.c*/D(ffiload,"•FFI") \
|
||||
/* sysfn.c*/M(tRawMode,"•term.RawMode") M(tFlush,"•term.Flush") M(tCharB,"•term.CharB") M(tCharN,"•term.CharN") M(tOutRaw,"•term.OutRaw") M(tErrRaw,"•term.ErrRaw") \
|
||||
/* inverse.c*/M(setInvReg, "(SetInvReg)") M(setInvSwap, "(SetInvSwap)") M(nativeInvReg, "(NativeInvReg)") M(nativeInvSwap, "(NativeInvSwap)") \
|
||||
/*internal.c*/M(itype,"•internal.Type") M(elType,"•internal.ElType") M(refc,"•internal.Refc") M(isPure,"•internal.IsPure") A(info,"•internal.Info") M(heapDump,"•internal.HeapDump") \
|
||||
|
||||
@ -1081,6 +1081,10 @@ B getMathNS(void);
|
||||
B getPrimitives(void);
|
||||
|
||||
static Body* file_nsGen;
|
||||
|
||||
NFnDesc* ffiloadDesc;
|
||||
B ffiload_c2(B t, B w, B x);
|
||||
|
||||
B sys_c1(B t, B x) {
|
||||
assert(isArr(x));
|
||||
M_HARR(r, a(x)->ia) SGetU(x)
|
||||
@ -1140,10 +1144,10 @@ B sys_c1(B t, B x) {
|
||||
else if (eqStr(c, U"fbytes")) cr = m_nfn(fBytesDesc, inc(REQ_PATH));
|
||||
else if (eqStr(c, U"flines")) cr = m_nfn(fLinesDesc, inc(REQ_PATH));
|
||||
else if (eqStr(c, U"import")) cr = m_nfn(importDesc, inc(REQ_PATH));
|
||||
else if (eqStr(c, U"currenterror")) cr = inc(bi_currentError);
|
||||
#if FFI
|
||||
else if (eqStr(c, U"loadffi")) cr = inc(bi_ffiload);
|
||||
else if (eqStr(c, U"ffi")) cr = m_nfn(ffiloadDesc, inc(REQ_PATH));
|
||||
#endif
|
||||
else if (eqStr(c, U"currenterror")) cr = inc(bi_currentError);
|
||||
else if (eqStr(c, U"state")) {
|
||||
if (q_N(comp_currArgs)) thrM("No arguments present for •state");
|
||||
cr = m_hVec3(inc(REQ_PATH), inc(REQ_NAME), inc(comp_currArgs));
|
||||
@ -1177,6 +1181,7 @@ void sysfn_init() {
|
||||
fExistsDesc = registerNFn(m_str8l("(file).Exists"), fexists_c1, c2_bad);
|
||||
importDesc = registerNFn(m_str32(U"•Import"), import_c1, import_c2);
|
||||
reBQNDesc = registerNFn(m_str8l("(REPL)"), repl_c1, repl_c2);
|
||||
ffiloadDesc = registerNFn(m_str32(U"•FFI"), c1_bad, ffiload_c2);
|
||||
}
|
||||
void sysfnPost_init() {
|
||||
file_nsGen = m_nnsDesc("path","at","list","bytes","chars","lines","type","exists","name","mapbytes","createdir");
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "utils/utf.h"
|
||||
#include "utils/cstr.h"
|
||||
#include "nfns.h"
|
||||
#include "utils/file.h"
|
||||
#include <dlfcn.h>
|
||||
#if FFI==2
|
||||
#include <ffi.h>
|
||||
@ -634,6 +635,7 @@ B ffiload_c2(B t, B w, B x) {
|
||||
#endif
|
||||
if (tRes.resSingle && mutCount!=1) thrF("FFI: Return was \"&\", but found %i mutated variables", mutCount);
|
||||
|
||||
w = path_rel(nfn_objU(t), w);
|
||||
char* ws = toCStr(w);
|
||||
void* dl = dlopen(ws, RTLD_NOW);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user