EgorBo / CppPinvokeGenerator

A simple pinvoke generator based on CppAst to generate C# for C++
BSD 2-Clause "Simplified" License
31 stars 6 forks source link

Is it related to the UrhoSharp? #1

Open OmidID opened 5 years ago

OmidID commented 5 years ago

Do you have plan to use it in UrhoSharp? Could be nice to have better generator. Currently it's not possible to use native libraries and sample codes from Urho3D. Maybe with new generator will be possible and also would be nice to generate codes in Windows too.

EgorBo commented 5 years ago

@OmidID Honestly, not sure, but I'll try.

OmidID commented 5 years ago

Perfect! I hope to receive good news from you :) Thanks

OmidID commented 5 years ago

I try to bind Urho3D header files and I got an error

var options = new CppParserOptions();
// TODO: test on macOS
options.ConfigureForWindowsMsvc(CppTargetCpu.X86_64);
options.AdditionalArguments.Add("-std=c++17");
options.IncludeFolders.Add(outputFolder);
options.IncludeFolders.Add(Path.Combine(outputFolder, "Urho3D", "ThirdParty"));
CppCompilation compilation = CppParser.ParseFile(Path.Combine(outputFolder, @"Urho3DAll.h"), options);

Error: System.ArgumentException: 'An item with the same key has already been added. Key: c:@T@RPCNOTIFICATION_ROUTINE'

   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at CppAst.CppModelBuilder.VisitTypeDefDecl(CXCursor cursor, CXCursor parent, CXClientData data)
   at CppAst.CppModelBuilder.VisitMember(CXCursor cursor, CXCursor parent, CXClientData data)
   at CppAst.CppModelBuilder.VisitTranslationUnit(CXCursor cursor, CXCursor parent, CXClientData data)
   at ClangSharp.clang.visitChildren(CXCursor parent, CXCursorVisitor visitor, CXClientData client_data)
   at CppAst.CppParser.ParseInternal(List`1 cppFiles, CppParserOptions options)
   at CppAst.CppParser.ParseFiles(List`1 cppFilenameList, CppParserOptions options)
   at SimdJson.Program.Main(String[] args)

It's weird in the CppAst code i can see there is a checking before add new item to typedefs. I cannot understand why it's will be pass the checking duplicate item! https://github.com/xoofx/CppAst/blob/0.3.0/src/CppAst/CppModelBuilder.cs#L1359