C Value comparison

Value objects supports Lua comparison operators.
A C Value will be compared by its content for numerical types and by memory address for pointers and strings.

Warning

  • You can only compare between Value objects, not with Lua values.
  • To compare Value objects with Lua values, convert them before.

Example

local c = require "c" -- Create a Pointer to a Buffer in memory local c_ptr = c.Pointer(sys.Buffer("\x48\x65\x6C\x6C\x6F\x20\x4C\x75\x61\x52\x54\x20\x21\x00")) -- always false : we are comparing a memory pointer with a Lua string value print(c_ptr == "Hello LuaRT !") -- always true : converts the memory pointer as a C string pointer to a Lua string value print(tostring(c_ptr:as("char*")) == "Hello LuaRT !")