Global function cleanup

This commit is contained in:
Garry Newman 2019-06-25 12:13:04 +01:00
parent d5abb32aeb
commit f53e1aaba0
5 changed files with 59 additions and 355 deletions

View File

@ -9,234 +9,89 @@ namespace Steamworks
{
internal static class SteamAPI
{
internal static class Win64
internal static class Native
{
[DllImport( "steam_api64", EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )]
[return: MarshalAs( UnmanagedType.I1 )]
public static extern bool SteamAPI_Init();
[DllImport( "steam_api64", EntryPoint = "SteamAPI_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_RunCallbacks();
[DllImport( "steam_api64", EntryPoint = "SteamAPI_RegisterCallback", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_RegisterCallback", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_RegisterCallback( IntPtr pCallback, int callback );
[DllImport( "steam_api64", EntryPoint = "SteamAPI_UnregisterCallback", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_UnregisterCallback", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_UnregisterCallback( IntPtr pCallback );
[DllImport( "steam_api64", EntryPoint = "SteamAPI_RegisterCallResult", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_RegisterCallResult", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_RegisterCallResult( IntPtr pCallback, SteamAPICall_t callback );
[DllImport( "steam_api64", EntryPoint = "SteamAPI_UnregisterCallResult", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_UnregisterCallResult", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_UnregisterCallResult( IntPtr pCallback, SteamAPICall_t callback );
[DllImport( "steam_api64", EntryPoint = "SteamAPI_Shutdown", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_Shutdown", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_Shutdown();
[DllImport( "steam_api64", EntryPoint = "SteamAPI_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamUser SteamAPI_GetHSteamUser();
[DllImport( "steam_api64", EntryPoint = "SteamAPI_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamPipe SteamAPI_GetHSteamPipe();
[DllImport( "steam_api64", EntryPoint = "SteamAPI_RestartAppIfNecessary", CallingConvention = CallingConvention.Cdecl )]
[return: MarshalAs( UnmanagedType.I1 )]
public static extern bool SteamAPI_RestartAppIfNecessary( uint unOwnAppID );
}
internal static class Posix
{
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_Init", CallingConvention = CallingConvention.Cdecl )]
[return: MarshalAs( UnmanagedType.I1 )]
public static extern bool SteamAPI_Init();
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_RunCallbacks();
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_RegisterCallback", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_RegisterCallback( IntPtr pCallback, int callback );
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_UnregisterCallback", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_UnregisterCallback( IntPtr pCallback );
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_RegisterCallResult", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_RegisterCallResult( IntPtr pCallback, SteamAPICall_t callback );
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_UnregisterCallResult", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_UnregisterCallResult( IntPtr pCallback, SteamAPICall_t callback );
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_Shutdown", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamAPI_Shutdown();
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamUser SteamAPI_GetHSteamUser();
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamPipe SteamAPI_GetHSteamPipe();
[DllImport( "libsteam_api", EntryPoint = "SteamAPI_RestartAppIfNecessary", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_RestartAppIfNecessary", CallingConvention = CallingConvention.Cdecl )]
[return: MarshalAs( UnmanagedType.I1 )]
public static extern bool SteamAPI_RestartAppIfNecessary( uint unOwnAppID );
}
static internal bool Init()
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamAPI_Init();
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamAPI_Init();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamAPI_Init();
}
static internal void RunCallbacks()
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamAPI_RunCallbacks();
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamAPI_RunCallbacks();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamAPI_RunCallbacks();
}
static internal void RegisterCallback( IntPtr pCallback, int callback )
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamAPI_RegisterCallback( pCallback, callback );
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamAPI_RegisterCallback( pCallback, callback );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamAPI_RegisterCallback( pCallback, callback );
}
static internal void UnregisterCallback( IntPtr pCallback )
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamAPI_UnregisterCallback( pCallback );
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamAPI_UnregisterCallback( pCallback );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamAPI_UnregisterCallback( pCallback );
}
static internal void RegisterCallResult( IntPtr pCallback, SteamAPICall_t callback )
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamAPI_RegisterCallResult( pCallback, callback );
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamAPI_RegisterCallResult( pCallback, callback );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamAPI_RegisterCallResult( pCallback, callback );
}
static internal void UnregisterCallResult( IntPtr pCallback, SteamAPICall_t callback )
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamAPI_UnregisterCallResult( pCallback, callback );
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamAPI_UnregisterCallResult( pCallback, callback );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamAPI_UnregisterCallResult( pCallback, callback );
}
static internal void Shutdown()
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamAPI_Shutdown();
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamAPI_Shutdown();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamAPI_Shutdown();
}
static internal HSteamUser GetHSteamUser()
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamAPI_GetHSteamUser();
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamAPI_GetHSteamUser();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamAPI_GetHSteamUser();
}
static internal HSteamPipe GetHSteamPipe()
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamAPI_GetHSteamPipe();
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamAPI_GetHSteamPipe();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamAPI_GetHSteamPipe();
}
static internal bool RestartAppIfNecessary( uint unOwnAppID )
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamAPI_RestartAppIfNecessary( unOwnAppID );
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamAPI_RestartAppIfNecessary( unOwnAppID );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamAPI_RestartAppIfNecessary( unOwnAppID );
}
}

View File

@ -9,98 +9,39 @@ namespace Steamworks
{
internal static class SteamGameServer
{
internal static class Win64
internal static class Native
{
[DllImport( "steam_api64", EntryPoint = "SteamGameServer_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamGameServer_RunCallbacks();
[DllImport( "steam_api64", EntryPoint = "SteamGameServer_Shutdown", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_Shutdown", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamGameServer_Shutdown();
[DllImport( "steam_api64", EntryPoint = "SteamGameServer_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamUser SteamGameServer_GetHSteamUser();
[DllImport( "steam_api64", EntryPoint = "SteamGameServer_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamPipe SteamGameServer_GetHSteamPipe();
}
internal static class Posix
{
[DllImport( "libsteam_api", EntryPoint = "SteamGameServer_RunCallbacks", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamGameServer_RunCallbacks();
[DllImport( "libsteam_api", EntryPoint = "SteamGameServer_Shutdown", CallingConvention = CallingConvention.Cdecl )]
public static extern void SteamGameServer_Shutdown();
[DllImport( "libsteam_api", EntryPoint = "SteamGameServer_GetHSteamUser", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamUser SteamGameServer_GetHSteamUser();
[DllImport( "libsteam_api", EntryPoint = "SteamGameServer_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamGameServer_GetHSteamPipe", CallingConvention = CallingConvention.Cdecl )]
public static extern HSteamPipe SteamGameServer_GetHSteamPipe();
}
static internal void RunCallbacks()
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamGameServer_RunCallbacks();
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamGameServer_RunCallbacks();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamGameServer_RunCallbacks();
}
static internal void Shutdown()
{
if ( Config.Os == OsType.Windows )
{
Win64.SteamGameServer_Shutdown();
}
else if ( Config.Os == OsType.Posix )
{
Posix.SteamGameServer_Shutdown();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
Native.SteamGameServer_Shutdown();
}
static internal HSteamUser GetHSteamUser()
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamGameServer_GetHSteamUser();
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamGameServer_GetHSteamUser();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamGameServer_GetHSteamUser();
}
static internal HSteamPipe GetHSteamPipe()
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamGameServer_GetHSteamPipe();
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamGameServer_GetHSteamPipe();
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamGameServer_GetHSteamPipe();
}
}

View File

@ -9,100 +9,40 @@ namespace Steamworks
{
internal static class SteamInternal
{
internal static class Win64
internal static class Native
{
[DllImport( "steam_api64", EntryPoint = "SteamInternal_GameServer_Init", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamInternal_GameServer_Init", CallingConvention = CallingConvention.Cdecl )]
[return: MarshalAs( UnmanagedType.I1 )]
public static extern bool SteamInternal_GameServer_Init( uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchVersionString );
[DllImport( "steam_api64", EntryPoint = "SteamInternal_FindOrCreateUserInterface", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamInternal_FindOrCreateUserInterface", CallingConvention = CallingConvention.Cdecl )]
public static extern IntPtr SteamInternal_FindOrCreateUserInterface( int steamuser, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string versionname );
[DllImport( "steam_api64", EntryPoint = "SteamInternal_FindOrCreateGameServerInterface", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamInternal_FindOrCreateGameServerInterface", CallingConvention = CallingConvention.Cdecl )]
public static extern IntPtr SteamInternal_FindOrCreateGameServerInterface( int steamuser, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string versionname );
[DllImport( "steam_api64", EntryPoint = "SteamInternal_CreateInterface", CallingConvention = CallingConvention.Cdecl )]
public static extern IntPtr SteamInternal_CreateInterface( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string version );
}
internal static class Posix
{
[DllImport( "libsteam_api", EntryPoint = "SteamInternal_GameServer_Init", CallingConvention = CallingConvention.Cdecl )]
[return: MarshalAs( UnmanagedType.I1 )]
public static extern bool SteamInternal_GameServer_Init( uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchVersionString );
[DllImport( "libsteam_api", EntryPoint = "SteamInternal_FindOrCreateUserInterface", CallingConvention = CallingConvention.Cdecl )]
public static extern IntPtr SteamInternal_FindOrCreateUserInterface( int steamuser, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string versionname );
[DllImport( "libsteam_api", EntryPoint = "SteamInternal_FindOrCreateGameServerInterface", CallingConvention = CallingConvention.Cdecl )]
public static extern IntPtr SteamInternal_FindOrCreateGameServerInterface( int steamuser, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string versionname );
[DllImport( "libsteam_api", EntryPoint = "SteamInternal_CreateInterface", CallingConvention = CallingConvention.Cdecl )]
[DllImport( Platform.LibraryName, EntryPoint = "SteamInternal_CreateInterface", CallingConvention = CallingConvention.Cdecl )]
public static extern IntPtr SteamInternal_CreateInterface( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string version );
}
static internal bool GameServer_Init( uint unIP, ushort usPort, ushort usGamePort, ushort usQueryPort, int eServerMode, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchVersionString )
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString );
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamInternal_GameServer_Init( unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString );
}
static internal IntPtr FindOrCreateUserInterface( int steamuser, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string versionname )
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamInternal_FindOrCreateUserInterface( steamuser, versionname );
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamInternal_FindOrCreateUserInterface( steamuser, versionname );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamInternal_FindOrCreateUserInterface( steamuser, versionname );
}
static internal IntPtr FindOrCreateGameServerInterface( int steamuser, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string versionname )
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamInternal_FindOrCreateGameServerInterface( steamuser, versionname );
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamInternal_FindOrCreateGameServerInterface( steamuser, versionname );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamInternal_FindOrCreateGameServerInterface( steamuser, versionname );
}
static internal IntPtr CreateInterface( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string version )
{
if ( Config.Os == OsType.Windows )
{
return Win64.SteamInternal_CreateInterface( version );
}
else if ( Config.Os == OsType.Posix )
{
return Posix.SteamInternal_CreateInterface( version );
}
else
{
throw new System.Exception( "this platform isn't supported" );
}
return Native.SteamInternal_CreateInterface( version );
}
}

View File

@ -11,8 +11,13 @@ internal static class Platform
{
#if PLATFORM_WIN64
public const int StructPlatformPackSize = 8;
#else
public const string LibraryName = "steam_api64";
#elif PLATFORM_WIN32
public const int StructPlatformPackSize = 4;
public const string LibraryName = "steam_api";
#elif PLATFORM_POSIX64
public const int StructPlatformPackSize = 4;
public const string LibraryName = "libsteam_api";
#endif
public const int StructPackSize = 4;

View File

@ -27,20 +27,11 @@ public void GenerateGlobalFunctions( string startingWith, string filename )
{
StartBlock( $"internal static class {startingWith}" );
{
StartBlock( $"internal static class Win64" );
StartBlock( $"internal static class Native" );
{
foreach ( var func in functions )
{
WriteMarshalledFunction( func, "steam_api64" );
}
}
EndBlock();
StartBlock( $"internal static class Posix" );
{
foreach ( var func in functions )
{
WriteMarshalledFunction( func, "libsteam_api" );
WriteMarshalledFunction( func );
}
}
EndBlock();
@ -87,56 +78,28 @@ private void WriteGlobalFunction( string cname, SteamApiDefinition.MethodDef fun
{
var callargs = string.Join( ", ", args.Select( x => x.AsCallArgument() ) );
StartBlock( "if ( Config.Os == OsType.Windows )" );
if ( returnType.IsReturnedWeird )
{
if ( returnType.IsReturnedWeird )
{
WriteLine( $"var retVal = default( {returnType.TypeName} );" );
WriteLine( $"Win64.{func.Name}( ref retVal, {callargs} );" );
WriteLine( $"{returnType.Return( "retVal" )}" );
}
else if ( returnType.IsVoid )
{
WriteLine( $"Win64.{func.Name}( {callargs} );" );
}
else
{
var v = $"Win64.{func.Name}( {callargs} )";
WriteLine( returnType.Return( v ) );
}
WriteLine( $"var retVal = default( {returnType.TypeName} );" );
WriteLine( $"Native.{func.Name}( ref retVal, {callargs} );" );
WriteLine( $"{returnType.Return( "retVal" )}" );
}
Else( " if ( Config.Os == OsType.Posix )" );
else if ( returnType.IsVoid )
{
if ( returnType.IsReturnedWeird )
{
WriteLine( $"var retVal = default( {returnType.TypeName} );" );
WriteLine( $"Posix.{func.Name}( ref retVal, {callargs} );" );
WriteLine( $"{returnType.Return( "retVal" )}" );
}
else if ( returnType.IsVoid )
{
WriteLine( $"Posix.{func.Name}( {callargs} );" );
}
else
{
var v = $"Posix.{func.Name}( {callargs} )";
WriteLine( returnType.Return( v ) );
}
WriteLine( $"Native.{func.Name}( {callargs} );" );
}
Else();
else
{
WriteLine( "throw new System.Exception( \"this platform isn't supported\" );" );
var v = $"Native.{func.Name}( {callargs} )";
WriteLine( returnType.Return( v ) );
}
EndBlock();
}
EndBlock();
}
private void WriteMarshalledFunction( SteamApiDefinition.MethodDef func, string dllName )
private void WriteMarshalledFunction( SteamApiDefinition.MethodDef func )
{
var returnType = BaseType.Parse( func.ReturnType );
returnType.Func = func.Name;
@ -153,7 +116,7 @@ private void WriteMarshalledFunction( SteamApiDefinition.MethodDef func, string
var argstr = string.Join( ", ", args.Select( x => x.AsArgument() ) );
var delegateargstr = string.Join( ", ", args.Select( x => x.AsArgument() ) );
WriteLine( $"[DllImport( \"{dllName}\", EntryPoint = \"{func.Name}\", CallingConvention = CallingConvention.Cdecl )]" );
WriteLine( $"[DllImport( Platform.LibraryName, EntryPoint = \"{func.Name}\", CallingConvention = CallingConvention.Cdecl )]" );
if ( returnType.ReturnAttribute != null )
WriteLine( returnType.ReturnAttribute );