lsalamon / csharp-to-cpp-cli Goto Github PK
View Code? Open in Web Editor NEWThis project forked from lodle/csharp-to-cpp-cli
Convert C# classes to be used with C++/CLi DLL which then can be used with c++
This project forked from lodle/csharp-to-cpp-cli
Convert C# classes to be used with C++/CLi DLL which then can be used with c++
This creates a native wrapper around managed C# classes using C++/Cli. Include a reference to CSharpToCpp.DLL and mark the classes you want exposed using the ExposeToCpp Attribute. Then run CSharpToCppGenerator pointed at your Dll and it will parse it generating the files you need to complie into a c++/cli dll. Works with String and native types (int, double, bool). Support for List and Dictonary soon. For Example: [ExposeToCpp] public class TestClass { public String ClassName { get; set; } public int ClassCount { get; set; } public TestClass() { } } Produces: ////////////////////////////// Header ////////////////////////////// #pragma once #include "BaseClass.h" #ifndef DLLFN #ifndef DLL_EXPORT #define DLLFN __declspec( dllimport ) #else #define DLLFN __declspec( dllexport ) #endif #endif class TestClassI { public: virtual void GetClassName(char* szOutBuff, size_t nOutBuffSize)=0; virtual void SetClassName(const char* _ClassName)=0; virtual int GetClassCount()=0; virtual void SetClassCount(int _ClassCount)=0; virtual int GetInt()=0; virtual void ToString(char* szOutBuff, size_t nOutBuffSize)=0; virtual int GetHashCode()=0; }; extern "C" { DLLFN TestClassI* NewTestClass(); #ifdef DLL_EXPORT TestClassI* NewTestClassCPP(CSharpTestLib::TestClass^ _Internal); #endif } ////////////////////////////// CPP ////////////////////////////// #define DLL_EXPORT #include "TestClass.h" using namespace CSharpTestLib; class TestClassCPP : public TestClassI { public: TestClassCPP() { m_TestClass = gcnew TestClass(); } TestClassCPP(TestClass^ _Internal) { m_TestClass = _Internal; } virtual void GetClassName(char* szOutBuff, size_t nOutBuffSize) { System::String^ ret = m_TestClass->ClassName; std::string szRet = marshal_as<std::string>(ret); strncpy_s(szOutBuff, nOutBuffSize, szRet.c_str(), szRet.size()); } virtual void SetClassName(const char* _ClassName) { m_TestClass->ClassName = gcnew System::String(_ClassName); } virtual int GetClassCount() { return m_TestClass->ClassCount; } virtual void SetClassCount(int _ClassCount) { m_TestClass->ClassCount = _ClassCount; } virtual int GetInt() { return m_TestClass->GetInt(); } virtual void ToString(char* szOutBuff, size_t nOutBuffSize) { System::String^ ret = m_TestClass->ToString(); std::string szRet = marshal_as<std::string>(ret); strncpy_s(szOutBuff, nOutBuffSize, szRet.c_str(), szRet.size()); } virtual int GetHashCode() { return m_TestClass->GetHashCode(); } TestClass^ InternalObject(){return m_TestClass;} virtual void Destroy(){delete this;} private: gcroot<TestClass^> m_TestClass; }; extern "C" { DLLFN TestClassI* NewTestClass() { return new TestClassCPP(); } TestClassI* NewTestClassCPP(TestClass^ _Internal) { return new TestClassCPP(_Internal); } } //////////////////////////////
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.