Last active
July 13, 2021 21:01
-
-
Save flibitijibibo/ff5b81326573fb60ced8ed93b6d75485 to your computer and use it in GitHub Desktop.
Barfs out all the SDL P/Invoke functions needed to dynamically link
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reflection; | |
static class Program | |
{ | |
static void Main(string[] args) | |
{ | |
MethodInfo[] methods = typeof(SDL2.SDL).GetMethods(BindingFlags.Public | BindingFlags.Static); | |
foreach (MethodInfo m in methods) | |
{ | |
/* Ignore UTF8 helpers */ | |
if (m.Name.StartsWith("UTF8")) | |
{ | |
continue; | |
} | |
/* Ignore macros */ | |
bool isMacro = true; | |
foreach (char c in m.Name) | |
{ | |
if (char.IsLetter(c) && char.IsLower(c)) | |
{ | |
isMacro = false; | |
break; | |
} | |
} | |
if (isMacro) | |
{ | |
continue; | |
} | |
/* Ignore platform crap */ | |
if ( m.Name.Contains("Android") || | |
m.Name.Contains("iPhone") || | |
m.Name.Contains("WinRT") || | |
m.Name.Contains("Metal") || | |
m.Name.Contains("UIKit") || | |
m.Name.Contains("Chromebook") || | |
m.Name.Contains("DeX") || | |
m.Name.Contains("SetWindowsMessageHook") ) | |
{ | |
continue; | |
} | |
/* Finally, a real function! */ | |
Console.WriteLine("SDL2!" + m.Name); | |
} | |
/* Special cases for SDL_malloc/SDL_free */ | |
Console.WriteLine("SDL2!SDL_malloc"); | |
Console.WriteLine("SDL2!SDL_free"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment