FFI: Always resolve metamethods for pointers to structs.

This commit is contained in:
Mike Pall
2012-09-08 21:03:40 +02:00
parent 0648fd47cb
commit 21cea85d92
2 changed files with 24 additions and 10 deletions

View File

@@ -218,10 +218,18 @@ static int carith_int64(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
{
cTValue *tv = NULL;
if (tviscdata(L->base))
tv = lj_ctype_meta(cts, cdataV(L->base)->ctypeid, mm);
if (!tv && L->base+1 < L->top && tviscdata(L->base+1))
tv = lj_ctype_meta(cts, cdataV(L->base+1)->ctypeid, mm);
if (tviscdata(L->base)) {
CTypeID id = cdataV(L->base)->ctypeid;
CType *ct = ctype_raw(cts, id);
if (ctype_isptr(ct->info)) id = ctype_cid(ct->info);
tv = lj_ctype_meta(cts, id, mm);
}
if (!tv && L->base+1 < L->top && tviscdata(L->base+1)) {
CTypeID id = cdataV(L->base+1)->ctypeid;
CType *ct = ctype_raw(cts, id);
if (ctype_isptr(ct->info)) id = ctype_cid(ct->info);
tv = lj_ctype_meta(cts, id, mm);
}
if (!tv) {
const char *repr[2];
int i, isenum = -1, isstr = -1;