Skip to content

Commit

Permalink
Add flag to prevent obsolete enum generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Nov 8, 2022
1 parent e4f7618 commit f2e488f
Show file tree
Hide file tree
Showing 53 changed files with 44 additions and 1,249 deletions.
3 changes: 2 additions & 1 deletion generator.json
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,8 @@
"cacheDir": "build/cache",
"cacheKey": "webgpu",
"controlDescriptors": [
"convert-windows-only"
"convert-windows-only",
"no-obsolete-enum"
],
"converter": {},
"prefix": "wgpu",
Expand Down
78 changes: 42 additions & 36 deletions src/Core/Silk.NET.BuildTools/Baking/EnumPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,47 +91,53 @@ private static void StripCommonPrefix(Profile profile, BindTask task)

if (prefix.Length > 0)
{
@enum.Tokens.AddRange
var newEnums = @enum.Tokens.Select
(
@enum.Tokens.Select
(
x =>
{
var newName = Naming.Translate(x.NativeName[prefix.Length..], task.FunctionPrefix);
if (newName == x.Name)
{
return null;
}
x =>
{
var newName = Naming.Translate(x.NativeName[prefix.Length..], task.FunctionPrefix);
if (newName == x.Name)
{
return null;
}

var attrs = x.Attributes.ToList();
if (!x.Attributes.Any(y => y.Name is "Obsolete" or "System.Obsolete"))
var attrs = x.Attributes.ToList();
if (!x.Attributes.Any(y => y.Name is "Obsolete" or "System.Obsolete"))
{
x.Attributes.Add
(
new Attribute
{
x.Attributes.Add
(
new Attribute
{
Name = "Obsolete",
Arguments = new List<string>
{
$"\"Deprecated in favour of \\\"{newName}\\\"\""
}
}
);
Name = "Obsolete",
Arguments = new List<string>
{
$"\"Deprecated in favour of \\\"{newName}\\\"\""
}
}
);
}

return new Token
{
Attributes = attrs,
Doc = x.Doc,
Name = newName,
NativeName = x.NativeName,
Value = x.Value
};
}
)
.Where(x => x is not null)
.ToList()
);
return new Token
{
Attributes = attrs,
Doc = x.Doc,
Name = newName,
NativeName = x.NativeName,
Value = x.Value
};
}
)
.Where(x => x is not null)
.ToList();

