DeviceDependentGenerator extended to allow generation of enum dependent templates. Name suffix separate to its own attribute.
This commit is contained in:
1 parent
a21ab3134e
commit
9ff0431f59
3 files changed
+26
-5
No files matched your search
@@ -3,7 +3,8 @@ using PerfectNumbers.Core.Gpu.Accelerators;
|
||||
|
||||
namespace PerfectNumbers.Core.Cpu;
|
||||
|
||||
[DeviceDependentTemplate(typeof(ComputationDevice), suffix: "Order")]
|
||||
[DeviceDependentTemplate(typeof(ComputationDevice))]
|
||||
[NameSuffix("Order")]
|
||||
internal struct MersenneCpuDivisorScanSessionWithTemplate() : IMersenneNumberDivisorByDivisorTester.IDivisorScanSession
|
||||
{
|
||||
#if DEVICE_GPU || DEVICE_HYBRID
|
||||
|
||||
@@ -6,7 +6,8 @@ using PerfectNumbers.Core.Gpu.Accelerators;
|
||||
|
||||
namespace PerfectNumbers.Core.Cpu;
|
||||
|
||||
[DeviceDependentTemplate(typeof(ComputationDevice), suffix: "Order")]
|
||||
[DeviceDependentTemplate(typeof(ComputationDevice))]
|
||||
[NameSuffix("Order")]
|
||||
public struct MersenneNumberDivisorByDivisorCpuTesterWithTemplate() : IMersenneNumberDivisorByDivisorTester
|
||||
{
|
||||
public BigInteger DivisorLimit;
|
||||
|
||||
@@ -5,13 +5,32 @@ namespace PerfectNumbers.Core;
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class DeviceDependentTemplateAttribute : Attribute
|
||||
{
|
||||
public DeviceDependentTemplateAttribute(Type enumType, string? suffix = null)
|
||||
public DeviceDependentTemplateAttribute(Type enumType)
|
||||
{
|
||||
EnumType = enumType ?? throw new ArgumentNullException(nameof(enumType));
|
||||
Suffix = suffix;
|
||||
}
|
||||
|
||||
public Type EnumType { get; }
|
||||
}
|
||||
|
||||
public string? Suffix { get; }
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = true)]
|
||||
public sealed class EnumDependentTemplateAttribute : Attribute
|
||||
{
|
||||
public EnumDependentTemplateAttribute(Type enumType)
|
||||
{
|
||||
EnumType = enumType ?? throw new ArgumentNullException(nameof(enumType));
|
||||
}
|
||||
|
||||
public Type EnumType { get; }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class NameSuffixAttribute : Attribute
|
||||
{
|
||||
public NameSuffixAttribute(string suffix)
|
||||
{
|
||||
Suffix = suffix ?? throw new ArgumentNullException(nameof(suffix));
|
||||
}
|
||||
|
||||
public string Suffix { get; }
|
||||
}
|
||||
Reference in new issue
Block a user