yuckify / cppsharp

0 stars 0 forks source link

Project:

cppsharp

A compiler that takes annotated c++ files. It generates a c# interface for c++ source code. The interface uses Internalcall which does not perform security checks when pass through the c# -> c++ boundary, however the performance is better than using PInvoke.

Overview of Design:

This application generates an interface that allows c# to call into c++ code and c++ code to call into select c# functions. A series of macros are used to annotate your c++ source code to determine how the interface will be generated.

Usage Details:

cppsharp operates like an advanced preprocessor. It only needs to know about declarations and headers, it does not need to know anything about linkage. For basic usage use the "-I" flag to tell cppsharp where to find headers. Use -o to determine where to put generated files. To generate the interface simply append the header or source files to the end of the cppsharp command.

Example Scenario: the potential environment is as follows "./include" contains headers "./bin" contains generated source files and binaries "./Test.hpp" contains the interface to generate

the resulting command to generate the c# interface cppsharp.exe -I:./include -o:./bin Test.hpp

a short explanation of generated files "./bin/Test.xml" the parsed Test.hpp file generated by castxml, useful for debugging "./bin/Test.cs" the generated c# interface, include this in your project to call into the c++ code "./bin/Test_cppsharp.cpp" header for generated interface "./bin/Test_cppsharp.hpp" header for generated interface "./bin/cppsharp_init.cpp" contains a function to initialize the generated interface

short explanation for usage of generated source files The generated c++ sources have to be compiled with your project so expose the appropriate interface to the c# code. The generated c# file needs to be compiled with your c# code into an assembly.

see the files in the "test" directory for more details on basic usage of cppsharp

Dependencies:

castxml mono c# boost jam - to build test on windows MINGW - to build/run test on windows

API:

__export

Examples: Export all public functions and variables in a class class ExampleA { public: int a; int doExample(); } __export;

__import