mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Start fumbling the actual vtable instead of the flat functions
This commit is contained in:
parent
d7a546d913
commit
96df72c291
@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AssemblyName>Facepunch.Steamworks</AssemblyName>
|
||||
|
||||
@ -41,6 +41,10 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Generated\Interfaces\" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net40'">C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client</FrameworkPathOverride>
|
||||
|
367
Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs
Normal file
367
Facepunch.Steamworks/Generated/Interfaces/ISteamApps.cs
Normal file
@ -0,0 +1,367 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using SteamNative;
|
||||
|
||||
|
||||
namespace Steamworks.Internal
|
||||
{
|
||||
public class ISteamApps : BaseSteamInterface
|
||||
{
|
||||
public override void InitInternals()
|
||||
{
|
||||
BIsSubscribedDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsSubscribedDelegate>( Marshal.ReadIntPtr( VTable, 0) );
|
||||
BIsLowViolenceDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsLowViolenceDelegate>( Marshal.ReadIntPtr( VTable, 8) );
|
||||
BIsCybercafeDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsCybercafeDelegate>( Marshal.ReadIntPtr( VTable, 16) );
|
||||
BIsVACBannedDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsVACBannedDelegate>( Marshal.ReadIntPtr( VTable, 24) );
|
||||
GetCurrentGameLanguageDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetCurrentGameLanguageDelegate>( Marshal.ReadIntPtr( VTable, 32) );
|
||||
GetAvailableGameLanguagesDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAvailableGameLanguagesDelegate>( Marshal.ReadIntPtr( VTable, 40) );
|
||||
BIsSubscribedAppDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsSubscribedAppDelegate>( Marshal.ReadIntPtr( VTable, 48) );
|
||||
BIsDlcInstalledDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsDlcInstalledDelegate>( Marshal.ReadIntPtr( VTable, 56) );
|
||||
GetEarliestPurchaseUnixTimeDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetEarliestPurchaseUnixTimeDelegate>( Marshal.ReadIntPtr( VTable, 64) );
|
||||
BIsSubscribedFromFreeWeekendDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsSubscribedFromFreeWeekendDelegate>( Marshal.ReadIntPtr( VTable, 72) );
|
||||
GetDLCCountDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetDLCCountDelegate>( Marshal.ReadIntPtr( VTable, 80) );
|
||||
BGetDLCDataByIndexDelegatePointer = Marshal.GetDelegateForFunctionPointer<BGetDLCDataByIndexDelegate>( Marshal.ReadIntPtr( VTable, 88) );
|
||||
InstallDLCDelegatePointer = Marshal.GetDelegateForFunctionPointer<InstallDLCDelegate>( Marshal.ReadIntPtr( VTable, 96) );
|
||||
UninstallDLCDelegatePointer = Marshal.GetDelegateForFunctionPointer<UninstallDLCDelegate>( Marshal.ReadIntPtr( VTable, 104) );
|
||||
RequestAppProofOfPurchaseKeyDelegatePointer = Marshal.GetDelegateForFunctionPointer<RequestAppProofOfPurchaseKeyDelegate>( Marshal.ReadIntPtr( VTable, 112) );
|
||||
GetCurrentBetaNameDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetCurrentBetaNameDelegate>( Marshal.ReadIntPtr( VTable, 120) );
|
||||
MarkContentCorruptDelegatePointer = Marshal.GetDelegateForFunctionPointer<MarkContentCorruptDelegate>( Marshal.ReadIntPtr( VTable, 128) );
|
||||
GetInstalledDepotsDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetInstalledDepotsDelegate>( Marshal.ReadIntPtr( VTable, 136) );
|
||||
GetAppInstallDirDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAppInstallDirDelegate>( Marshal.ReadIntPtr( VTable, 144) );
|
||||
BIsAppInstalledDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsAppInstalledDelegate>( Marshal.ReadIntPtr( VTable, 152) );
|
||||
GetAppOwnerDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAppOwnerDelegate>( Marshal.ReadIntPtr( VTable, 160) );
|
||||
GetLaunchQueryParamDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetLaunchQueryParamDelegate>( Marshal.ReadIntPtr( VTable, 168) );
|
||||
GetDlcDownloadProgressDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetDlcDownloadProgressDelegate>( Marshal.ReadIntPtr( VTable, 176) );
|
||||
GetAppBuildIdDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetAppBuildIdDelegate>( Marshal.ReadIntPtr( VTable, 184) );
|
||||
RequestAllProofOfPurchaseKeysDelegatePointer = Marshal.GetDelegateForFunctionPointer<RequestAllProofOfPurchaseKeysDelegate>( Marshal.ReadIntPtr( VTable, 192) );
|
||||
GetFileDetailsDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetFileDetailsDelegate>( Marshal.ReadIntPtr( VTable, 200) );
|
||||
GetLaunchCommandLineDelegatePointer = Marshal.GetDelegateForFunctionPointer<GetLaunchCommandLineDelegate>( Marshal.ReadIntPtr( VTable, 208) );
|
||||
BIsSubscribedFromFamilySharingDelegatePointer = Marshal.GetDelegateForFunctionPointer<BIsSubscribedFromFamilySharingDelegate>( Marshal.ReadIntPtr( VTable, 216) );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsSubscribedDelegate( IntPtr self );
|
||||
private BIsSubscribedDelegate BIsSubscribedDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsSubscribed()
|
||||
{
|
||||
return BIsSubscribedDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsLowViolenceDelegate( IntPtr self );
|
||||
private BIsLowViolenceDelegate BIsLowViolenceDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsLowViolence()
|
||||
{
|
||||
return BIsLowViolenceDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsCybercafeDelegate( IntPtr self );
|
||||
private BIsCybercafeDelegate BIsCybercafeDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsCybercafe()
|
||||
{
|
||||
return BIsCybercafeDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsVACBannedDelegate( IntPtr self );
|
||||
private BIsVACBannedDelegate BIsVACBannedDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsVACBanned()
|
||||
{
|
||||
return BIsVACBannedDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate IntPtr GetCurrentGameLanguageDelegate( IntPtr self );
|
||||
private GetCurrentGameLanguageDelegate GetCurrentGameLanguageDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public string GetCurrentGameLanguage()
|
||||
{
|
||||
return GetString( GetCurrentGameLanguageDelegatePointer( Self ) );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate IntPtr GetAvailableGameLanguagesDelegate( IntPtr self );
|
||||
private GetAvailableGameLanguagesDelegate GetAvailableGameLanguagesDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public string GetAvailableGameLanguages()
|
||||
{
|
||||
return GetString( GetAvailableGameLanguagesDelegatePointer( Self ) );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsSubscribedAppDelegate( IntPtr self, AppId_t appID );
|
||||
private BIsSubscribedAppDelegate BIsSubscribedAppDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsSubscribedApp( AppId_t appID )
|
||||
{
|
||||
return BIsSubscribedAppDelegatePointer( Self, appID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsDlcInstalledDelegate( IntPtr self, AppId_t appID );
|
||||
private BIsDlcInstalledDelegate BIsDlcInstalledDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsDlcInstalled( AppId_t appID )
|
||||
{
|
||||
return BIsDlcInstalledDelegatePointer( Self, appID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate uint GetEarliestPurchaseUnixTimeDelegate( IntPtr self, AppId_t nAppID );
|
||||
private GetEarliestPurchaseUnixTimeDelegate GetEarliestPurchaseUnixTimeDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public uint GetEarliestPurchaseUnixTime( AppId_t nAppID )
|
||||
{
|
||||
return GetEarliestPurchaseUnixTimeDelegatePointer( Self, nAppID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsSubscribedFromFreeWeekendDelegate( IntPtr self );
|
||||
private BIsSubscribedFromFreeWeekendDelegate BIsSubscribedFromFreeWeekendDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsSubscribedFromFreeWeekend()
|
||||
{
|
||||
return BIsSubscribedFromFreeWeekendDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate int GetDLCCountDelegate( IntPtr self );
|
||||
private GetDLCCountDelegate GetDLCCountDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public int GetDLCCount()
|
||||
{
|
||||
return GetDLCCountDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BGetDLCDataByIndexDelegate( IntPtr self, int iDLC, ref AppId_t pAppID, [MarshalAs( UnmanagedType.U1 )] ref bool pbAvailable, StringBuilder pchName, int cchNameBufferSize );
|
||||
private BGetDLCDataByIndexDelegate BGetDLCDataByIndexDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BGetDLCDataByIndex( int iDLC, ref AppId_t pAppID, [MarshalAs( UnmanagedType.U1 )] ref bool pbAvailable, StringBuilder pchName, int cchNameBufferSize )
|
||||
{
|
||||
return BGetDLCDataByIndexDelegatePointer( Self, iDLC, ref pAppID, ref pbAvailable, pchName, cchNameBufferSize );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate void InstallDLCDelegate( IntPtr self, AppId_t nAppID );
|
||||
private InstallDLCDelegate InstallDLCDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public void InstallDLC( AppId_t nAppID )
|
||||
{
|
||||
InstallDLCDelegatePointer( Self, nAppID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate void UninstallDLCDelegate( IntPtr self, AppId_t nAppID );
|
||||
private UninstallDLCDelegate UninstallDLCDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public void UninstallDLC( AppId_t nAppID )
|
||||
{
|
||||
UninstallDLCDelegatePointer( Self, nAppID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate void RequestAppProofOfPurchaseKeyDelegate( IntPtr self, AppId_t nAppID );
|
||||
private RequestAppProofOfPurchaseKeyDelegate RequestAppProofOfPurchaseKeyDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public void RequestAppProofOfPurchaseKey( AppId_t nAppID )
|
||||
{
|
||||
RequestAppProofOfPurchaseKeyDelegatePointer( Self, nAppID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool GetCurrentBetaNameDelegate( IntPtr self, StringBuilder pchName, int cchNameBufferSize );
|
||||
private GetCurrentBetaNameDelegate GetCurrentBetaNameDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool GetCurrentBetaName( StringBuilder pchName, int cchNameBufferSize )
|
||||
{
|
||||
return GetCurrentBetaNameDelegatePointer( Self, pchName, cchNameBufferSize );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool MarkContentCorruptDelegate( IntPtr self, [MarshalAs( UnmanagedType.U1 )] bool bMissingFilesOnly );
|
||||
private MarkContentCorruptDelegate MarkContentCorruptDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool MarkContentCorrupt( [MarshalAs( UnmanagedType.U1 )] bool bMissingFilesOnly )
|
||||
{
|
||||
return MarkContentCorruptDelegatePointer( Self, bMissingFilesOnly );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate uint GetInstalledDepotsDelegate( IntPtr self, AppId_t appID, ref DepotId_t pvecDepots, uint cMaxDepots );
|
||||
private GetInstalledDepotsDelegate GetInstalledDepotsDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public uint GetInstalledDepots( AppId_t appID, ref DepotId_t pvecDepots, uint cMaxDepots )
|
||||
{
|
||||
return GetInstalledDepotsDelegatePointer( Self, appID, ref pvecDepots, cMaxDepots );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate uint GetAppInstallDirDelegate( IntPtr self, AppId_t appID, StringBuilder pchFolder, uint cchFolderBufferSize );
|
||||
private GetAppInstallDirDelegate GetAppInstallDirDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public uint GetAppInstallDir( AppId_t appID, StringBuilder pchFolder, uint cchFolderBufferSize )
|
||||
{
|
||||
return GetAppInstallDirDelegatePointer( Self, appID, pchFolder, cchFolderBufferSize );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsAppInstalledDelegate( IntPtr self, AppId_t appID );
|
||||
private BIsAppInstalledDelegate BIsAppInstalledDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsAppInstalled( AppId_t appID )
|
||||
{
|
||||
return BIsAppInstalledDelegatePointer( Self, appID );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate void GetAppOwnerDelegate( IntPtr self, ref CSteamID retVal );
|
||||
private GetAppOwnerDelegate GetAppOwnerDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public CSteamID GetAppOwner()
|
||||
{
|
||||
var retVal = default( CSteamID );
|
||||
GetAppOwnerDelegatePointer( Self, ref retVal );
|
||||
return retVal;
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate IntPtr GetLaunchQueryParamDelegate( IntPtr self, string pchKey );
|
||||
private GetLaunchQueryParamDelegate GetLaunchQueryParamDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public string GetLaunchQueryParam( string pchKey )
|
||||
{
|
||||
return GetString( GetLaunchQueryParamDelegatePointer( Self, pchKey ) );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool GetDlcDownloadProgressDelegate( IntPtr self, AppId_t nAppID, ref ulong punBytesDownloaded, ref ulong punBytesTotal );
|
||||
private GetDlcDownloadProgressDelegate GetDlcDownloadProgressDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool GetDlcDownloadProgress( AppId_t nAppID, ref ulong punBytesDownloaded, ref ulong punBytesTotal )
|
||||
{
|
||||
return GetDlcDownloadProgressDelegatePointer( Self, nAppID, ref punBytesDownloaded, ref punBytesTotal );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate int GetAppBuildIdDelegate( IntPtr self );
|
||||
private GetAppBuildIdDelegate GetAppBuildIdDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public int GetAppBuildId()
|
||||
{
|
||||
return GetAppBuildIdDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate void RequestAllProofOfPurchaseKeysDelegate( IntPtr self );
|
||||
private RequestAllProofOfPurchaseKeysDelegate RequestAllProofOfPurchaseKeysDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public void RequestAllProofOfPurchaseKeys()
|
||||
{
|
||||
RequestAllProofOfPurchaseKeysDelegatePointer( Self );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate SteamAPICall_t GetFileDetailsDelegate( IntPtr self, string pszFileName );
|
||||
private GetFileDetailsDelegate GetFileDetailsDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public SteamAPICall_t GetFileDetails( string pszFileName )
|
||||
{
|
||||
return GetFileDetailsDelegatePointer( Self, pszFileName );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
public delegate int GetLaunchCommandLineDelegate( IntPtr self, StringBuilder pszCommandLine, int cubCommandLine );
|
||||
private GetLaunchCommandLineDelegate GetLaunchCommandLineDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public int GetLaunchCommandLine( StringBuilder pszCommandLine, int cubCommandLine )
|
||||
{
|
||||
return GetLaunchCommandLineDelegatePointer( Self, pszCommandLine, cubCommandLine );
|
||||
}
|
||||
|
||||
#region FunctionMeta
|
||||
[UnmanagedFunctionPointer( CallingConvention.ThisCall )]
|
||||
[return: MarshalAs( UnmanagedType.I1 )]
|
||||
public delegate bool BIsSubscribedFromFamilySharingDelegate( IntPtr self );
|
||||
private BIsSubscribedFromFamilySharingDelegate BIsSubscribedFromFamilySharingDelegatePointer;
|
||||
|
||||
#endregion
|
||||
public bool BIsSubscribedFromFamilySharing()
|
||||
{
|
||||
return BIsSubscribedFromFamilySharingDelegatePointer( Self );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
16
Facepunch.Steamworks/Generated/SteamApi.cs
Normal file
16
Facepunch.Steamworks/Generated/SteamApi.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
||||
public static class SteamApi
|
||||
{
|
||||
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )]
|
||||
[return: MarshalAs( UnmanagedType.U1 )]
|
||||
public static extern bool Init();
|
||||
|
||||
[DllImport( "Steam_api64", EntryPoint = "SteamAPI_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
|
||||
public static extern int GetHSteamUser();
|
||||
|
||||
}
|
11
Facepunch.Steamworks/Generated/SteamInternal.cs
Normal file
11
Facepunch.Steamworks/Generated/SteamInternal.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
|
||||
public static class SteamInternal
|
||||
{
|
||||
[DllImport( "Steam_api64", EntryPoint = "SteamInternal_FindOrCreateUserInterface", CallingConvention = CallingConvention.Cdecl )]
|
||||
public static extern IntPtr FindOrCreateUserInterface( int hSteamUser, [MarshalAs( UnmanagedType.LPStr )] string pszVersion );
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
||||
|
||||
namespace SteamNative
|
||||
{
|
||||
internal struct GID_t
|
||||
public struct GID_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -19,7 +19,7 @@ public static implicit operator ulong( GID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct JobID_t
|
||||
public struct JobID_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -34,7 +34,7 @@ public static implicit operator ulong( JobID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct TxnID_t
|
||||
public struct TxnID_t
|
||||
{
|
||||
public GID_t Value;
|
||||
|
||||
@ -49,7 +49,7 @@ public static implicit operator GID_t( TxnID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct PackageId_t
|
||||
public struct PackageId_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -64,7 +64,7 @@ public static implicit operator uint( PackageId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct BundleId_t
|
||||
public struct BundleId_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -79,7 +79,7 @@ public static implicit operator uint( BundleId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct AppId_t
|
||||
public struct AppId_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -94,7 +94,7 @@ public static implicit operator uint( AppId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct AssetClassId_t
|
||||
public struct AssetClassId_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -109,7 +109,7 @@ public static implicit operator ulong( AssetClassId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct PhysicalItemId_t
|
||||
public struct PhysicalItemId_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -124,7 +124,7 @@ public static implicit operator uint( PhysicalItemId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct DepotId_t
|
||||
public struct DepotId_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -139,7 +139,7 @@ public static implicit operator uint( DepotId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct RTime32
|
||||
public struct RTime32
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -154,7 +154,7 @@ public static implicit operator uint( RTime32 value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct CellID_t
|
||||
public struct CellID_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -169,7 +169,7 @@ public static implicit operator uint( CellID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamAPICall_t
|
||||
public struct SteamAPICall_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -184,7 +184,7 @@ public static implicit operator ulong( SteamAPICall_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct AccountID_t
|
||||
public struct AccountID_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -199,7 +199,7 @@ public static implicit operator uint( AccountID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct PartnerId_t
|
||||
public struct PartnerId_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -214,7 +214,7 @@ public static implicit operator uint( PartnerId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ManifestId_t
|
||||
public struct ManifestId_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -229,7 +229,7 @@ public static implicit operator ulong( ManifestId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SiteId_t
|
||||
public struct SiteId_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -244,7 +244,7 @@ public static implicit operator ulong( SiteId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct PartyBeaconID_t
|
||||
public struct PartyBeaconID_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -259,7 +259,7 @@ public static implicit operator ulong( PartyBeaconID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HAuthTicket
|
||||
public struct HAuthTicket
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -274,7 +274,7 @@ public static implicit operator uint( HAuthTicket value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct BREAKPAD_HANDLE
|
||||
public struct BREAKPAD_HANDLE
|
||||
{
|
||||
public IntPtr Value;
|
||||
|
||||
@ -289,7 +289,7 @@ public static implicit operator IntPtr( BREAKPAD_HANDLE value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HSteamPipe
|
||||
public struct HSteamPipe
|
||||
{
|
||||
public int Value;
|
||||
|
||||
@ -304,7 +304,7 @@ public static implicit operator int( HSteamPipe value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HSteamUser
|
||||
public struct HSteamUser
|
||||
{
|
||||
public int Value;
|
||||
|
||||
@ -319,7 +319,7 @@ public static implicit operator int( HSteamUser value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct FriendsGroupID_t
|
||||
public struct FriendsGroupID_t
|
||||
{
|
||||
public short Value;
|
||||
|
||||
@ -334,7 +334,7 @@ public static implicit operator short( FriendsGroupID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HServerListRequest
|
||||
public struct HServerListRequest
|
||||
{
|
||||
public IntPtr Value;
|
||||
|
||||
@ -349,7 +349,7 @@ public static implicit operator IntPtr( HServerListRequest value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HServerQuery
|
||||
public struct HServerQuery
|
||||
{
|
||||
public int Value;
|
||||
|
||||
@ -364,7 +364,7 @@ public static implicit operator int( HServerQuery value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct UGCHandle_t
|
||||
public struct UGCHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -379,7 +379,7 @@ public static implicit operator ulong( UGCHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct PublishedFileUpdateHandle_t
|
||||
public struct PublishedFileUpdateHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -394,7 +394,7 @@ public static implicit operator ulong( PublishedFileUpdateHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct PublishedFileId_t
|
||||
public struct PublishedFileId_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -409,7 +409,7 @@ public static implicit operator ulong( PublishedFileId_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct UGCFileWriteStreamHandle_t
|
||||
public struct UGCFileWriteStreamHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -424,7 +424,7 @@ public static implicit operator ulong( UGCFileWriteStreamHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamLeaderboard_t
|
||||
public struct SteamLeaderboard_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -439,7 +439,7 @@ public static implicit operator ulong( SteamLeaderboard_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamLeaderboardEntries_t
|
||||
public struct SteamLeaderboardEntries_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -454,7 +454,7 @@ public static implicit operator ulong( SteamLeaderboardEntries_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SNetSocket_t
|
||||
public struct SNetSocket_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -469,7 +469,7 @@ public static implicit operator uint( SNetSocket_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SNetListenSocket_t
|
||||
public struct SNetListenSocket_t
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -484,7 +484,7 @@ public static implicit operator uint( SNetListenSocket_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ScreenshotHandle
|
||||
public struct ScreenshotHandle
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -499,7 +499,7 @@ public static implicit operator uint( ScreenshotHandle value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HTTPRequestHandle
|
||||
public struct HTTPRequestHandle
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -514,7 +514,7 @@ public static implicit operator uint( HTTPRequestHandle value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HTTPCookieContainerHandle
|
||||
public struct HTTPCookieContainerHandle
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -529,7 +529,7 @@ public static implicit operator uint( HTTPCookieContainerHandle value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct InputHandle_t
|
||||
public struct InputHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -544,7 +544,7 @@ public static implicit operator ulong( InputHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct InputActionSetHandle_t
|
||||
public struct InputActionSetHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -559,7 +559,7 @@ public static implicit operator ulong( InputActionSetHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct InputDigitalActionHandle_t
|
||||
public struct InputDigitalActionHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -574,7 +574,7 @@ public static implicit operator ulong( InputDigitalActionHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct InputAnalogActionHandle_t
|
||||
public struct InputAnalogActionHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -589,7 +589,7 @@ public static implicit operator ulong( InputAnalogActionHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ControllerHandle_t
|
||||
public struct ControllerHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -604,7 +604,7 @@ public static implicit operator ulong( ControllerHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ControllerActionSetHandle_t
|
||||
public struct ControllerActionSetHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -619,7 +619,7 @@ public static implicit operator ulong( ControllerActionSetHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ControllerDigitalActionHandle_t
|
||||
public struct ControllerDigitalActionHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -634,7 +634,7 @@ public static implicit operator ulong( ControllerDigitalActionHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct ControllerAnalogActionHandle_t
|
||||
public struct ControllerAnalogActionHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -649,7 +649,7 @@ public static implicit operator ulong( ControllerAnalogActionHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct UGCQueryHandle_t
|
||||
public struct UGCQueryHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -664,7 +664,7 @@ public static implicit operator ulong( UGCQueryHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct UGCUpdateHandle_t
|
||||
public struct UGCUpdateHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -679,7 +679,7 @@ public static implicit operator ulong( UGCUpdateHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct HHTMLBrowser
|
||||
public struct HHTMLBrowser
|
||||
{
|
||||
public uint Value;
|
||||
|
||||
@ -694,7 +694,7 @@ public static implicit operator uint( HHTMLBrowser value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamItemInstanceID_t
|
||||
public struct SteamItemInstanceID_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -709,7 +709,7 @@ public static implicit operator ulong( SteamItemInstanceID_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamItemDef_t
|
||||
public struct SteamItemDef_t
|
||||
{
|
||||
public int Value;
|
||||
|
||||
@ -724,7 +724,7 @@ public static implicit operator int( SteamItemDef_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamInventoryResult_t
|
||||
public struct SteamInventoryResult_t
|
||||
{
|
||||
public int Value;
|
||||
|
||||
@ -739,7 +739,7 @@ public static implicit operator int( SteamInventoryResult_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct SteamInventoryUpdateHandle_t
|
||||
public struct SteamInventoryUpdateHandle_t
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -754,7 +754,7 @@ public static implicit operator ulong( SteamInventoryUpdateHandle_t value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct CGameID
|
||||
public struct CGameID
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
@ -769,7 +769,7 @@ public static implicit operator ulong( CGameID value )
|
||||
}
|
||||
}
|
||||
|
||||
internal struct CSteamID
|
||||
public struct CSteamID
|
||||
{
|
||||
public ulong Value;
|
||||
|
||||
|
51
Facepunch.Steamworks/Utility/BaseSteamInterface.cs
Normal file
51
Facepunch.Steamworks/Utility/BaseSteamInterface.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Steamworks.Internal
|
||||
{
|
||||
public abstract class BaseSteamInterface
|
||||
{
|
||||
public IntPtr Self;
|
||||
public IntPtr VTable;
|
||||
|
||||
public virtual string InterfaceName => "STEAMAPPS_INTERFACE_VERSION008";
|
||||
|
||||
public BaseSteamInterface()
|
||||
{
|
||||
if ( Steamworks.Steam.HUser == 0 )
|
||||
throw new System.Exception( "Steamworks is uninitialized" );
|
||||
|
||||
Self = SteamInternal.FindOrCreateUserInterface( Steamworks.Steam.HUser, InterfaceName );
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Couldn't find interface {InterfaceName}" );
|
||||
|
||||
VTable = Marshal.ReadIntPtr( Self, 0 );
|
||||
if ( Self == IntPtr.Zero )
|
||||
throw new System.Exception( $"Invalid VTable for {InterfaceName}" );
|
||||
|
||||
InitInternals();
|
||||
}
|
||||
|
||||
public abstract void InitInternals();
|
||||
|
||||
static byte[] stringbuffer = new byte[1024 * 128];
|
||||
|
||||
internal string GetString( IntPtr p )
|
||||
{
|
||||
// return Marshal.PtrToStringUTF8( p );
|
||||
lock ( stringbuffer )
|
||||
{
|
||||
int len = 0;
|
||||
while ( Marshal.ReadByte( p, len ) != 0 && len < stringbuffer.Length ) { ++len; }
|
||||
Marshal.Copy( p, stringbuffer, 0, len );
|
||||
return Encoding.UTF8.GetString( stringbuffer, 0, len );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
112
Generator/CodeWriter/ClassVTable.cs
Normal file
112
Generator/CodeWriter/ClassVTable.cs
Normal file
@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Generator
|
||||
{
|
||||
public partial class CodeWriter
|
||||
{
|
||||
public void GenerateVTableClass( string className, string filename )
|
||||
{
|
||||
var clss = Parser.Classes.Single( x => x.Name == className );
|
||||
|
||||
sb = new StringBuilder();
|
||||
|
||||
WriteLine( $"using System;" );
|
||||
WriteLine( $"using System.Runtime.InteropServices;" );
|
||||
WriteLine( $"using System.Text;" );
|
||||
WriteLine( $"using SteamNative;" );
|
||||
WriteLine();
|
||||
|
||||
WriteLine();
|
||||
|
||||
StartBlock( $"namespace Steamworks.Internal" );
|
||||
{
|
||||
StartBlock( $"public class {clss.Name} : BaseSteamInterface" );
|
||||
{
|
||||
WriteFunctionPointerReader( clss );
|
||||
|
||||
WriteLine();
|
||||
|
||||
foreach ( var func in clss.Functions )
|
||||
{
|
||||
WriteFunction( clss, func );
|
||||
WriteLine();
|
||||
}
|
||||
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
EndBlock();
|
||||
|
||||
System.IO.File.WriteAllText( $"{filename}", sb.ToString() );
|
||||
}
|
||||
|
||||
void WriteFunctionPointerReader( CodeParser.Class clss )
|
||||
{
|
||||
StartBlock( $"public override void InitInternals()" );
|
||||
{
|
||||
for (int i=0; i< clss.Functions.Count; i++ )
|
||||
{
|
||||
var func = clss.Functions[i];
|
||||
WriteLine( $"{func.Name}DelegatePointer = Marshal.GetDelegateForFunctionPointer<{func.Name}Delegate>( Marshal.ReadIntPtr( VTable, {i*8}) );" );
|
||||
}
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
|
||||
private void WriteFunction( CodeParser.Class clss, CodeParser.Class.Function func )
|
||||
{
|
||||
var returnType = BaseType.Parse( func.ReturnType );
|
||||
|
||||
var args = func.Arguments.Select( x => BaseType.Parse( x.Value, x.Key ) ).ToArray();
|
||||
var argstr = string.Join( ", ", args.Select( x => x.AsArgument() ) );
|
||||
var delegateargstr = "IntPtr self, " + string.Join( ", ", args.Select( x => x.AsArgument() ) );
|
||||
|
||||
if ( returnType.IsReturnedWeird )
|
||||
{
|
||||
delegateargstr += $", ref {returnType.TypeName} retVal";
|
||||
delegateargstr = delegateargstr.Replace( ", , ", ", " );
|
||||
//returnType = new VoidType();
|
||||
}
|
||||
|
||||
|
||||
WriteLine( $"#region FunctionMeta" );
|
||||
|
||||
WriteLine( $"[UnmanagedFunctionPointer( CallingConvention.ThisCall )]" );
|
||||
|
||||
if ( returnType.ReturnAttribute != null)
|
||||
WriteLine( returnType.ReturnAttribute );
|
||||
|
||||
WriteLine( $"public delegate {(returnType.IsReturnedWeird?"void":returnType.TypeNameFrom)} {func.Name}Delegate( {delegateargstr} );".Replace( "( IntPtr self, )", "( IntPtr self )" ) );
|
||||
WriteLine( $"private {func.Name}Delegate {func.Name}DelegatePointer;" );
|
||||
WriteLine();
|
||||
WriteLine( $"#endregion" );
|
||||
|
||||
StartBlock( $"public {returnType.TypeName} {func.Name}( {argstr} )".Replace( "( )", "()" ) );
|
||||
{
|
||||
var callargs = string.Join( ", ", args.Select( x => x.AsCallArgument() ) );
|
||||
|
||||
if ( returnType.IsReturnedWeird )
|
||||
{
|
||||
WriteLine( $"var retVal = default( {returnType.TypeName} );" );
|
||||
WriteLine( $"{func.Name}DelegatePointer( Self, {callargs}, ref retVal );".Replace( ", , ", ", " ) );
|
||||
WriteLine( $"{returnType.Return( "retVal" )}" );
|
||||
}
|
||||
else if ( returnType.IsVoid )
|
||||
{
|
||||
WriteLine( $"{func.Name}DelegatePointer( Self, {callargs} );".Replace( "( Self, )", "( Self )" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
var v = $"{func.Name}DelegatePointer( Self, {callargs} )".Replace( "( Self, )", "( Self )" );
|
||||
|
||||
WriteLine( returnType.Return( v ) );
|
||||
}
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
}
|
||||
}
|
@ -11,10 +11,13 @@ namespace Generator
|
||||
public partial class CodeWriter
|
||||
{
|
||||
private SteamApiDefinition def;
|
||||
public CodeParser Parser;
|
||||
|
||||
public CodeWriter( SteamApiDefinition def )
|
||||
public CodeWriter( CodeParser parser, SteamApiDefinition def )
|
||||
{
|
||||
this.def = def;
|
||||
Parser = parser;
|
||||
|
||||
this.def = def;
|
||||
WorkoutTypes();
|
||||
}
|
||||
|
||||
@ -87,7 +90,11 @@ public void ToFolder( string folder )
|
||||
{
|
||||
GenerateClasses( $"{folder}SteamNative." );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
GenerateVTableClass( "ISteamApps", $"{folder}../Generated/Interfaces/ISteamApps.cs" );
|
||||
}
|
||||
}
|
||||
|
||||
void WorkoutTypes()
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ void Structs()
|
||||
// Main struct
|
||||
//
|
||||
WriteLine( $"[StructLayout( LayoutKind.Sequential, Pack = {defaultPack} )]" );
|
||||
StartBlock( $"internal struct {c.Name}" );
|
||||
StartBlock( $"public struct {c.Name}" );
|
||||
{
|
||||
if ( !string.IsNullOrEmpty( c.CallbackId ) )
|
||||
{
|
||||
@ -101,7 +101,7 @@ void Structs()
|
||||
//
|
||||
WriteLine();
|
||||
WriteLine( $"[StructLayout( LayoutKind.Sequential, Pack = {defaultPack} )]" );
|
||||
StartBlock( $"internal struct PackSmall" );
|
||||
StartBlock( $"public struct PackSmall" );
|
||||
{
|
||||
StructFields( c.Fields );
|
||||
|
||||
|
@ -43,7 +43,7 @@ private void Types()
|
||||
if ( SkipTypesStartingWith.Any( x => o.Name.StartsWith( x ) ) )
|
||||
continue;
|
||||
|
||||
StartBlock( $"internal struct {o.Name}" );
|
||||
StartBlock( $"public struct {o.Name}" );
|
||||
{
|
||||
WriteLine( $"public {ToManagedType( o.Type )} Value;" );
|
||||
WriteLine();
|
||||
|
103
Generator/CodeWriter/Types/BaseType.cs
Normal file
103
Generator/CodeWriter/Types/BaseType.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
internal class BaseType
|
||||
{
|
||||
public string VarName;
|
||||
public string NativeType;
|
||||
public virtual string TypeName => $"{NativeType}";
|
||||
public virtual string TypeNameFrom => TypeName;
|
||||
|
||||
public static BaseType Parse( string type, string varname = null )
|
||||
{
|
||||
if ( type == "void" ) return new VoidType { NativeType = type, VarName = varname };
|
||||
if ( type.Replace( " ", "" ) == "constchar*" ) return new ConstCharType { NativeType = type, VarName = varname };
|
||||
if ( type == "char *" ) return new StringBuilderType { NativeType = type, VarName = varname };
|
||||
|
||||
var basicType = type.Trim( ' ', '*' );
|
||||
|
||||
|
||||
if ( basicType == "int32" ) return new IntType { NativeType = type, VarName = varname };
|
||||
if ( basicType == "uint32" ) return new UIntType { NativeType = type, VarName = varname };
|
||||
if ( basicType == "CSteamID" ) return new CSteamIdType { NativeType = type, VarName = varname };
|
||||
if ( basicType == "uint64" ) return new ULongType { NativeType = type, VarName = varname };
|
||||
if ( basicType == "bool" ) return new BoolType { NativeType = type, VarName = varname };
|
||||
|
||||
if ( basicType.EndsWith( "_t" ) || basicType == "CSteamID" ) return new StructType { NativeType = type, VarName = varname, StructName = basicType };
|
||||
|
||||
return new BaseType { NativeType = type, VarName = varname };
|
||||
}
|
||||
|
||||
public virtual string AsArgument() => $"{Ref}{TypeName} {VarName}";
|
||||
public virtual string AsCallArgument() => $"{Ref}{VarName}";
|
||||
|
||||
public virtual string Return( string varname ) => $"return {varname};";
|
||||
public virtual string ReturnAttribute => null;
|
||||
|
||||
public virtual string Ref => NativeType.EndsWith( "*" ) ? "ref " : "";
|
||||
|
||||
public virtual bool IsVoid => false;
|
||||
public virtual bool IsReturnedWeird => false;
|
||||
}
|
||||
|
||||
|
||||
internal class BoolType : BaseType
|
||||
{
|
||||
public override string TypeName => $"bool";
|
||||
public override string AsArgument() => $"[MarshalAs( UnmanagedType.U1 )] {Ref}{TypeName} {VarName}";
|
||||
public override string ReturnAttribute => "[return: MarshalAs( UnmanagedType.I1 )]";
|
||||
|
||||
}
|
||||
|
||||
internal class StructType : BaseType
|
||||
{
|
||||
public string StructName;
|
||||
|
||||
public override string TypeName => StructName;
|
||||
}
|
||||
|
||||
internal class CSteamIdType : BaseType
|
||||
{
|
||||
public override bool IsReturnedWeird => true;
|
||||
}
|
||||
|
||||
internal class IntType : BaseType
|
||||
{
|
||||
public override string TypeName => $"int";
|
||||
}
|
||||
|
||||
internal class UIntType : BaseType
|
||||
{
|
||||
public override string TypeName => $"uint";
|
||||
}
|
||||
|
||||
internal class ULongType : BaseType
|
||||
{
|
||||
public override string TypeName => $"ulong";
|
||||
}
|
||||
|
||||
internal class ConstCharType : BaseType
|
||||
{
|
||||
public override string TypeName => $"string";
|
||||
public override string TypeNameFrom => $"IntPtr";
|
||||
public override string Return( string varname ) => $"return GetString( {varname} );";
|
||||
|
||||
public override string Ref => "";
|
||||
}
|
||||
|
||||
internal class StringBuilderType : BaseType
|
||||
{
|
||||
public override string TypeName => $"StringBuilder";
|
||||
public override string Ref => "";
|
||||
}
|
||||
|
||||
internal class VoidType : BaseType
|
||||
{
|
||||
public override string TypeName => $"void";
|
||||
public override string TypeNameFrom => $"void";
|
||||
public override string Return( string varname ) => $"";
|
||||
public override bool IsVoid => true;
|
||||
}
|
@ -48,9 +48,13 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Argument.cs" />
|
||||
<Compile Include="CodeParser\CodeParser.Class.cs" />
|
||||
<Compile Include="CodeParser\CodeParser.cs" />
|
||||
<Compile Include="CodeParser\ParseClasses.cs" />
|
||||
<Compile Include="CodeWriter\ClassVTable.cs" />
|
||||
<Compile Include="CodeWriter\Class.cs" />
|
||||
<Compile Include="CodeWriter\Constants.cs" />
|
||||
<Compile Include="CodeWriter\Types\BaseType.cs" />
|
||||
<Compile Include="CodeWriter\Writing.cs" />
|
||||
<Compile Include="CodeWriter\CodeWriter.cs" />
|
||||
<Compile Include="CodeWriter\Enums.cs" />
|
||||
|
@ -18,9 +18,10 @@ static void Main( string[] args )
|
||||
|
||||
var parser = new CodeParser( @"steam_sdk" );
|
||||
|
||||
parser.ExtendDefinition( def );
|
||||
parser.ParseClasses();
|
||||
parser.ExtendDefinition( def );
|
||||
|
||||
var generator = new CodeWriter( def );
|
||||
var generator = new CodeWriter( parser, def );
|
||||
|
||||
generator.ToFolder( "../Facepunch.Steamworks/SteamNative/" );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user