[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Enabling __eq metamethod for numbers
- From: Flyer31 Test <flyer31@...>
- Date: Fri, 21 Jan 2022 08:21:48 +0100
I had a similar problem when I introduced my string buffer elements,
e. g. SBtmp.
Of couse I also want to check the case "SBtmp== string".
I also modified this luaV_equalobj function - I just modified it
such,that it very first will check whether either type is
LUA_VUSERDATA, and in this case it will tryo to invoke the __eq meta
function in any case.. .:
+ if( ttypetag(t1) == LUA_VUSERDATA || ttypetag(t2) == LUA_VUSERDATA){
+ if (uvalue(t1) == uvalue(t2)) return 1;
+ else if (L == NULL) return 0;
+ tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);
+ if (tm == NULL)
+ tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);
+ //break; /* will try TM */
+ }
+ else{
...
+ }
So I did it even a bit more generally... working generally for all
userdata, where at least one of the comparison partners is of type
LUA_VUSERDATA.