2020-02-22 23:16:04 +03:00
using System ;
using System.Collections.Generic ;
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
namespace Generator
{
public partial class CodeWriter
{
void CustomEnums ( )
{
2020-02-27 12:21:38 +03:00
StartBlock ( "public enum CallbackType" ) ;
2020-02-22 23:16:04 +03:00
foreach ( var c in def . callback_structs . OrderBy ( x = > x . CallbackId ) )
{
2020-02-27 13:01:43 +03:00
if ( Cleanup . IsDeprecated ( c . Name ) )
Write ( "// " ) ;
2020-02-22 23:16:04 +03:00
WriteLine ( $"{c.Name.Replace( " _t ", " " ) } = {c.CallbackId}," ) ;
}
EndBlock ( ) ;
2020-02-27 12:21:38 +03:00
2020-02-27 13:01:43 +03:00
int last = - 1 ;
2020-02-27 12:21:38 +03:00
StartBlock ( "internal static partial class CallbackTypeFactory" ) ;
StartBlock ( "internal static System.Collections.Generic.Dictionary<CallbackType, System.Type> All = new System.Collections.Generic.Dictionary<CallbackType, System.Type>" ) ;
foreach ( var c in def . callback_structs . OrderBy ( x = > x . CallbackId ) )
{
2020-02-28 16:26:06 +03:00
if ( Cleanup . IsDeprecated ( c . Name ) )
continue ;
if ( last = = c . CallbackId )
2020-02-27 12:21:38 +03:00
Write ( "// " ) ;
WriteLine ( $"{{ CallbackType.{c.Name.Replace( " _t ", " " ) }, typeof( {Cleanup.ConvertType(c.Name)} )}}," ) ;
2020-02-27 13:01:43 +03:00
last = c . CallbackId ;
2020-02-27 12:21:38 +03:00
}
EndBlock ( ";" ) ;
EndBlock ( ) ;
}
2020-02-22 23:16:04 +03:00
}
}