New Feature - Support for functions returning references
Hello!
Today I've added support for functions which return references. This is almost completly transparent ie. you use SH_DECL_HOOK* normally, then you use SH_ADD_HOOK_* normally, etc. If you want to use it, you only need to download the newest sourcehook.h from svn. I've tested it with const and non-const references, many hooks, recalls, even callclasses and META_RESULT_ORIG_RET and META_RESULT_OVERRIDE_RET work (see testrefret.cpp in svn). There's one special new thing: If you want to return MRES_IGNORED or MRES_HANDLED from a hook handler for a function returning a reference, you'd have to use RETURN_META_VALUE normally; the return value gets ignored so you can pass in anything, but you usually don't have a spare variable lying around to return. So you can (=should) use RETURN_META_NOREF instead: RETURN_META_NOREF(MRES_IGNORED, int&); works like RETURN_META_VALUE but returns some garbage which you don't have to care about If you're interested in how I implemented all this (you might have heard that I was planning a separate SH_DECL_* macro set; luckily I didn't have to go that far), read sourcehook.hxx around line 307. Actually, if you're too lazy to look it up, I'll copy it here: Quote:
Code:
struct MyTestQuote:
What still needs to be done: -- Someone add it to the wiki XD So, have fun with it! PS: I'm leaving for vacation for 2 weeks so if something doesn't work, complain here, I'll fix it when I'm back XD (though I've tested it pretty extensively on both MSVC and GCC). Merci. |
Re: New Feature - Support for functions returning references
Thanks for this addition, PM. Have fun on vacation!
|
Re: New Feature - Support for functions returning references
Thanks PM!
...now if I could only remember what I was trying to hook that was returning a reference... PS: nice 1337 karma |
Re: New Feature - Support for functions returning references
Vacation again? You bumb :\
Thanks for the update as always =) |
| All times are GMT -4. The time now is 07:19. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.