bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.68k stars 743 forks source link

Preset for HCC #265

Open almson opened 8 years ago

almson commented 8 years ago

I'm trying to create a preset for AMD's new GPGPU effort, particularly for the HCC interface. (Honestly, the alphabet soup is such a mess that I'm not going to even begin to explain all of the moving parts. Suffice it to say that I'm targeting hc.hpp).

The first stumbling block I've hit is Unexpected token '::' for the following line:

// namespace alias
// namespace hc::fast_math is an alias of namespace Kalmar::fast_math
namespace fast_math = Kalmar::fast_math;

I'd appreciate any pointers. Does the Parser support this syntax? Is there a workaround?

saudet commented 8 years ago

It probably doesn't support that exact syntax, yes.

almson commented 8 years ago

So is there a way I can ignore this line? I'm assuming I can emulate the alias with new Info ("fast_math").cppText ("Kalmar::fast_math"). Sorry, I'm totally new to this and would appreciate pointers.

almson commented 8 years ago

From reading the code, it seems there is no facility to do simple find&replace. cppText seems to only work in specific cases of #define. Am I correct?

If you like, I can post the code I have now. Currently, I have a cppbuild.sh that downloads the HCC header files (no install needed) and a skeleton of a pom and an hc.java.

saudet commented 8 years ago

cppText expects #define yes, but works with any identifier, it's used by the preprocessor, though you won't be able to do anything that the C++ preprocessor can't do in the first place.

We'll likely have to fix JavaCPP's Parser, but it should be pretty easy. There's someone who a few minutes ago has just fixed a similar bug: https://github.com/bytedeco/javacpp-presets/issues/264

If you could help in a similar way, it would be very much appreciated.

almson commented 8 years ago

May I ask why you chose to write your own C++ parser instead of using one of many third-party ones? The Eclipse parser opens hc.hpp without problems (try it: https://github.com/almson/eclipse-cdt-standalone-astparser). There's other options too: https://stackoverflow.com/questions/12865587/parsing-c-source-code-in-java-environment

saudet commented 8 years ago

Because no existing parser was designed to output a Java interface. Of course that's the long term plan, enhancing some existing parser so it supports what we need. As usual, your help would be very welcome.

saudet commented 8 years ago

Fixed the namespace alias issue. Let me know if you encounter any other issues. Thanks for reporting!

saudet commented 7 years ago

I've fixed the parsing issue you were having. Any other issues with HCC?

saudet commented 7 years ago

FYI, JetBrains chose to create their own C++ parser, instead of using an existing one as well: https://blog.jetbrains.com/clion/2015/07/clion-1-1-eap-starts/#comment-13321 If you just keep complaining and don't actually do anything, nothing will get done! Please consider actually doing something. Thank you :)