Skip to content

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

Description

@ArcanoxDragon

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions