From cbc154da665e4aaa4e4a4426fb5838a589a1ca58 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 30 Apr 2019 13:01:30 +0100 Subject: [PATCH] We can treat mac and linux as the same os --- Facepunch.Steamworks/Config.cs | 7 ++-- Facepunch.Steamworks/Generated/SteamApi.cs | 42 +++++++++---------- .../Generated/SteamGameServer.cs | 18 ++++---- .../Generated/SteamInternal.cs | 18 ++++---- Generator/CodeWriter/ClassVTable.cs | 1 - Generator/CodeWriter/GlobalFunctions.cs | 10 ++--- 6 files changed, 47 insertions(+), 49 deletions(-) diff --git a/Facepunch.Steamworks/Config.cs b/Facepunch.Steamworks/Config.cs index 42b126b..4b0dc7d 100644 --- a/Facepunch.Steamworks/Config.cs +++ b/Facepunch.Steamworks/Config.cs @@ -19,11 +19,11 @@ public static OsType Os } else if ( File.Exists( @"/System/Library/CoreServices/SystemVersion.plist" ) ) { - _os = OsType.MacOs; + _os = OsType.Posix; } else if ( File.Exists( @"/proc/sys/kernel/ostype" ) ) { - _os = OsType.Linux; + _os = OsType.Posix; } else { @@ -55,7 +55,6 @@ public enum OsType { None, Windows, - Linux, - MacOs, + Posix, } } diff --git a/Facepunch.Steamworks/Generated/SteamApi.cs b/Facepunch.Steamworks/Generated/SteamApi.cs index 6c154d7..43f2367 100644 --- a/Facepunch.Steamworks/Generated/SteamApi.cs +++ b/Facepunch.Steamworks/Generated/SteamApi.cs @@ -44,7 +44,7 @@ internal static class Win64 public static extern bool SteamAPI_RestartAppIfNecessary( uint unOwnAppID ); } - internal static class MacOs + internal static class Posix { [DllImport( "libsteam_api", EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )] [return: MarshalAs( UnmanagedType.I1 )] @@ -85,9 +85,9 @@ static internal bool Init() { return Win64.SteamAPI_Init(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamAPI_Init(); + return Posix.SteamAPI_Init(); } else { @@ -101,9 +101,9 @@ static internal void RunCallbacks() { Win64.SteamAPI_RunCallbacks(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamAPI_RunCallbacks(); + Posix.SteamAPI_RunCallbacks(); } else { @@ -117,9 +117,9 @@ static internal void RegisterCallback( IntPtr pCallback, int callback ) { Win64.SteamAPI_RegisterCallback( pCallback, callback ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamAPI_RegisterCallback( pCallback, callback ); + Posix.SteamAPI_RegisterCallback( pCallback, callback ); } else { @@ -133,9 +133,9 @@ static internal void UnregisterCallback( IntPtr pCallback ) { Win64.SteamAPI_UnregisterCallback( pCallback ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamAPI_UnregisterCallback( pCallback ); + Posix.SteamAPI_UnregisterCallback( pCallback ); } else { @@ -149,9 +149,9 @@ static internal void RegisterCallResult( IntPtr pCallback, SteamAPICall_t callba { Win64.SteamAPI_RegisterCallResult( pCallback, callback ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamAPI_RegisterCallResult( pCallback, callback ); + Posix.SteamAPI_RegisterCallResult( pCallback, callback ); } else { @@ -165,9 +165,9 @@ static internal void UnregisterCallResult( IntPtr pCallback, SteamAPICall_t call { Win64.SteamAPI_UnregisterCallResult( pCallback, callback ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamAPI_UnregisterCallResult( pCallback, callback ); + Posix.SteamAPI_UnregisterCallResult( pCallback, callback ); } else { @@ -181,9 +181,9 @@ static internal void Shutdown() { Win64.SteamAPI_Shutdown(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamAPI_Shutdown(); + Posix.SteamAPI_Shutdown(); } else { @@ -197,9 +197,9 @@ static internal HSteamUser GetHSteamUser() { return Win64.SteamAPI_GetHSteamUser(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamAPI_GetHSteamUser(); + return Posix.SteamAPI_GetHSteamUser(); } else { @@ -213,9 +213,9 @@ static internal HSteamPipe GetHSteamPipe() { return Win64.SteamAPI_GetHSteamPipe(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamAPI_GetHSteamPipe(); + return Posix.SteamAPI_GetHSteamPipe(); } else { @@ -229,9 +229,9 @@ static internal bool RestartAppIfNecessary( uint unOwnAppID ) { return Win64.SteamAPI_RestartAppIfNecessary( unOwnAppID ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamAPI_RestartAppIfNecessary( unOwnAppID ); + return Posix.SteamAPI_RestartAppIfNecessary( unOwnAppID ); } else { diff --git a/Facepunch.Steamworks/Generated/SteamGameServer.cs b/Facepunch.Steamworks/Generated/SteamGameServer.cs index 12636c3..26ee636 100644 --- a/Facepunch.Steamworks/Generated/SteamGameServer.cs +++ b/Facepunch.Steamworks/Generated/SteamGameServer.cs @@ -24,7 +24,7 @@ internal static class Win64 public static extern HSteamPipe SteamGameServer_GetHSteamPipe(); } - internal static class MacOs + internal static class Posix { [DllImport( "libsteam_api", EntryPoint = "SteamGameServer_RunCallbacks", CallingConvention = CallingConvention.Cdecl )] public static extern void SteamGameServer_RunCallbacks(); @@ -45,9 +45,9 @@ static internal void RunCallbacks() { Win64.SteamGameServer_RunCallbacks(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamGameServer_RunCallbacks(); + Posix.SteamGameServer_RunCallbacks(); } else { @@ -61,9 +61,9 @@ static internal void Shutdown() { Win64.SteamGameServer_Shutdown(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - MacOs.SteamGameServer_Shutdown(); + Posix.SteamGameServer_Shutdown(); } else { @@ -77,9 +77,9 @@ static internal HSteamUser GetHSteamUser() { return Win64.SteamGameServer_GetHSteamUser(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamGameServer_GetHSteamUser(); + return Posix.SteamGameServer_GetHSteamUser(); } else { @@ -93,9 +93,9 @@ static internal HSteamPipe GetHSteamPipe() { return Win64.SteamGameServer_GetHSteamPipe(); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamGameServer_GetHSteamPipe(); + return Posix.SteamGameServer_GetHSteamPipe(); } else { diff --git a/Facepunch.Steamworks/Generated/SteamInternal.cs b/Facepunch.Steamworks/Generated/SteamInternal.cs index 8771135..5fb432a 100644 --- a/Facepunch.Steamworks/Generated/SteamInternal.cs +++ b/Facepunch.Steamworks/Generated/SteamInternal.cs @@ -25,7 +25,7 @@ internal static class Win64 public static extern IntPtr SteamInternal_CreateInterface( string version ); } - internal static class MacOs + internal static class Posix { [DllImport( "libsteam_api", EntryPoint = "SteamInternal_GameServer_Init", CallingConvention = CallingConvention.Cdecl )] [return: MarshalAs( UnmanagedType.I1 )] @@ -47,9 +47,9 @@ static internal bool GameServer_Init( uint unIP, ushort usPort, ushort usGamePor { return Win64.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString ); + return Posix.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString ); } else { @@ -63,9 +63,9 @@ static internal IntPtr FindOrCreateUserInterface( int steamuser, string versionn { return Win64.SteamInternal_FindOrCreateUserInterface( steamuser, versionname ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamInternal_FindOrCreateUserInterface( steamuser, versionname ); + return Posix.SteamInternal_FindOrCreateUserInterface( steamuser, versionname ); } else { @@ -79,9 +79,9 @@ static internal IntPtr FindOrCreateGameServerInterface( int steamuser, string ve { return Win64.SteamInternal_FindOrCreateGameServerInterface( steamuser, versionname ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamInternal_FindOrCreateGameServerInterface( steamuser, versionname ); + return Posix.SteamInternal_FindOrCreateGameServerInterface( steamuser, versionname ); } else { @@ -95,9 +95,9 @@ static internal IntPtr CreateInterface( string version ) { return Win64.SteamInternal_CreateInterface( version ); } - else if ( Config.Os == OsType.MacOs ) + else if ( Config.Os == OsType.Posix ) { - return MacOs.SteamInternal_CreateInterface( version ); + return Posix.SteamInternal_CreateInterface( version ); } else { diff --git a/Generator/CodeWriter/ClassVTable.cs b/Generator/CodeWriter/ClassVTable.cs index 4f575b1..e392fd7 100644 --- a/Generator/CodeWriter/ClassVTable.cs +++ b/Generator/CodeWriter/ClassVTable.cs @@ -112,7 +112,6 @@ void WriteFunctionPointerReader( CodeParser.Class clss ) } else { - WriteLine( $"_{func.Name} = Marshal.GetDelegateForFunctionPointer( Marshal.ReadIntPtr( VTable, {locations[i]}) );" ); if ( returnType.IsReturnedWeird ) diff --git a/Generator/CodeWriter/GlobalFunctions.cs b/Generator/CodeWriter/GlobalFunctions.cs index d25f418..c99085c 100644 --- a/Generator/CodeWriter/GlobalFunctions.cs +++ b/Generator/CodeWriter/GlobalFunctions.cs @@ -36,7 +36,7 @@ public void GenerateGlobalFunctions( string startingWith, string filename ) } EndBlock(); - StartBlock( $"internal static class MacOs" ); + StartBlock( $"internal static class Posix" ); { foreach ( var func in functions ) { @@ -107,21 +107,21 @@ private void WriteGlobalFunction( string cname, SteamApiDefinition.MethodDef fun WriteLine( returnType.Return( v ) ); } } - Else( " if ( Config.Os == OsType.MacOs )" ); + Else( " if ( Config.Os == OsType.Posix )" ); { if ( returnType.IsReturnedWeird ) { WriteLine( $"var retVal = default( {returnType.TypeName} );" ); - WriteLine( $"MacOs.{func.Name}( ref retVal, {callargs} );" ); + WriteLine( $"Posix.{func.Name}( ref retVal, {callargs} );" ); WriteLine( $"{returnType.Return( "retVal" )}" ); } else if ( returnType.IsVoid ) { - WriteLine( $"MacOs.{func.Name}( {callargs} );" ); + WriteLine( $"Posix.{func.Name}( {callargs} );" ); } else { - var v = $"MacOs.{func.Name}( {callargs} )"; + var v = $"Posix.{func.Name}( {callargs} )"; WriteLine( returnType.Return( v ) ); }