I have a macro:
#define BIND(c_slot, cxx_target) c_slot = & Generate<
decltype(c_slot)
, decltype(&cxx_target)
, &cxx_target
>::call;
I would use it like this:
BIND( table->fooslot , Base::foofunc );
Generate
looks like this:
template<typename Fc, typename Target, Target target>
struct Generate;
template < typename R , typename ...Arg ,
typename RTarg , typename ...TargArg ,
RTarg(ExtObjBase_noTemplate::*target)(TargArg...) >
struct Generate< R(*)(PyObject*, Arg...), RTarg(ExtObjBase_noTemplate::* )(TargArg...), target >
{
static R call( PyObject* self, Arg... carg)
{
std::cout << "SLOT!" << std::endl;
try
{
RTarg r_cxx = (cxxbase_for(self)->*target) (Convert<Arg>::to_cxx(carg) ...);
return Convert<RTarg>::to_c(r_cxx);
}
catch (...)
{
:
}
}
};
I would like to improve that std::cout so that it outputs WHICH slot.
Something like:
#define BIND(c_slot, cxx_target) c_slot = & Generate<
decltype(c_slot)
, decltype(&cxx_target)
, &cxx_target
, #c_slot
>::call;
But I can't figure out how to make it work.
Is there a way to do this?
EDIT: one possible approach would be to have:
static std::map<void*, std::string> names_map;
:
#define BIND(c_slot, cxx_target) \
c_slot = & Generate< decltype(c_slot) ,decltype(&cxx_target), &cxx_target >::call; \
names_map[offset_of(&cxx_target)] = std::string(#c_slot);
:
template < STUFF >
struct Generate< STUFF >
{
static R call( STUFF )
{
COUT( "SLOT: " << names_map[offset_of(???)] );
... is there any way to get that to work?
EDIT: this has been solved here