mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
FFI: Always resolve metamethods for pointers to structs.
This commit is contained in:
parent
0648fd47cb
commit
21cea85d92
@ -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)
|
static int lj_carith_meta(lua_State *L, CTState *cts, CDArith *ca, MMS mm)
|
||||||
{
|
{
|
||||||
cTValue *tv = NULL;
|
cTValue *tv = NULL;
|
||||||
if (tviscdata(L->base))
|
if (tviscdata(L->base)) {
|
||||||
tv = lj_ctype_meta(cts, cdataV(L->base)->ctypeid, mm);
|
CTypeID id = cdataV(L->base)->ctypeid;
|
||||||
if (!tv && L->base+1 < L->top && tviscdata(L->base+1))
|
CType *ct = ctype_raw(cts, id);
|
||||||
tv = lj_ctype_meta(cts, cdataV(L->base+1)->ctypeid, mm);
|
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) {
|
if (!tv) {
|
||||||
const char *repr[2];
|
const char *repr[2];
|
||||||
int i, isenum = -1, isstr = -1;
|
int i, isenum = -1, isstr = -1;
|
||||||
|
@ -1081,12 +1081,18 @@ static void crec_arith_meta(jit_State *J, CTState *cts, RecordFFData *rd)
|
|||||||
{
|
{
|
||||||
cTValue *tv = NULL;
|
cTValue *tv = NULL;
|
||||||
if (J->base[0]) {
|
if (J->base[0]) {
|
||||||
if (tviscdata(&rd->argv[0]))
|
if (tviscdata(&rd->argv[0])) {
|
||||||
tv = lj_ctype_meta(cts, argv2cdata(J, J->base[0], &rd->argv[0])->ctypeid,
|
CTypeID id = argv2cdata(J, J->base[0], &rd->argv[0])->ctypeid;
|
||||||
(MMS)rd->data);
|
CType *ct = ctype_raw(cts, id);
|
||||||
if (!tv && J->base[1] && tviscdata(&rd->argv[1]))
|
if (ctype_isptr(ct->info)) id = ctype_cid(ct->info);
|
||||||
tv = lj_ctype_meta(cts, argv2cdata(J, J->base[1], &rd->argv[1])->ctypeid,
|
tv = lj_ctype_meta(cts, id, (MMS)rd->data);
|
||||||
(MMS)rd->data);
|
}
|
||||||
|
if (!tv && J->base[1] && tviscdata(&rd->argv[1])) {
|
||||||
|
CTypeID id = argv2cdata(J, J->base[1], &rd->argv[1])->ctypeid;
|
||||||
|
CType *ct = ctype_raw(cts, id);
|
||||||
|
if (ctype_isptr(ct->info)) id = ctype_cid(ct->info);
|
||||||
|
tv = lj_ctype_meta(cts, id, (MMS)rd->data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (tv) {
|
if (tv) {
|
||||||
if (tvisfunc(tv)) {
|
if (tvisfunc(tv)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user