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
]
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] [ alleg-Bugs-2333410 ] think of a way to allocate user event type numbers.
- From: "Peter Hull" <peterhull90@xxxxxxxxxx>
- Date: Thu, 27 Nov 2008 22:20:33 +0000
On Thu, Nov 27, 2008 at 7:44 AM, SourceForge.net
<noreply@xxxxxxxxxx> wrote:
> Comment By: Milan Mimica (mmimica)
> Date: 2008-11-27 08:44
> The alternative is doing something at preprocessor level, like AL_ID:
> #define MY_EVENT_TYPE AL_ID('M','E','V','T')
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)
Pete