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

weird parsed error: std::pair<int,std::pair<int,int>>,std::pair<std::string, std::pair<int,int>> #614

Closed
ericxsun opened this issue Sep 3, 2018 · 6 comments
Labels

Comments

@ericxsun
Copy link

ericxsun commented Sep 3, 2018

pom of chilitags is not changed. (version: javacpp-presets 1.4.3-SNAPSHOT)

I added two simple lines in chilitags/src/main/java/org/bytedeco/javacpp/presets/chilitags.java,

.put(new Info("std::pair<int,int>").pointerTypes("IntIntPair").define())
.put(new Info("std::pair<int,std::pair<int,int> >").pointerTypes("IntIntPairIntPair").define())

while compiling with mvn clean install --projects .,chilitags , weird errors occurred
first one:

JNIEXPORT jobject JNICALL Java_org_bytedeco_javacpp_chilitags_00024IntIntPairIntPair_second__I(JNIEnv* env, jobject obj, jint arg0) {
    ::std::pair<int,std::pair<int,int> >* ptr = (::std::pair<int,std::pair<int,int> >*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
    if (ptr == NULL) {
        env->ThrowNew(JavaCPP_getClass(env, 8), "This pointer address is NULL.");
        return 0;
    }
    jlong position = env->GetLongField(obj, JavaCPP_positionFID);
    ptr += position;
    jobject rarg = obj;
    ptr->second = arg0;
    return rarg;
}
/chilitags/target/classes/org/bytedeco/javacpp/jnichilitags.cpp:2375:17: error: no viable overloaded '='
    ptr->second = arg0;
    ~~~~~~~~~~~ ^ ~~~~

second one:

JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_chilitags_00024IntIntPairIntPair_second__(JNIEnv* env, jobject obj) {
    ::std::pair<int,std::pair<int,int> >* ptr = (::std::pair<int,std::pair<int,int> >*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
    if (ptr == NULL) {
        env->ThrowNew(JavaCPP_getClass(env, 8), "This pointer address is NULL.");
        return 0;
    }
    jlong position = env->GetLongField(obj, JavaCPP_positionFID);
    ptr += position;
    jint rarg = 0;
    int rval = ptr->second;
    rarg = (jint)rval;
    return rarg;
}
chilitags/target/classes/org/bytedeco/javacpp/jnichilitags.cpp:2387:9: error: no viable conversion from 'std::__1::pair<int, int>' to 'int'
    int rval = ptr->second;
        ^      ~~~~~~~~~~~

type of ptr's second value is std::pair<int, int>, why that was int <---> std::pair<int, int> conversion.

Thanks a lot for your help.

@ericxsun
Copy link
Author

ericxsun commented Sep 3, 2018

When only adding

.put(new Info("std::pair<int,int>").pointerTypes("IntIntPair").define())
.put(new Info("std::pair<std::string,std::pair<int,int> >").pointerTypes("IntIntPairStringPair").define())

such error will occur

JNIEXPORT jint JNICALL Java_org_bytedeco_javacpp_chilitags_00024IntIntPairStringPair_first__(JNIEnv* env, jobject obj) {
    ::std::pair<std::string,std::pair<int,int> >* ptr = (::std::pair<std::string,std::pair<int,int> >*)jlong_to_ptr(env->GetLongField(obj, JavaCPP_addressFID));
    if (ptr == NULL) {
        env->ThrowNew(JavaCPP_getClass(env, 8), "This pointer address is NULL.");
        return 0;
    }
    jlong position = env->GetLongField(obj, JavaCPP_positionFID);
    ptr += position;
    jint rarg = 0;
    int rval = ptr->first;
    rarg = (jint)rval;
    return rarg;
}
chilitags/target/classes/org/bytedeco/javacpp/jnichilitags.cpp:2336:9: error: no viable conversion from 'std::__1::basic_string<char>' to 'int'
    int rval = ptr->first;
        ^      ~~~~~~~~~~

@ericxsun ericxsun changed the title weird parsed error: std::pair<int,std::pair<int,int>> weird parsed error: std::pair<int,std::pair<int,int>>,std::pair<std::string, std::pair<int,int>> Sep 3, 2018
@saudet saudet added the bug label Sep 3, 2018
@ericxsun
Copy link
Author

ericxsun commented Sep 3, 2018

@saudet Is there any plan and schedule to fix it?

@saudet
Copy link
Member

saudet commented Sep 3, 2018

Yes, I'll look into that shortly. Thanks for reporting!

saudet added a commit to bytedeco/javacpp that referenced this issue Sep 9, 2018
@saudet
Copy link
Member

saudet commented Sep 9, 2018

I've fixed that with commit bytedeco/javacpp@2f4e1d2, thanks for reporting!

@ericxsun
Copy link
Author

@saudet Thank you a lot.

@saudet
Copy link
Member

saudet commented Oct 16, 2018

Fix included in JavaCPP 1.4.3! Thanks again for reporting.

@saudet saudet closed this as completed Oct 16, 2018
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