Re: [AD] [ alleg-Bugs-2333410 ] think of a way to allocate user event type numbers.

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Hull wrote:
I think this would be a good way to do it, because we could still use
switch() on it. Those four char constants were used quite a bit on the
old mac os; I think the probability of collision is quite low (as long
as everyone doesn't spontaneously decide to use 'AL' as the first 2
chars..!)
This scheme also leaves values 0x000000 to 0x20202020 and 0x80808080
to 0xFFFFFFFF free, if we stick to ascii printing chars, so we could
reserve part of these ranges for al_get_free_user_event_id(), giving
the paranoid addon writer a choice (a tradeoff of guaranteed
uniqueness vs. not being able to use switch)

How about this:
#define ALLEGRO_EVENT_ID(a,b,c,d,e,f)     ((((a)-0x41)<<25) \
                                         | (((b)-0x41)<<20) \
                                         | (((c)-0x41)<<15) \
                                         | (((d)-0x41)<<10) \
                                         | (((e)-0x41)<<5)  \
                                         |  ((f)-0x41))

It uniquely codes any of the upper case letters and [\]^_`. Leaves 2 bits for something...


--
Milan Mimica
http://sparklet.sf.net




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/