OSLib / wimp.h / wimp_ERROR_BOX_CATEGORY
Jonathan Coxhead
jonathan at doves.demon.co.uk
Mon Jun 5 19:17:35 BST 2000
On 31 May 00, at 10:34, Dave Appleby wrote:
> OSLib 6.01 / wimp.h / wimp_ERROR_BOX_CATEGORY
>
> I think that using the shift value for the new categories
> makes things unnescessarily complex. Surely the programmer
> doesn't need to know how the flags are arrived at...
The API Readme described the reasoning behind this ...
Macros are normally provided to help with getting fields out: for
a 1-bit field, a macro |X| such that
To Use
-- ---
Read the field (v & X) != NONE
Write a 0 v &= ~X
Write a 1 v |= X
and for a multi-bit field, macros X and X_SHIFT such that
To Use
-- ---
Read the field (v & X) >> X_SHIFT
Write a value |w| v = (v & ~X) | w << X_SHIFT.
> So, can I suggest removing wimp_ERROR_BOX_CATEGORY_SHIFT,
> and defining absolute values for the category flag bits instead?
You need both X and X_SHIFT to be able to extract the value of the
CATEGORY, for example if you want to have an array indexed by the category
number.
Of course, since you have both, you define your own macros as you prefer
them:
#define ERROR_BOX_CATEGORY_INFO (wimp_ERROR_BOX_CATEGORY_INFO <<
wimp_ERROR_BOX_CATEGORY_SHIFT)
#define ERROR_BOX_CATEGORY_ERROR (wimp_ERROR_BOX_CATEGORY_ERROR <<
wimp_ERROR_BOX_CATEGORY_SHIFT)
etc. This approach means that you have all the tools you need to do what
ever you want, though maybe not in the shortest way possible.
/|
o o o (_|/
/|
(_/
More information about the oslib-user
mailing list