bytedeco/javacpp

Cannot virtualize a function with optional argument

Open

#653 创建于 2023年2月17日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Java (620 fork)batch import
enhancementhelp wanted

仓库指标

Star
 (4,279 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

GIven this C++ function:

class M {
  public:
    virtual void f(bool b = true) {  }
};

The parser generates two methods:

    public native void f(@Cast("bool") boolean b/*=true*/);
    public native void f();

I want to virtualize f. If I virtualize both methods:

    @Virtual public native void f(@Cast("bool") boolean b/*=true*/);
    @Virtual public native void f();

The generator produces a subclass with:

virtual void f() override;

that doesn't compile (error "marked override but doesn't override"). If I virtualize only one:

@Virtual public native void f(@Cast("bool") boolean on/*=true*/);
public native void f();

The generator produces a wrapper with:

          (dynamic_cast<JavaCPP_M*>(ptr) != NULL ? ((JavaCPP_M*)ptr)->f() : ptr->f());

that doesn't compile either (error "no matching function for call to 'JavaCPP_M::f()'").

Did I miss something or is there something to fix ?

贡献者指南