mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-12 06:38:01 +03:00
Use new structs properly
This commit is contained in:
parent
cf8aa9501c
commit
db7c8d66a4
@ -205,9 +205,9 @@ namespace Generator
|
|||||||
return $"{Name}{value}";
|
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 = "";
|
var marshalling = "";
|
||||||
if ( !NativeType.Contains( "_t" ) )
|
if ( !NativeType.Contains( "_t" ) )
|
||||||
ps = string.Empty;
|
ps = string.Empty;
|
||||||
|
@ -281,7 +281,7 @@ namespace Generator
|
|||||||
{
|
{
|
||||||
foreach ( var a in callargs )
|
foreach ( var a in callargs )
|
||||||
{
|
{
|
||||||
if ( !a.InteropParameter( false ).StartsWith( "IntPtr" ) )
|
if ( !a.InteropParameter( false, false, false ).StartsWith( "IntPtr" ) )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ namespace Generator
|
|||||||
if ( m.ClassName == "SteamApi" )
|
if ( m.ClassName == "SteamApi" )
|
||||||
flatName = methodName;
|
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} ";
|
if ( argstring != "" ) argstring = $" {argstring} ";
|
||||||
|
|
||||||
WriteLine( $"{ret.Return()} {m.ClassName}_{methodName}({argstring});" );
|
WriteLine( $"{ret.Return()} {m.ClassName}_{methodName}({argstring});" );
|
||||||
|
@ -89,7 +89,7 @@ namespace Generator
|
|||||||
if ( classname == "SteamApi" )
|
if ( classname == "SteamApi" )
|
||||||
flatName = methodName;
|
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} ";
|
if ( argstring != "" ) argstring = $" {argstring} ";
|
||||||
|
|
||||||
StartBlock( $"public virtual {ret.Return()} {classname}_{methodName}({argstring})" );
|
StartBlock( $"public virtual {ret.Return()} {classname}_{methodName}({argstring})" );
|
||||||
@ -113,16 +113,25 @@ namespace Generator
|
|||||||
|
|
||||||
foreach ( var a in arguments )
|
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;" );
|
AfterLines.Add( $"{a.Name} = {a.Name}_ps;" );
|
||||||
a.Name = "ref " + a.Name + "_ps";
|
a.Name = "ref " + a.Name + "_ps";
|
||||||
|
|
||||||
if ( retcode != "" )
|
if ( retcode != "" )
|
||||||
retcode = "var ret = ";
|
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 ) ) );
|
argstring = string.Join( ", ", arguments.Select( x => x.InteropVariable( false ) ) );
|
||||||
|
|
||||||
@ -178,7 +187,7 @@ namespace Generator
|
|||||||
if ( classname == "SteamApi" )
|
if ( classname == "SteamApi" )
|
||||||
flatName = methodName;
|
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 )
|
if ( methodDef.NeedsSelfPointer )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user