mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-24 13:45:37 +03:00
Use new structs properly
This commit is contained in:
parent
cf8aa9501c
commit
db7c8d66a4
@ -205,9 +205,9 @@ internal string InteropVariable( bool AsRawValues )
|
||||
return $"{Name}{value}";
|
||||
}
|
||||
|
||||
internal string InteropParameter( bool LargePack, bool includeMarshalling = false )
|
||||
internal string InteropParameter( bool NoPacking, bool LargePack, bool includeMarshalling )
|
||||
{
|
||||
var ps = LargePack ? "" : ".PackSmall";
|
||||
var ps = NoPacking ? "" : (LargePack ? ".Pack8" : ".Pack4");
|
||||
var marshalling = "";
|
||||
if ( !NativeType.Contains( "_t" ) )
|
||||
ps = string.Empty;
|
||||
|
@ -281,7 +281,7 @@ private void Detect_IntPtrArgs( List<Argument> argList, List<Argument> callargs
|
||||
{
|
||||
foreach ( var a in callargs )
|
||||
{
|
||||
if ( !a.InteropParameter( false ).StartsWith( "IntPtr" ) )
|
||||
if ( !a.InteropParameter( false, false, false ).StartsWith( "IntPtr" ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ private void PlatformInterfaceMethod( SteamApiDefinition.MethodDef m )
|
||||
if ( m.ClassName == "SteamApi" )
|
||||
flatName = methodName;
|
||||
|
||||
var argstring = string.Join( ", ", arguments.Select( x => x.InteropParameter( true, true ) ) );
|
||||
var argstring = string.Join( ", ", arguments.Select( x => x.InteropParameter( true, true, true ) ) );
|
||||
if ( argstring != "" ) argstring = $" {argstring} ";
|
||||
|
||||
WriteLine( $"{ret.Return()} {m.ClassName}_{methodName}({argstring});" );
|
||||
|
@ -89,7 +89,7 @@ private void PlatformClassMethod( string classname, SteamApiDefinition.MethodDef
|
||||
if ( classname == "SteamApi" )
|
||||
flatName = methodName;
|
||||
|
||||
var argstring = string.Join( ", ", arguments.Select( x => x.InteropParameter( true, true ) ) );
|
||||
var argstring = string.Join( ", ", arguments.Select( x => x.InteropParameter( true, true, true ) ) );
|
||||
if ( argstring != "" ) argstring = $" {argstring} ";
|
||||
|
||||
StartBlock( $"public virtual {ret.Return()} {classname}_{methodName}({argstring})" );
|
||||
@ -113,16 +113,25 @@ private void PlatformClassMethod( string classname, SteamApiDefinition.MethodDef
|
||||
|
||||
foreach ( var a in arguments )
|
||||
{
|
||||
if ( a.InteropParameter( LargePack ).Contains( ".PackSmall" ) )
|
||||
if ( a.InteropParameter( false, LargePack, false ).Contains( ".Pack4" ) )
|
||||
{
|
||||
WriteLine( $"var {a.Name}_ps = new {a.ManagedType.Trim( '*' )}.PackSmall();" );
|
||||
WriteLine( $"var {a.Name}_ps = new {a.ManagedType.Trim( '*' )}.Pack4();" );
|
||||
AfterLines.Add( $"{a.Name} = {a.Name}_ps;" );
|
||||
a.Name = "ref " + a.Name + "_ps";
|
||||
|
||||
if ( retcode != "" )
|
||||
retcode = "var ret = ";
|
||||
}
|
||||
}
|
||||
else if ( a.InteropParameter( false, LargePack, false ).Contains( ".Pack8" ) )
|
||||
{
|
||||
WriteLine( $"var {a.Name}_ps = new {a.ManagedType.Trim( '*' )}.Pack8();" );
|
||||
AfterLines.Add( $"{a.Name} = {a.Name}_ps;" );
|
||||
a.Name = "ref " + a.Name + "_ps";
|
||||
|
||||
if ( retcode != "" )
|
||||
retcode = "var ret = ";
|
||||
}
|
||||
}
|
||||
|
||||
argstring = string.Join( ", ", arguments.Select( x => x.InteropVariable( false ) ) );
|
||||
|
||||
@ -178,7 +187,7 @@ private void InteropClassMethod( string library, string classname, SteamApiDefin
|
||||
if ( classname == "SteamApi" )
|
||||
flatName = methodName;
|
||||
|
||||
var argstring = string.Join( ", ", arguments.Select( x => x.InteropParameter( LargePack, true ) ) );
|
||||
var argstring = string.Join( ", ", arguments.Select( x => x.InteropParameter( false, LargePack, true ) ) );
|
||||
|
||||
if ( methodDef.NeedsSelfPointer )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user