try generate nvgraph binding
in nvgraph.h there are enums that declared like
typedef enum
{
NVGRAPH_PLUS_TIMES_SR = 0,
NVGRAPH_MIN_PLUS_SR = 1,
NVGRAPH_MAX_MIN_SR = 2,
NVGRAPH_OR_AND_SR = 3,
} nvgraphSemiring_t;
the generator don't generate the correct name
Yes, this is a bug.
This is an anonymous enum type with a typedef. First, in the generator, anonymous enums generally get a generated name. Second, typedefs aren't supported in C#, but I try to place the value in a struct, which can be passed by value to C. Piggy deals with these issues separately, and currently doesn't handle the combined (i.e., you just want to use the damn typedef name in a C# enum). I'll try to add a fix to the template/*.pig files in the next release, which will be a while (I'm rewriting the low-level NFA recognizer, adding a Java serializer, and likely to write a new C++ serializer based on the C++ grammars in Antlr4. In lieu of that, a work around is here:
using 'ClangSupport.pig';
using 'Enums.pig';
using 'Structs.pig';
using 'Funcs.pig';
using 'Namespace.pig';
using 'Typedefs.pig';
template Project1ClangSupport : ClangSupport
{
init {{
namespace_name = "Csharp";
limit = ".*\\.*Cpp.*\\.*";
dllname = "Cpp";
ClangSupport._anonymous_enum_map = new Dictionary<string, string>() {
{ "NVGRAPH_PLUS_TIMES_SR", "nvgraphSemiring_t" }
};
ClangSupport.AddAppliedOccurrenceRewrites(true, new Dictionary<string, string>() {
{ "nvgraphSemiring_t", "nvgraphSemiring_t" },
});
ClangSupport.AddAppliedOccurrenceRewrites(false, new Dictionary<string, string>() {
{ "nvgraphSemiring_t", "nvgraphSemiring_t" },
});
}}
pass Start { ( TranslationUnitDecl ) }
}
application
Project1ClangSupport.Start
Namespace.GenerateStart
Enums.GenerateEnums
Typedefs.GeneratePointerTypes
Structs.GenerateStructs
Typedefs.GenerateTypedefs
Funcs.Start
Funcs.Functions
Funcs.End
Namespace.GenerateEnd
;
The _anonymous_enum_map variable contains a mapping for anonymous enums--if the generator sees a constant with name NVGRAPH_PLUS_TIMES_SR, use nvgraphSemiring_t as the name of the enum instead of deriving one. AddAppliedOccurrenceRewrites is used to avoid generating a struct for the typedef, and instead just use the name nvgraphSemiring_t. When in doubt, peruse the Templates/*.pig files, or overwrite them as needed.