diff options
Diffstat (limited to 'src/lj_cconv.c')
-rw-r--r-- | src/lj_cconv.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/lj_cconv.c b/src/lj_cconv.c index 1e6df8d8..94a9895f 100644 --- a/src/lj_cconv.c +++ b/src/lj_cconv.c | |||
@@ -22,17 +22,26 @@ LJ_NORET static void cconv_err_conv(CTState *cts, CType *d, CType *s, | |||
22 | const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); | 22 | const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); |
23 | const char *src; | 23 | const char *src; |
24 | if ((flags & CCF_FROMTV)) | 24 | if ((flags & CCF_FROMTV)) |
25 | src = lj_obj_typename[1+(ctype_isnum(s->info) ? LUA_TNUMBER : LUA_TSTRING)]; | 25 | src = lj_obj_typename[1+(ctype_isnum(s->info) ? LUA_TNUMBER : |
26 | ctype_isarray(s->info) ? LUA_TSTRING : LUA_TNIL)]; | ||
26 | else | 27 | else |
27 | src = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, s), NULL)); | 28 | src = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, s), NULL)); |
28 | lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); | 29 | if (CCF_GETARG(flags)) |
30 | lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); | ||
31 | else | ||
32 | lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); | ||
29 | } | 33 | } |
30 | 34 | ||
31 | /* Bad conversion from TValue. */ | 35 | /* Bad conversion from TValue. */ |
32 | LJ_NORET static void cconv_err_convtv(CTState *cts, CType *d, TValue *o) | 36 | LJ_NORET static void cconv_err_convtv(CTState *cts, CType *d, TValue *o, |
37 | CTInfo flags) | ||
33 | { | 38 | { |
34 | const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); | 39 | const char *dst = strdata(lj_ctype_repr(cts->L, ctype_typeid(cts, d), NULL)); |
35 | lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, typename(o), dst); | 40 | const char *src = typename(o); |
41 | if (CCF_GETARG(flags)) | ||
42 | lj_err_argv(cts->L, CCF_GETARG(flags), LJ_ERR_FFI_BADCONV, src, dst); | ||
43 | else | ||
44 | lj_err_callerv(cts->L, LJ_ERR_FFI_BADCONV, src, dst); | ||
36 | } | 45 | } |
37 | 46 | ||
38 | /* Initializer overflow. */ | 47 | /* Initializer overflow. */ |
@@ -570,13 +579,14 @@ void lj_cconv_ct_tv(CTState *cts, CType *d, | |||
570 | sid = CTID_BOOL; | 579 | sid = CTID_BOOL; |
571 | } else if (tvisnil(o)) { | 580 | } else if (tvisnil(o)) { |
572 | tmpptr = (void *)0; | 581 | tmpptr = (void *)0; |
582 | flags |= CCF_FROMTV; | ||
573 | } else if (tvisudata(o)) { | 583 | } else if (tvisudata(o)) { |
574 | tmpptr = uddata(udataV(o)); | 584 | tmpptr = uddata(udataV(o)); |
575 | } else if (tvislightud(o)) { | 585 | } else if (tvislightud(o)) { |
576 | tmpptr = lightudV(o); | 586 | tmpptr = lightudV(o); |
577 | } else { | 587 | } else { |
578 | err_conv: | 588 | err_conv: |
579 | cconv_err_convtv(cts, d, o); | 589 | cconv_err_convtv(cts, d, o, flags); |
580 | } | 590 | } |
581 | s = ctype_get(cts, sid); | 591 | s = ctype_get(cts, sid); |
582 | doconv: | 592 | doconv: |