lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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.