Hi all,
I am trying to make Lua a == b call a C function. I have provided a metatable from C following the example described here:
To debug I have tried to follow the logic steps described in the manual
Yet the following script (invoked from lua_pcall after pushing instances onto the stack and setting their metatables):
function testfunc(a, b)
print("Type:")
print(type(a))
print("Metatables equal?")
print(type(a) == type(b))
print(getmetatable(a) == getmetatable(b))
print(getmetatable(a)["__eq"] == getmetatable(b)["__eq"])
eqfunc = getmetatable(a)["__eq"]
print("Calling __eq directly")
print(eqfunc(a, b))
print("Calling via ==")
print(a == b)
end
produces
Type:
userdata
Metatables equal?
true
true
true
Calling __eq directly
*** INSIDE C FUNCTION ***
false
Calling via ==
false
i.e. the == operator does not call the C function
Could anyone please shed some light on this issue?
Thanks
Oliver