diff --git a/Generator/Argument.cs b/Generator/Argument.cs index db672d3..8a42e02 100644 --- a/Generator/Argument.cs +++ b/Generator/Argument.cs @@ -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; diff --git a/Generator/CodeWriter/Class.cs b/Generator/CodeWriter/Class.cs index 356be54..ce9908f 100644 --- a/Generator/CodeWriter/Class.cs +++ b/Generator/CodeWriter/Class.cs @@ -281,7 +281,7 @@ private void Detect_IntPtrArgs( List argList, List callargs { foreach ( var a in callargs ) { - if ( !a.InteropParameter( false ).StartsWith( "IntPtr" ) ) + if ( !a.InteropParameter( false, false, false ).StartsWith( "IntPtr" ) ) { continue; } diff --git a/Generator/CodeWriter/Interface.cs b/Generator/CodeWriter/Interface.cs index f7d7d36..d100639 100644 --- a/Generator/CodeWriter/Interface.cs +++ b/Generator/CodeWriter/Interface.cs @@ -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});" ); diff --git a/Generator/CodeWriter/PlatformClass.cs b/Generator/CodeWriter/PlatformClass.cs index 3452be9..dac9acb 100644 --- a/Generator/CodeWriter/PlatformClass.cs +++ b/Generator/CodeWriter/PlatformClass.cs @@ -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 ) {