FFI: Add support for converting cdata to tonumber().

This commit is contained in:
Mike Pall
2010-12-05 00:40:23 +01:00
parent 233076d3f9
commit 513b0ba18f
2 changed files with 14 additions and 2 deletions

View File

@@ -22,6 +22,10 @@
#include "lj_tab.h"
#include "lj_meta.h"
#include "lj_state.h"
#if LJ_HASFFI
#include "lj_ctype.h"
#include "lj_cconv.h"
#endif
#include "lj_bc.h"
#include "lj_ff.h"
#include "lj_dispatch.h"
@@ -190,6 +194,14 @@ LJLIB_ASM(tonumber) LJLIB_REC(.)
setnumV(L->base-1, numV(o));
return FFH_RES(1);
}
#if LJ_HASFFI
if (tviscdata(o)) {
CTState *cts = ctype_cts(L);
lj_cconv_ct_tv(cts, ctype_get(cts, CTID_DOUBLE),
(uint8_t *)&(L->base-1)->n, o, CCF_CAST);
return FFH_RES(1);
}
#endif
} else {
const char *p = strdata(lj_lib_checkstr(L, 1));
char *ep;