Ticket #2744: enum_with_duplicated_values.patch
File enum_with_duplicated_values.patch, 1.4 KB (added by , 14 years ago) |
---|
-
libs/python/src/object/enum.cpp
185 185 (*this).attr(name_) = x; 186 186 187 187 dict d = extract<dict>(this->attr("values"))(); 188 d[value] = x; 189 188 if (d.has_key(value)) 189 { 190 extract<tuple> checker(d[value]); 191 if (!checker.check()) 192 { 193 list v; 194 v.append(d[value]); 195 d[value] = v; 196 } 197 list result(d[value]); 198 result.append(x); 199 d[value] = tuple(result); 200 } 201 else 202 d[value] = x; 203 190 204 // Set the name field in the new enum instanec 191 205 enum_object* p = downcast<enum_object>(x.ptr()); 192 206 Py_XDECREF(p->name); … … 198 212 dict d = extract<dict>(this->attr("values"))(); 199 213 list values = d.values(); 200 214 scope current; 201 215 202 216 for (unsigned i = 0, max = len(values); i < max; ++i) 203 217 { 204 api::setattr(current, object(values[i].attr("name")), values[i]); 218 extract<tuple> checker(values[i]); 219 if (checker.check()) { 220 tuple t(checker()); 221 for (unsigned j = 0, maxj = len(t); j < maxj; ++j) 222 api::setattr(current, object(t[j].attr("name")), t[j]); 223 } 224 else 225 { 226 api::setattr(current, object(values[i].attr("name")), values[i]); 227 } 205 228 } 206 229 } 207 230