Closed klemens-morgenstern closed 8 years ago
I forgot: this is utterly inefficient, because it copies everything around. But it sort-of matches your import structur.
And here's the prototype for a class import. Currently tested on mingw.
It's currently rather short, but can be used in the following way:
auto cl = import_class<class override_class, int>(sm, "some_space::some_class", type_size, 42);
//str at pos 2 is the type_alias, the third is optional. Since the signature is given this is optional.
auto i = cl.call<const override_class, int()>("get")();
cl.call<void(int)>("set")(42);
//implemented above
auto func = import_mangled<
override_class, double(double, double), int(int, int)>(sm, "func");
(cl->*func)(3.,2.);
(cl->*func)(1 ,2 );
//alternate syntax:
auto func = cl.import<double(double, double), int(int, int)>("func");
I changed the type_index values to the ctti-variant so incomplete types can be used as type-aliases.
Alright, so there's also no way to allow type_aliases with an incomplete type in a portable manor. gcc works fine with ctti_type_info (which allows that) but msvc doesn't.
Elsewise I think, we would now have a basis to discuss the basic design. And really: except for the vtable, we now have everything you can get out of a dll.
Ok, so i got the class import to work with incomplete types. At least with gcc. MSVC crashes for some reason at constructor-call, I don't get the reason there.
I also built-in a check before the move-ctor test, to see if the DbgHelp version is new enough. I actually did NOT test it with another version then 4.0, but this one doesn't know the move-semantic demangling!
I've just cherry-picked the dbghelp.hpp from your fork. Hopefully, it will be moved to Boost.WinAPI soon.
The deadline for breaking changes in Boost is near, so probably I'll merge this pull request only after the Boost 1.61 release. This gives you a lot of time to polish and experiment with the functionality (here's a Boost's schedule http://www.boost.org/development/index.html)
Well, considering the insanity of my code that makes sense. It's currently more a proof-of-concept implementation, so I'd be really happy if you could look over that.
I'll remove the DbgHelp.h as soon as it get's merged into winapi. Since I had to change a few details the current msvc is broken. It tends to do that.
This is because the way I adapted the api_version structure doesn't fit the rest of the winapi-library.
Ok, he denied the dbghelp. Now I could put it into my fork, but I think that wouldn't be the smartest thing to do, since you probably want the issue fixed before the 1.61 release. If you move it into dll/detail, you might want to use this version because it is consistent with the winapi stuff.
EDIT Ok it got in...
Ok, this is rather strange behaviour, actually the tests pass: https://ci.appveyor.com/project/klemens-morgenstern/boost-dll/build/1.61.22-develop https://travis-ci.org/klemens-morgenstern/Boost.DLL/builds/109211865
I would need feedback on that, if you expect me to implement more. The basically works, though you might dislike the syntax or have additions.
Ok, I looked over the mangled import stuff again, it looks alright to me - though that might be bcause I wrote it. The template stuff is weird, but I think sufficiently understandable. Again: I'd need some feedback.
I added a test for the type_info just to realize that I did not implement that properly in MSVC, now I have a version which works locally by looking through the vtable, which is rather frightening. Seems to be different on 64-Bit, I'll try to find a fix.
The error seems to come from boost.filesystem.
I only merged your changes, so the Appveyor rebuilds - the error was an issue in boost/core od boost/filesystem. Thus it works. We can remove the DbgHelp, since the undname does work and provides the rvalue references because it is in the current runtime - not another tool. So if you do not like the class import, we should at least use the undname feature.
Ok, time to watch regression tests and polish the code :)
Awesome! If you'd like so documentation, please tell me. Did you actually tell the boost community about that feature? Because people might miss it, and it wouldn't be tested.
I'd appreciate documentation for new features and a few usage examples :)
A few more things to tune:
smart_library
is actually smart, but it's unclear what does it do from it's name. Probably it must be renamed into shared_library_mangled
/mangled_library
/cpp_shared_library
. Any naming ideas are welcomed.smart_library::get_mem_fn()
using shared_library::get()
? shared_library::get()
must be capable of loading member functions, if it fails it must be fixed in shared_library
code.After new features will be well tested and stabilized and documented a note could be sent to G+ or Boost lists. And of course note about new features will appear in Boost's 1.62/1.63 changelog.
Ok, I'll add some doc, probably on the weekend
cpp_library
if necessary, but then again, I would've just named it library
not shared_library
because the sharing part is rather obvious. The full descriptive name would be something like demangling_and_overload_considering_library
, that's why I named it smart.
But since the shared_library imports C-Declarations and the smart_lib C++, cpp_library would probably be the most fitting.
Import features is in. Looks like this: