mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-01-23 20:17:58 +03:00
More marshalling
This commit is contained in:
parent
43705fed86
commit
28a781d511
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -154,52 +154,58 @@ namespace Generator
|
||||
internal string InteropParameter( bool LargePack, bool includeMarshalling = false )
|
||||
{
|
||||
var ps = LargePack ? "" : ".PackSmall";
|
||||
|
||||
var marshalling = "";
|
||||
if ( !NativeType.Contains( "_t" ) )
|
||||
ps = string.Empty;
|
||||
|
||||
if ( TypeDef != null )
|
||||
ps = string.Empty;
|
||||
|
||||
if ( includeMarshalling )
|
||||
if ( includeMarshalling )
|
||||
{
|
||||
if ( NativeType == "bool" ) marshalling = "[MarshalAs(UnmanagedType.U1)]";
|
||||
if ( NativeType == "bool *" ) marshalling = "[MarshalAs(UnmanagedType.U1)]";
|
||||
|
||||
if ( TypeDef != null && TypeDef.NativeType.Contains( "_t" ) )
|
||||
{
|
||||
// if ( !TypeDef.NativeType.Contains( "*" ) )
|
||||
// return $"{TypeDef.ManagedType} {Name}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( ShouldBeIntPtr )
|
||||
return $"IntPtr /*{NativeType}*/ {Name}";
|
||||
return $"IntPtr /*{NativeType}*/ {Name}".Trim();
|
||||
|
||||
if ( IsStructShouldBePassedAsRef )
|
||||
return $"ref {ManagedType.Trim( '*', ' ' )}{ps} /*{NativeType}*/ {Name}";
|
||||
return $"{marshalling} ref {ManagedType.Trim( '*', ' ' )}{ps} /*{NativeType}*/ {Name}".Trim();
|
||||
|
||||
if ( ShouldBePassedAsOut )
|
||||
return $"out {ManagedType.Trim( '*', ' ' )} /*{NativeType}*/ {Name}";
|
||||
return $"{marshalling} out {ManagedType.Trim( '*', ' ' )} /*{NativeType}*/ {Name}".Trim();
|
||||
|
||||
if ( NativeType == "char *" || NativeType == "char **" )
|
||||
{
|
||||
return $"System.Text.StringBuilder /*{NativeType}*/ {Name}";
|
||||
return $"System.Text.StringBuilder /*{NativeType}*/ {Name}".Trim();
|
||||
}
|
||||
|
||||
if ( TypeDef != null )
|
||||
{
|
||||
if ( NativeType.EndsWith( "*" ) )
|
||||
{
|
||||
return $"IntPtr /*{NativeType}*/ {Name}";
|
||||
return $"IntPtr /*{NativeType}*/ {Name}".Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{TypeDef.Name} /*{NativeType}*/ {Name}";
|
||||
return $"{marshalling} {TypeDef.Name} /*{NativeType}*/ {Name}".Trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( NativeType.EndsWith( "*" ) && ManagedType.Contains( "_t" ) )
|
||||
{
|
||||
return $"IntPtr /*{NativeType}*/ {Name} ";
|
||||
return $"IntPtr /*{NativeType}*/ {Name} ".Trim();
|
||||
}
|
||||
|
||||
return $"{ManagedType} /*{NativeType}*/ {Name} ";
|
||||
return $"{marshalling} {ManagedType} /*{NativeType}*/ {Name} ".Trim();
|
||||
}
|
||||
|
||||
internal string Return()
|
||||
|
@ -173,7 +173,7 @@ namespace Generator
|
||||
|
||||
WriteLine( $"[DllImportAttribute( \"{library}\", EntryPoint = \"{flatName}\" )]" );
|
||||
|
||||
if ( ret.Return() == "bool" )WriteLine( "[return: MarshalAs(UnmanagedType.Bool)]" );
|
||||
if ( ret.Return() == "bool" ) WriteLine( "[return: MarshalAs(UnmanagedType.U1)]" );
|
||||
|
||||
WriteLine( $"internal static extern {ret.Return()} {methodName}({argstring});" );
|
||||
LastMethodName = methodDef.Name;
|
||||
|
Loading…
x
Reference in New Issue
Block a user