Put callback functions in the right order on non windows

This commit is contained in:
Garry Newman 2016-11-01 11:05:26 +00:00
parent c9443b75f2
commit 39c5860041
3 changed files with 1125 additions and 304 deletions

File diff suppressed because it is too large Load Diff

View File

@ -230,12 +230,22 @@ private void Callback( SteamApiDefinition.StructDef c )
WriteLine( "handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) );" ); WriteLine( "handle.vTablePtr = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( Callback.VTable ) ) );" );
StartBlock( "var vTable = new Callback.VTable()" ); StartBlock( "var vTable = new Callback.VTable()" );
{ {
WriteLine( "ResultA = Marshal.GetFunctionPointerForDelegate( funcB ), // The order of these functions is a point of contention" ); WriteLine( "ResultA = Marshal.GetFunctionPointerForDelegate( funcA )," );
WriteLine( "ResultB = Marshal.GetFunctionPointerForDelegate( funcA ), // Doesn't seem to matter win64, but win32 crashes if WithInfo not first" ); WriteLine( "ResultB = Marshal.GetFunctionPointerForDelegate( funcB )," );
WriteLine( "GetSize = Marshal.GetFunctionPointerForDelegate( funcC ), // Which is the opposite of how they are in code, but whatever works" ); WriteLine( "GetSize = Marshal.GetFunctionPointerForDelegate( funcC )," );
} }
EndBlock( ";" ); EndBlock( ";" );
WriteLine( "//" );
WriteLine( "// The order of these functions are swapped on Windows" );
WriteLine( "//" );
StartBlock( "if ( Platform.Os == OperatingSystem.Windows )" );
{
WriteLine( "vTable.ResultA = Marshal.GetFunctionPointerForDelegate( funcB );" );
WriteLine( "vTable.ResultB = Marshal.GetFunctionPointerForDelegate( funcA );" );
}
EndBlock();
WriteLine( "Marshal.StructureToPtr( vTable, handle.vTablePtr, false );" ); WriteLine( "Marshal.StructureToPtr( vTable, handle.vTablePtr, false );" );
WriteLine( "" ); WriteLine( "" );

View File

@ -43,6 +43,17 @@ private void StartBlock( string v )
indent++; indent++;
} }
private void Else( string v = "" )
{
indent--;
WriteLine( "}" );
WriteLine( "else"+ v );
WriteLine( "{" );
indent++;
}
private void WriteLines( List<string> beforeLines ) private void WriteLines( List<string> beforeLines )
{ {
foreach ( var line in beforeLines ) foreach ( var line in beforeLines )