Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return value can't be changed on functions? #218

Open
ArcanoxDragon opened this issue Dec 29, 2021 · 0 comments
Open

Return value can't be changed on functions? #218

ArcanoxDragon opened this issue Dec 29, 2021 · 0 comments

Comments

@ArcanoxDragon
Copy link

ArcanoxDragon commented Dec 29, 2021

I'm having troubles properly overriding the return value on some functions I'm trying to map. I have multiple <map function= mappings, the first of which applies to all functions that I import, and the second of which specifically takes one single function of which I need to override the return value:

<mapping>
    <!-- Default config for all elements -->
    <map element=".*" visibility="internal" />

    <!-- Default mappings of exported symbols -->
    <map struct=".*" group="MyGroup.Types" />
    <map function="(.*)" group="MyGroup.Functions" name="$1" dll="&quot;somelibrary&quot;" />

    <!-- Overrides for specific function parameters and return types -->
    <map function="a_specific_function" type="SomeType" />
</mapping>

The first 3 mappings are all definitely applied, however the type attribute on the final mapping does not work. I actually suffered through setting up a locally packaged version of SharpGenTools to debug the SDK while my project is building, and I can see the rule being applied on the a_specific_function "Callable", but it looks like Rule.MappingType is simply not used for functions. I found where it is applied for in lines 125-130 of MethodTransform.cs but for some reason it isn't sticking, or is getting reset somewhere. I set a breakpoint on line 142 of InteropSignatureTransform.cs and the value of callable.ReturnValue that gets passed to GetInteropTypeForReturnValue is the default return type, not the one specified in the rule I have (I can see in the debugger that the value of callable.CppElement.Rule.MappingType is exactly what I'm trying to set it to, it's just not being obeyed).
When a_specific_function is generated, it uses the default return value type no matter what I do.

Something else I noticed is that, because IsFinalMappingName defaults to false and not null, it causes the name="$1" attribute on the first function mapping to have no effect on a_specific_function due to line 122 in CppElement.Extensions.cs, and the default naming rules are applied instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant