diff options
| author | Mike Pall <mike> | 2011-02-19 12:56:12 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2011-02-19 12:56:12 +0100 |
| commit | bd29d16141d07ca4e436fe457fd6cbefd638ad15 (patch) | |
| tree | fe4095b299e394d22cfc80e8995ef0d615c2f7f4 /src/lib_ffi.c | |
| parent | 3e2a7a2d7fcb763b39df1f17b440b16896bec0e7 (diff) | |
| download | luajit-bd29d16141d07ca4e436fe457fd6cbefd638ad15.tar.gz luajit-bd29d16141d07ca4e436fe457fd6cbefd638ad15.tar.bz2 luajit-bd29d16141d07ca4e436fe457fd6cbefd638ad15.zip | |
FFI: Improve conversion error messages.
Diffstat (limited to 'src/lib_ffi.c')
| -rw-r--r-- | src/lib_ffi.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib_ffi.c b/src/lib_ffi.c index 361c3ba1..e88b6f54 100644 --- a/src/lib_ffi.c +++ b/src/lib_ffi.c | |||
| @@ -74,7 +74,7 @@ static void *ffi_checkptr(lua_State *L, int narg, CTypeID id) | |||
| 74 | void *p; | 74 | void *p; |
| 75 | if (o >= L->top) | 75 | if (o >= L->top) |
| 76 | lj_err_arg(L, narg, LJ_ERR_NOVAL); | 76 | lj_err_arg(L, narg, LJ_ERR_NOVAL); |
| 77 | lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, 0); | 77 | lj_cconv_ct_tv(cts, ctype_get(cts, id), (uint8_t *)&p, o, CCF_ARG(narg)); |
| 78 | return p; | 78 | return p; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| @@ -86,7 +86,8 @@ static int32_t ffi_checkint(lua_State *L, int narg) | |||
| 86 | int32_t i; | 86 | int32_t i; |
| 87 | if (o >= L->top) | 87 | if (o >= L->top) |
| 88 | lj_err_arg(L, narg, LJ_ERR_NOVAL); | 88 | lj_err_arg(L, narg, LJ_ERR_NOVAL); |
| 89 | lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, 0); | 89 | lj_cconv_ct_tv(cts, ctype_get(cts, CTID_INT32), (uint8_t *)&i, o, |
| 90 | CCF_ARG(narg)); | ||
| 90 | return i; | 91 | return i; |
| 91 | } | 92 | } |
| 92 | 93 | ||
| @@ -444,9 +445,11 @@ LJLIB_CF(ffi_string) LJLIB_REC(.) | |||
| 444 | size_t len; | 445 | size_t len; |
| 445 | if (o+1 < L->top) { | 446 | if (o+1 < L->top) { |
| 446 | len = (size_t)ffi_checkint(L, 2); | 447 | len = (size_t)ffi_checkint(L, 2); |
| 447 | lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o, 0); | 448 | lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CVOID), (uint8_t *)&p, o, |
| 449 | CCF_ARG(1)); | ||
| 448 | } else { | 450 | } else { |
| 449 | lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CCHAR), (uint8_t *)&p, o, 0); | 451 | lj_cconv_ct_tv(cts, ctype_get(cts, CTID_P_CCHAR), (uint8_t *)&p, o, |
| 452 | CCF_ARG(1)); | ||
| 450 | len = strlen(p); | 453 | len = strlen(p); |
| 451 | } | 454 | } |
| 452 | L->top = o+1; /* Make sure this is the last item on the stack. */ | 455 | L->top = o+1; /* Make sure this is the last item on the stack. */ |
