CppSharp icon indicating copy to clipboard operation
CppSharp copied to clipboard

Duplicated function for overloads & missing functions when trying to wrap GenICam reference implementation

Open ax-meyer opened this issue 2 years ago • 1 comments

Brief Description

I am trying to wrap the GenICam reference implementation https://www.emva.org/wp-content/uploads/GenICam_Package_2023.07.zip.

The generated code won't compile.

After wrapping, the file IPortStacked.cs contains the same definition twice for an overload:

// void Write(PORT_REGISTER_STACK_ENTRY *pEntries, size_t numEntries) = 0
private static global::GenICam.Delegates.Action___IntPtr___IntPtr_ulong _WriteDelegateInstance;

// void Write(const void *pBuffer, int64_t Address, int64_t Length) = 0
private static global::GenICam.Delegates.Action___IntPtr___IntPtr_long_long _WriteDelegateInstance;

Additionally, some functions are missing: In NodeMapRef.cs

private static void _GetSupportedSchemaVersionsDelegateHook(__IntPtr __instance, __IntPtr SchemaVersions)
{
    var __target = global::GenICam.GenApi3_4.CNodeMapRef.__GetInstance(__instance);
    var __result0 = global::GenICam.GenICam3_4.GcstringVector.__GetOrCreateInstance(SchemaVersions, false, skipVTables: true);
    __target.GetSupportedSchemaVersions(__result0);
}

the function call in the last line GetSupportedSchemaVersions does not exist - __target is of type CNodeMapRef, but GetSupportedSchemaVersions only exists in CNodeMapFactory

OS: up2date Windows 11, net7

Used headers

GenICam.h from Reference Implementation\GenICam_V3_4_1-Win64_x64_VC141-Release-SDK\library\CPP\include in the ZIP linked above

Used settings
public void Setup(Driver driver)
{
    var baseIncludeDir = @"<path-to-extracted-download>\GenICam_Package_2023.07\Reference Implementation\GenICam_V3_4_1-Win64_x64_VC141-Release-SDK\library\CPP\include";
    var baseLibDir = @"<path-to-extracted-download>\GenICam_Package_2023.07\Reference Implementation\GenICam_V3_4_1-Win64_x64_VC141-Release-SDK\library\CPP\lib\Win64_x64";

    var options = driver.Options;
    options.OutputDir = @"<path-to-test-solution-folder>\GenicamUsageTest\GenICam";
    options.GeneratorKind = GeneratorKind.CSharp;
    options.GenerationOutputMode = GenerationOutputMode.FilePerUnit;
    var module = options.AddModule("GenICam");

    module.IncludeDirs.Add(baseIncludeDir);
    module.Headers.Add("GenICam.h");

    module.LibraryDirs.Add(baseLibDir);

    driver.ParserOptions.AddArguments("-fcxx-exceptions");
    driver.ParserOptions.EnableRTTI = true;
    driver.ParserOptions.AddDefines("_WIN32");
    driver.ParserOptions.AddDefines("_MT");
}

Target: MSVC

Other settings

Stack trace or incompilable generated code

It's over 20k lines of generated code, see attached sample project: GeniCamWrapperTest\GenicamUsageTest\GenICam\*.cs GeniCamWrapperTest.zip

Am I just missing some settings I need to tweak? Or is a large library like GenICam just to complex for auto-wrapping?

Thanks in advance for any help!

ax-meyer avatar Nov 14 '23 15:11 ax-meyer

Not sure if it's too complex for auto wrapping, just looks like there's some bugs/edge cases in CppSharp. I don't really have time to help you troubleshoot these at the moment, if you want to see these fixed earlier you can try to debug the generator yourself, and/or try to come up with isolated test cases for these issues, that will increase the probability of them being fixed soon significantly.

tritao avatar Nov 14 '23 19:11 tritao