diff --git a/README.md b/README.md new file mode 100644 index 0000000..a31539b --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# Cpp2Beef +Cpp2Beef is a library for writing high quality beef bindings for C and C-Style C++. Cpp2Beef does the heavy lifting so you can focus on the library specific stuff. + +You can find bindings generated by Cpp2Beef at https://git.unicon-gmbh.de/BeefBindings. + +## Usage +1. Create a `Setup` workspace and add Cpp2Beef from remote (`https://git.unicon-gmbh.de/Rune/Cpp2Beef.git`) +2. Add Cpp2Beef as a dependency +3. Write your generator +```beef +class ExampleGenerator : Cpp2BeefGenerator, this(Span args) +{ + protected override Span Args => args; + protected override Flags Flags => .None; + + // You can have your binding in one file or in multiple, file management is up to you + StreamWriter writer = new .()..Create("../src/Example.bf")..Write(""" + // This file was generated by Cpp2Beef + + using System; + using System.Interop; + + namespace Example; + + + """) ~ delete _; + + protected override StreamWriter GetWriterForHeader(StringView header) + { + // Here you define the target file to which a cursor should be written + // Returning null skips the cursor + if (header.EndsWith("example.h")) + return writer; + return null; + } + + protected override Block GetCursorBlock(CXCursor cursor) + { + // Optional. This can be used put cursors in custom blocks + // This is useful if you want all your functions to be a static class + if (cursor.kind == .FunctionDecl) + return .CustomBlock("Example"); + return base.GetCursorBlock(cursor); + } + + protected override void HandleCursor(CXCursor cursor) + { + // Optional. Can be used to write custom logic, how a cursor should be written + // If your going for this I'd recommend looking at examples in BeefBindings + base.HandleCursor(cursor); + } + + protected override void WriteCustomAttributes(CXCursor cursor) + { + // Optional. + base.WriteCustomAttributes(cursor); + } + + protected override void GetNameInBindings(LibClang.CXCursor cursor, String outString) + { + // Optional but you pretty much want to always override this. + // Allows you to change the name of cursors + base.GetNameInBindings(cursor, outString); + } + + // There are functions you can override, but these are the most common +} +```