Support several include/exclude symbols option using the -i or -x options.
---
ctypesgen.py | 6 ++++--
ctypesgencore/options.py | 4 ++--
ctypesgencore/processor/operations.py | 8 ++++----
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/ctypesgen.py b/ctypesgen.py
index 7fb8a49..ae1f579 100755
--- a/ctypesgen.py
+++ b/ctypesgen.py
@@ -87,9 +87,11 @@ if __name__=="__main__":
op.add_option('', '--no-macros', action='store_false', dest='include_macros',
default=True, help="Don't output macros.")
op.add_option('-i', '--include-symbols', dest='include_symbols',
- default=None, help='regular expression for symbols to always include')
+ action='append', default=[],
+ help='regular expression for symbols to always include')
op.add_option('-x', '--exclude-symbols', dest='exclude_symbols',
- default=None, help='regular expression for symbols to exclude')
+ action='append', default=[],
+ help='regular expression for symbols to exclude')
op.add_option('', '--no-stddef-types', action='store_true',
dest='no_stddef_types', default=False,
help='Do not support extra C types from stddef.h')
diff --git a/ctypesgencore/options.py b/ctypesgencore/options.py
index ad19417..242b81d 100644
--- a/ctypesgencore/options.py
+++ b/ctypesgencore/options.py
@@ -20,8 +20,8 @@ default_values={
"save_preprocessed_headers": None,
"all_headers": False,
"builtin_symbols": False,
- "include_symbols": None,
- "exclude_symbols": None,
+ "include_symbols": [],
+ "exclude_symbols": [],
"show_all_errors": False,
"show_long_errors": False,
"show_macro_warnings": True,
diff --git a/ctypesgencore/processor/operations.py b/ctypesgencore/processor/operations.py
index b1839eb..a92db37 100644
--- a/ctypesgencore/processor/operations.py
+++ b/ctypesgencore/processor/operations.py
@@ -68,8 +68,8 @@ def remove_macros(data,opts):
def filter_by_regexes_exclude(data,opts):
"""filter_by_regexes_exclude() uses regular expressions specified by options
dictionary to filter symbols."""
- if opts.exclude_symbols:
- expr=re.compile(opts.exclude_symbols)
+ for symbols in opts.exclude_symbols:
+ expr=re.compile(symbols)
for object in data.all:
if expr.match(object.py_name()):
object.include_rule="never"
@@ -77,8 +77,8 @@ def filter_by_regexes_exclude(data,opts):
def filter_by_regexes_include(data,opts):
"""filter_by_regexes_include() uses regular expressions specified by options
dictionary to re-include symbols previously rejected by other operations."""
- if opts.include_symbols:
- expr=re.compile(opts.include_symbols)
+ for symbols in opts.include_symbols:
+ expr=re.compile(symbols)
for object in data.all:
if object.include_rule!="never":
if expr.match(object.py_name()):
--
1.8.5.2