adds an attribute to the set
| 215 | |
| 216 | // adds an attribute to the set |
| 217 | void AttributeSet_Add |
| 218 | ( |
| 219 | AttributeSet *set, // set to update |
| 220 | Attribute_ID attr_id, // attribute identifier |
| 221 | SIValue value // attribute value |
| 222 | ) { |
| 223 | ASSERT(set != NULL); |
| 224 | |
| 225 | // return if set is read-only |
| 226 | if(unlikely(ATTRIBUTE_SET_IS_READONLY(*set))) { |
| 227 | return; |
| 228 | } |
| 229 | |
| 230 | #ifdef RG_DEBUG |
| 231 | // value must be a valid property type |
| 232 | ASSERT(SI_TYPE(value) & SI_VALID_PROPERTY_VALUE); |
| 233 | // make sure attribute isn't already in set |
| 234 | ASSERT(AttributeSet_Get(*set, attr_id) == ATTRIBUTE_NOTFOUND); |
| 235 | #endif |
| 236 | |
| 237 | AttributeSet _set = AttributeSet_AddPrepare(set, 1); |
| 238 | |
| 239 | // set attribute |
| 240 | Attribute *attr = _set->attributes + _set->attr_count - 1; |
| 241 | attr->id = attr_id; |
| 242 | attr->value = SI_CloneValue(value); |
| 243 | |
| 244 | // update pointer |
| 245 | *set = _set; |
| 246 | } |
| 247 | |
| 248 | // add, remove or update an attribute |
| 249 | // this function allows NULL value to be added to the set |
no test coverage detected