added MOO_IN_SMPTR_RANGE(), MOO_SMPTR_TO_OOP(), MOO_OOP_TO_SMPTR().

refactored ffi a bit more
This commit is contained in:
hyunghwan.chung 2017-01-10 13:56:19 +00:00
parent faf6ca28e5
commit 1612143499
9 changed files with 132 additions and 50 deletions

@ -1,5 +1,13 @@
class(#byte) _FFI(Module) from 'ffi' class(#byte) _FFI(Module) from 'ffi'
{ {
(*
* the ffi module installs the following methods
* method(#class) _newInstSize
* method open: name
* method close
* method call
* method call: func sig: sig with: args.
*)
} }
class FFI(Object) class FFI(Object)
@ -43,6 +51,8 @@ class FFI(Object)
(f isError) ifTrue: [^f]. (f isError) ifTrue: [^f].
self.funcs at: name put: f. self.funcs at: name put: f.
]. ].
^self.ffi call: f sig: sig with: args
(*^self.ffi call: f sig: sig with: args*)
^self.ffi call(f, sig, args)
} }
} }

@ -488,6 +488,18 @@ moo_oop_t moo_oowtoint (moo_t* moo, moo_oow_t w)
} }
} }
moo_oop_t moo_ooitoint (moo_t* moo, moo_ooi_t i)
{
if (MOO_IN_SMOOI_RANGE(i))
{
return MOO_SMOOI_TO_OOP(i);
}
else
{
return make_bigint_with_ooi (moo, i);
}
}
static MOO_INLINE moo_oop_t expand_bigint (moo_t* moo, moo_oop_t oop, moo_oow_t inc) static MOO_INLINE moo_oop_t expand_bigint (moo_t* moo, moo_oop_t oop, moo_oow_t inc)
{ {
moo_oop_t z; moo_oop_t z;

@ -1337,7 +1337,7 @@ static moo_pfrc_t _equal_objects (moo_t* moo, moo_ooi_t nargs)
switch (MOO_OOP_GET_TAG(rcv)) switch (MOO_OOP_GET_TAG(rcv))
{ {
case MOO_OOP_TAG_SMINT: case MOO_OOP_TAG_SMOOI:
return MOO_OOP_TO_SMOOI(rcv) == MOO_OOP_TO_SMOOI(arg)? 1: 0; return MOO_OOP_TO_SMOOI(rcv) == MOO_OOP_TO_SMOOI(arg)? 1: 0;
case MOO_OOP_TAG_CHAR: case MOO_OOP_TAG_CHAR:
@ -1700,7 +1700,7 @@ static moo_pfrc_t pf_hash (moo_t* moo, moo_ooi_t nargs)
switch (MOO_OOP_GET_TAG(rcv)) switch (MOO_OOP_GET_TAG(rcv))
{ {
case MOO_OOP_TAG_SMINT: case MOO_OOP_TAG_SMOOI:
hv = MOO_OOP_TO_SMOOI(rcv); hv = MOO_OOP_TO_SMOOI(rcv);
break; break;

@ -325,15 +325,19 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
/* opening a raw shared object */ /* opening a raw shared object */
bcslen = MOO_COUNTOF(buf); bcslen = MOO_COUNTOF(buf);
if (moo_convootobcstr (moo, name, &ucslen, buf, &bcslen) <= -1) return MOO_NULL; if (moo_convootobcstr (moo, name, &ucslen, buf, &bcslen) <= -1) return MOO_NULL;
handle = lt_dlopenext (buf);
if (!handle) if (moo_findbchar (buf, bcslen, '.'))
{ {
MOO_DEBUG2 (moo, "Failed to open(ext) DL %hs - %hs\n", buf, lt_dlerror());
handle = lt_dlopen (buf); handle = lt_dlopen (buf);
if (!handle) MOO_DEBUG2 (moo, "Failed to open DL %hs - %s\n", buf, lt_dlerror()); if (!handle) MOO_DEBUG2 (moo, "Failed to open DL %hs - %s\n", buf, lt_dlerror());
else MOO_DEBUG2 (moo, "Opened DL %hs handle %p\n", buf, handle); else MOO_DEBUG2 (moo, "Opened DL %hs handle %p\n", buf, handle);
} }
else MOO_DEBUG2 (moo, "Opened(ext) DL %hs handle %p\n", buf, handle); else
{
handle = lt_dlopenext (buf);
if (!handle) MOO_DEBUG2 (moo, "Failed to open(ext) DL %hs - %s\n", buf, lt_dlerror());
else MOO_DEBUG2 (moo, "Opened(ext) DL %hs handle %p\n", buf, handle);
}
} }
return handle; return handle;
@ -755,7 +759,7 @@ int main (int argc, char* argv[])
} }
} }
printf ("COMPILE OK. STARTING EXECUTION ...\n"); MOO_DEBUG0 (moo, "COMPILE OK. STARTING EXECUTION...\n");
xret = 0; xret = 0;
g_moo = moo; g_moo = moo;
setup_tick (); setup_tick ();

