|
@@ -273,7 +273,9 @@ LJLIB_CF(ffi_meta___tostring)
|
|
msg = "ctype<%s>";
|
|
msg = "ctype<%s>";
|
|
id = *(CTypeID *)p;
|
|
id = *(CTypeID *)p;
|
|
} else {
|
|
} else {
|
|
- CType *ct = ctype_raw(ctype_cts(L), id);
|
|
|
|
|
|
+ CTState *cts = ctype_cts(L);
|
|
|
|
+ CType *ct = ctype_raw(cts, id);
|
|
|
|
+ if (ctype_isref(ct->info)) ct = ctype_rawchild(cts, ct);
|
|
if (ctype_iscomplex(ct->info)) {
|
|
if (ctype_iscomplex(ct->info)) {
|
|
setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size));
|
|
setstrV(L, L->top-1, lj_ctype_repr_complex(L, cdataptr(cd), ct->size));
|
|
goto checkgc;
|
|
goto checkgc;
|
|
@@ -281,16 +283,19 @@ LJLIB_CF(ffi_meta___tostring)
|
|
setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd),
|
|
setstrV(L, L->top-1, lj_ctype_repr_int64(L, *(uint64_t *)cdataptr(cd),
|
|
(ct->info & CTF_UNSIGNED)));
|
|
(ct->info & CTF_UNSIGNED)));
|
|
goto checkgc;
|
|
goto checkgc;
|
|
- } else if (ctype_isstruct(ct->info) || ctype_isvector(ct->info)) {
|
|
|
|
- /* Handle ctype __tostring metamethod. */
|
|
|
|
- CTState *cts = ctype_cts(L);
|
|
|
|
- cTValue *tv = lj_ctype_meta(cts, id, MM_tostring);
|
|
|
|
- if (tv)
|
|
|
|
- return lj_meta_tailcall(L, tv);
|
|
|
|
- } else if (ctype_isptr(ct->info)) {
|
|
|
|
- p = cdata_getptr(p, ct->size);
|
|
|
|
} else if (ctype_isfunc(ct->info)) {
|
|
} else if (ctype_isfunc(ct->info)) {
|
|
p = *(void **)p;
|
|
p = *(void **)p;
|
|
|
|
+ } else {
|
|
|
|
+ if (ctype_isptr(ct->info)) {
|
|
|
|
+ p = cdata_getptr(p, ct->size);
|
|
|
|
+ ct = ctype_rawchild(cts, ct);
|
|
|
|
+ }
|
|
|
|
+ if (ctype_isstruct(ct->info) || ctype_isvector(ct->info)) {
|
|
|
|
+ /* Handle ctype __tostring metamethod. */
|
|
|
|
+ cTValue *tv = lj_ctype_meta(cts, ctype_typeid(cts, ct), MM_tostring);
|
|
|
|
+ if (tv)
|
|
|
|
+ return lj_meta_tailcall(L, tv);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p);
|
|
lj_str_pushf(L, msg, strdata(lj_ctype_repr(L, id, NULL)), p);
|