Skip to content

Passing this should be passed as a pointer #239

Description

@NickAcPT

Repro header:

struct TestInterface_;
struct MyStruct_;

#ifdef __cplusplus
typedef MyStruct_ MyStruct;
#endif

struct TestInterface_ {
    int (__stdcall *TestMethod)(MyStruct *vm);
};

struct MyStruct_ {
    const struct TestInterface_ *functions;
#ifdef __cplusplus
    int TestMethod() {
        return functions->TestMethod(this);
    }
#endif
};

Generated (Invalid) C# code:

public unsafe partial struct TestInterface_
{
    [NativeTypeName("int (*)(MyStruct *) __attribute__((stdcall))")]
    public delegate* unmanaged[Cdecl]<MyStruct_*, int> TestMethod;
}

public unsafe partial struct MyStruct_
{
    [NativeTypeName("const struct TestInterface_ *")]
    public TestInterface_* functions;

    public int TestMethod()
    {
        return functions->TestMethod(this);
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions