Permalink
Browse files

Filter anonymous enums from location too.

  • Loading branch information...
1 parent 9ace560 commit 107001e5f2ff6b0567ca1c19460fc2fc8849aae7 Cournapeau David committed Dec 3, 2008
Showing with 19 additions and 1 deletion.
  1. +19 −1 scripts/xml2cython.py
View
@@ -55,10 +55,28 @@ def generate_main(header, xml, output, lfilter=None, ffilter=None, funcs_list=No
needed = puller.values()
+ # Filter "anonymous" enumerations according to location
+ # XXX: we should do this in classify
+ from ctypeslib.codegen import typedesc
+ if lfilter:
+ anoenums = {}
+ for it in items:
+ try:
+ origin = locations[it][0]
+ if lfilter(origin):
+ if isinstance(it, typedesc.Enumeration):
+ anoenums[it] = it
+ except KeyError:
+ pass
+ anoenumvals = []
+ for v in anoenums.values():
+ anoenumvals.extend(v.values)
+ else:
+ anoenumvals = enumvals.values()
+
# Order 'anonymous' enum values alphabetically
def cmpenum(a, b):
return cmp(a.name, b.name)
- anoenumvals = enumvals.values()
anoenumvals.sort(cmpenum)
# List of items to generate code for

0 comments on commit 107001e

Please sign in to comment.