if (task.Controls.Contains("no-obsolete-enum"))
{
@enum.Tokens = newEnums;
}
else
{
@enum.Tokens.AddRange(newEnums);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ public enum AlphaMode : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Premultiplied\"")]
[NativeName("Name", "WGPUAlphaMode_Premultiplied")]
AlphaModePremultiplied = 0x0,
[Obsolete("Deprecated in favour of \"Unpremultiplied\"")]
[NativeName("Name", "WGPUAlphaMode_Unpremultiplied")]
AlphaModeUnpremultiplied = 0x1,
[Obsolete("Deprecated in favour of \"Opaque\"")]
[NativeName("Name", "WGPUAlphaMode_Opaque")]
AlphaModeOpaque = 0x2,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUAlphaMode_Force32")]
AlphaModeForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUAlphaMode_Premultiplied")]
Premultiplied = 0x0,
[NativeName("Name", "WGPUAlphaMode_Unpremultiplied")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ public enum LoggingType : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Verbose\"")]
[NativeName("Name", "WGPULoggingType_Verbose")]
LoggingTypeVerbose = 0x0,
[Obsolete("Deprecated in favour of \"Info\"")]
[NativeName("Name", "WGPULoggingType_Info")]
LoggingTypeInfo = 0x1,
[Obsolete("Deprecated in favour of \"Warning\"")]
[NativeName("Name", "WGPULoggingType_Warning")]
LoggingTypeWarning = 0x2,
[Obsolete("Deprecated in favour of \"Error\"")]
[NativeName("Name", "WGPULoggingType_Error")]
LoggingTypeError = 0x3,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPULoggingType_Force32")]
LoggingTypeForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPULoggingType_Verbose")]
Verbose = 0x0,
[NativeName("Name", "WGPULoggingType_Info")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,6 @@ public enum LogLevel : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Off\"")]
[NativeName("Name", "WGPULogLevel_Off")]
LogLevelOff = 0x0,
[Obsolete("Deprecated in favour of \"Error\"")]
[NativeName("Name", "WGPULogLevel_Error")]
LogLevelError = 0x1,
[Obsolete("Deprecated in favour of \"Warn\"")]
[NativeName("Name", "WGPULogLevel_Warn")]
LogLevelWarn = 0x2,
[Obsolete("Deprecated in favour of \"Info\"")]
[NativeName("Name", "WGPULogLevel_Info")]
LogLevelInfo = 0x3,
[Obsolete("Deprecated in favour of \"Debug\"")]
[NativeName("Name", "WGPULogLevel_Debug")]
LogLevelDebug = 0x4,
[Obsolete("Deprecated in favour of \"Trace\"")]
[NativeName("Name", "WGPULogLevel_Trace")]
LogLevelTrace = 0x5,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPULogLevel_Force32")]
LogLevelForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPULogLevel_Off")]
Off = 0x0,
[NativeName("Name", "WGPULogLevel_Error")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,6 @@ namespace Silk.NET.WebGPU.Extensions.WGPU
[NativeName("Name", "WGPUNativeFeature")]
public enum NativeFeature : int
{
[Obsolete("Deprecated in favour of \"PushConstants\"")]
[NativeName("Name", "WGPUNativeFeature_PUSH_CONSTANTS")]
NativeFeaturePushConstants = 0x60000001,
[Obsolete("Deprecated in favour of \"TextureAdapterSpecificFormatFeatures\"")]
[NativeName("Name", "WGPUNativeFeature_TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES")]
NativeFeatureTextureAdapterSpecificFormatFeatures = 0x60000002,
[Obsolete("Deprecated in favour of \"MultiDrawIndirect\"")]
[NativeName("Name", "WGPUNativeFeature_MULTI_DRAW_INDIRECT")]
NativeFeatureMultiDrawIndirect = 0x60000003,
[Obsolete("Deprecated in favour of \"MultiDrawIndirectCount\"")]
[NativeName("Name", "WGPUNativeFeature_MULTI_DRAW_INDIRECT_COUNT")]
NativeFeatureMultiDrawIndirectCount = 0x60000004,
[Obsolete("Deprecated in favour of \"VertexWritableStorage\"")]
[NativeName("Name", "WGPUNativeFeature_VERTEX_WRITABLE_STORAGE")]
NativeFeatureVertexWritableStorage = 0x60000005,
[NativeName("Name", "WGPUNativeFeature_PUSH_CONSTANTS")]
PushConstants = 0x60000001,
[NativeName("Name", "WGPUNativeFeature_TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES")]
Expand Down
15 changes: 0 additions & 15 deletions src/WebGPU/Silk.NET.WebGPU/Enums/AdapterType.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ public enum AdapterType : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"DiscreteGpu\"")]
[NativeName("Name", "WGPUAdapterType_DiscreteGPU")]
AdapterTypeDiscreteGpu = 0x0,
[Obsolete("Deprecated in favour of \"IntegratedGpu\"")]
[NativeName("Name", "WGPUAdapterType_IntegratedGPU")]
AdapterTypeIntegratedGpu = 0x1,
[Obsolete("Deprecated in favour of \"Cpu\"")]
[NativeName("Name", "WGPUAdapterType_CPU")]
AdapterTypeCpu = 0x2,
[Obsolete("Deprecated in favour of \"Unknown\"")]
[NativeName("Name", "WGPUAdapterType_Unknown")]
AdapterTypeUnknown = 0x3,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUAdapterType_Force32")]
AdapterTypeForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUAdapterType_DiscreteGPU")]
DiscreteGpu = 0x0,
[NativeName("Name", "WGPUAdapterType_IntegratedGPU")]
Expand Down
12 changes: 0 additions & 12 deletions src/WebGPU/Silk.NET.WebGPU/Enums/AddressMode.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ public enum AddressMode : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Repeat\"")]
[NativeName("Name", "WGPUAddressMode_Repeat")]
AddressModeRepeat = 0x0,
[Obsolete("Deprecated in favour of \"MirrorRepeat\"")]
[NativeName("Name", "WGPUAddressMode_MirrorRepeat")]
AddressModeMirrorRepeat = 0x1,
[Obsolete("Deprecated in favour of \"ClampToEdge\"")]
[NativeName("Name", "WGPUAddressMode_ClampToEdge")]
AddressModeClampToEdge = 0x2,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUAddressMode_Force32")]
AddressModeForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUAddressMode_Repeat")]
Repeat = 0x0,
[NativeName("Name", "WGPUAddressMode_MirrorRepeat")]
Expand Down
27 changes: 0 additions & 27 deletions src/WebGPU/Silk.NET.WebGPU/Enums/BackendType.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,6 @@ namespace Silk.NET.WebGPU
[NativeName("Name", "WGPUBackendType")]
public enum BackendType : int
{
[Obsolete("Deprecated in favour of \"Null\"")]
[NativeName("Name", "WGPUBackendType_Null")]
BackendTypeNull = 0x0,
[Obsolete("Deprecated in favour of \"WebGpu\"")]
[NativeName("Name", "WGPUBackendType_WebGPU")]
BackendTypeWebGpu = 0x1,
[Obsolete("Deprecated in favour of \"D3D11\"")]
[NativeName("Name", "WGPUBackendType_D3D11")]
BackendTypeD3D11 = 0x2,
[Obsolete("Deprecated in favour of \"D3D12\"")]
[NativeName("Name", "WGPUBackendType_D3D12")]
BackendTypeD3D12 = 0x3,
[Obsolete("Deprecated in favour of \"Metal\"")]
[NativeName("Name", "WGPUBackendType_Metal")]
BackendTypeMetal = 0x4,
[Obsolete("Deprecated in favour of \"Vulkan\"")]
[NativeName("Name", "WGPUBackendType_Vulkan")]
BackendTypeVulkan = 0x5,
[Obsolete("Deprecated in favour of \"OpenGL\"")]
[NativeName("Name", "WGPUBackendType_OpenGL")]
BackendTypeOpenGL = 0x6,
[Obsolete("Deprecated in favour of \"OpenGles\"")]
[NativeName("Name", "WGPUBackendType_OpenGLES")]
BackendTypeOpenGles = 0x7,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUBackendType_Force32")]
BackendTypeForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUBackendType_Null")]
Null = 0x0,
[NativeName("Name", "WGPUBackendType_WebGPU")]
Expand Down
42 changes: 0 additions & 42 deletions src/WebGPU/Silk.NET.WebGPU/Enums/BlendFactor.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,6 @@ namespace Silk.NET.WebGPU
[NativeName("Name", "WGPUBlendFactor")]
public enum BlendFactor : int
{
[Obsolete("Deprecated in favour of \"Zero\"")]
[NativeName("Name", "WGPUBlendFactor_Zero")]
BlendFactorZero = 0x0,
[Obsolete("Deprecated in favour of \"One\"")]
[NativeName("Name", "WGPUBlendFactor_One")]
BlendFactorOne = 0x1,
[Obsolete("Deprecated in favour of \"Src\"")]
[NativeName("Name", "WGPUBlendFactor_Src")]
BlendFactorSrc = 0x2,
[Obsolete("Deprecated in favour of \"OneMinusSrc\"")]
[NativeName("Name", "WGPUBlendFactor_OneMinusSrc")]
BlendFactorOneMinusSrc = 0x3,
[Obsolete("Deprecated in favour of \"SrcAlpha\"")]
[NativeName("Name", "WGPUBlendFactor_SrcAlpha")]
BlendFactorSrcAlpha = 0x4,
[Obsolete("Deprecated in favour of \"OneMinusSrcAlpha\"")]
[NativeName("Name", "WGPUBlendFactor_OneMinusSrcAlpha")]
BlendFactorOneMinusSrcAlpha = 0x5,
[Obsolete("Deprecated in favour of \"Dst\"")]
[NativeName("Name", "WGPUBlendFactor_Dst")]
BlendFactorDst = 0x6,
[Obsolete("Deprecated in favour of \"OneMinusDst\"")]
[NativeName("Name", "WGPUBlendFactor_OneMinusDst")]
BlendFactorOneMinusDst = 0x7,
[Obsolete("Deprecated in favour of \"DstAlpha\"")]
[NativeName("Name", "WGPUBlendFactor_DstAlpha")]
BlendFactorDstAlpha = 0x8,
[Obsolete("Deprecated in favour of \"OneMinusDstAlpha\"")]
[NativeName("Name", "WGPUBlendFactor_OneMinusDstAlpha")]
BlendFactorOneMinusDstAlpha = 0x9,
[Obsolete("Deprecated in favour of \"SrcAlphaSaturated\"")]
[NativeName("Name", "WGPUBlendFactor_SrcAlphaSaturated")]
BlendFactorSrcAlphaSaturated = 0xA,
[Obsolete("Deprecated in favour of \"Constant\"")]
[NativeName("Name", "WGPUBlendFactor_Constant")]
BlendFactorConstant = 0xB,
[Obsolete("Deprecated in favour of \"OneMinusConstant\"")]
[NativeName("Name", "WGPUBlendFactor_OneMinusConstant")]
BlendFactorOneMinusConstant = 0xC,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUBlendFactor_Force32")]
BlendFactorForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUBlendFactor_Zero")]
Zero = 0x0,
[NativeName("Name", "WGPUBlendFactor_One")]
Expand Down
18 changes: 0 additions & 18 deletions src/WebGPU/Silk.NET.WebGPU/Enums/BlendOperation.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,6 @@ public enum BlendOperation : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Add\"")]
[NativeName("Name", "WGPUBlendOperation_Add")]
BlendOperationAdd = 0x0,
[Obsolete("Deprecated in favour of \"Subtract\"")]
[NativeName("Name", "WGPUBlendOperation_Subtract")]
BlendOperationSubtract = 0x1,
[Obsolete("Deprecated in favour of \"ReverseSubtract\"")]
[NativeName("Name", "WGPUBlendOperation_ReverseSubtract")]
BlendOperationReverseSubtract = 0x2,
[Obsolete("Deprecated in favour of \"Min\"")]
[NativeName("Name", "WGPUBlendOperation_Min")]
BlendOperationMin = 0x3,
[Obsolete("Deprecated in favour of \"Max\"")]
[NativeName("Name", "WGPUBlendOperation_Max")]
BlendOperationMax = 0x4,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUBlendOperation_Force32")]
BlendOperationForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUBlendOperation_Add")]
Add = 0x0,
[NativeName("Name", "WGPUBlendOperation_Subtract")]
Expand Down
15 changes: 0 additions & 15 deletions src/WebGPU/Silk.NET.WebGPU/Enums/BufferBindingType.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ public enum BufferBindingType : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Undefined\"")]
[NativeName("Name", "WGPUBufferBindingType_Undefined")]
BufferBindingTypeUndefined = 0x0,
[Obsolete("Deprecated in favour of \"Uniform\"")]
[NativeName("Name", "WGPUBufferBindingType_Uniform")]
BufferBindingTypeUniform = 0x1,
[Obsolete("Deprecated in favour of \"Storage\"")]
[NativeName("Name", "WGPUBufferBindingType_Storage")]
BufferBindingTypeStorage = 0x2,
[Obsolete("Deprecated in favour of \"ReadOnlyStorage\"")]
[NativeName("Name", "WGPUBufferBindingType_ReadOnlyStorage")]
BufferBindingTypeReadOnlyStorage = 0x3,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUBufferBindingType_Force32")]
BufferBindingTypeForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUBufferBindingType_Undefined")]
Undefined = 0x0,
[NativeName("Name", "WGPUBufferBindingType_Uniform")]
Expand Down
21 changes: 0 additions & 21 deletions src/WebGPU/Silk.NET.WebGPU/Enums/BufferMapAsyncStatus.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,6 @@ public enum BufferMapAsyncStatus : int
{
[NativeName("Name", "")]
None = 0,
[Obsolete("Deprecated in favour of \"Success\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_Success")]
BufferMapAsyncStatusSuccess = 0x0,
[Obsolete("Deprecated in favour of \"Error\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_Error")]
BufferMapAsyncStatusError = 0x1,
[Obsolete("Deprecated in favour of \"Unknown\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_Unknown")]
BufferMapAsyncStatusUnknown = 0x2,
[Obsolete("Deprecated in favour of \"DeviceLost\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_DeviceLost")]
BufferMapAsyncStatusDeviceLost = 0x3,
[Obsolete("Deprecated in favour of \"DestroyedBeforeCallback\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_DestroyedBeforeCallback")]
BufferMapAsyncStatusDestroyedBeforeCallback = 0x4,
[Obsolete("Deprecated in favour of \"UnmappedBeforeCallback\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_UnmappedBeforeCallback")]
BufferMapAsyncStatusUnmappedBeforeCallback = 0x5,
[Obsolete("Deprecated in favour of \"Force32\"")]
[NativeName("Name", "WGPUBufferMapAsyncStatus_Force32")]
BufferMapAsyncStatusForce32 = 0x7FFFFFFF,
[NativeName("Name", "WGPUBufferMapAsyncStatus_Success")]
Success = 0x0,
[NativeName("Name", "WGPUBufferMapAsyncStatus_Error")]
Expand Down
Loading

0 comments on commit f2e488f

Please sign in to comment.