Skip to content

Commit

Permalink
Dereference Order of Operations Fix
Browse files Browse the repository at this point in the history
-Added paratheses around dereference statements
  • Loading branch information
curin committed Jun 27, 2024
1 parent 2ba20f9 commit 9c301e9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
18 changes: 1 addition & 17 deletions sources/SilkTouch/Mods/AddOpaqueCOM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private string GetNewName(string comName)
{
if (node.Identifier.ToString() == "lpVtbl")
{
return PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, node);
return ParenthesizedExpression(PrefixUnaryExpression(SyntaxKind.PointerIndirectionExpression, node));
}

return base.VisitIdentifierName(node);
Expand Down Expand Up @@ -226,22 +226,6 @@ private string GetNewName(string comName)

return ret;
}


public override SyntaxNode? VisitClassDeclaration(ClassDeclarationSyntax node) =>
VisitType(node, node.Identifier, base.VisitClassDeclaration);

public override SyntaxNode? VisitRecordDeclaration(RecordDeclarationSyntax node) =>
VisitType(node, node.Identifier, base.VisitRecordDeclaration);

public override SyntaxNode? VisitEnumDeclaration(EnumDeclarationSyntax node) =>
VisitType(node, node.Identifier, base.VisitEnumDeclaration);

public override SyntaxNode? VisitDelegateDeclaration(DelegateDeclarationSyntax node) =>
VisitType(node, node.Identifier, base.VisitDelegateDeclaration);

public override SyntaxNode? VisitInterfaceDeclaration(InterfaceDeclarationSyntax node) =>
VisitType(node, node.Identifier, base.VisitInterfaceDeclaration);

public override SyntaxNode? VisitVariableDeclaration(VariableDeclarationSyntax node)
{
Expand Down
10 changes: 5 additions & 5 deletions sources/Windows/DirectX/headers/d3dcommon/D3DBlob.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public unsafe partial struct D3DBlob : ID3DBlob.Interface, INativeGuid
[VtblIndex(0)]
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
{
return ((delegate* unmanaged<D3DBlob, Guid*, void**, int>)(*lpVtbl[0]))(
return ((delegate* unmanaged<D3DBlob, Guid*, void**, int>)((*lpVtbl)[0]))(
this,
riid,
ppvObject
Expand All @@ -39,7 +39,7 @@ public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void**
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged<D3DBlob, uint>)(*lpVtbl[1]))(this);
return ((delegate* unmanaged<D3DBlob, uint>)((*lpVtbl)[1]))(this);
}

/// <inheritdoc cref = "IUnknown.Release"/>
Expand All @@ -49,7 +49,7 @@ public uint AddRef()
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged<D3DBlob, uint>)(*lpVtbl[2]))(this);
return ((delegate* unmanaged<D3DBlob, uint>)((*lpVtbl)[2]))(this);
}

/// <include file='ID3DBlob.xml' path='doc/member[@name="ID3DBlob.GetBufferPointer"]/*'/>
Expand All @@ -59,7 +59,7 @@ public uint Release()
[return: NativeTypeName("LPVOID")]
public void* GetBufferPointer()
{
return ((delegate* unmanaged<D3DBlob, void*>)(*lpVtbl[3]))(this);
return ((delegate* unmanaged<D3DBlob, void*>)((*lpVtbl)[3]))(this);
}

/// <include file='ID3DBlob.xml' path='doc/member[@name="ID3DBlob.GetBufferSize"]/*'/>
Expand All @@ -69,7 +69,7 @@ public uint Release()
[return: NativeTypeName("SIZE_T")]
public nuint GetBufferSize()
{
return ((delegate* unmanaged<D3DBlob, nuint>)(*lpVtbl[4]))(this);
return ((delegate* unmanaged<D3DBlob, nuint>)((*lpVtbl)[4]))(this);
}

public interface Interface : IUnknown.Interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public unsafe partial struct D3DDestructionNotifier : ID3DDestructionNotifier.In
[VtblIndex(0)]
public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject)
{
return ((delegate* unmanaged<D3DDestructionNotifier, Guid*, void**, int>)(*lpVtbl[0]))(
return ((delegate* unmanaged<D3DDestructionNotifier, Guid*, void**, int>)((*lpVtbl)[0]))(
this,
riid,
ppvObject
Expand All @@ -39,7 +39,7 @@ public HRESULT QueryInterface([NativeTypeName("const IID &")] Guid* riid, void**
[return: NativeTypeName("ULONG")]
public uint AddRef()
{
return ((delegate* unmanaged<D3DDestructionNotifier, uint>)(*lpVtbl[1]))(this);
return ((delegate* unmanaged<D3DDestructionNotifier, uint>)((*lpVtbl)[1]))(this);
}

/// <inheritdoc cref = "IUnknown.Release"/>
Expand All @@ -49,7 +49,7 @@ public uint AddRef()
[return: NativeTypeName("ULONG")]
public uint Release()
{
return ((delegate* unmanaged<D3DDestructionNotifier, uint>)(*lpVtbl[2]))(this);
return ((delegate* unmanaged<D3DDestructionNotifier, uint>)((*lpVtbl)[2]))(this);
}

/// <include file='ID3DDestructionNotifier.xml' path='doc/member[@name="ID3DDestructionNotifier.RegisterDestructionCallback"]/*'/>
Expand All @@ -68,7 +68,7 @@ public HRESULT RegisterDestructionCallback(
delegate* unmanaged<void*, void>,
void*,
uint*,
int>)(*lpVtbl[3])
int>)((*lpVtbl)[3])
)(this, callbackFn, pData, pCallbackID);
}

Expand All @@ -78,7 +78,7 @@ public HRESULT RegisterDestructionCallback(
[VtblIndex(4)]
public HRESULT UnregisterDestructionCallback(uint callbackID)
{
return ((delegate* unmanaged<D3DDestructionNotifier, uint, int>)(*lpVtbl[4]))(
return ((delegate* unmanaged<D3DDestructionNotifier, uint, int>)((*lpVtbl)[4]))(
this,
callbackID
);
Expand Down
4 changes: 2 additions & 2 deletions sources/Windows/DirectX/headers/d3dcommon/ID3DInclude.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public HRESULT Open(
void*,
void**,
uint*,
int>)(*lpVtbl[0])
int>)((*lpVtbl)[0])
)(
(ID3DInclude*)Unsafe.AsPointer(ref this),
IncludeType,
Expand All @@ -48,7 +48,7 @@ public HRESULT Open(
[VtblIndex(1)]
public HRESULT Close([NativeTypeName("LPCVOID")] void* pData)
{
return ((delegate* unmanaged<ID3DInclude*, void*, int>)(*lpVtbl[1]))(
return ((delegate* unmanaged<ID3DInclude*, void*, int>)((*lpVtbl)[1]))(
(ID3DInclude*)Unsafe.AsPointer(ref this),
pData
);
Expand Down

0 comments on commit 9c301e9

Please sign in to comment.