bodensx / jnaerator

Automatically exported from code.google.com/p/jnaerator
0 stars 0 forks source link

various ways of declaring function pointers don't work #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Several ways of declaring function pointers are not handled
correctly.  This is an issue with the java code that is generated.  It
doesn't seem to realize that it is a function pointer, instead
treating it as if it were simply the function's return value.  For
example, the following are all standard-conforming C code (see K&R, A.
10.1, "if a parameter is declared to have type ‘‘function returning
type,’’ the declaration is adjusted to read ‘‘pointer to function
returning type.’’")

typedef int (foo_cb_t)(void *);
extern void test_cb1(foo_cb_t func);
extern void test_cb2(foo_cb_t *func);
extern void test_cb3(int (func)(void*));

What is the expected output? What do you see instead?

The above examples are translated to:

       void test_cb1(int func);
       void test_cb2(IntByReference func);
       void test_cb2(IntBuffer func);
        * Conversion Error : /// Original signature : <code>void
test_cb3(null)</code><br>
        * extern extern void test_cb3(int func); (Argument func cannot be
converted

Should be treated as a function pointer, which can achieved like so:

extern void test_cb4(int (*func)(void*));

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

JNAerator 0.9.5 on OpenSolaris x86.

Is the problem still present in the latest SVN version ? (you can easily
build from sources with these instructions :
http://code.google.com/p/javacl/wiki/Build)

Haven't checked.

Please provide any additional information below.

Original issue reported on code.google.com by mahr...@gmail.com on 13 Mar 2011 at 3:55

GoogleCodeExporter commented 8 years ago
Hello,

Thanks for your report,
Will look into that ASAP :-)

Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 13 Mar 2011 at 10:53

GoogleCodeExporter commented 8 years ago
Hello,

This bug is now fixed in the SVN tree, which you can build from sources (see 
http://code.google.com/p/jnaerator/wiki/CompilingJNAerator).
An updated snapshot (0.9.7-SNAPSHOT) will soon be uploaded to the Maven repo.

Thanks again for entering this bug report :-)
Cheers
--
zOlive

Original comment by olivier.chafik@gmail.com on 18 Mar 2011 at 6:01