2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Parse a set of attributes in a single interface
8 #include <exec/lists.h>
9 #include <proto/exec.h>
12 /*****************************************************************************
15 #include <proto/oop.h>
17 AROS_LH5(LONG
, OOP_ParseAttrs
,
20 AROS_LHA(struct TagItem
*, tags
, A0
),
21 AROS_LHA(IPTR
*, storage
, A1
),
22 AROS_LHA(ULONG
, numattrs
, D0
),
23 AROS_LHA(OOP_AttrCheck
*, attrcheck
, A2
),
24 AROS_LHA(OOP_AttrBase
, attrbase
, D1
),
27 struct Library
*, OOPBase
, 20, OOP
)
30 Parse a taglist of attributes and put the result in an array.
31 It will only parse the attr from a single interface
32 which is indicated by the 'attrbase' parameter.
35 tags - tags to be parsed.
36 storage - array where the tag values will be stored.
37 To get the value for a certain tag just use
38 ao#? attribute offset as an index into the array.
39 The array must be of size 'numattrs', ie. the number
40 of attributes in the interface.
42 numattrs - number of attributes in the interface.
43 attrcheck - will is a flag that where flags will be set according
44 to the attributes' offset. Since this is only 32
45 bytes you can only parse interfaces
46 with <= 32 attributes with this function.
47 If you try with more, you will get a
48 ooperr_ParseAttrs_TooManyAttrs error.
49 The flags will be set like this if an attr is found:
51 attrcheck |= 1L << attribute_offset
53 attrbase - attrbase for the interface whise attrs we should look for.
57 0 for success, and an error otherwise.
59 ooperr_ParseAttrs_TooManyAttrs.
72 29-10-95 digulla automatically created from
73 intuition_lib.fd and clib/intuition_protos.h
75 *****************************************************************************/
83 return ooperr_ParseAttrs_TooManyAttrs
;
85 /* Parse the taglist. Since we reimplement NextTagItem() instead
86 of calling it this should be really fast. */
88 register IPTR tag
= tags
->ti_Tag
;
90 /* Instead of having a default: in switch we have an if test
91 here because tag > TAG_SKIP is the most-often case.
93 With the way gcc generates code for switc() when
94 there are low number of case: (no jumptable,
95 just "binarysearch" jumping) this is much faster.
98 /* Get the attribute offset */
99 /* Look for same attrbase */
100 if ((tag
& (~METHOD_MASK
)) == attrbase
) {
101 register IPTR offset
;
103 offset
= tag
& METHOD_MASK
;
104 if (offset
>= numattrs
)
107 // bug("---PARSERATTRS: OFFSET %d\n", offset);
108 storage
[offset
] = tags
->ti_Data
;
109 /* Mark it as found */
110 // bug("--- ADDING %p TO ATTRCHECK\n", 1L << offset);
111 *attrcheck
|= 1L << offset
;
122 tags
= (struct TagItem
*)tags
->ti_Data
;
128 tags
+= tags
->ti_Data
+ 1;
131 } /* if (tag <= TAG_SKIP) */
139 } /* OOP_ParseAttrs */