Facepunch.Steamworks/Generator/Program.cs

49 lines
1.3 KiB
C#
Raw Normal View History

2016-10-18 18:34:28 +03:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Generator
{
class Program
{
public static SteamApiDefinition Definitions;
static void Main( string[] args )
2016-10-18 18:34:28 +03:00
{
2016-10-31 12:00:47 +03:00
var content = System.IO.File.ReadAllText( "steam_sdk/steam_api.json" );
2016-10-18 18:34:28 +03:00
var def = Newtonsoft.Json.JsonConvert.DeserializeObject<SteamApiDefinition>( content );
AddMissing( def );
2016-10-30 23:52:42 +03:00
2016-10-31 12:00:47 +03:00
var parser = new CodeParser( @"steam_sdk" );
2016-10-29 22:28:16 +03:00
parser.ExtendDefinition( def );
2016-10-29 22:28:16 +03:00
Definitions = def;
var generator = new CodeWriter( parser, def );
2016-10-18 18:34:28 +03:00
2019-04-16 13:45:44 +03:00
generator.ToFolder( "../Facepunch.Steamworks/Generated/" );
2016-10-18 18:34:28 +03:00
}
2016-10-30 23:52:42 +03:00
private static void AddMissing( SteamApiDefinition output )
2016-10-30 23:52:42 +03:00
{
var content = System.IO.File.ReadAllText( "steam_api_missing.json" );
var missing = Newtonsoft.Json.JsonConvert.DeserializeObject<SteamApiDefinition>( content );
2016-10-30 23:52:42 +03:00
output.structs.AddRange( missing.structs );
output.methods.AddRange( missing.methods );
2018-03-21 13:42:55 +03:00
foreach ( var s in output.structs )
{
if ( s.Fields == null ) s.Fields = new SteamApiDefinition.StructDef.StructFields[0];
}
2016-10-30 23:52:42 +03:00
}
2016-10-18 18:34:28 +03:00
}
}