FFI: Box all accessed or returned enums.

This commit is contained in:
Mike Pall
2012-07-17 22:20:03 +02:00
parent 2139c6791f
commit 4d9c29a78c
11 changed files with 121 additions and 60 deletions

View File

@@ -297,6 +297,9 @@ LJLIB_CF(ffi_meta___tostring)
goto checkgc;
} else if (ctype_isfunc(ct->info)) {
p = *(void **)p;
} else if (ctype_isenum(ct->info)) {
msg = "cdata<%s>: %d";
p = (void *)(uintptr_t)*(uint32_t **)p;
} else {
if (ctype_isptr(ct->info)) {
p = cdata_getptr(p, ct->size);
@@ -348,7 +351,6 @@ LJLIB_CF(ffi_clib___index) LJLIB_REC(clib_index 1)
CTypeID sid = ctype_cid(s->info);
void *sp = *(void **)cdataptr(cd);
CType *ct = ctype_raw(cts, sid);
if (ctype_isenum(ct->info)) ct = ctype_child(cts, ct);
if (lj_cconv_tv_ct(cts, ct, sid, L->top-1, sp))
lj_gc_check(L);
return 1;