javacpp icon indicating copy to clipboard operation
javacpp copied to clipboard

Preset generator cannot handle "const auto FOO = 42u;"

Open frankier opened this issue 4 years ago • 2 comments

If we have a source file with something like:

namespace bar {
const auto FOO = 42u;
}

We get:

Caused by: org.bytedeco.javacpp.tools.ParserException: /path/to/header.hpp:2:Could not parse declaration at '='

At the moment it seems the parser chokes so much that it doesn't seem possible to even skip() these declarations, so you have to do something like:

infoMap.put(new Info("basename.hpp").linePatterns("\\s*const auto.*", ".*;\\s*").skip())

I think ideally these would be parsed, and if it was an unambiguous literal, type inference performed, otherwise cppTypes required before conversion.

frankier avatar Jun 21 '20 10:06 frankier

This is used in OpenPose, which I'm currently wrapping and also used in gapi https://github.com/bytedeco/javacpp-presets/issues/780

frankier avatar Jun 21 '20 11:06 frankier

Thanks for reporting! I've fixed that in the last commit, so please give it a try with 1.5.4-SNAPSHOT.

However, it won't try to deduce the type, so pretty much the only thing we can do at this stage is InfoMap.put(new Info("auto").skip()). We'll need to enhance this such that we can do things like InfoMap.put(new Info("FOO").cppTypes("int")), as it currently works for preprocessor macros...

saudet avatar Jun 22 '20 04:06 saudet