bytedeco/javacpp

multiple inheritance and flatten

Open

#288 opened on Mar 7, 2019

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Java (620 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (4,279 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Hi I have the following example that fails to generate wrappers for Z1 and Z2 classes.

  • For Z1 it will generate extra constructor call for Y that will no compile
  • For Z2 it will not generate method Boo

Please advice, Lenny

header file

class X {
public:
    virtual void Foo();
};

class Y {
public:
    Y(const bool& );
    virtual void Boo();
};

class Z1 : public X,  public Y {
public:
    Z1();
    using Y::Boo;
};

class Z2 : public X,  protected Y {
public:
    Z2();
    using Y::Boo;
};

presets

@Properties(
        names = {"windows-x86_64"},
        value = { @Platform( include = { "<test.hxx>", } ), },
        target = "org.bytedeco.javacpp.test"
)
@NoException
public class test implements InfoMapper {
    @Override
    public void map(InfoMap infoMap) {

       infoMap.put(new Info("Y").flatten());
    }
}

generated java file

package org.bytedeco.javacpp;

import org.bytedeco.javacpp.annotation.Cast;
import org.bytedeco.javacpp.annotation.Name;
import org.bytedeco.javacpp.annotation.Namespace;

public class test extends org.bytedeco.javacpp.presets.test {
    static {
        Loader.load();
    }

// Parsed from <test.hxx>


    public static class X extends Pointer {
        static {
            Loader.load();
        }

        /**
         * Default native constructor.
         */
        public X() {
            super((Pointer) null);
            allocate();
        }

        /**
         * Native array allocator. Access with {@link Pointer#position(long)}.
         */
        public X(long size) {
            super((Pointer) null);
            allocateArray(size);
        }

        /**
         * Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}.
         */
        public X(Pointer p) {
            super(p);
        }

        private native void allocate();

        private native void allocateArray(long size);

        @Override
        public X position(long position) {
            return (X) super.position(position);
        }

        public native void Foo();
    }

    public static class Y extends Pointer {
        static {
            Loader.load();
        }

        /**
         * Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}.
         */
        public Y(Pointer p) {
            super(p);
        }

        public Y(@Cast("const bool") boolean arg0) {
            super((Pointer) null);
            allocate(arg0);
        }

        private native void allocate(@Cast("const bool") boolean arg0);

        public native void Boo();
    }

    public static class Z1 extends X {
        static {
            Loader.load();
        }

        /**
         * Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}.
         */
        public Z1(Pointer p) {
            super(p);
        }

        /**
         * Native array allocator. Access with {@link Pointer#position(long)}.
         */
        public Z1(long size) {
            super((Pointer) null);
            allocateArray(size);
        }

        private native void allocateArray(long size);

        @Override
        public Z1 position(long position) {
            return (Z1) super.position(position);
        }

        public Y asY() {
            return asY(this);
        }

        @Namespace
        public static native @Name("static_cast<Y*>")
        Y asY(Z1 pointer);

        public Y(@Cast("const bool") boolean arg0) {
            super((Pointer) null);
            allocate(arg0);
        }

        private native void allocate(@Cast("const bool") boolean arg0);

        public native void Boo();

        public Z1() {
            super((Pointer) null);
            allocate();
        }

        private native void allocate();
    }

    public static class Z2 extends X {
        static {
            Loader.load();
        }

        /**
         * Pointer cast constructor. Invokes {@link Pointer#Pointer(Pointer)}.
         */
        public Z2(Pointer p) {
            super(p);
        }

        /**
         * Native array allocator. Access with {@link Pointer#position(long)}.
         */
        public Z2(long size) {
            super((Pointer) null);
            allocateArray(size);
        }

        private native void allocateArray(long size);

        @Override
        public Z2 position(long position) {
            return (Z2) super.position(position);
        }

        public Z2() {
            super((Pointer) null);
            allocate();
        }

        private native void allocate();
    }

}

Contributor guide