If I remember right, Monkey doesn't play well with header files. I'd say your best bet for this effect is to just rename the headers to CPP files (Possibly "*.h.cpp"; that's what I usually go with), then you just import them first. It's a bit of a hack, but it works pretty well. I ended up doing this with symbolic links in the past. Well, either that, or you make a new target. I just use the C/C++ preprocessor for projects that are for standard C/C++ and Monkey at the same time. I simply don't import any of the project-local header files if a custom Monkey flag/variable is enabled/defined (Which I obviously define myself). I honestly think we should patch 'Trans' to just support header files, at least then we wouldn't have to add ".cpp" to everything. Or maybe we could add something for getting the module's global path from C++ (Maybe through the Monkey and C++ preprocessors)? That's a bit of a stretch, though.
The thing is, Monkey isn't the best at producing the most optimal structure for its generated code (Unless it's JavaScript, then it's not bad). With the C/C++ based targets, it simply adds it all to one file. That being said, this approach is actually pretty good performance-wise. The issues really start coming in when you have 20+ large modules on top of the default modules along with the reflection filter set to everything ("*"). Then you end up having GCC/MinGW sit there for 20 minutes using 800+ MB of RAM, doing effectively nothing. But, that could technically be seen as an optimization issue with the standard 'reflection' module.
Anyway, the point I'm trying to make is that external C/C++ code in Monkey is overall different. You can use anything you want, but if you delegate it to Monkey, you could run into issues. If you want a really nice experience with this, you'll probably just want to either have your users grab the C/C++ version, set it up with their compiler's includes and what-not, then use the library normally from external C or C++ code at Monkey's level. Either that, or what I said earlier (Which is more hassle for you, but less hassle for them).
And don't get me started on adopting Monkey's "object model" for the sake of supporting the garbage collector without using a wrapper (It's not that bad, it's just annoying; only really needed for the classes being directly worked with, though).
You basically need to pick a trade-off.
|