diff options
author | Mike Pall <mike> | 2012-05-29 12:08:21 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-05-29 12:09:18 +0200 |
commit | fa2572da6c45a6dc18cec8cf9ecc80869b6ac04e (patch) | |
tree | 675141759c1780ca0b4432e3afdfef2748f4bc2e /src | |
parent | 97b7edb206830d661e1eab30b40bffed93e9569e (diff) | |
download | luajit-fa2572da6c45a6dc18cec8cf9ecc80869b6ac04e.tar.gz luajit-fa2572da6c45a6dc18cec8cf9ecc80869b6ac04e.tar.bz2 luajit-fa2572da6c45a6dc18cec8cf9ecc80869b6ac04e.zip |
FFI: Convert io.* file handle to FILE * pointer (but as a void *).
Diffstat (limited to 'src')
-rw-r--r-- | src/lj_cconv.c | 5 | ||||
-rw-r--r-- | src/lj_crecord.c | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lj_cconv.c b/src/lj_cconv.c index 240a8d10..b09c0abe 100644 --- a/src/lj_cconv.c +++ b/src/lj_cconv.c | |||
@@ -603,7 +603,10 @@ void lj_cconv_ct_tv(CTState *cts, CType *d, | |||
603 | tmpptr = (void *)0; | 603 | tmpptr = (void *)0; |
604 | flags |= CCF_FROMTV; | 604 | flags |= CCF_FROMTV; |
605 | } else if (tvisudata(o)) { | 605 | } else if (tvisudata(o)) { |
606 | tmpptr = uddata(udataV(o)); | 606 | GCudata *ud = udataV(o); |
607 | tmpptr = uddata(ud); | ||
608 | if (ud->udtype == UDTYPE_IO_FILE) | ||
609 | tmpptr = *(void **)tmpptr; | ||
607 | } else if (tvislightud(o)) { | 610 | } else if (tvislightud(o)) { |
608 | tmpptr = lightudV(o); | 611 | tmpptr = lightudV(o); |
609 | } else if (tvisfunc(o)) { | 612 | } else if (tvisfunc(o)) { |
diff --git a/src/lj_crecord.c b/src/lj_crecord.c index 74d62d6c..268800e4 100644 --- a/src/lj_crecord.c +++ b/src/lj_crecord.c | |||
@@ -385,7 +385,14 @@ static TRef crec_ct_tv(jit_State *J, CType *d, TRef dp, TRef sp, cTValue *sval) | |||
385 | } else if (tref_isnil(sp)) { | 385 | } else if (tref_isnil(sp)) { |
386 | sp = lj_ir_kptr(J, NULL); | 386 | sp = lj_ir_kptr(J, NULL); |
387 | } else if (tref_isudata(sp)) { | 387 | } else if (tref_isudata(sp)) { |
388 | sp = emitir(IRT(IR_ADD, IRT_P32), sp, lj_ir_kint(J, sizeof(GCudata))); | 388 | GCudata *ud = udataV(sval); |
389 | if (ud->udtype == UDTYPE_IO_FILE) { | ||
390 | TRef tr = emitir(IRT(IR_FLOAD, IRT_U8), sp, IRFL_UDATA_UDTYPE); | ||
391 | emitir(IRTGI(IR_EQ), tr, lj_ir_kint(J, UDTYPE_IO_FILE)); | ||
392 | sp = emitir(IRT(IR_FLOAD, IRT_PTR), sp, IRFL_UDATA_FILE); | ||
393 | } else { | ||
394 | sp = emitir(IRT(IR_ADD, IRT_P32), sp, lj_ir_kint(J, sizeof(GCudata))); | ||
395 | } | ||
389 | } else if (tref_isstr(sp)) { | 396 | } else if (tref_isstr(sp)) { |
390 | if (ctype_isenum(d->info)) { /* Match string against enum constant. */ | 397 | if (ctype_isenum(d->info)) { /* Match string against enum constant. */ |
391 | GCstr *str = strV(sval); | 398 | GCstr *str = strV(sval); |