arcticfox1919/LuaDardo

Different userdata objects are sharing the same metatable.

dzylikecode opened this issue · 0 comments

/// lua_dardo-0.0.5\lib\src\state\lua_state_impl.dart
  void _setMetatable(Object? val, LuaTable? mt) {
    if (val is LuaTable) {
      val.metatable = mt;
      return;
    }
    String key = "_MT${LuaValue.typeOf(val)}";
    registry!.put(key, mt);
  }
  
/// lua_dardo-0.0.5\lib\src\state\lua_value.dart
    static LuaType typeOf(Object? val) {
    if (val == null) {
      return LuaType.luaNil;
    } else if (val is bool) {
      return LuaType.luaBoolean;
    } else if (val is int || val is double) {
      return LuaType.luaNumber;
    } else if (val is String) {
      return LuaType.luaString;
    } else if (val is LuaTable) {
      return LuaType.luaTable;
    } else if (val is Closure) {
      return LuaType.luaFunction;
    } else if (val is Userdata) {
      return LuaType.luaUserdata;
    } else {
      throw Exception("TODO");
    }
  }

which makes Userdata<a> uses the same metatable as Userdata<b>