tarzanking / javacpp

Automatically exported from code.google.com/p/javacpp
GNU General Public License v2.0
0 stars 0 forks source link

Function parameter annotated with @Const and @ByRef doesn't produce right code #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. public native void constByrefTest(@Const @ByRef Foobar obj);

What is the expected output? What do you see instead?
pointer->constByrefTest((const unicoi::test::Foobar&)(*pointer0));

but got

pointer->constByrefTest(*(const unicoi::test::Foobar&)pointer0);

What version of the product are you using? On what operating system?
20111001

Please provide any additional information below.
Attached my fix, but would like to know if it can have other bad consequences.

Original issue reported on code.google.com by bid...@gmail.com on 17 Oct 2011 at 4:44

Attachments:

GoogleCodeExporter commented 9 years ago
Actually, I think that should produce
    pointer->constByrefTest(*(const unicoi::test::Foobar*)pointer0);
Would that look good?

BTW, we do not need a const cast for simple pointers, so
    public native void constByrefTest(@ByRef Foobar obj);
should work.

Original comment by samuel.a...@gmail.com on 19 Oct 2011 at 3:53

GoogleCodeExporter commented 9 years ago
Actually I use
    public native void constByrefTest(@ByRef Foobar obj);
on the other cases and things all work properly.

But in this particular case it is for the FunctionPointer and I had to add 
@Const and found the bug.

Your fix works too and actually makes more sense.

Original comment by bid...@gmail.com on 19 Oct 2011 at 2:43

GoogleCodeExporter commented 9 years ago
I made changes in the SVN repository. It should fix this issue. Can you check? 
Thank you

Original comment by samuel.a...@gmail.com on 20 Oct 2011 at 2:18

GoogleCodeExporter commented 9 years ago
This problem has been fixed!

Original comment by bid...@gmail.com on 25 Oct 2011 at 2:07

GoogleCodeExporter commented 9 years ago
Great!

Original comment by samuel.a...@gmail.com on 29 Oct 2011 at 5:12