Permalink
Browse files

Handle ffilter option.

  • Loading branch information...
1 parent e749556 commit c41b627616d8279b55ed54340f05d2cf049e42db @cournape committed Dec 1, 2008
Showing with 6 additions and 4 deletions.
  1. +6 −4 xml2cython.py
View
10 xml2cython.py
@@ -17,16 +17,17 @@
from misc import classify, query_items
from cycodegen import generate_cython
-def generate_main(header, xml, output, lfilter=None):
+def generate_main(header, xml, output, lfilter=None, ffilter=None):
items, named, locations = query_items(xml)
output.write("cdef extern from '%s':\n" % header)
funcs, tpdefs, enumvals, enums, structs, vars, unions = \
classify(items, locations, lfilter=lfilter)
+ kept_funcs = [i for i in funcs.values() if ffilter(i.name)]
puller = TypePuller(items)
- for f in funcs.values():
+ for f in kept_funcs:
puller.pull(f)
needed = puller.values()
@@ -38,7 +39,7 @@ def cmpenum(a, b):
anoenumvals.sort(cmpenum)
# List of items to generate code for
- gen = list(needed) + funcs.values()
+ gen = list(needed) + kept_funcs
generate_cython(output, gen, anoenumvals)
class Usage(Exception):
@@ -93,7 +94,8 @@ def main(argv=None):
# Generate cython code
out = StringIO()
try:
- generate_main(header_input, xml_input, out, lfilter=lfilter)
+ generate_main(header_input, xml_input, out, lfilter=lfilter,
+ ffilter=ffilter)
if output:
f = open(output, 'w')
try:

0 comments on commit c41b627

Please sign in to comment.