google/autocxx

Unable to Call Base Class Functions When Base is a Template Class in autocxx

edsky opened this issue · 0 comments

Describe the bug
There seems to be a limitation in autocxx when dealing with base classes that are templated. In the provided example, the base class S is a template, and the derived class B1 is unable to call any function from the templated base class or use its type deduction features.

To Reproduce
To reproduce the behavior, the following setup was used with Rust and C++ code snippets:

C++ Header (input.h):

#pragma once

#include <memory>

template <typename T>
class S {
    virtual void foo1() const {};
};

class A {
public:
    virtual void foo() const {};
    virtual ~A() {}
};

class B0 : public A {
public:
    void bar() const {}
};

class B1 : public S<A> {
public:
    void bar() const {}
};

Rust Code (main.rs):

autocxx::include_cpp!{
    #include "input.h"
    safety!(unsafe_ffi)
    generate!("S")
    generate!("A")
    generate!("B0")
    generate!("B1")
}

fn main() {
    use ffi::*;
    use autocxx::WithinUniquePtr;

    let b0 = B0::new().within_unique_ptr();
    b0.as_ref().unwrap().as_ref().foo();

    // let b1 = B1::new().within_unique_ptr();
    // b1.as_ref().unwrap().as_ref().foo1();
}

Expected behavior
The expected behavior is that autocxx should be able to handle template base classes and allow derived classes to call functions from these base classes. In the provided example, we expect B1 to be able to call foo1() from its base class S.

Additional context
Currently, autocxx seems to struggle with template inheritance, leading to difficulties in utilizing base class methods in derived classes. This issue appears to be specific to the handling of template classes in autocxx.