apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Creative solution to a lack of recursive #define's?
Date Fri, 25 Apr 2003 18:43:17 GMT
I'm attempting to come up with some more clever tracing semantics.
One thing I would like out of the user's foo_hook_method() invocation
is the stringized 'name' of their hook entry point.  Seems I hit a wall.

Right now, apr_hooks uses the global 'apr_hook_debug_current'
pointer to track which module is registering hooks.  Mostly painless
for the usual cases, since Apache sets up that pointer as it invokes
a module's register_hooks() entry point.  But if a hook is registered
outside of that function, whoa boy.

Anyways, since the recursive #defines below don't work, and we don't
want the hook implementor to have to go through any 'extra' hoops,
does anyone have some thoughts on the fragment below for stringizing
the entry point 'pf's name?

#define APR_IMPLEMENT_HOOK_TRACE_PROTO(ns,name) \
#define ns##_hook_##name(pf, aszPre, aszSucc, nOrder) \
    (ns##_hook_##name)(pf, aszPre, aszSucc, nOrder, #pf)

/** macro to declare the hook correctly */    
#define APR_DECLARE_EXTERNAL_HOOK(ns,link,ret,name,args) \
typedef ret ns##_HOOK_##name##_t args; \
link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf, \
                                      const char * const *aszPre, \
                                      const char * const *aszSucc, int nOrder\
                                      const char * szFnName); \
link##_DECLARE(ret) ns##_run_##name args; \
APR_IMPLEMENT_HOOK_GET_PROTO(ns,link,name); \
APR_IMPLEMENT_HOOK_TRACE_PROTO(ns,name) \
typedef struct ns##_LINK_##name##_t \
    { \
    ns##_HOOK_##name##_t *pFunc; \
    const char *szName; \
    const char * const *aszPredecessors; \
    const char * const *aszSuccessors; \
    int nOrder; \
    } ns##_LINK_##name##_t;



Mime
View raw message