bytedeco/javacpp

Cannot virtualize a function with optional argument

Open

#653 aperta il 17 feb 2023

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Java (620 fork)batch import
enhancementhelp wanted

Metriche repository

Star
 (4279 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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 ?

Guida contributor