123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412 |
- #ifndef _WASABI_MULTIPATCH_H
- #define _WASABI_MULTIPATCH_H
- // (c) 2005 Nullsoft, Inc.
- #include "dispatch.h"
- /*
- Author: Ben Allison <[email protected]>
- The purpose of the MultiPatch class is to allow a class to have multiple Dispatchable interfaces.
- It is an alternative to the method of using a stub class with virtual functions.
- (you see these classes all over Wasabi, either ending in I or X, depending on age)
- Since each vtable entry costs 4 bytes per object (8 on 64bit), using this method adds some code size
- (and, in some multiple-inheritance situations, memory per object for vtable overrides)
- Of course, MultiPatch's dispatching function adds code size, too. But the function shouldn't be any
- larger or slower than the dispatching in the api_X class anyway.
- Using MultiPatch, each method call goes through this chain:
- dispatch->multipatch->your class method
- as opposed to:
- dispatch->your class method (single inheritance)
- or:
- dispatch->virtual function->your class method (api_X method)
- A clever compiler might be able to optimize away the _multipatch function call by
- pushing "patch" on the top of the parameter stack and jmp'ing.
- For an example on usage, scroll down to the bottom of the page.
- */
- template <int patch_t, class base_t>
- class MultiPatch : public base_t
- {
- protected:
- virtual int _multipatch(int patch, int msg, void *retval, void **params=0, int nparam=0) = 0;
- private:
- int _dispatch(int msg, void *retval, void **params=0, int nparam=0)
- {
- return _multipatch(patch_t, msg, retval, params, nparam);
- }
- public:
- /* these helper functions are a direct copy from Dispatchable...
- * They need to be duplicated, because the compiler gets confused when trying to cast
- * from Dispatchable to the child class (since that class has multiple Dispatchable parents)
- *
- * They could potentially be eliminated by modifying Dispatchable's versions, but the risk of breakage
- * isn't worth it.
- */
- template <class CLASSNAME, class RETVAL>
- void cb(RETVAL (CLASSNAME::*fn)(), void *retval, void **params) {
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)();
- }
- template <class CLASSNAME>
- void vcb(void (CLASSNAME::*fn)(), void *retval, void **params) {
- (static_cast<CLASSNAME *>(this)->*fn)();
- }
- template <class CLASSNAME, class RETVAL, class PARAM1>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1);
- }
- template <class CLASSNAME, class PARAM1>
- void vcb(void (CLASSNAME::*fn)(PARAM1), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1);
- }
- template <class CLASSNAME, class PARAM1, class PARAM2>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2);
- }
- // 3 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3);
- }
- // 4 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4);
- }
- // 5 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5);
- }
- // 6 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6);
- }
- // 7 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7);
- }
- // 8 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8);
- }
- // 9 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9);
- }
- // 10 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9, class PARAM10>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9, PARAM10), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- PARAM10 *p10 = static_cast<PARAM10*>(params[9]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10);
- }
- template <class CLASSNAME, class RETVAL, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9, class PARAM10>
- void cb(RETVAL (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9, PARAM10), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- PARAM10 *p10 = static_cast<PARAM10*>(params[9]);
- *static_cast<RETVAL*>(retval) = (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10);
- }
- // 14 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9, class PARAM10, class PARAM11, class PARAM12, class PARAM13, class PARAM14>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9, PARAM10, PARAM11, PARAM12, PARAM13, PARAM14), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- PARAM10 *p10 = static_cast<PARAM10*>(params[9]);
- PARAM11 *p11 = static_cast<PARAM11*>(params[10]);
- PARAM12 *p12 = static_cast<PARAM12*>(params[11]);
- PARAM13 *p13 = static_cast<PARAM13*>(params[12]);
- PARAM14 *p14 = static_cast<PARAM14*>(params[13]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10, *p11, *p12, *p13, *p14);
- }
- // 16 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9, class PARAM10, class PARAM11, class PARAM12, class PARAM13, class PARAM14, class PARAM15, class PARAM16>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9, PARAM10, PARAM11, PARAM12, PARAM13, PARAM14, PARAM15, PARAM16), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- PARAM10 *p10 = static_cast<PARAM10*>(params[9]);
- PARAM11 *p11 = static_cast<PARAM11*>(params[10]);
- PARAM12 *p12 = static_cast<PARAM12*>(params[11]);
- PARAM13 *p13 = static_cast<PARAM13*>(params[12]);
- PARAM14 *p14 = static_cast<PARAM14*>(params[13]);
- PARAM15 *p15 = static_cast<PARAM15*>(params[14]);
- PARAM16 *p16 = static_cast<PARAM16*>(params[15]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10, *p11, *p12, *p13, *p14, *p15, *p16);
- }
- // 17 params
- template <class CLASSNAME, class PARAM1, class PARAM2, class PARAM3, class PARAM4, class PARAM5, class PARAM6, class PARAM7, class PARAM8, class PARAM9, class PARAM10, class PARAM11, class PARAM12, class PARAM13, class PARAM14, class PARAM15, class PARAM16, class PARAM17>
- void vcb(void (CLASSNAME::*fn)(PARAM1, PARAM2, PARAM3, PARAM4, PARAM5, PARAM6, PARAM7, PARAM8, PARAM9, PARAM10, PARAM11, PARAM12, PARAM13, PARAM14, PARAM15, PARAM16, PARAM17), void *retval, void **params) {
- PARAM1 *p1 = static_cast<PARAM1*>(params[0]);
- PARAM2 *p2 = static_cast<PARAM2*>(params[1]);
- PARAM3 *p3 = static_cast<PARAM3*>(params[2]);
- PARAM4 *p4 = static_cast<PARAM4*>(params[3]);
- PARAM5 *p5 = static_cast<PARAM5*>(params[4]);
- PARAM6 *p6 = static_cast<PARAM6*>(params[5]);
- PARAM7 *p7 = static_cast<PARAM7*>(params[6]);
- PARAM8 *p8 = static_cast<PARAM8*>(params[7]);
- PARAM9 *p9 = static_cast<PARAM9*>(params[8]);
- PARAM10 *p10 = static_cast<PARAM10*>(params[9]);
- PARAM11 *p11 = static_cast<PARAM11*>(params[10]);
- PARAM12 *p12 = static_cast<PARAM12*>(params[11]);
- PARAM13 *p13 = static_cast<PARAM13*>(params[12]);
- PARAM14 *p14 = static_cast<PARAM14*>(params[13]);
- PARAM15 *p15 = static_cast<PARAM15*>(params[14]);
- PARAM16 *p16 = static_cast<PARAM16*>(params[15]);
- PARAM17 *p17 = static_cast<PARAM17*>(params[16]);
- (static_cast<CLASSNAME *>(this)->*fn)(*p1, *p2, *p3, *p4, *p5, *p6, *p7, *p8, *p9, *p10, *p11, *p12, *p13, *p14, *p15, *p16, *p17);
- }
- };
- #define RECVS_MULTIPATCH int _multipatch(int patch, int msg, void *retval, void **params=0, int nparam=0)
- #define START_MULTIPATCH \
- int CBCLASS::_multipatch(int patch, int msg, void *retval, void **params, int nparam) { \
- switch (patch) {
- //FINISH case DESTRUCT: delete this; return 1;
- #define END_MULTIPATCH \
- default: return 0; \
- } \
- return 1; \
- }
- #define FORWARD_MULTIPATCH(x) \
- default: return x::_multipatch(patch, msg, retval, params, nparam); \
- } \
- return 1; \
- }
- #define START_PATCH(x) case x: switch(msg) {
- #define END_PATCH default: return 0; } break;
- #define NEXT_PATCH(x) END_PATCH START_PATCH(x)
- #define M_CB(p, c, x, y) case (x): MultiPatch<p,c>::cb(&CBCLASS::y, retval, params); break;
- #define M_VCB(p, c, x, y) case (x): MultiPatch<p,c>::vcb(&CBCLASS::y, retval, params); break;
- #define MULTIPATCH_CODES enum
- #endif
- /* use example:
- enum
- {
- Test_Patch1 = 10,
- Test_Patch2 = 20,
- };
- class Test : public MultiPatch<Test_Patch1, api_class1>,
- public MultiPatch<Test_Patch2, api_class2>
- {
- public:
- int TestFunc1();
- void TestFunc2();
- void TestFunc3();
- protected:
- RECVS_MULTIPATCH;
- };
- #ifdef CBCLASS
- #undef CBCLASS
- #endif
- #define CBCLASS Test
- START_MULTIPATCH;
- START_PATCH(Test_Patch1)
- M_CB(Test_Patch1, api_class1, API_CLASS1_FUNC1, TestFunc1);
- NEXT_PATCH(Test_Patch2)
- M_VCB(Test_Patch2, api_class2, API_CLASS1_FUNC1, TestFunc2);
- M_VCB(Test_Patch2, api_class2, API_CLASS1_FUNC2, TestFunc3);
- END_PATCH
- END_MULTIPATCH;
- #undef CBCLASS
- */
|