Skip to content

Commit 762204c

Browse files
committed
Dealt with Additional Review Comments
1 parent 46320ae commit 762204c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+531
-1463
lines changed

generator.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"sources/**/helper-types/HSTRING.gen.cs"
5757
],
5858
"InjectedRemappedNames": {
59-
"BOOL": "MaybeBool<int>"
59+
"BOOL": "MaybeBool<int>",
60+
"HANDLE": "Handle"
6061
},
6162
"InjectedGeneratorOptions": [
6263
"--config",
@@ -165,7 +166,8 @@
165166
"!sources/**/helper-types/Handle.gen.cs"
166167
],
167168
"InjectedRemappedNames": {
168-
"BOOL": "MaybeBool<int>"
169+
"BOOL": "MaybeBool<int>",
170+
"HANDLE": "Handle"
169171
},
170172
"InjectedGeneratorOptions": [
171173
"--config",

sources/Core/Core/DSL/MaybeBool`1.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,29 @@ public static implicit operator MaybeBool<T>(bool value)
6161
/// <param name="lh">left hand value</param>
6262
/// <param name="rh">right hand value</param>
6363
/// <returns></returns>
64-
public static bool operator ==(MaybeBool<T> lh, int rh) => lh == (rh != 0);
64+
public static bool operator ==(MaybeBool<T> lh, T rh) => lh.Value.Equals(rh);
6565

6666
/// <summary>
6767
/// Compares boolean value and int
6868
/// </summary>
6969
/// <param name="lh">left hand value</param>
7070
/// <param name="rh">right hand value</param>
7171
/// <returns></returns>
72-
public static bool operator !=(MaybeBool<T> lh, int rh) => lh != (rh != 0);
72+
public static bool operator !=(MaybeBool<T> lh, T rh) => !lh.Value.Equals(rh);
7373

7474
/// <summary>
7575
/// compares boolean value and int
7676
/// </summary>
7777
/// <param name="lh">left hand value</param>
7878
/// <param name="rh">right hand value</param>
7979
/// <returns></returns>
80-
public static bool operator ==(int lh, MaybeBool<T> rh) => (lh != 0) == rh;
80+
public static bool operator ==(T lh, MaybeBool<T> rh) => lh.Equals(rh.Value);
8181

8282
/// <summary>
8383
/// Compares boolean value and int
8484
/// </summary>
8585
/// <param name="lh">left hand value</param>
8686
/// <param name="rh">right hand value</param>
8787
/// <returns></returns>
88-
public static bool operator !=(int lh, MaybeBool<T> rh) => (lh != 0) != rh;
88+
public static bool operator !=(T lh, MaybeBool<T> rh) => !lh.Equals(rh.Value);
8989
}

sources/Core/Core/HRESULT.Manual.cs

Lines changed: 139 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -10,142 +10,142 @@ namespace Silk.NET.Core;
1010
/// <summary>
1111
/// Common error code value returned by Microsoft methods
1212
/// </summary>
13-
public partial struct HResult
14-
{
15-
/// <summary>
16-
/// Has the function failed
17-
/// </summary>
18-
public bool Failed => Value < 0;
19-
20-
/// <summary>
21-
/// Has the function succeeded
22-
/// </summary>
23-
public bool Succeeded => Value >= 0;
24-
25-
/// <summary>
26-
/// Does the given HResult value indicates success
27-
/// </summary>
28-
/// <param name="hr">HResult value</param>
29-
/// <returns>Whether the value indicates success</returns>
30-
[MethodImpl((MethodImplOptions)768)]
31-
public static bool IndicatesSuccess(int hr) => hr >= 0;
32-
33-
/// <summary>
34-
/// Does the given HResult value indicates failure
35-
/// </summary>
36-
/// <param name="hr">HResult value</param>
37-
/// <returns>Whether the value indicates failure</returns>
38-
[MethodImpl((MethodImplOptions)768)]
39-
public static bool IndicatesFailure(int hr) => hr < 0;
40-
41-
/// <summary>
42-
/// Does the given HResult status indicates error
43-
/// </summary>
44-
/// <param name="status">HResult status value</param>
45-
/// <returns>Whether the value indicates error</returns>
46-
[MethodImpl((MethodImplOptions)768)]
47-
public static bool IndicatesError(int status) => ((uint)status >> 31) == 1;
48-
49-
/// <summary>
50-
/// Gets the code from the given HResult value
51-
/// </summary>
52-
/// <param name="hr">HResult value</param>
53-
/// <returns>code of the HResult</returns>
54-
[MethodImpl((MethodImplOptions)768)]
55-
public static int GetCode(int hr) => hr & 0xFFFF;
56-
57-
/// <summary>
58-
/// Gets the facility from the given HResult value
59-
/// </summary>
60-
/// <param name="hr">HResult value</param>
61-
/// <returns>facility of the HResult</returns>
62-
[MethodImpl((MethodImplOptions)768)]
63-
public static int GetFacility(int hr) => (hr >> 16) & 0x1FFF;
64-
65-
/// <summary>
66-
/// Gets the severity from the given HResult value
67-
/// </summary>
68-
/// <param name="hr">HResult value</param>
69-
/// <returns>severity of the HResult</returns>
70-
[MethodImpl((MethodImplOptions)768)]
71-
public static int GetSeverity(int hr) => (hr >> 31) & 1;
72-
73-
/// <summary>
74-
/// Creates a HResult from the given severity, facility, and code values
75-
/// </summary>
76-
/// <param name="severity">severity value</param>
77-
/// <param name="facility">facility value</param>
78-
/// <param name="code">code value</param>
79-
/// <returns>HResult with the given severity, facility, and code</returns>
80-
[MethodImpl((MethodImplOptions)768)]
81-
public static int Create(int severity, int facility, int code) =>
82-
(int)(((uint)severity << 31) | ((uint)facility << 16) | (uint)code);
83-
84-
/// <summary>
85-
/// Constructs a HResult from the given severity, facility, and code values
86-
/// </summary>
87-
/// <param name="severity">severity value</param>
88-
/// <param name="facility">facility value</param>
89-
/// <param name="code">code value</param>
90-
public HResult(int severity, int facility, int code) =>
91-
Value = Create(severity, facility, code);
92-
93-
/// <summary>
94-
/// Does this HResult represent a success
95-
/// </summary>
96-
public bool IsSuccess
97-
{
98-
[MethodImpl((MethodImplOptions)768)]
99-
get => IndicatesSuccess(Value);
100-
}
101-
102-
/// <summary>
103-
/// Does this HResult represent a failure
104-
/// </summary>
105-
public bool IsFailure
106-
{
107-
[MethodImpl((MethodImplOptions)768)]
108-
get => IndicatesFailure(Value);
109-
}
110-
111-
/// <summary>
112-
/// Does this HResult represent a error
113-
/// </summary>
114-
public bool IsError
115-
{
116-
[MethodImpl((MethodImplOptions)768)]
117-
get => IndicatesError(Value);
118-
}
119-
120-
/// <summary>
121-
/// Gets the code for this HResult
122-
/// </summary>
123-
public int Code
124-
{
125-
[MethodImpl((MethodImplOptions)768)]
126-
get => GetCode(Value);
127-
}
128-
129-
/// <summary>
130-
/// Gets the facility for this HResult
131-
/// </summary>
132-
public int Facility
133-
{
134-
[MethodImpl((MethodImplOptions)768)]
135-
get => GetFacility(Value);
136-
}
137-
138-
/// <summary>
139-
/// Gets the severity for this HResult
140-
/// </summary>
141-
public int Severity
142-
{
143-
[MethodImpl((MethodImplOptions)768)]
144-
get => GetSeverity(Value);
145-
}
146-
147-
/// <summary>
148-
/// Throws this HResult as an exception
149-
/// </summary>
150-
public void Throw() => Marshal.ThrowExceptionForHR(Value);
151-
}
13+
//public partial struct HResult
14+
//{
15+
// /// <summary>
16+
// /// Has the function failed
17+
// /// </summary>
18+
// public bool Failed => Value < 0;
19+
20+
// /// <summary>
21+
// /// Has the function succeeded
22+
// /// </summary>
23+
// public bool Succeeded => Value >= 0;
24+
25+
// /// <summary>
26+
// /// Does the given HResult value indicates success
27+
// /// </summary>
28+
// /// <param name="hr">HResult value</param>
29+
// /// <returns>Whether the value indicates success</returns>
30+
// [MethodImpl((MethodImplOptions)768)]
31+
// public static bool IndicatesSuccess(int hr) => hr >= 0;
32+
33+
// /// <summary>
34+
// /// Does the given HResult value indicates failure
35+
// /// </summary>
36+
// /// <param name="hr">HResult value</param>
37+
// /// <returns>Whether the value indicates failure</returns>
38+
// [MethodImpl((MethodImplOptions)768)]
39+
// public static bool IndicatesFailure(int hr) => hr < 0;
40+
41+
// /// <summary>
42+
// /// Does the given HResult status indicates error
43+
// /// </summary>
44+
// /// <param name="status">HResult status value</param>
45+
// /// <returns>Whether the value indicates error</returns>
46+
// [MethodImpl((MethodImplOptions)768)]
47+
// public static bool IndicatesError(int status) => ((uint)status >> 31) == 1;
48+
49+
// /// <summary>
50+
// /// Gets the code from the given HResult value
51+
// /// </summary>
52+
// /// <param name="hr">HResult value</param>
53+
// /// <returns>code of the HResult</returns>
54+
// [MethodImpl((MethodImplOptions)768)]
55+
// public static int GetCode(int hr) => hr & 0xFFFF;
56+
57+
// /// <summary>
58+
// /// Gets the facility from the given HResult value
59+
// /// </summary>
60+
// /// <param name="hr">HResult value</param>
61+
// /// <returns>facility of the HResult</returns>
62+
// [MethodImpl((MethodImplOptions)768)]
63+
// public static int GetFacility(int hr) => (hr >> 16) & 0x1FFF;
64+
65+
// /// <summary>
66+
// /// Gets the severity from the given HResult value
67+
// /// </summary>
68+
// /// <param name="hr">HResult value</param>
69+
// /// <returns>severity of the HResult</returns>
70+
// [MethodImpl((MethodImplOptions)768)]
71+
// public static int GetSeverity(int hr) => (hr >> 31) & 1;
72+
73+
// /// <summary>
74+
// /// Creates a HResult from the given severity, facility, and code values
75+
// /// </summary>
76+
// /// <param name="severity">severity value</param>
77+
// /// <param name="facility">facility value</param>
78+
// /// <param name="code">code value</param>
79+
// /// <returns>HResult with the given severity, facility, and code</returns>
80+
// [MethodImpl((MethodImplOptions)768)]
81+
// public static int Create(int severity, int facility, int code) =>
82+
// (int)(((uint)severity << 31) | ((uint)facility << 16) | (uint)code);
83+
84+
// /// <summary>
85+
// /// Constructs a HResult from the given severity, facility, and code values
86+
// /// </summary>
87+
// /// <param name="severity">severity value</param>
88+
// /// <param name="facility">facility value</param>
89+
// /// <param name="code">code value</param>
90+
// public HResult(int severity, int facility, int code) =>
91+
// Value = Create(severity, facility, code);
92+
93+
// /// <summary>
94+
// /// Does this HResult represent a success
95+
// /// </summary>
96+
// public bool IsSuccess
97+
// {
98+
// [MethodImpl((MethodImplOptions)768)]
99+
// get => IndicatesSuccess(Value);
100+
// }
101+
102+
// /// <summary>
103+
// /// Does this HResult represent a failure
104+
// /// </summary>
105+
// public bool IsFailure
106+
// {
107+
// [MethodImpl((MethodImplOptions)768)]
108+
// get => IndicatesFailure(Value);
109+
// }
110+
111+
// /// <summary>
112+
// /// Does this HResult represent a error
113+
// /// </summary>
114+
// public bool IsError
115+
// {
116+
// [MethodImpl((MethodImplOptions)768)]
117+
// get => IndicatesError(Value);
118+
// }
119+
120+
// /// <summary>
121+
// /// Gets the code for this HResult
122+
// /// </summary>
123+
// public int Code
124+
// {
125+
// [MethodImpl((MethodImplOptions)768)]
126+
// get => GetCode(Value);
127+
// }
128+
129+
// /// <summary>
130+
// /// Gets the facility for this HResult
131+
// /// </summary>
132+
// public int Facility
133+
// {
134+
// [MethodImpl((MethodImplOptions)768)]
135+
// get => GetFacility(Value);
136+
// }
137+
138+
// /// <summary>
139+
// /// Gets the severity for this HResult
140+
// /// </summary>
141+
// public int Severity
142+
// {
143+
// [MethodImpl((MethodImplOptions)768)]
144+
// get => GetSeverity(Value);
145+
// }
146+
147+
// /// <summary>
148+
// /// Throws this HResult as an exception
149+
// /// </summary>
150+
// public void Throw() => Marshal.ThrowExceptionForHR(Value);
151+
//}

sources/Core/Core/IComInterface.cs renamed to sources/Core/Core/IComVtbl.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
namespace Silk.NET.Core
55
{
66
/// <summary>
7-
/// A specialized native interface representing a ComType
7+
/// Represents a type that can be represented as a pointer to a COM V-Table. (i.e. a pointer to a pointer to the first
8+
/// function pointer)
89
/// </summary>
9-
public interface IComInterface : INativeGuid
10+
public interface IComVtbl : INativeGuid
1011
{
1112
/// <summary>
12-
/// Gets the address of the pointer to the interface object address
13+
/// Gets the address of the pointer to the V-Table as a given interface.
1314
/// </summary>
1415
/// <typeparam name="TNativeInterface">The native interface object type</typeparam>
15-
/// <returns>pointer to interface object address </returns>
16+
/// <returns>the pointer to the V-Table as a given interface</returns>
1617
Ptr2D<TNativeInterface> GetAddressOf<TNativeInterface>()
1718
where TNativeInterface : unmanaged;
1819

1920
/// <summary>
20-
/// Gets the address of the pointer to the interface object address
21+
/// Gets the address of the pointer to the V-Table.
2122
/// </summary>
22-
/// <returns>pointer to interface object address </returns>
23+
/// <returns> pointer to the V-Table</returns>
2324
Ptr2D GetAddressOf();
2425
}
2526
}

sources/Core/Core/IComVtbl`1.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Silk.NET.Core;
5+
6+
/// <summary>
7+
/// A marker interface declaring this type to have a V-table for the given COM type.
8+
/// </summary>
9+
/// <typeparam name="T">The COM type this type contains a V-table to.</typeparam>
10+
public interface IComVtbl<T> : IComVtbl where T : IComVtbl
11+
{
12+
13+
}

sources/Core/Core/Pointers/Ptr.generic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public unsafe struct Ptr<T>(T* ptr)
345345
[MethodImpl(
346346
MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization
347347
)]
348-
public static implicit operator Ptr<T>(nint ptr) => new((T*)ptr.ToPointer());
348+
public static explicit operator Ptr<T>(nint ptr) => new((T*)ptr.ToPointer());
349349

350350
/// <summary>
351351
/// Creates a <see cref="Ref{T}"/> from a <see cref="Ptr{T}"/>

sources/Core/Core/Silk.NET.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
2626
</PropertyGroup>
2727
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
28-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
28+
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
2929
</PropertyGroup>
3030
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
3131
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>

0 commit comments

Comments
 (0)