2018-11-28 22:18:09 +00:00
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
|
|
{
|
|
|
|
class KAutoObject
|
|
|
|
{
|
|
|
|
protected Horizon System;
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public KAutoObject(Horizon System)
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
this.System = System;
|
2018-11-28 22:18:09 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public virtual KernelResult SetName(string Name)
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
if (!System.AutoObjectNames.TryAdd(Name, this))
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
|
|
|
return KernelResult.InvalidState;
|
|
|
|
}
|
|
|
|
|
|
|
|
return KernelResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public static KernelResult RemoveName(Horizon System, string Name)
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
if (!System.AutoObjectNames.TryRemove(Name, out _))
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
|
|
|
return KernelResult.NotFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
return KernelResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-05 00:52:39 +00:00
|
|
|
public static KAutoObject FindNamedObject(Horizon System, string Name)
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
if (System.AutoObjectNames.TryGetValue(Name, out KAutoObject Obj))
|
2018-11-28 22:18:09 +00:00
|
|
|
{
|
2018-12-05 00:52:39 +00:00
|
|
|
return Obj;
|
2018-11-28 22:18:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|