2
0
mirror of https://github.com/raylib-cs/raylib-cs synced 2025-04-05 11:19:39 -04:00
raylib-cs/Raylib-cs/Generator.cs
ChrisDill 759a652501 Added raylib-example project
- Separate project to test raylib on its own.
-
2018-07-28 09:26:59 +01:00

56 lines
2.1 KiB
C#

using CppSharp;
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Passes;
namespace Raylibcs
{
/// <summary>
/// Generates the bindings for raylib
/// ConsoleDriver.Run(new SampleLibrary());
/// </summary>
public class SampleLibrary : ILibrary
{
void ILibrary.Setup(Driver driver)
{
var options = driver.Options;
var module = options.AddModule("raylib");
// module.IncludeDirs.Add("C:\\raylib\\raylib\\release\\include");
module.IncludeDirs.Add("C:\\raylib\\raylib\\src");
module.Headers.Add("raylib.h");
module.Headers.Add("rlgl.h");
module.Headers.Add("raymath.h");
// module.Headers.Add("easings.h");
module.LibraryDirs.Add("C:\\raylib\\raylib\\projects\\VS2017\\x64\\Debug.DLL");
module.Libraries.Add("raylib.lib");
var parserOptions = driver.ParserOptions;
options.GeneratorKind = GeneratorKind.CSharp;
options.Verbose = true;
}
void ILibrary.SetupPasses(Driver driver)
{
driver.Context.TranslationUnitPasses.RenameDeclsUpperCase(RenameTargets.Any);
// driver.AddTranslationUnitPass(new FunctionToInstanceMethodPass());
// driver.AddTranslationUnitPass(new HandleDefaultParamValuesPass());
// driver.AddTranslationUnitPass(new CheckOperatorsOverloadsPass());
// driver.Context.TranslationUnitPasses.RemovePrefix("KEY_");
}
public void Preprocess(Driver driver, ASTContext ctx)
{
ctx.SetNameOfEnumWithMatchingItem("KEY_UNKOWN", "Key");
ctx.GenerateEnumFromMacros("Flag", "FLAG_(.*)");
ctx.GenerateEnumFromMacros("Key", "KEY_(.*)");
ctx.GenerateEnumFromMacros("Mouse", "MOUSE_(.*)");
ctx.GenerateEnumFromMacros("Colors", "RAYWHITE");
// ctx.GenerateEnumFromMacros("Gamepad", "GAMEPAD_(.*)");
}
public void Postprocess(Driver driver, ASTContext ctx)
{
}
}
}