@ -1009,11 +1009,6 @@ int moo_inttooow (
moo_oow_t* w moo_oow_t* w
); );
moo_oop_t moo_oowtoint (
moo_t* moo,
moo_oow_t w
);
moo_oop_t moo_addints ( moo_oop_t moo_addints (
moo_t* moo, moo_t* moo,
moo_oop_t x, moo_oop_t x,

@ -110,7 +110,7 @@ int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_oow_t heapsz, const moo_vmprim_t
fill_bigint_tables (moo); fill_bigint_tables (moo);
moo->tagged_classes[MOO_OOP_TAG_SMINT] = &moo->_small_integer; moo->tagged_classes[MOO_OOP_TAG_SMOOI] = &moo->_small_integer;
moo->tagged_classes[MOO_OOP_TAG_CHAR] = &moo->_character; moo->tagged_classes[MOO_OOP_TAG_CHAR] = &moo->_character;
moo->tagged_classes[MOO_OOP_TAG_ERROR] = &moo->_error_class; moo->tagged_classes[MOO_OOP_TAG_ERROR] = &moo->_error_class;

@ -196,7 +196,7 @@ typedef enum moo_method_type_t moo_method_type_t;
*/ */
#define MOO_OOP_TAG_BITS 2 #define MOO_OOP_TAG_BITS 2
#define MOO_OOP_TAG_SMINT 1 #define MOO_OOP_TAG_SMOOI 1
#define MOO_OOP_TAG_CHAR 2 #define MOO_OOP_TAG_CHAR 2
#define MOO_OOP_TAG_ERROR 3 #define MOO_OOP_TAG_ERROR 3
@ -204,11 +204,11 @@ typedef enum moo_method_type_t moo_method_type_t;
#define MOO_OOP_IS_NUMERIC(oop) (MOO_OOP_GET_TAG(oop) != 0) #define MOO_OOP_IS_NUMERIC(oop) (MOO_OOP_GET_TAG(oop) != 0)
#define MOO_OOP_IS_POINTER(oop) (MOO_OOP_GET_TAG(oop) == 0) #define MOO_OOP_IS_POINTER(oop) (MOO_OOP_GET_TAG(oop) == 0)
#define MOO_OOP_IS_SMOOI(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_SMINT) #define MOO_OOP_IS_SMOOI(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_SMOOI)
#define MOO_OOP_IS_CHAR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_CHAR) #define MOO_OOP_IS_CHAR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_CHAR)
#define MOO_OOP_IS_ERROR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_ERROR) #define MOO_OOP_IS_ERROR(oop) (MOO_OOP_GET_TAG(oop) == MOO_OOP_TAG_ERROR)
#define MOO_SMOOI_TO_OOP(num) ((moo_oop_t)((((moo_ooi_t)(num)) << MOO_OOP_TAG_BITS) | MOO_OOP_TAG_SMINT)) #define MOO_SMOOI_TO_OOP(num) ((moo_oop_t)((((moo_ooi_t)(num)) << MOO_OOP_TAG_BITS) | MOO_OOP_TAG_SMOOI))
#define MOO_OOP_TO_SMOOI(oop) (((moo_ooi_t)oop) >> MOO_OOP_TAG_BITS) #define MOO_OOP_TO_SMOOI(oop) (((moo_ooi_t)oop) >> MOO_OOP_TAG_BITS)
#define MOO_CHAR_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << MOO_OOP_TAG_BITS) | MOO_OOP_TAG_CHAR)) #define MOO_CHAR_TO_OOP(num) ((moo_oop_t)((((moo_oow_t)(num)) << MOO_OOP_TAG_BITS) | MOO_OOP_TAG_CHAR))
#define MOO_OOP_TO_CHAR(oop) (((moo_oow_t)oop) >> MOO_OOP_TAG_BITS) #define MOO_OOP_TO_CHAR(oop) (((moo_oow_t)oop) >> MOO_OOP_TAG_BITS)
@ -227,6 +227,17 @@ typedef enum moo_method_type_t moo_method_type_t;
#define MOO_SMOOI_MIN (-MOO_SMOOI_MAX) #define MOO_SMOOI_MIN (-MOO_SMOOI_MAX)
#define MOO_IN_SMOOI_RANGE(ooi) ((ooi) >= MOO_SMOOI_MIN && (ooi) <= MOO_SMOOI_MAX) #define MOO_IN_SMOOI_RANGE(ooi) ((ooi) >= MOO_SMOOI_MIN && (ooi) <= MOO_SMOOI_MAX)
/* SMPTR is a special SMOOI value which has been devised to
* encode an address value whose low MOO_OOP_TAG_BITS bits are 0.
* its class is still SmallInteger. A pointer returned by most of
* system functions would be aligned to the pointer size.
* you can use tthe followings macros when storing such a pointer
* in a small integer without loss. */
#define MOO_IN_SMPTR_RANGE(ptr) ((((moo_oow_t)ptr) & MOO_LBMASK(moo_oow_t, MOO_OOP_TAG_BITS)) == 0)
#define MOO_SMPTR_TO_OOP(ptr) ((moo_oop_t)(((moo_oow_t)ptr) | MOO_OOP_TAG_SMOOI))
#define MOO_OOP_TO_SMPTR(oop) ((void*)(((moo_oow_t)oop) & ~MOO_LBMASK(moo_oow_t, MOO_OOP_TAG_BITS)))
/* TODO: There are untested code where a small integer is converted to moo_oow_t. /* TODO: There are untested code where a small integer is converted to moo_oow_t.
* for example, the spec making macro treats the number as moo_oow_t instead of moo_ooi_t. * for example, the spec making macro treats the number as moo_oow_t instead of moo_ooi_t.
* as of this writing, i skip testing that part with the spec value exceeding MOO_SMOOI_MAX. * as of this writing, i skip testing that part with the spec value exceeding MOO_SMOOI_MAX.
@ -1298,6 +1309,17 @@ MOO_EXPORT moo_oop_t moo_makestring (
moo_oow_t len moo_oow_t len
); );
MOO_EXPORT moo_oop_t moo_oowtoint (
moo_t* moo,
moo_oow_t w
);
MOO_EXPORT moo_oop_t moo_ooitoint (
moo_t* moo,
moo_ooi_t i
);
/* ========================================================================= /* =========================================================================
* TEMPORARY OOP MANAGEMENT FUNCTIONS * TEMPORARY OOP MANAGEMENT FUNCTIONS
* ========================================================================= */ * ========================================================================= */

@ -28,6 +28,7 @@
#include "console.h" #include "console.h"
#include <moo-utl.h> #include <moo-utl.h>
#include <string.h>
#if defined(_WIN32) #if defined(_WIN32)
#elif defined(__DOS__) #elif defined(__DOS__)

@ -33,10 +33,10 @@
#define HAVE_DYNCALL #define HAVE_DYNCALL
#if defined(HAVE_DYNCALL) #if defined(HAVE_DYNCALL)
/* TODO: defined dcAllocMem and dcFreeMeme before builing the dynload and dyncall library */ # include <dyncall.h>
# include <dyncall.h> /* TODO: remove this. make dyXXXX calls to callbacks */
#endif #endif
typedef void* ptr_t;
typedef struct ffi_t ffi_t; typedef struct ffi_t ffi_t;
struct ffi_t struct ffi_t
@ -56,14 +56,18 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_ooi_t nargs)
{ {
#if defined(HAVE_DYNCALL) #if defined(HAVE_DYNCALL)
ffi_t* rcv; ffi_t* rcv;
moo_oop_t arg; moo_oop_t name;
MOO_ASSERT (moo, nargs == 1); if (nargs != 1)
{
moo_seterrnum (moo, MOO_EINVAL);
goto reterr;
}
rcv = (ffi_t*)MOO_STACK_GETRCV(moo, nargs); rcv = (ffi_t*)MOO_STACK_GETRCV(moo, nargs);
arg = MOO_STACK_GETARG(moo, nargs, 0); name = MOO_STACK_GETARG(moo, nargs, 0);
if (!MOO_ISTYPEOF(moo, arg, MOO_OBJ_TYPE_CHAR) || !MOO_OBJ_GET_FLAGS_EXTRA(arg)) /* TODO: better null check instead of FLAGS_EXTREA check */ if (!MOO_ISTYPEOF(moo, name, MOO_OBJ_TYPE_CHAR) || !MOO_OBJ_GET_FLAGS_EXTRA(name)) /* TODO: better null check instead of FLAGS_EXTREA check */
{ {
moo_seterrnum (moo, MOO_EINVAL); moo_seterrnum (moo, MOO_EINVAL);
goto reterr; goto reterr;
@ -75,9 +79,10 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_ooi_t nargs)
goto reterr; goto reterr;
} }
rcv->handle = moo->vmprim.dl_open (moo, ((moo_oop_char_t)arg)->slot, 0); rcv->handle = moo->vmprim.dl_open (moo, ((moo_oop_char_t)name)->slot, 0);
if (!rcv->handle) goto reterr; if (!rcv->handle) goto reterr;
MOO_DEBUG3 (moo, "<ffi.open> %.*js => %p\n", MOO_OBJ_GET_SIZE(name), ((moo_oop_char_t)name)->slot, rcv->handle);
MOO_STACK_SETRETTORCV (moo, nargs); MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
@ -95,22 +100,32 @@ static moo_pfrc_t pf_close (moo_t* moo, moo_ooi_t nargs)
#if defined(HAVE_DYNCALL) #if defined(HAVE_DYNCALL)
ffi_t* rcv; ffi_t* rcv;
MOO_ASSERT (moo, nargs == 0); if (nargs != 0)
{
moo_seterrnum (moo, MOO_EINVAL);
goto reterr;
}
rcv = (ffi_t*)MOO_STACK_GETRCV(moo, nargs); rcv = (ffi_t*)MOO_STACK_GETRCV(moo, nargs);
if (!moo->vmprim.dl_open) if (!moo->vmprim.dl_open)
{ {
moo_seterrnum (moo, MOO_ENOIMPL); moo_seterrnum (moo, MOO_ENOIMPL);
return MOO_PF_SUCCESS; goto reterr;
} }
MOO_DEBUG1 (moo, "<ffi.close> %p\n", rcv->handle);
moo->vmprim.dl_close (moo, rcv->handle); moo->vmprim.dl_close (moo, rcv->handle);
rcv->handle = MOO_NULL; rcv->handle = MOO_NULL;
MOO_STACK_SETRETTORCV (moo, nargs); MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
reterr:
MOO_STACK_SETRETTOERROR (moo, nargs);
return MOO_PF_SUCCESS;
#else #else
moo_seterrnum (moo, MOO_ENOIMPL); moo_seterrnum (moo, MOO_ENOIMPL);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
@ -153,7 +168,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_ooi_t nargs)
moo_oop_oop_t arr; moo_oop_oop_t arr;
int mode_set; int mode_set;
f = MOO_OOP_TO_SMOOI(fun); /* TODO: decode pointer properly */ f = MOO_OOP_TO_SMPTR(fun);
arr = (moo_oop_oop_t)args; arr = (moo_oop_oop_t)args;
dc = dcNewCallVM (4096); dc = dcNewCallVM (4096);
@ -163,11 +178,12 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_ooi_t nargs)
goto reterr; goto reterr;
} }
MOO_DEBUG1 (moo, "FFI: CALLING............%p\n", f); MOO_DEBUG2 (moo, "<ffi.call> %p in %p\n", f, rcv->handle);
/*dcMode (dc, DC_CALL_C_DEFAULT); /*dcMode (dc, DC_CALL_C_DEFAULT);
dcReset (dc);*/ dcReset (dc);*/
/*for (i = 2; i < MOO_OBJ_GET_SIZE(sig); i++) /*for (i = 1; i < MOO_OBJ_GET_SIZE(sig); i++)
{ {
if (((moo_oop_char_t)sig)->slot[i] == '|') if (((moo_oop_char_t)sig)->slot[i] == '|')
{ {
@ -179,7 +195,7 @@ MOO_DEBUG0 (moo, "CALL MODE 111 ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPP
} }
if (!mode_set) */ dcMode (dc, DC_CALL_C_DEFAULT); if (!mode_set) */ dcMode (dc, DC_CALL_C_DEFAULT);
for (i = 2; i < MOO_OBJ_GET_SIZE(sig); i++) for (i = 1; i < MOO_OBJ_GET_SIZE(sig); i++)
{ {
MOO_DEBUG1 (moo, "FFI: CALLING ARG %c\n", ((moo_oop_char_t)sig)->slot[i]); MOO_DEBUG1 (moo, "FFI: CALLING ARG %c\n", ((moo_oop_char_t)sig)->slot[i]);
switch (((moo_oop_char_t)sig)->slot[i]) switch (((moo_oop_char_t)sig)->slot[i])
@ -194,19 +210,22 @@ MOO_DEBUG2 (moo, "CALL MODE 222 ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPP
case 'c': case 'c':
/* TODO: sanity check on the argument type */ /* TODO: sanity check on the argument type */
dcArgChar (dc, MOO_OOP_TO_CHAR(arr->slot[i - 2])); dcArgChar (dc, MOO_OOP_TO_CHAR(arr->slot[i - 1]));
break; break;
case 'i': case 'i':
dcArgInt (dc, MOO_OOP_TO_SMOOI(arr->slot[i - 2])); /* TODO: use moo_inttoooi () */
dcArgInt (dc, MOO_OOP_TO_SMOOI(arr->slot[i - 1]));
break; break;
case 'l': case 'l':
dcArgLong (dc, MOO_OOP_TO_SMOOI(arr->slot[i - 2])); /* TODO: use moo_inttoooi () */
dcArgLong (dc, MOO_OOP_TO_SMOOI(arr->slot[i - 1]));
break; break;
case 'L': case 'L':
dcArgLongLong (dc, MOO_OOP_TO_SMOOI(arr->slot[i - 2])); /* TODO: use moo_inttoooi () */
dcArgLongLong (dc, MOO_OOP_TO_SMOOI(arr->slot[i - 1]));
break; break;
#if 0 #if 0
@ -217,7 +236,7 @@ MOO_DEBUG2 (moo, "CALL MODE 222 ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPP
moo_oow_t bcslen, ucslen; moo_oow_t bcslen, ucslen;
moo_bch_t bcs[1024]; moo_bch_t bcs[1024];
ucslen = MOO_OBJ_GET_SIZE(arr->slot[i - 2]); ucslen = MOO_OBJ_GET_SIZE(arr->slot[i - 1]);
moo_convootobchars (moo, ((moo_oop_char_t)arr->slot[i - 2])->slot, &ucslen, bcs, &bcslen); /* proper string conversion */ moo_convootobchars (moo, ((moo_oop_char_t)arr->slot[i - 2])->slot, &ucslen, bcs, &bcslen); /* proper string conversion */
bcs[bcslen] = '\0'; bcs[bcslen] = '\0';
@ -245,26 +264,39 @@ MOO_DEBUG2 (moo, "CALL MODE 222 ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPP
case 'i': case 'i':
{ {
int r = dcCallInt (dc, f); moo_oop_t r;
MOO_DEBUG1 (moo, "CALLED... %d\n", r); r = moo_ooitoint (moo, dcCallInt (dc, f));
MOO_DEBUG2 (moo, "CALL ERROR %d %d\n", dcGetError (dc), DC_ERROR_UNSUPPORTED_MODE); if (!r) return MOO_PF_HARD_FAILURE;
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(r)); MOO_STACK_SETRET (moo, nargs, r);
break; break;
} }
case 'l': case 'l':
{ {
long r = dcCallLong (dc, f); moo_oop_t r;
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(r)); r = moo_ooitoint (moo, dcCallLong (dc, f));
if (!r) return MOO_PF_HARD_FAILURE;
MOO_STACK_SETRET (moo, nargs, r);
break; break;
} }
#if (STIX_SIZEOF_LONG_LONG > 0)
case 'L': case 'L':
{ {
long long r = dcCallLongLong (dc, f); long long r = dcCallLongLong (dc, f);
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(r)); mod_oop_t r;
#if STIX_SIZEOF_LONG_LONG <= STIX_SIZEOF_LONG
r = moo_ooitoint (moo, dcCallLongLong (dc, f));
#else
# error TODO:...
#endif
if (!rr) return MOD_PF_HARD_FAILURE;
MOO_STACK_SETRET (moo, nargs, r);
break; break;
} }
#endif
#if 0 #if 0
case 'b': /* byte array */ case 'b': /* byte array */
@ -319,15 +351,19 @@ static moo_pfrc_t pf_getsym (moo_t* moo, moo_ooi_t nargs)
{ {
#if defined(HAVE_DYNCALL) #if defined(HAVE_DYNCALL)
ffi_t* rcv; ffi_t* rcv;
moo_oop_t fun; moo_oop_t name;
void* sym; void* sym;
MOO_ASSERT (moo, nargs == 1); if (nargs != 1)
{
moo_seterrnum (moo, MOO_EINVAL);
goto reterr;
}
rcv = (ffi_t*)MOO_STACK_GETRCV(moo, nargs); rcv = (ffi_t*)MOO_STACK_GETRCV(moo, nargs);
fun = MOO_STACK_GETARG(moo, nargs, 0); name = MOO_STACK_GETARG(moo, nargs, 0);
if (!MOO_ISTYPEOF(moo,fun,MOO_OBJ_TYPE_CHAR)) if (!MOO_ISTYPEOF(moo,name,MOO_OBJ_TYPE_CHAR)) /* TODO: null check on the symbol name? */
{ {
moo_seterrnum (moo, MOO_EINVAL); moo_seterrnum (moo, MOO_EINVAL);
goto reterr; goto reterr;
@ -339,11 +375,13 @@ static moo_pfrc_t pf_getsym (moo_t* moo, moo_ooi_t nargs)
goto reterr; goto reterr;
} }
sym = moo->vmprim.dl_getsym (moo, rcv->handle, ((moo_oop_char_t)fun)->slot); sym = moo->vmprim.dl_getsym (moo, rcv->handle, ((moo_oop_char_t)name)->slot);
if (!sym) goto reterr; if (!sym) goto reterr;
/* TODO: how to hold an address? as an integer???? or a byte array? */ MOO_DEBUG4 (moo, "<ffi.getsym> %.*js => %p in %p\n", MOO_OBJ_GET_SIZE(name), ((moo_oop_char_t)name)->slot, sym, rcv->handle);
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP((moo_oow_t)sym));
MOO_ASSERT (moo, MOO_IN_SMPTR_RANGE(sym));
MOO_STACK_SETRET (moo, nargs, MOO_SMPTR_TO_OOP(sym));
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
reterr: reterr:
@ -427,7 +465,7 @@ static moo_pfimpl_t query (moo_t* moo, moo_mod_t* mod, const moo_ooch_t* name)
static void unload (moo_t* moo, moo_mod_t* mod) static void unload (moo_t* moo, moo_mod_t* mod)
{ {
/* TODO: close all open libraries...?? */ /* TODO: anything? close open open dll handles? For that, pf_open must store the value it returns to mod->ctx or somewhere..*/
} }
int moo_mod_ffi (moo_t* moo, moo_mod_t* mod) int moo_mod_ffi (moo_t* moo, moo_mod_t* mod)