[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix for proper C++ conformance
From: |
Wiz Aus |
Subject: |
Fix for proper C++ conformance |
Date: |
Wed, 05 Oct 2005 16:10:21 +1000 |
Managed to get all the lilypond code to at least *compile* now, although a
long way off linking and running!
The main changes I had to make is to add
friend void _##NAME##_start_translation_timestep(NAME*); \
friend void _##NAME##_stop_translation_timestep(NAME*); \
friend void _##NAME##_process_music(NAME*); \
friend void _##NAME##_process_acknowledge(NAME*);
to the end of #define TRANSLATOR_DECLARATIONS(NAME) in translator.hh
And then in translator.icc, I changed the differences of
IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS and
ADD_ACKNOWLEDGER, like so:
#define IMPLEMENT_FETCH_PRECOMPUTABLE_METHODS(T) \
IMPLEMENT_PROXY_METHOD(T, start_translation_timestep) \
IMPLEMENT_PROXY_METHOD(T, stop_translation_timestep) \
IMPLEMENT_PROXY_METHOD(T, process_music)
\
IMPLEMENT_PROXY_METHOD(T, process_acknowledged)
\
void \
T::fetch_precomputable_methods (Translator_void_method_ptr ptrs[]) \
{ \
ptrs[START_TRANSLATION_TIMESTEP] = \
( & T::start_translation_timestep == \
& Translator::start_translation_timestep) \
? 0 \
: (Translator_void_method_ptr) & _##T##_start_translation_timestep; \
\
ptrs[STOP_TRANSLATION_TIMESTEP] = \
( & T::stop_translation_timestep == &
Translator::stop_translation_timestep) \
? 0 \
: (Translator_void_method_ptr) & _##T##_stop_translation_timestep; \
\
ptrs[PROCESS_MUSIC] = \
( & T::process_music == & Translator::process_music) \
? 0 \
: (Translator_void_method_ptr) & _##T##_process_music; \
\
ptrs[PROCESS_ACKNOWLEDGED] = \
( & T::process_acknowledged == & Translator::process_acknowledged) \
? 0 \
: (Translator_void_method_ptr) & _##T##_process_acknowledged; \
}
#define ADD_ACKNOWLEDGER(CLASS, NAME)
\
static void _##CLASS##_##NAME(CLASS * engr, Grob_info info) \
{
\
engr->acknowledge_ ## NAME(info);
\
}
\
void CLASS ## NAME ## _ack_adder ()
\
{
\
add_acknowledger
((Engraver_void_function_engraver_grob_info)&_##CLASS##_##NAME, #NAME,
&CLASS::acknowledge_static_array_); \
}
\
ADD_SCM_INIT_FUNC (CLASS ## NAME ## _ack_adder_initclass, CLASS ## NAME ##
_ack_adder);
All this does is ensure that member functions aren't stored directly as
standalone function pointers - it creates a thunk or proxy function to call
the member function and then stores that.
The thunks get created whether they're needed or not, but maybe a really
good compiler would optimization them out (doubtful).
I do have to ask though - why on earth not do these as regular virtual
functions??
_________________________________________________________________
REALESTATE: biggest buy/rent/share listings
http://ninemsn.realestate.com.au
- Fix for proper C++ conformance,
Wiz Aus <=