Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overloaded virtual functions #353

Closed
floybix opened this issue Jan 6, 2017 · 1 comment
Closed

overloaded virtual functions #353

floybix opened this issue Jan 6, 2017 · 1 comment
Labels

Comments

@floybix
Copy link
Contributor

floybix commented Jan 6, 2017

Hi again,

This is all working amazingly well... but I've run into a problem with a callback that has an overloaded function.

The C++ code is

class b2ContactListener
{
public:
	virtual ~b2ContactListener() {}

	virtual void BeginContact(b2Contact* contact) {}

	virtual void BeginContact(b2ParticleSystem* particleSystem,
                                  b2ParticleContact* particleContact) {}

In the presets java I do

.put(new Info("b2ContactListener").virtualize())

which results in this snippet, in the jniliquidfun.cpp file:

class JavaCPP_hidden JavaCPP__0003a_0003ab2ContactListener : public ::b2ContactListener {
public:
    jobject obj;
    static jmethodID BeginContact__Lorg_bytedeco_javacpp_liquidfun_00024b2ParticleSystem_2Lorg_bytedeco_javacpp_liquidfun_00024b2ParticleContact_2;
    static jmethodID BeginContact__Lorg_bytedeco_javacpp_liquidfun_00024b2Contact_2;

    JavaCPP__0003a_0003ab2ContactListener() : ::b2ContactListener(), obj(NULL) { }
    using ::b2ContactListener::BeginContact;
    virtual void BeginContact(::b2ParticleSystem* arg0, ::b2ParticleContact* arg1);
    void super_BeginContact(::b2ParticleSystem* arg0, ::b2ParticleContact* arg1) { ::b2ContactListener::BeginContact(arg0, arg1); }
    using ::b2ContactListener::BeginContact;
    virtual void BeginContact(::b2Contact* arg0);
    void super_BeginContact(::b2Contact* arg0) { ::b2ContactListener::BeginContact(arg0); }

This gives an error from clang++ about the repeated "using" statements:

/Users/felix/Devel/javacpp-presets/liquidfun/target/classes/org/bytedeco/javacpp/jniliquidfun.cpp:599:32: error: 
      redeclaration of using decl
    using ::b2ContactListener::BeginContact;
          ~~~~~~~~~~~~~~~~~~~~~^
/Users/felix/Devel/javacpp-presets/liquidfun/target/classes/org/bytedeco/javacpp/jniliquidfun.cpp:596:32: note: 
      previous using declaration
    using ::b2ContactListener::BeginContact;
                               ^

Any help would be appreciated.

@saudet saudet added the bug label Jan 6, 2017
@saudet
Copy link
Member

saudet commented Jan 6, 2017

That gets generated on this line:
https://github.com/bytedeco/javacpp/blob/master/src/main/java/org/bytedeco/javacpp/tools/Generator.java#L2069
So we would need to add a check for duplicate methodInfo.memberName[0] there. To fix that, I think I'd just loop over memberList, and check the first line of each see if it's not the same. I will do it later (eventually) if someone else doesn't do it for me in the meantime :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants