Types cleanup

This commit is contained in:
Garry Newman 2016-10-29 12:55:23 +01:00
parent 561f185551
commit ba06bce930
4 changed files with 113 additions and 41 deletions

View File

@ -11,6 +11,7 @@ public static implicit operator GID_t( ulong value )
{
return new GID_t(){ Value = value };
}
public static implicit operator ulong( GID_t value )
{
return value.Value;
@ -25,6 +26,7 @@ public static implicit operator JobID_t( ulong value )
{
return new JobID_t(){ Value = value };
}
public static implicit operator ulong( JobID_t value )
{
return value.Value;
@ -39,6 +41,7 @@ public static implicit operator TxnID_t( GID_t value )
{
return new TxnID_t(){ Value = value };
}
public static implicit operator GID_t( TxnID_t value )
{
return value.Value;
@ -53,6 +56,7 @@ public static implicit operator PackageId_t( uint value )
{
return new PackageId_t(){ Value = value };
}
public static implicit operator uint( PackageId_t value )
{
return value.Value;
@ -67,6 +71,7 @@ public static implicit operator BundleId_t( uint value )
{
return new BundleId_t(){ Value = value };
}
public static implicit operator uint( BundleId_t value )
{
return value.Value;
@ -81,6 +86,7 @@ public static implicit operator AppId_t( uint value )
{
return new AppId_t(){ Value = value };
}
public static implicit operator uint( AppId_t value )
{
return value.Value;
@ -95,6 +101,7 @@ public static implicit operator AssetClassId_t( ulong value )
{
return new AssetClassId_t(){ Value = value };
}
public static implicit operator ulong( AssetClassId_t value )
{
return value.Value;
@ -109,6 +116,7 @@ public static implicit operator PhysicalItemId_t( uint value )
{
return new PhysicalItemId_t(){ Value = value };
}
public static implicit operator uint( PhysicalItemId_t value )
{
return value.Value;
@ -123,6 +131,7 @@ public static implicit operator DepotId_t( uint value )
{
return new DepotId_t(){ Value = value };
}
public static implicit operator uint( DepotId_t value )
{
return value.Value;
@ -137,6 +146,7 @@ public static implicit operator RTime32( uint value )
{
return new RTime32(){ Value = value };
}
public static implicit operator uint( RTime32 value )
{
return value.Value;
@ -151,6 +161,7 @@ public static implicit operator CellID_t( uint value )
{
return new CellID_t(){ Value = value };
}
public static implicit operator uint( CellID_t value )
{
return value.Value;
@ -165,6 +176,7 @@ public static implicit operator SteamAPICall_t( ulong value )
{
return new SteamAPICall_t(){ Value = value };
}
public static implicit operator ulong( SteamAPICall_t value )
{
return value.Value;
@ -179,6 +191,7 @@ public static implicit operator AccountID_t( uint value )
{
return new AccountID_t(){ Value = value };
}
public static implicit operator uint( AccountID_t value )
{
return value.Value;
@ -193,6 +206,7 @@ public static implicit operator PartnerId_t( uint value )
{
return new PartnerId_t(){ Value = value };
}
public static implicit operator uint( PartnerId_t value )
{
return value.Value;
@ -207,6 +221,7 @@ public static implicit operator ManifestId_t( ulong value )
{
return new ManifestId_t(){ Value = value };
}
public static implicit operator ulong( ManifestId_t value )
{
return value.Value;
@ -221,6 +236,7 @@ public static implicit operator HAuthTicket( uint value )
{
return new HAuthTicket(){ Value = value };
}
public static implicit operator uint( HAuthTicket value )
{
return value.Value;
@ -235,6 +251,7 @@ public static implicit operator BREAKPAD_HANDLE( IntPtr value )
{
return new BREAKPAD_HANDLE(){ Value = value };
}
public static implicit operator IntPtr( BREAKPAD_HANDLE value )
{
return value.Value;
@ -249,6 +266,7 @@ public static implicit operator HSteamPipe( int value )
{
return new HSteamPipe(){ Value = value };
}
public static implicit operator int( HSteamPipe value )
{
return value.Value;
@ -263,6 +281,7 @@ public static implicit operator HSteamUser( int value )
{
return new HSteamUser(){ Value = value };
}
public static implicit operator int( HSteamUser value )
{
return value.Value;
@ -277,6 +296,7 @@ public static implicit operator FriendsGroupID_t( short value )
{
return new FriendsGroupID_t(){ Value = value };
}
public static implicit operator short( FriendsGroupID_t value )
{
return value.Value;
@ -291,6 +311,7 @@ public static implicit operator HServerListRequest( IntPtr value )
{
return new HServerListRequest(){ Value = value };
}
public static implicit operator IntPtr( HServerListRequest value )
{
return value.Value;
@ -305,6 +326,7 @@ public static implicit operator HServerQuery( int value )
{
return new HServerQuery(){ Value = value };
}
public static implicit operator int( HServerQuery value )
{
return value.Value;
@ -319,6 +341,7 @@ public static implicit operator UGCHandle_t( ulong value )
{
return new UGCHandle_t(){ Value = value };
}
public static implicit operator ulong( UGCHandle_t value )
{
return value.Value;
@ -333,6 +356,7 @@ public static implicit operator PublishedFileUpdateHandle_t( ulong value )
{
return new PublishedFileUpdateHandle_t(){ Value = value };
}
public static implicit operator ulong( PublishedFileUpdateHandle_t value )
{
return value.Value;
@ -347,6 +371,7 @@ public static implicit operator PublishedFileId_t( ulong value )
{
return new PublishedFileId_t(){ Value = value };
}
public static implicit operator ulong( PublishedFileId_t value )
{
return value.Value;
@ -361,6 +386,7 @@ public static implicit operator UGCFileWriteStreamHandle_t( ulong value )
{
return new UGCFileWriteStreamHandle_t(){ Value = value };
}
public static implicit operator ulong( UGCFileWriteStreamHandle_t value )
{
return value.Value;
@ -375,6 +401,7 @@ public static implicit operator SteamLeaderboard_t( ulong value )
{
return new SteamLeaderboard_t(){ Value = value };
}
public static implicit operator ulong( SteamLeaderboard_t value )
{
return value.Value;
@ -389,6 +416,7 @@ public static implicit operator SteamLeaderboardEntries_t( ulong value )
{
return new SteamLeaderboardEntries_t(){ Value = value };
}
public static implicit operator ulong( SteamLeaderboardEntries_t value )
{
return value.Value;
@ -403,6 +431,7 @@ public static implicit operator SNetSocket_t( uint value )
{
return new SNetSocket_t(){ Value = value };
}
public static implicit operator uint( SNetSocket_t value )
{
return value.Value;
@ -417,6 +446,7 @@ public static implicit operator SNetListenSocket_t( uint value )
{
return new SNetListenSocket_t(){ Value = value };
}
public static implicit operator uint( SNetListenSocket_t value )
{
return value.Value;
@ -431,6 +461,7 @@ public static implicit operator ScreenshotHandle( uint value )
{
return new ScreenshotHandle(){ Value = value };
}
public static implicit operator uint( ScreenshotHandle value )
{
return value.Value;
@ -445,6 +476,7 @@ public static implicit operator HTTPRequestHandle( uint value )
{
return new HTTPRequestHandle(){ Value = value };
}
public static implicit operator uint( HTTPRequestHandle value )
{
return value.Value;
@ -459,6 +491,7 @@ public static implicit operator HTTPCookieContainerHandle( uint value )
{
return new HTTPCookieContainerHandle(){ Value = value };
}
public static implicit operator uint( HTTPCookieContainerHandle value )
{
return value.Value;
@ -473,6 +506,7 @@ public static implicit operator ClientUnifiedMessageHandle( ulong value )
{
return new ClientUnifiedMessageHandle(){ Value = value };
}
public static implicit operator ulong( ClientUnifiedMessageHandle value )
{
return value.Value;
@ -487,6 +521,7 @@ public static implicit operator ControllerHandle_t( ulong value )
{
return new ControllerHandle_t(){ Value = value };
}
public static implicit operator ulong( ControllerHandle_t value )
{
return value.Value;
@ -501,6 +536,7 @@ public static implicit operator ControllerActionSetHandle_t( ulong value )
{
return new ControllerActionSetHandle_t(){ Value = value };
}
public static implicit operator ulong( ControllerActionSetHandle_t value )
{
return value.Value;
@ -515,6 +551,7 @@ public static implicit operator ControllerDigitalActionHandle_t( ulong value )
{
return new ControllerDigitalActionHandle_t(){ Value = value };
}
public static implicit operator ulong( ControllerDigitalActionHandle_t value )
{
return value.Value;
@ -529,6 +566,7 @@ public static implicit operator ControllerAnalogActionHandle_t( ulong value )
{
return new ControllerAnalogActionHandle_t(){ Value = value };
}
public static implicit operator ulong( ControllerAnalogActionHandle_t value )
{
return value.Value;
@ -543,6 +581,7 @@ public static implicit operator UGCQueryHandle_t( ulong value )
{
return new UGCQueryHandle_t(){ Value = value };
}
public static implicit operator ulong( UGCQueryHandle_t value )
{
return value.Value;
@ -557,6 +596,7 @@ public static implicit operator UGCUpdateHandle_t( ulong value )
{
return new UGCUpdateHandle_t(){ Value = value };
}
public static implicit operator ulong( UGCUpdateHandle_t value )
{
return value.Value;
@ -571,6 +611,7 @@ public static implicit operator HHTMLBrowser( uint value )
{
return new HHTMLBrowser(){ Value = value };
}
public static implicit operator uint( HHTMLBrowser value )
{
return value.Value;
@ -585,6 +626,7 @@ public static implicit operator SteamItemInstanceID_t( ulong value )
{
return new SteamItemInstanceID_t(){ Value = value };
}
public static implicit operator ulong( SteamItemInstanceID_t value )
{
return value.Value;
@ -599,6 +641,7 @@ public static implicit operator SteamItemDef_t( int value )
{
return new SteamItemDef_t(){ Value = value };
}
public static implicit operator int( SteamItemDef_t value )
{
return value.Value;
@ -613,6 +656,7 @@ public static implicit operator SteamInventoryResult_t( int value )
{
return new SteamInventoryResult_t(){ Value = value };
}
public static implicit operator int( SteamInventoryResult_t value )
{
return value.Value;
@ -627,6 +671,7 @@ public static implicit operator CGameID( ulong value )
{
return new CGameID(){ Value = value };
}
public static implicit operator ulong( CGameID value )
{
return value.Value;
@ -641,6 +686,7 @@ public static implicit operator CSteamID( ulong value )
{
return new CSteamID(){ Value = value };
}
public static implicit operator ulong( CSteamID value )
{
return value.Value;

View File

@ -1,40 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Generator
{
public partial class CodeWriter
{
private void Types()
{
foreach ( var o in def.typedefs.Where( x => !x.Name.Contains( "::" ) ) )
{
if ( o.Name == "ValvePackingSentinel_t" ) continue;
if ( o.Name == "SteamAPIWarningMessageHook_t" ) continue;
if ( o.Name == "Salt_t" ) continue;
if ( o.Name == "SteamAPI_CheckCallbackRegistered_t" ) continue;
if ( o.Name == "compile_time_assert_type" ) continue;
if ( o.Name.StartsWith( "uint" ) ) continue;
if ( o.Name.StartsWith( "int" ) ) continue;
if ( o.Name.StartsWith( "ulint" ) ) continue;
if ( o.Name.StartsWith( "lint" ) ) continue;
if ( o.Name.StartsWith( "PFN" ) ) 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();
StartBlock( $"public static implicit operator {ToManagedType( o.Type )}( {o.Name} value )" );
WriteLine( $"return value.Value;" );
EndBlock();
EndBlock();
WriteLine();
}
}
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Generator
{
public partial class CodeWriter
{
//
// Don't give a fuck about these types
//
public readonly static string[] SkipTypes = new string[]
{
"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( "::" ) ) )
{
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();
}
}
}
}

View File

@ -52,7 +52,7 @@
<Compile Include="CodeWriter.cs" />
<Compile Include="CodeWriter\Enums.cs" />
<Compile Include="CodeWriter\Struct.cs" />
<Compile Include="CodeWriter.Types.cs" />
<Compile Include="CodeWriter\Types.cs" />
<Compile Include="CodeWriter\Utility.cs" />
<Compile Include="CodeWriter\Interface.cs" />
<Compile Include="Program.cs" />