2018-11-28 14:18:09 -08:00
|
|
|
namespace Ryujinx.HLE.HOS.Kernel
|
|
|
|
{
|
|
|
|
class KAutoObject
|
|
|
|
{
|
|
|
|
protected Horizon System;
|
|
|
|
|
2018-12-04 12:23:37 -08:00
|
|
|
public KAutoObject(Horizon system)
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
2018-12-04 12:23:37 -08:00
|
|
|
System = system;
|
2018-11-28 14:18:09 -08:00
|
|
|
}
|
|
|
|
|
2018-12-04 12:23:37 -08:00
|
|
|
public virtual KernelResult SetName(string name)
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
2018-12-04 12:23:37 -08:00
|
|
|
if (!System.AutoObjectNames.TryAdd(name, this))
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
|
|
|
return KernelResult.InvalidState;
|
|
|
|
}
|
|
|
|
|
|
|
|
return KernelResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-04 12:23:37 -08:00
|
|
|
public static KernelResult RemoveName(Horizon system, string name)
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
2018-12-04 12:23:37 -08:00
|
|
|
if (!system.AutoObjectNames.TryRemove(name, out _))
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
|
|
|
return KernelResult.NotFound;
|
|
|
|
}
|
|
|
|
|
|
|
|
return KernelResult.Success;
|
|
|
|
}
|
|
|
|
|
2018-12-04 12:23:37 -08:00
|
|
|
public static KAutoObject FindNamedObject(Horizon system, string name)
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
2018-12-04 12:23:37 -08:00
|
|
|
if (system.AutoObjectNames.TryGetValue(name, out KAutoObject obj))
|
2018-11-28 14:18:09 -08:00
|
|
|
{
|
2018-12-04 12:23:37 -08:00
|
|
|
return obj;
|
2018-11-28 14:18:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|