mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Parse defines
This commit is contained in:
parent
778faa1049
commit
17b84c4f58
@ -91,20 +91,20 @@ public void FillInterfaces( int hpipe, int huser )
|
||||
|
||||
client = new SteamNative.SteamClient( clientPtr );
|
||||
|
||||
user = client.GetISteamUser( huser, hpipe, "SteamUser019" );
|
||||
utils = client.GetISteamUtils( hpipe, "SteamUtils008" );
|
||||
networking = client.GetISteamNetworking( huser, hpipe, "SteamNetworking005" );
|
||||
gameServerStats = client.GetISteamGameServerStats( huser, hpipe, "SteamGameServerStats001" );
|
||||
http = client.GetISteamHTTP( huser, hpipe, "STEAMHTTP_INTERFACE_VERSION002" );
|
||||
inventory = client.GetISteamInventory( huser, hpipe, "STEAMINVENTORY_INTERFACE_V001" );
|
||||
ugc = client.GetISteamUGC( huser, hpipe, "STEAMUGC_INTERFACE_VERSION009" );
|
||||
apps = client.GetISteamApps( huser, hpipe, "STEAMAPPS_INTERFACE_VERSION008" );
|
||||
gameServer = client.GetISteamGameServer( huser, hpipe, "SteamGameServer012" );
|
||||
friends = client.GetISteamFriends( huser, hpipe, "SteamFriends015" );
|
||||
servers = client.GetISteamMatchmakingServers( huser, hpipe, "SteamMatchMakingServers002" );
|
||||
userstats = client.GetISteamUserStats( huser, hpipe, "STEAMUSERSTATS_INTERFACE_VERSION011" );
|
||||
screenshots = client.GetISteamScreenshots( huser, hpipe, "STEAMSCREENSHOTS_INTERFACE_VERSION003" );
|
||||
remoteStorage = client.GetISteamRemoteStorage( huser, hpipe, "STEAMREMOTESTORAGE_INTERFACE_VERSION014" );
|
||||
user = client.GetISteamUser( huser, hpipe, SteamNative.Defines.STEAMUSER_INTERFACE_VERSION );
|
||||
utils = client.GetISteamUtils( hpipe, SteamNative.Defines.STEAMUTILS_INTERFACE_VERSION );
|
||||
networking = client.GetISteamNetworking( huser, hpipe, SteamNative.Defines.STEAMNETWORKING_INTERFACE_VERSION );
|
||||
gameServerStats = client.GetISteamGameServerStats( huser, hpipe, SteamNative.Defines.STEAMGAMESERVERSTATS_INTERFACE_VERSION );
|
||||
http = client.GetISteamHTTP( huser, hpipe, SteamNative.Defines.STEAMHTTP_INTERFACE_VERSION );
|
||||
inventory = client.GetISteamInventory( huser, hpipe, SteamNative.Defines.STEAMINVENTORY_INTERFACE_VERSION );
|
||||
ugc = client.GetISteamUGC( huser, hpipe, SteamNative.Defines.STEAMUGC_INTERFACE_VERSION );
|
||||
apps = client.GetISteamApps( huser, hpipe, SteamNative.Defines.STEAMAPPS_INTERFACE_VERSION );
|
||||
gameServer = client.GetISteamGameServer( huser, hpipe, SteamNative.Defines.STEAMGAMESERVER_INTERFACE_VERSION );
|
||||
friends = client.GetISteamFriends( huser, hpipe, SteamNative.Defines.STEAMFRIENDS_INTERFACE_VERSION );
|
||||
servers = client.GetISteamMatchmakingServers( huser, hpipe, SteamNative.Defines.STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION );
|
||||
userstats = client.GetISteamUserStats( huser, hpipe, SteamNative.Defines.STEAMUSERSTATS_INTERFACE_VERSION );
|
||||
screenshots = client.GetISteamScreenshots( huser, hpipe, SteamNative.Defines.STEAMSCREENSHOTS_INTERFACE_VERSION );
|
||||
remoteStorage = client.GetISteamRemoteStorage( huser, hpipe, SteamNative.Defines.STEAMREMOTESTORAGE_INTERFACE_VERSION );
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -53,4 +53,31 @@ public static class CallbackIdentifiers
|
||||
public const int ClientInventory = 4700;
|
||||
public const int ClientBluetoothManager = 4800;
|
||||
}
|
||||
public static class Defines
|
||||
{
|
||||
public const string STEAMAPPLIST_INTERFACE_VERSION = "STEAMAPPLIST_INTERFACE_VERSION001";
|
||||
public const string STEAMAPPS_INTERFACE_VERSION = "STEAMAPPS_INTERFACE_VERSION008";
|
||||
public const string STEAMAPPTICKET_INTERFACE_VERSION = "STEAMAPPTICKET_INTERFACE_VERSION001";
|
||||
public const string STEAMCONTROLLER_INTERFACE_VERSION = "SteamController004";
|
||||
public const string STEAMFRIENDS_INTERFACE_VERSION = "SteamFriends015";
|
||||
public const string STEAMGAMECOORDINATOR_INTERFACE_VERSION = "SteamGameCoordinator001";
|
||||
public const string STEAMGAMESERVER_INTERFACE_VERSION = "SteamGameServer012";
|
||||
public const string STEAMGAMESERVERSTATS_INTERFACE_VERSION = "SteamGameServerStats001";
|
||||
public const string STEAMHTMLSURFACE_INTERFACE_VERSION = "STEAMHTMLSURFACE_INTERFACE_VERSION_003";
|
||||
public const string STEAMHTTP_INTERFACE_VERSION = "STEAMHTTP_INTERFACE_VERSION002";
|
||||
public const string STEAMINVENTORY_INTERFACE_VERSION = "STEAMINVENTORY_INTERFACE_V001";
|
||||
public const string STEAMMATCHMAKING_INTERFACE_VERSION = "SteamMatchMaking009";
|
||||
public const string STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION = "SteamMatchMakingServers002";
|
||||
public const string STEAMMUSIC_INTERFACE_VERSION = "STEAMMUSIC_INTERFACE_VERSION001";
|
||||
public const string STEAMMUSICREMOTE_INTERFACE_VERSION = "STEAMMUSICREMOTE_INTERFACE_VERSION001";
|
||||
public const string STEAMNETWORKING_INTERFACE_VERSION = "SteamNetworking005";
|
||||
public const string STEAMREMOTESTORAGE_INTERFACE_VERSION = "STEAMREMOTESTORAGE_INTERFACE_VERSION014";
|
||||
public const string STEAMSCREENSHOTS_INTERFACE_VERSION = "STEAMSCREENSHOTS_INTERFACE_VERSION003";
|
||||
public const string STEAMUGC_INTERFACE_VERSION = "STEAMUGC_INTERFACE_VERSION009";
|
||||
public const string STEAMUNIFIEDMESSAGES_INTERFACE_VERSION = "STEAMUNIFIEDMESSAGES_INTERFACE_VERSION001";
|
||||
public const string STEAMUSER_INTERFACE_VERSION = "SteamUser019";
|
||||
public const string STEAMUSERSTATS_INTERFACE_VERSION = "STEAMUSERSTATS_INTERFACE_VERSION011";
|
||||
public const string STEAMUTILS_INTERFACE_VERSION = "SteamUtils008";
|
||||
public const string STEAMVIDEO_INTERFACE_VERSION = "STEAMVIDEO_INTERFACE_V001";
|
||||
}
|
||||
}
|
||||
|
@ -54,6 +54,17 @@ internal void ExtendDefinition( SteamApiDefinition def )
|
||||
}
|
||||
}
|
||||
|
||||
def.Defines = new Dictionary<string, string>();
|
||||
{
|
||||
var r = new Regex( @"#define ([a-zA-Z_]+) ""(.+)""" );
|
||||
var ma = r.Matches( Content );
|
||||
|
||||
foreach ( Match m in ma )
|
||||
{
|
||||
def.Defines.Add( m.Groups[1].Value.Replace( "Callbacks", "" ), m.Groups[2].Value );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,59 +8,21 @@ namespace Generator
|
||||
{
|
||||
public partial class CodeWriter
|
||||
{
|
||||
//
|
||||
// Don't give a fuck about these types
|
||||
//
|
||||
public readonly static string[] SkipTypes = new string[]
|
||||
private void Constants()
|
||||
{
|
||||
"ValvePackingSentinel_t",
|
||||
"SteamAPIWarningMessageHook_t",
|
||||
"Salt_t",
|
||||
"SteamAPI_CheckCallbackRegistered_t",
|
||||
"compile_time_assert_type"
|
||||
};
|
||||
|
||||
//
|
||||
// Native types and function defs
|
||||
//
|
||||
public readonly static string[] SkipTypesStartingWith = new string[]
|
||||
{
|
||||
"uint",
|
||||
"int",
|
||||
"ulint",
|
||||
"lint",
|
||||
"PFN"
|
||||
};
|
||||
|
||||
private void Types()
|
||||
{
|
||||
foreach ( var o in def.typedefs.Where( x => !x.Name.Contains( "::" ) ) )
|
||||
StartBlock( "public static class CallbackIdentifiers" );
|
||||
foreach ( var o in def.CallbackIds )
|
||||
{
|
||||
if ( SkipTypes.Contains( o.Name ) )
|
||||
continue;
|
||||
|
||||
if ( SkipTypesStartingWith.Any( x => o.Name.StartsWith( x ) ) )
|
||||
continue;
|
||||
|
||||
StartBlock( $"public struct {o.Name}" );
|
||||
{
|
||||
WriteLine( $"public {ToManagedType( o.Type )} Value;" );
|
||||
WriteLine();
|
||||
StartBlock( $"public static implicit operator {o.Name}( {ToManagedType( o.Type )} value )" );
|
||||
{
|
||||
WriteLine( $"return new {o.Name}(){{ Value = value }};" );
|
||||
}
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
StartBlock( $"public static implicit operator {ToManagedType( o.Type )}( {o.Name} value )" );
|
||||
{
|
||||
WriteLine( $"return value.Value;" );
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
WriteLine( $"public const int {o.Key} = {o.Value};" );
|
||||
}
|
||||
EndBlock();
|
||||
|
||||
StartBlock( "public static class Defines" );
|
||||
foreach ( var o in def.Defines )
|
||||
{
|
||||
WriteLine( $"public const string {o.Key} = \"{o.Value}\";" );
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -8,14 +9,59 @@ namespace Generator
|
||||
{
|
||||
public partial class CodeWriter
|
||||
{
|
||||
private void Constants()
|
||||
//
|
||||
// Don't give a fuck about these types
|
||||
//
|
||||
public readonly static string[] SkipTypes = new string[]
|
||||
{
|
||||
StartBlock( "public static class CallbackIdentifiers" );
|
||||
foreach ( var o in def.CallbackIds )
|
||||
"ValvePackingSentinel_t",
|
||||
"SteamAPIWarningMessageHook_t",
|
||||
"Salt_t",
|
||||
"SteamAPI_CheckCallbackRegistered_t",
|
||||
"compile_time_assert_type"
|
||||
};
|
||||
|
||||
//
|
||||
// Native types and function defs
|
||||
//
|
||||
public readonly static string[] SkipTypesStartingWith = new string[]
|
||||
{
|
||||
"uint",
|
||||
"int",
|
||||
"ulint",
|
||||
"lint",
|
||||
"PFN"
|
||||
};
|
||||
|
||||
private void Types()
|
||||
{
|
||||
foreach ( var o in def.typedefs.Where( x => !x.Name.Contains( "::" ) ) )
|
||||
{
|
||||
WriteLine( $"public const int {o.Key} = {o.Value};" );
|
||||
if ( SkipTypes.Contains( o.Name ) )
|
||||
continue;
|
||||
|
||||
if ( SkipTypesStartingWith.Any( x => o.Name.StartsWith( x ) ) )
|
||||
continue;
|
||||
|
||||
StartBlock( $"public struct {o.Name}" );
|
||||
{
|
||||
WriteLine( $"public {ToManagedType( o.Type )} Value;" );
|
||||
WriteLine();
|
||||
StartBlock( $"public static implicit operator {o.Name}( {ToManagedType( o.Type )} value )" );
|
||||
{
|
||||
WriteLine( $"return new {o.Name}(){{ Value = value }};" );
|
||||
}
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
StartBlock( $"public static implicit operator {ToManagedType( o.Type )}( {o.Name} value )" );
|
||||
{
|
||||
WriteLine( $"return value.Value;" );
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
EndBlock();
|
||||
WriteLine();
|
||||
}
|
||||
EndBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,5 +83,6 @@ public class ParamType
|
||||
|
||||
|
||||
public Dictionary<string, int> CallbackIds { get; internal set; }
|
||||
public Dictionary<string, string> Defines { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user