diff options
author | Garrett Regier <garrett.regier@riftio.com> | 2015-02-14 11:15:50 -0800 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-04-20 16:47:36 -0400 |
commit | 7e5a553e7b597a7d53e901307c5f46a660b9c124 (patch) | |
tree | 3e8a4f49d66091ef28396492d0cddd506ed6e5f7 /tests/scanner | |
parent | 564e3b1baf8cad0c08f88bef09bbb14272fd65e2 (diff) | |
download | gobject-introspection-7e5a553e7b597a7d53e901307c5f46a660b9c124.tar.gz |
scanner: Add --symbol-filter-cmd
Add the command line flag --symbol-filter-cmd to g-ir-scanner
which allows running symbol names through a filtering shell
command. The symbol is sent as stdin to the filter command
and expects a filtered result written to stdout.
https://bugzilla.gnome.org/show_bug.cgi?id=744534
Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
Diffstat (limited to 'tests/scanner')
-rw-r--r-- | tests/scanner/Makefile.am | 14 | ||||
-rw-r--r-- | tests/scanner/Symbolfilter-1.0-expected.gir | 45 | ||||
-rw-r--r-- | tests/scanner/symbolfilter.h | 10 | ||||
-rw-r--r-- | tests/scanner/symbolfilter.py | 38 |
4 files changed, 107 insertions, 0 deletions
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am index 2b3188ef..92a22c38 100644 --- a/tests/scanner/Makefile.am +++ b/tests/scanner/Makefile.am @@ -188,6 +188,20 @@ Identfilter-1.0.gir: identfilter.h --identifier-filter-cmd="$(PYTHON) $(srcdir)/identfilter.py" \ --output=$@ $< +EXTRA_DIST += \ + symbolfilter.py \ + symbolfilter.h \ + Symbolfilter-1.0-expected.gir +CLEANFILES += Symbolfilter-1.0.gir +CHECKGIRS += Symbolfilter-1.0.gir + +Symbolfilter-1.0.gir: symbolfilter.h + $(AM_V_GEN) $(INTROSPECTION_SCANNER) $(INTROSPECTION_SCANNER_ARGS) \ + --warn-all --reparse-validate \ + --namespace=Symbolfilter --accept-unprefixed --nsversion=1.0 --header-only \ + --symbol-filter-cmd="$(PYTHON) $(srcdir)/symbolfilter.py" \ + --output=$@ $< + if BUILD_DOCTOOL DOCGIRS = Regress-1.0.gir CHECKDOCS = $(DOCGIRS:.gir=-C) $(DOCGIRS:.gir=-Python) $(DOCGIRS:.gir=-Gjs) $(DOCGIRS:.gir=-sections.txt) diff --git a/tests/scanner/Symbolfilter-1.0-expected.gir b/tests/scanner/Symbolfilter-1.0-expected.gir new file mode 100644 index 00000000..db063d19 --- /dev/null +++ b/tests/scanner/Symbolfilter-1.0-expected.gir @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- This file was automatically generated from C sources - DO NOT EDIT! +To affect the contents of this file, edit the original C definitions, +and/or use gtk-doc annotations. --> +<repository version="1.2" + xmlns="http://www.gtk.org/introspection/core/1.0" + xmlns:c="http://www.gtk.org/introspection/c/1.0" + xmlns:glib="http://www.gtk.org/introspection/glib/1.0"> + <namespace name="Symbolfilter" + version="1.0" + shared-library="" + c:identifier-prefixes="Symbolfilter" + c:symbol-prefixes="symbolfilter"> + <record name="Object" c:type="SymbolfilterObject" disguised="1"> + <method name="filterObjectFooMethod" + c:identifier="SymbolfilterObjectFooMethod"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <instance-parameter name="self" transfer-ownership="none"> + <type name="Object" c:type="SymbolfilterObject*"/> + </instance-parameter> + </parameters> + </method> + <method name="filterObjectFree" c:identifier="SymbolfilterObjectFree"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <instance-parameter name="self" transfer-ownership="none"> + <type name="Object" c:type="SymbolfilterObject*"/> + </instance-parameter> + </parameters> + </method> + <function name="new" + c:identifier="SymbolfilterObjectNew" + introspectable="0"> + <return-value> + <type name="Object" c:type="SymbolfilterObject*"/> + </return-value> + </function> + </record> + </namespace> +</repository> diff --git a/tests/scanner/symbolfilter.h b/tests/scanner/symbolfilter.h new file mode 100644 index 00000000..f42dfb36 --- /dev/null +++ b/tests/scanner/symbolfilter.h @@ -0,0 +1,10 @@ +#ifndef __SYMBOLFILTER_H__ +#define __SYMBOLFILTER_H__ + +typedef struct _SymbolfilterObject SymbolfilterObject; + +SymbolfilterObject *SymbolfilterObjectNew (void); +void SymbolfilterObjectFooMethod (SymbolfilterObject *self); +void SymbolfilterObjectFree (SymbolfilterObject *self); + +#endif diff --git a/tests/scanner/symbolfilter.py b/tests/scanner/symbolfilter.py new file mode 100644 index 00000000..589d0b78 --- /dev/null +++ b/tests/scanner/symbolfilter.py @@ -0,0 +1,38 @@ +# -*- Mode: Python; py-indent-offset: 4 -*- +# vim: tabstop=4 shiftwidth=4 expandtab +# +# Copyright (C) 2015 Garrett Regier <garrett.regier@riftio.com> +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 +# USA + +""" +Script which reads symbols in the form of "FooBar" from stdin and +translates them to snake case like "foo_bar". +""" + +import sys + + +def ensure_snake_case(text): + text = ''.join(x if x.islower() else '_' + x.lower() for x in text) + + # Remove the extra '_' for the starting uppercase letter + return text[1:] + + +if __name__ == '__main__': + text = ensure_snake_case(sys.stdin.read()) + sys.stdout.write(text) |