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 ]


On 2008-11-27, Peter Hull <peterhull90@xxxxxxxxxx> wrote:
> 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)

I agree.  switch is much more important than the low probability of
collisions.  I don't think we need to stick to printable characters
though.  Maybe suggest picking three bytes in the printable range,
then use 0-255 for the fourth byte.

Peter





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