bytedeco/javacpp

Cannot virtualize a function with optional argument

Open

#653 opened on 2023年2月17日

GitHub で見る
 (3 comments) (0 reactions) (0 assignees)Java (620 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (4,279 stars)
PR merge metrics
 (30d に merged 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 ?

コントリビューターガイド