From b39ee80ecd89ef18cef5718a16435ca333b4b947 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Mon, 29 Apr 2019 15:47:56 +0100 Subject: [PATCH] Special path for Windows call convention when returning a SteamId --- .../Generated/Interfaces/ISteamApps.cs | 16 ++- .../Generated/Interfaces/ISteamFriends.cs | 112 +++++++++++++----- .../Generated/Interfaces/ISteamGameServer.cs | 32 +++-- .../Generated/Interfaces/ISteamUser.cs | 16 ++- Facepunch.Steamworks/SteamServer.cs | 2 +- Generator/CodeWriter/ClassVTable.cs | 37 ++++-- 6 files changed, 159 insertions(+), 56 deletions(-) diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs index 6b13bc2..cc553cf 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs @@ -38,6 +38,7 @@ namespace Steamworks _GetAppInstallDir = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 144) ); _BIsAppInstalled = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 152) ); _GetAppOwner = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 160) ); + _GetAppOwner_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 160) ); _GetLaunchQueryParam = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 168) ); _GetDlcDownloadProgress = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 176) ); _GetAppBuildId = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 184) ); @@ -280,15 +281,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetAppOwner( IntPtr self, ref SteamId retVal ); + private delegate SteamId FGetAppOwner( IntPtr self ); private FGetAppOwner _GetAppOwner; + private delegate void FGetAppOwner_Windows( IntPtr self, ref SteamId retVal ); + private FGetAppOwner_Windows _GetAppOwner_Windows; #endregion internal SteamId GetAppOwner() { - var retVal = default( SteamId ); - _GetAppOwner( Self, ref retVal ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetAppOwner_Windows( Self, ref retVal ); + return retVal; + } + + return _GetAppOwner( Self ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs index d7cdea8..cae65e0 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamFriends.cs @@ -22,6 +22,7 @@ namespace Steamworks _GetPersonaState = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16) ); _GetFriendCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24) ); _GetFriendByIndex = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32) ); + _GetFriendByIndex_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32) ); _GetFriendRelationship = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40) ); _GetFriendPersonaState = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 48) ); _GetFriendPersonaName = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 56) ); @@ -37,12 +38,14 @@ namespace Steamworks _HasFriend = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 136) ); _GetClanCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 144) ); _GetClanByIndex = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 152) ); + _GetClanByIndex_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 152) ); _GetClanName = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 160) ); _GetClanTag = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 168) ); _GetClanActivityCounts = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 176) ); _DownloadClanActivityCounts = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 184) ); _GetFriendCountFromSource = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 192) ); _GetFriendFromSourceByIndex = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 200) ); + _GetFriendFromSourceByIndex_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 200) ); _IsUserInSource = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 208) ); _SetInGameVoiceSpeaking = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 216) ); _ActivateGameOverlay = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 224) ); @@ -57,8 +60,10 @@ namespace Steamworks _RequestUserInformation = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 296) ); _RequestClanOfficerList = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 304) ); _GetClanOwner = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 312) ); + _GetClanOwner_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 312) ); _GetClanOfficerCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 320) ); _GetClanOfficerByIndex = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 328) ); + _GetClanOfficerByIndex_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 328) ); _GetUserRestrictions = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 336) ); _SetRichPresence = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 344) ); _ClearRichPresence = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 352) ); @@ -69,12 +74,14 @@ namespace Steamworks _InviteUserToGame = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 392) ); _GetCoplayFriendCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 400) ); _GetCoplayFriend = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 408) ); + _GetCoplayFriend_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 408) ); _GetFriendCoplayTime = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 416) ); _GetFriendCoplayGame = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 424) ); _JoinClanChatRoom = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 432) ); _LeaveClanChatRoom = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 440) ); _GetClanChatMemberCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 448) ); _GetChatMemberByIndex = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 456) ); + _GetChatMemberByIndex_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 456) ); _SendClanChatMessage = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 464) ); _GetClanChatMessage = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 472) ); _IsClanChatAdmin = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 480) ); @@ -138,15 +145,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetFriendByIndex( IntPtr self, ref SteamId retVal, int iFriend, int iFriendFlags ); + private delegate SteamId FGetFriendByIndex( IntPtr self, int iFriend, int iFriendFlags ); private FGetFriendByIndex _GetFriendByIndex; + private delegate void FGetFriendByIndex_Windows( IntPtr self, ref SteamId retVal, int iFriend, int iFriendFlags ); + private FGetFriendByIndex_Windows _GetFriendByIndex_Windows; #endregion internal SteamId GetFriendByIndex( int iFriend, int iFriendFlags ) { - var retVal = default( SteamId ); - _GetFriendByIndex( Self, ref retVal, iFriend, iFriendFlags ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetFriendByIndex_Windows( Self, ref retVal, iFriend, iFriendFlags ); + return retVal; + } + + return _GetFriendByIndex( Self, iFriend, iFriendFlags ); } #region FunctionMeta @@ -307,15 +321,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetClanByIndex( IntPtr self, ref SteamId retVal, int iClan ); + private delegate SteamId FGetClanByIndex( IntPtr self, int iClan ); private FGetClanByIndex _GetClanByIndex; + private delegate void FGetClanByIndex_Windows( IntPtr self, ref SteamId retVal, int iClan ); + private FGetClanByIndex_Windows _GetClanByIndex_Windows; #endregion internal SteamId GetClanByIndex( int iClan ) { - var retVal = default( SteamId ); - _GetClanByIndex( Self, ref retVal, iClan ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetClanByIndex_Windows( Self, ref retVal, iClan ); + return retVal; + } + + return _GetClanByIndex( Self, iClan ); } #region FunctionMeta @@ -376,15 +397,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetFriendFromSourceByIndex( IntPtr self, ref SteamId retVal, SteamId steamIDSource, int iFriend ); + private delegate SteamId FGetFriendFromSourceByIndex( IntPtr self, SteamId steamIDSource, int iFriend ); private FGetFriendFromSourceByIndex _GetFriendFromSourceByIndex; + private delegate void FGetFriendFromSourceByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDSource, int iFriend ); + private FGetFriendFromSourceByIndex_Windows _GetFriendFromSourceByIndex_Windows; #endregion internal SteamId GetFriendFromSourceByIndex( SteamId steamIDSource, int iFriend ) { - var retVal = default( SteamId ); - _GetFriendFromSourceByIndex( Self, ref retVal, steamIDSource, iFriend ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetFriendFromSourceByIndex_Windows( Self, ref retVal, steamIDSource, iFriend ); + return retVal; + } + + return _GetFriendFromSourceByIndex( Self, steamIDSource, iFriend ); } #region FunctionMeta @@ -534,15 +562,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetClanOwner( IntPtr self, ref SteamId retVal, SteamId steamIDClan ); + private delegate SteamId FGetClanOwner( IntPtr self, SteamId steamIDClan ); private FGetClanOwner _GetClanOwner; + private delegate void FGetClanOwner_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDClan ); + private FGetClanOwner_Windows _GetClanOwner_Windows; #endregion internal SteamId GetClanOwner( SteamId steamIDClan ) { - var retVal = default( SteamId ); - _GetClanOwner( Self, ref retVal, steamIDClan ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetClanOwner_Windows( Self, ref retVal, steamIDClan ); + return retVal; + } + + return _GetClanOwner( Self, steamIDClan ); } #region FunctionMeta @@ -558,15 +593,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetClanOfficerByIndex( IntPtr self, ref SteamId retVal, SteamId steamIDClan, int iOfficer ); + private delegate SteamId FGetClanOfficerByIndex( IntPtr self, SteamId steamIDClan, int iOfficer ); private FGetClanOfficerByIndex _GetClanOfficerByIndex; + private delegate void FGetClanOfficerByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDClan, int iOfficer ); + private FGetClanOfficerByIndex_Windows _GetClanOfficerByIndex_Windows; #endregion internal SteamId GetClanOfficerByIndex( SteamId steamIDClan, int iOfficer ) { - var retVal = default( SteamId ); - _GetClanOfficerByIndex( Self, ref retVal, steamIDClan, iOfficer ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetClanOfficerByIndex_Windows( Self, ref retVal, steamIDClan, iOfficer ); + return retVal; + } + + return _GetClanOfficerByIndex( Self, steamIDClan, iOfficer ); } #region FunctionMeta @@ -672,15 +714,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetCoplayFriend( IntPtr self, ref SteamId retVal, int iCoplayFriend ); + private delegate SteamId FGetCoplayFriend( IntPtr self, int iCoplayFriend ); private FGetCoplayFriend _GetCoplayFriend; + private delegate void FGetCoplayFriend_Windows( IntPtr self, ref SteamId retVal, int iCoplayFriend ); + private FGetCoplayFriend_Windows _GetCoplayFriend_Windows; #endregion internal SteamId GetCoplayFriend( int iCoplayFriend ) { - var retVal = default( SteamId ); - _GetCoplayFriend( Self, ref retVal, iCoplayFriend ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetCoplayFriend_Windows( Self, ref retVal, iCoplayFriend ); + return retVal; + } + + return _GetCoplayFriend( Self, iCoplayFriend ); } #region FunctionMeta @@ -741,15 +790,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetChatMemberByIndex( IntPtr self, ref SteamId retVal, SteamId steamIDClan, int iUser ); + private delegate SteamId FGetChatMemberByIndex( IntPtr self, SteamId steamIDClan, int iUser ); private FGetChatMemberByIndex _GetChatMemberByIndex; + private delegate void FGetChatMemberByIndex_Windows( IntPtr self, ref SteamId retVal, SteamId steamIDClan, int iUser ); + private FGetChatMemberByIndex_Windows _GetChatMemberByIndex_Windows; #endregion internal SteamId GetChatMemberByIndex( SteamId steamIDClan, int iUser ) { - var retVal = default( SteamId ); - _GetChatMemberByIndex( Self, ref retVal, steamIDClan, iUser ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetChatMemberByIndex_Windows( Self, ref retVal, steamIDClan, iUser ); + return retVal; + } + + return _GetChatMemberByIndex( Self, steamIDClan, iUser ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs index db98f8b..1df0c81 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamGameServer.cs @@ -28,6 +28,7 @@ namespace Steamworks _BLoggedOn = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 64) ); _BSecure = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 72) ); _GetSteamID = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 80) ); + _GetSteamID_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 80) ); _WasRestartRequested = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 88) ); _SetMaxPlayerCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 96) ); _SetBotPlayerCount = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 104) ); @@ -43,6 +44,7 @@ namespace Steamworks _SetRegion = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 184) ); _SendUserConnectAndAuthenticate = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 192) ); _CreateUnauthenticatedUserConnection = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 200) ); + _CreateUnauthenticatedUserConnection_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 200) ); _SendUserDisconnect = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 208) ); _BUpdateUserData = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 216) ); _GetAuthSessionTicket = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 224) ); @@ -178,15 +180,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetSteamID( IntPtr self, ref SteamId retVal ); + private delegate SteamId FGetSteamID( IntPtr self ); private FGetSteamID _GetSteamID; + private delegate void FGetSteamID_Windows( IntPtr self, ref SteamId retVal ); + private FGetSteamID_Windows _GetSteamID_Windows; #endregion internal SteamId GetSteamID() { - var retVal = default( SteamId ); - _GetSteamID( Self, ref retVal ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetSteamID_Windows( Self, ref retVal ); + return retVal; + } + + return _GetSteamID( Self ); } #region FunctionMeta @@ -347,15 +356,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FCreateUnauthenticatedUserConnection( IntPtr self, ref SteamId retVal ); + private delegate SteamId FCreateUnauthenticatedUserConnection( IntPtr self ); private FCreateUnauthenticatedUserConnection _CreateUnauthenticatedUserConnection; + private delegate void FCreateUnauthenticatedUserConnection_Windows( IntPtr self, ref SteamId retVal ); + private FCreateUnauthenticatedUserConnection_Windows _CreateUnauthenticatedUserConnection_Windows; #endregion internal SteamId CreateUnauthenticatedUserConnection() { - var retVal = default( SteamId ); - _CreateUnauthenticatedUserConnection( Self, ref retVal ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _CreateUnauthenticatedUserConnection_Windows( Self, ref retVal ); + return retVal; + } + + return _CreateUnauthenticatedUserConnection( Self ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs index f2ef301..affd6eb 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUser.cs @@ -20,6 +20,7 @@ namespace Steamworks _GetHSteamUser = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 0) ); _BLoggedOn = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 8) ); _GetSteamID = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16) ); + _GetSteamID_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 16) ); _InitiateGameConnection = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 24) ); _TerminateGameConnection = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 32) ); _TrackAppUsageEvent = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, 40) ); @@ -74,15 +75,22 @@ namespace Steamworks #region FunctionMeta [UnmanagedFunctionPointer( CallingConvention.ThisCall )] - private delegate void FGetSteamID( IntPtr self, ref SteamId retVal ); + private delegate SteamId FGetSteamID( IntPtr self ); private FGetSteamID _GetSteamID; + private delegate void FGetSteamID_Windows( IntPtr self, ref SteamId retVal ); + private FGetSteamID_Windows _GetSteamID_Windows; #endregion internal SteamId GetSteamID() { - var retVal = default( SteamId ); - _GetSteamID( Self, ref retVal ); - return retVal; + if ( Config.Os == OsType.Windows ) + { + var retVal = default( SteamId ); + _GetSteamID_Windows( Self, ref retVal ); + return retVal; + } + + return _GetSteamID( Self ); } #region FunctionMeta diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index c52a6ac..a441d14 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -361,7 +361,7 @@ namespace Steamworks /// /// We have received a server query on our game port. Pass it to Steam to handle. /// - public static unsafe void HandleIncomingPacket( byte[] data, int size, uint address, ushort port ) + public static unsafe void HandleIncomingPacket( byte[] data, int size, uint address, ushort port ) { fixed ( byte* ptr = data ) { diff --git a/Generator/CodeWriter/ClassVTable.cs b/Generator/CodeWriter/ClassVTable.cs index 8547aa6..90aa9c0 100644 --- a/Generator/CodeWriter/ClassVTable.cs +++ b/Generator/CodeWriter/ClassVTable.cs @@ -95,6 +95,7 @@ namespace Generator for (int i=0; i< clss.Functions.Count; i++ ) { var func = clss.Functions[i]; + var returnType = BaseType.Parse( func.ReturnType ); if ( Cleanup.IsDeprecated( $"{clss.Name}.{func.Name}" ) ) { @@ -103,6 +104,11 @@ namespace Generator else { WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {locations[i]}) );" ); + + if ( returnType.IsReturnedWeird ) + { + WriteLine( $"_{func.Name}_Windows = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {locations[i]}) );" ); + } } } } @@ -134,12 +140,6 @@ namespace Generator var argstr = string.Join( ", ", args.Select( x => x.AsArgument() ) ); var delegateargstr = string.Join( ", ", args.Select( x => x.AsArgument() ) ); - if ( returnType.IsReturnedWeird ) - { - delegateargstr = $"ref {returnType.TypeName} retVal, {delegateargstr}"; - delegateargstr = delegateargstr.Trim( ',', ' ' ); - } - if ( returnType is SteamApiCallType sap ) { sap.CallResult = func.CallResult; @@ -152,8 +152,17 @@ namespace Generator if ( returnType.ReturnAttribute != null) WriteLine( returnType.ReturnAttribute ); - WriteLine( $"private delegate {(returnType.IsReturnedWeird?"void":returnType.TypeNameFrom)} F{func.Name}( IntPtr self, {delegateargstr} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) ); + WriteLine( $"private delegate {returnType.TypeNameFrom} F{func.Name}( IntPtr self, {delegateargstr} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) ); WriteLine( $"private F{func.Name} _{func.Name};" ); + + if ( returnType.IsReturnedWeird ) + { + var windelargs = $"ref {returnType.TypeName} retVal, {delegateargstr}".Trim( ',', ' ' ); + + WriteLine( $"private delegate void F{func.Name}_Windows( IntPtr self, {windelargs} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) ); + WriteLine( $"private F{func.Name}_Windows _{func.Name}_Windows;" ); + } + WriteLine(); WriteLine( $"#endregion" ); @@ -163,11 +172,17 @@ namespace Generator if ( returnType.IsReturnedWeird ) { - WriteLine( $"var retVal = default( {returnType.TypeName} );" ); - WriteLine( $"_{func.Name}( Self, ref retVal, {callargs} );".Replace( ", );", " );" ) ); - WriteLine( $"{returnType.Return( "retVal" )}" ); + StartBlock( "if ( Config.Os == OsType.Windows )" ); + { + WriteLine( $"var retVal = default( {returnType.TypeName} );" ); + WriteLine( $"_{func.Name}_Windows( Self, ref retVal, {callargs} );".Replace( ", );", " );" ) ); + WriteLine( $"{returnType.Return( "retVal" )}" ); + } + EndBlock(); + WriteLine(); } - else if ( returnType.IsVoid ) + + if ( returnType.IsVoid ) { WriteLine( $"_{func.Name}( Self, {callargs} );".Replace( "( Self, )", "( Self )" ) ); }